PhotoCraft: An open-source, photo editor written by scratch in pure Rust
fix(ui): keep Color panel hex/RGB readout visible in short docks
nrq6993-a11y59660345f959
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rsindex 522c74dc1..db313ee6b 100644--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@ -3610,7 +3610,9 @@ pub(crate) fn color_field_fill_id() -> egui::Id {/// which folds onto a second line in a narrow dock. 120 pt when nothing sets a height.fn color_field_height(avail: Option<f32>, width: f32) -> f32 {let reserve = 32.0 + if width < 280.0 { 26.0 } else { 0.0 };- avail.filter(|a| a.is_finite()).map_or(120.0, |a| (a - reserve).clamp(120.0, 2000.0))+ // When docked, shrink the field so the hex/RGB readout stays in view (#6885). A 120 pt floor+ // here pushed the readout below the scroll area in a compact Color group.+ avail.filter(|a| a.is_finite()).map_or(120.0, |a| (a - reserve).clamp(0.0, 2000.0))}/// The colour the SV field draws for `hsva`, with what the field showed last (`hue`, `saturation`)@@ -4497,11 +4499,34 @@ mod color_tests {assert_eq!(color_field_height(None, 300.0), 120.0);assert_eq!(color_field_height(Some(500.0), 300.0), 468.0);assert_eq!(color_field_height(Some(500.0), 200.0), 442.0);- assert_eq!(color_field_height(Some(60.0), 300.0), 120.0);+ assert_eq!(color_field_height(Some(60.0), 300.0), 28.0);assert_eq!(color_field_height(Some(f32::NAN), 300.0), 120.0);assert_eq!(color_field_height(Some(1.0e9), 300.0), 2000.0);}+ /// A squeezed Color group still shows the hex/RGB readout, not only the spectrum field (#6885).+ #[test]+ fn docked_color_field_keeps_rgb_readout_at_compact_height() {+ use egui_kittest::kittest::Queryable;+ let app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ // Body height after tab strip and margins in a Color group at `compact_height` (130 pt).+ let inner = 86.0;+ let mut h = egui_kittest::Harness::builder().with_size(vec2(240.0, inner)).build_ui_state(+ |ui, app: &mut PhotocraftApp| {+ if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {+ ui.set_height(inner);+ ui.data_mut(|d| d.insert_temp(color_field_fill_id(), inner));+ color_field(app, ui);+ }+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::Pro);+ h.run_steps(2);+ assert!(h.query_by_label("R").is_some(), "RGB readout stays visible when the group is short");+ assert!(h.query_by_role(egui::accesskit::Role::TextInput).is_some(), "hex field stays visible");+ }+fn field_harness(app: PhotocraftApp) -> egui_kittest::Harness<'static, PhotocraftApp> {// 60 fps steps, so two clicks a frame apart are a double-click.let mut h = egui_kittest::Harness::builder().with_size(vec2(300.0, 200.0)).with_step_dt(1.0 / 60.0).build_ui_state(