PhotoCraft: An open-source, photo editor written by scratch in pure Rust
fix(ui): avoid drawing panel borders twice (#2226)
Tropical4aa511bb05b7
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rsindex 939bab5b7..76398bcc7 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.rsindex 03af8b0d7..a940ec3ed 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:?}");