From 4aa511bb05b77ecc353c4d528943bf3538bc2a32 Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Sat, 10 Oct 2026 00:57:01 -0500 Subject: [PATCH] fix(ui): avoid drawing panel borders twice (#2226) * fix: don't draw panel borders twice * fix: avoid drawing caption buttons over titlebar border * fix: remove manually painted separator on statusbar * titlebar test: caption buttons stop above the panel's separator line --------- Co-authored-by: Brandon Thomas --- crates/ui-egui/src/panels.rs | 7 ------- crates/ui-egui/src/titlebar.rs | 5 +++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 939bab5b7f..76398bcc7a 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -89,8 +89,6 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { ui, |ui| { if t.pro { - let r = ui.max_rect(); - ui.painter().line_segment([r.right_top() + vec2(m as f32, -8.0), r.right_bottom() + vec2(m as f32, 8.0)], Stroke::new(1.0, t.separator)); // Photoshop's toolbar header chevrons switch between one and two columns. let (cr, resp) = ui.allocate_exact_size(vec2(bx, 14.0), Sense::click()); icons::paint(ui, cr, if double { "chevrons-left" } else { "chevrons-right" }, 11.0, if resp.hovered() { t.text } else { t.text_faint }); @@ -777,9 +775,6 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { .exact_size(if t.pro { 36.0 } else { 42.0 }) .frame(egui::Frame::NONE.fill(t.chrome).inner_margin(egui::Margin::symmetric(10, 0))) .show(ui, |ui| { - let r = ui.max_rect(); - ui.painter().line_segment([r.left_top(), r.right_top()], Stroke::new(1.0, t.separator)); - ui.painter().line_segment([r.left_bottom(), r.right_bottom()], Stroke::new(1.0, t.separator)); ui.horizontal_centered(|ui| { if t.pro { crate::chrome_ui::home_button(app, ui); @@ -1316,8 +1311,6 @@ pub fn status_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { .exact_size(if t.pro { 24.0 } else { 30.0 }) .frame(egui::Frame::NONE.fill(t.chrome).inner_margin(egui::Margin::symmetric(10, 0))) .show(ui, |ui| { - let r = ui.max_rect(); - ui.painter().line_segment([r.left_top(), r.right_top()], Stroke::new(1.0, t.separator)); ui.horizontal_centered(|ui| { if t.pro { crate::chrome_ui::status_bar_pro(app, ui); diff --git a/crates/ui-egui/src/titlebar.rs b/crates/ui-egui/src/titlebar.rs index 03af8b0d7b..a940ec3ede 100644 --- a/crates/ui-egui/src/titlebar.rs +++ b/crates/ui-egui/src/titlebar.rs @@ -52,7 +52,7 @@ pub fn caption_buttons(app: &mut PhotocraftApp, ui: &mut Ui, bar: Rect) { let right = bar.right().min(ui.ctx().content_rect().right()); let mut clicked = None; for (i, c) in CAPTIONS.into_iter().enumerate() { - let r = Rect::from_min_size(pos2(right - WIDTH + i as f32 * BUTTON_WIDTH, bar.top()), vec2(BUTTON_WIDTH, bar.height())); + let r = Rect::from_min_size(pos2(right - WIDTH + i as f32 * BUTTON_WIDTH, bar.top()), vec2(BUTTON_WIDTH, bar.height() - 1.0)); let resp = ui.interact(r, caption_id(c), Sense::click()); let close = c == Caption::Close; let fill = match (resp.is_pointer_button_down_on(), resp.hovered()) { @@ -244,7 +244,8 @@ mod tests { let out = w.frame(vec![]); let [min, max, close] = CAPTIONS.map(|c| w.caption(c)); assert_eq!((close.right(), close.top()), (width, 0.0), "Close sits in the window's corner at {width}"); - assert!(close.height() >= 32.0 && [min, max, close].iter().all(|r| r.width() == BUTTON_WIDTH)); + // The bar's bottom point is the panel's separator line, which the buttons leave visible. + assert!(close.height() >= 31.0 && [min, max, close].iter().all(|r| r.width() == BUTTON_WIDTH)); assert_eq!((min.right(), max.right()), (max.left(), close.left())); let widgets = w.bar_widgets(); assert!(widgets.len() >= 10, "menus, search, theme, workspace: {widgets:?}");