From 8fa82ebe5c932d36a8c390b3a53bf331fda8292b Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 25 Oct 2026 10:53:30 +0100 Subject: [PATCH 1/3] Color panel: the Color Wheel fits the panel at its default height (#9394) The wheel's height subtracted an estimate of the HSB slider rows (3 x ROW_H) that is lower than the rows really drawn, and was floored at 80 pt, so at the Color group's default height it ran past the bottom and the panel scrolled. Measure what the rows used and floor at 28 pt, as the slider modes' ramp. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/color_panel_tests.rs | 27 +++++++++++++++++++++++++ crates/ui-egui/src/color_panel_ui.rs | 8 ++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/color_panel_tests.rs b/crates/ui-egui/src/color_panel_tests.rs index 6f7cc49729..ae99db906e 100644 --- a/crates/ui-egui/src/color_panel_tests.rs +++ b/crates/ui-egui/src/color_panel_tests.rs @@ -412,6 +412,33 @@ fn color_wheel_ignores_clicks_beside_it() { assert_eq!(bytes(h.state().session.tools.foreground), [0, 0, 255]); } +/// The Color Wheel shrinks to the Color group at its default height in every theme, as the +/// slider modes' ramp does, instead of running past the group's bottom into its scroll area. +#[test] +fn color_wheel_fits_the_default_color_group() { + for kind in ThemeKind::ALL { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.ui.color_panel.mode = ColorPanelMode::ColorWheel; + app.ui.theme = kind; + app.ui.dock_tabs.color = Group::Color.tabs(Tokens::for_kind(kind).pro).iter().position(|name| *name == "Color").unwrap(); + let mut h = Harness::builder().with_size(vec2(1440.0, 1200.0)).build_ui_state( + |ui, app: &mut PhotocraftApp| { + if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + crate::panels::right_dock(app, ui); + egui::CentralPanel::default().show(ui, |_| {}); + } + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, kind); + h.run_steps(4); + let group = crate::dock::last_rects(&h.ctx).into_iter().find(|(g, _)| *g == Group::Color).unwrap().1; + assert!((group.height() - Group::Color.default_height()).abs() < 0.5, "{kind:?}: Color group {group:?}"); + let wheel = h.query_by_label("Color Wheel").unwrap_or_else(|| panic!("{kind:?}: no Color Wheel")).rect(); + assert!(wheel.bottom() <= group.bottom(), "{kind:?}: wheel {wheel:?} runs past the Color group {group:?}"); + } +} + /// The Color tab in `mode` with a document holding one selected black rectangle, the Rectangle tool /// in hand, foreground blue and background red, editing the background chip if `background`. fn color_tab_with_a_shape(mode: ColorPanelMode, background: bool) -> Harness<'static, PhotocraftApp> { diff --git a/crates/ui-egui/src/color_panel_ui.rs b/crates/ui-egui/src/color_panel_ui.rs index 88028502e8..217df20cd2 100644 --- a/crates/ui-egui/src/color_panel_ui.rs +++ b/crates/ui-egui/src/color_panel_ui.rs @@ -537,6 +537,7 @@ fn rgb3(c: [f32; 4]) -> [f32; 3] { /// other corners; the add-to-swatches button sits under it. fn wheel(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let t = Tokens::get(ui.ctx()); + let top = ui.cursor().top(); let background = app.ui.color_panel.background; let rgb = active(app); let v = current_values(ui, Model::Hsb, background, rgb); @@ -556,9 +557,12 @@ fn wheel(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let mut changed = edited.is_some(); ui.add_space(6.0); let fill = ui.data(|d| d.get_temp::(color_field_fill_id())); - let gaps = 2.0 * ui.spacing().item_spacing.y + 6.0; let w = ui.available_width(); - let side = fill.filter(|f| f.is_finite()).map_or(w.min(220.0), |f| (f - top_h - gaps).min(w)).max(80.0); + // The wheel takes what the dock group has left under the sliders as drawn (they stand taller + // than `ROW_H`), down to 28 pt as the slider modes' ramp: an estimate and an 80 pt floor ran + // it past the bottom of the Color group at its default height. + let used = ui.cursor().top() - top; + let side = fill.filter(|f| f.is_finite()).map_or(w.min(220.0), |f| (f - used).min(w)).max(28.0); let (area, resp) = ui.allocate_exact_size(vec2(w, side), Sense::click_and_drag()); resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Other, ui.is_enabled(), "Color Wheel")); let (center, inner, outer) = wheel_geometry(area); From f9e2bc3d4a0dd40b7425aee58f5d8a5a0426e2e2 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 25 Oct 2026 10:57:51 +0100 Subject: [PATCH 2/3] Tests: the Color Wheel fit test bounds the wheel by the scroll area, not the group edge (#9394) Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/color_panel_tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/color_panel_tests.rs b/crates/ui-egui/src/color_panel_tests.rs index ae99db906e..204d07e5aa 100644 --- a/crates/ui-egui/src/color_panel_tests.rs +++ b/crates/ui-egui/src/color_panel_tests.rs @@ -435,7 +435,8 @@ fn color_wheel_fits_the_default_color_group() { let group = crate::dock::last_rects(&h.ctx).into_iter().find(|(g, _)| *g == Group::Color).unwrap().1; assert!((group.height() - Group::Color.default_height()).abs() < 0.5, "{kind:?}: Color group {group:?}"); let wheel = h.query_by_label("Color Wheel").unwrap_or_else(|| panic!("{kind:?}: no Color Wheel")).rect(); - assert!(wheel.bottom() <= group.bottom(), "{kind:?}: wheel {wheel:?} runs past the Color group {group:?}"); + // The group's scroll area ends at least 8 pt above its bottom edge (the card's bottom margin). + assert!(wheel.bottom() <= group.bottom() - 8.0, "{kind:?}: wheel {wheel:?} runs past the Color group {group:?}"); } } From 3b6e93b8f13204a238383035113edb7a3f3c586e Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 27 Oct 2026 02:51:30 +0100 Subject: [PATCH 3/3] Adapt to main: color wheel test uses the craft-ui dock area Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/color_panel_tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/color_panel_tests.rs b/crates/ui-egui/src/color_panel_tests.rs index 204d07e5aa..5dd64cb77b 100644 --- a/crates/ui-egui/src/color_panel_tests.rs +++ b/crates/ui-egui/src/color_panel_tests.rs @@ -424,7 +424,7 @@ fn color_wheel_fits_the_default_color_group() { let mut h = Harness::builder().with_size(vec2(1440.0, 1200.0)).build_ui_state( |ui, app: &mut PhotocraftApp| { if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { - crate::panels::right_dock(app, ui); + crate::panels::dock_area(app, ui); egui::CentralPanel::default().show(ui, |_| {}); } }, @@ -432,7 +432,7 @@ fn color_wheel_fits_the_default_color_group() { ); PhotocraftApp::setup_context(&h.ctx, kind); h.run_steps(4); - let group = crate::dock::last_rects(&h.ctx).into_iter().find(|(g, _)| *g == Group::Color).unwrap().1; + let group = crate::panel_docking::probe::native_group_rect(h.state(), &h.ctx, Group::Color).unwrap(); assert!((group.height() - Group::Color.default_height()).abs() < 0.5, "{kind:?}: Color group {group:?}"); let wheel = h.query_by_label("Color Wheel").unwrap_or_else(|| panic!("{kind:?}: no Color Wheel")).rect(); // The group's scroll area ends at least 8 pt above its bottom edge (the card's bottom margin).