Feat: UI / UX
This commit is contained in:
@@ -143,6 +143,10 @@ struct CagireDesktop {
|
||||
_analysis_handle: Option<AnalysisHandle>,
|
||||
midi_rx: Receiver<MidiCommand>,
|
||||
current_font: FontChoice,
|
||||
zoom_factor: f32,
|
||||
fullscreen: bool,
|
||||
decorations: bool,
|
||||
always_on_top: bool,
|
||||
mouse_x: Arc<AtomicU32>,
|
||||
mouse_y: Arc<AtomicU32>,
|
||||
mouse_down: Arc<AtomicU32>,
|
||||
@@ -161,8 +165,10 @@ impl CagireDesktop {
|
||||
|
||||
let current_font = FontChoice::from_setting(&b.settings.display.font);
|
||||
let terminal = create_terminal(current_font);
|
||||
let zoom_factor = b.settings.display.zoom_factor;
|
||||
|
||||
cc.egui_ctx.set_visuals(egui::Visuals::dark());
|
||||
cc.egui_ctx.set_zoom_factor(zoom_factor);
|
||||
|
||||
Self {
|
||||
app: b.app,
|
||||
@@ -180,6 +186,10 @@ impl CagireDesktop {
|
||||
_analysis_handle: b.analysis_handle,
|
||||
midi_rx: b.midi_rx,
|
||||
current_font,
|
||||
zoom_factor,
|
||||
fullscreen: false,
|
||||
decorations: true,
|
||||
always_on_top: false,
|
||||
mouse_x: b.mouse_x,
|
||||
mouse_y: b.mouse_y,
|
||||
mouse_down: b.mouse_down,
|
||||
@@ -412,7 +422,15 @@ impl eframe::App for CagireDesktop {
|
||||
}
|
||||
|
||||
let current_font = self.current_font;
|
||||
let current_zoom = self.zoom_factor;
|
||||
let current_fullscreen = self.fullscreen;
|
||||
let current_decorations = self.decorations;
|
||||
let current_always_on_top = self.always_on_top;
|
||||
let mut new_font = None;
|
||||
let mut new_zoom = None;
|
||||
let mut toggle_fullscreen = false;
|
||||
let mut toggle_decorations = false;
|
||||
let mut toggle_always_on_top = false;
|
||||
|
||||
egui::CentralPanel::default()
|
||||
.frame(egui::Frame::NONE.fill(egui::Color32::BLACK))
|
||||
@@ -449,6 +467,38 @@ impl eframe::App for CagireDesktop {
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.menu_button("Zoom", |ui| {
|
||||
for &level in &[0.5_f32, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0] {
|
||||
let selected = (current_zoom - level).abs() < 0.01;
|
||||
let label = format!("{:.0}%", level * 100.0);
|
||||
if ui.selectable_label(selected, label).clicked() {
|
||||
new_zoom = Some(level);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.separator();
|
||||
if ui
|
||||
.selectable_label(current_fullscreen, "Fullscreen")
|
||||
.clicked()
|
||||
{
|
||||
toggle_fullscreen = true;
|
||||
ui.close();
|
||||
}
|
||||
if ui
|
||||
.selectable_label(current_always_on_top, "Always On Top")
|
||||
.clicked()
|
||||
{
|
||||
toggle_always_on_top = true;
|
||||
ui.close();
|
||||
}
|
||||
if ui
|
||||
.selectable_label(!current_decorations, "Borderless")
|
||||
.clicked()
|
||||
{
|
||||
toggle_decorations = true;
|
||||
ui.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -459,6 +509,30 @@ impl eframe::App for CagireDesktop {
|
||||
settings.display.font = font.to_setting().to_string();
|
||||
settings.save();
|
||||
}
|
||||
if let Some(zoom) = new_zoom {
|
||||
self.zoom_factor = zoom;
|
||||
ctx.set_zoom_factor(zoom);
|
||||
let mut settings = Settings::load();
|
||||
settings.display.zoom_factor = zoom;
|
||||
settings.save();
|
||||
}
|
||||
if toggle_fullscreen {
|
||||
self.fullscreen = !self.fullscreen;
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Fullscreen(self.fullscreen));
|
||||
}
|
||||
if toggle_always_on_top {
|
||||
self.always_on_top = !self.always_on_top;
|
||||
let level = if self.always_on_top {
|
||||
egui::WindowLevel::AlwaysOnTop
|
||||
} else {
|
||||
egui::WindowLevel::Normal
|
||||
};
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::WindowLevel(level));
|
||||
}
|
||||
if toggle_decorations {
|
||||
self.decorations = !self.decorations;
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Decorations(self.decorations));
|
||||
}
|
||||
|
||||
ctx.request_repaint_after(Duration::from_millis(
|
||||
self.app.audio.config.refresh_rate.millis(),
|
||||
|
||||
Reference in New Issue
Block a user