PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Toolbar: the colour chips sit right under the tools again (#3745)
Unemars986f68f969b7
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rsindex 4bda4fcde..696e5b38c 100644--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@ -128,9 +128,11 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {+ chips_height(t.pro, t.round_chips, t.round_chips && double)+ if t.pro { 8.0 + if double { bx } else { bx * 2.0 + 3.0 } } else { 0.0 }+ 6.0;+ // As tall as the tools, so the colour chips sit right under them (Photoshop); a column+ // taller than the window scrolls and keeps the chips at the bottom.egui::ScrollArea::vertical().id_salt("toolbar-columns")- .auto_shrink([false, false])+ .auto_shrink([false, true]).max_height((ui.available_height() - footer).max(0.0)).min_scrolled_height(0.0).show(ui, |ui| {@@ -5234,8 +5236,12 @@ mod compact_visual_regressions {}fn toolbar_harness(kind: theme::ThemeKind, scale: f32) -> egui_kittest::Harness<'static, PhotocraftApp> {+ toolbar_harness_sized(kind, scale, 360.0)+ }++ fn toolbar_harness_sized(kind: theme::ThemeKind, scale: f32, height: f32) -> egui_kittest::Harness<'static, PhotocraftApp> {let mut ready = false;- let mut harness = egui_kittest::Harness::builder().with_size(vec2(400.0, 360.0)).with_pixels_per_point(scale).build_ui_state(+ let mut harness = egui_kittest::Harness::builder().with_size(vec2(400.0, height)).with_pixels_per_point(scale).build_ui_state(move |ui, app: &mut PhotocraftApp| {if !ready {egui_extras::install_image_loaders(ui.ctx());@@ -5304,6 +5310,18 @@ mod compact_visual_regressions {}}+ /// A window taller than the tools keeps the colour chips right under the last tool, as+ /// Photoshop does, instead of at the bottom of the toolbar.+ #[test]+ fn tall_toolbar_keeps_the_colour_chips_under_the_tools() {+ for kind in theme::ThemeKind::ALL {+ let harness = toolbar_harness_sized(kind, 1.0, 1600.0);+ let last = harness.get_by_label("Zoom Tool (Z)").rect();+ let swap = harness.get_by_label("Swap colours (X)").rect();+ assert!(swap.top() - last.bottom() < 80.0, "{kind:?}: the chips {swap:?} sit far below the last tool {last:?}");+ }+ }+#[test]fn capture_compact_visual_fixtures() {let Some(directory) = std::env::var_os("CRAFT_UI_VISUAL_FIXTURES").map(std::path::PathBuf::from) else { return };