From 19c58622888a7531e49b459515c0b1202fc30448 Mon Sep 17 00:00:00 2001 From: Andy Dixon Date: Sun, 11 Oct 2026 17:32:39 +0100 Subject: [PATCH] rust: apply sidebar width from Settings; egui Panel::show --- rust/app/src/app.rs | 11 +++++++++-- rust/app/src/sidebar.rs | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rust/app/src/app.rs b/rust/app/src/app.rs index b284da7..d861f1d 100644 --- a/rust/app/src/app.rs +++ b/rust/app/src/app.rs @@ -80,6 +80,8 @@ pub struct App { screenshot: Option<(PathBuf, u32)>, shot_settle: u32, run_local: Option<(String, Option)>, + /// Apply `prefs.sidebar_width` to the panel on the next frame (after Settings changed it). + resize_sidebar: bool, } const fn sc(m: Modifiers, k: Key) -> KeyboardShortcut { @@ -125,6 +127,7 @@ impl App { screenshot: opts.screenshot.map(|p| (p, 0)), shot_settle: 0, run_local: opts.run_local.map(|c| (c, None)), + resize_sidebar: false, }; if let Some((_, sid)) = &mut app.run_local { let id = app.s.svc.connect_local(); @@ -488,6 +491,7 @@ impl App { Request::ReloadProfiles => self.s.reload_profiles(), Request::ReloadPreferences => { self.s.prefs = self.s.svc.preferences(); + self.resize_sidebar = true; self.theme = theme_for(&self.s.prefs.theme); theme::apply(&self.s.ctx, self.theme); } @@ -783,8 +787,11 @@ impl eframe::App for App { egui::Panel::bottom("status").exact_size(26.0).frame(egui::Frame::NONE.fill(t.chrome)).show(ui, |ui| chrome::status_bar(self, ui)); } let width = self.s.prefs.sidebar_width.clamp(180, 500) as f32; - let side = egui::Panel::left("sidebar") - .default_size(width) + let mut panel = egui::Panel::left("sidebar").default_size(width); + if std::mem::take(&mut self.resize_sidebar) { + panel = panel.exact_size(width); + } + let side = panel .min_size(180.0) .max_size(500.0) .resizable(true) diff --git a/rust/app/src/sidebar.rs b/rust/app/src/sidebar.rs index 35ad290..9e97533 100644 --- a/rust/app/src/sidebar.rs +++ b/rust/app/src/sidebar.rs @@ -32,7 +32,7 @@ pub fn ui(app: &mut App, ui: &mut Ui) { ui.add_space(4.0); // Footer actions, pinned to the bottom of the sidebar. - egui::Panel::bottom("sidebar-footer").exact_size(36.0).frame(egui::Frame::NONE.fill(t.dock)).show_inside(ui, |ui| { + egui::Panel::bottom("sidebar-footer").exact_size(36.0).frame(egui::Frame::NONE.fill(t.dock)).show(ui, |ui| { ui.horizontal_centered(|ui| { ui.add_space(6.0); if widgets::icon_button(ui, icon::PLUS, "New connection (Ctrl/Cmd+N)").clicked() { @@ -56,7 +56,7 @@ pub fn ui(app: &mut App, ui: &mut Ui) { }); }); if !app.sidebar.selected.is_empty() { - egui::Panel::bottom("sidebar-bulk").frame(egui::Frame::NONE.fill(t.dock).inner_margin(6)).show_inside(ui, |ui| bulk_bar(app, ui)); + egui::Panel::bottom("sidebar-bulk").frame(egui::Frame::NONE.fill(t.dock).inner_margin(6)).show(ui, |ui| bulk_bar(app, ui)); } egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| list(app, ui)); }