From d931929653e3ffb42419e413271fe7d141bf0216 Mon Sep 17 00:00:00 2001 From: DuBearte <130190089+DuBearte@users.noreply.github.com> Date: Sun, 25 Oct 2026 10:17:49 -0400 Subject: [PATCH] fix(ui): Hue/Saturation's spectrum bars stretch with the panel (#9242) (#9250) The bars were capped at 300 px while the sliders above them fill the Properties panel; they now take its whole width too. Co-authored-by: Claude Opus 5.5 --- crates/ui-egui/src/adjust_editors.rs | 4 ++- crates/ui-egui/src/adjust_editors_tests.rs | 31 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/adjust_editors.rs b/crates/ui-egui/src/adjust_editors.rs index f646ddd452..4e6e738863 100644 --- a/crates/ui-egui/src/adjust_editors.rs +++ b/crates/ui-egui/src/adjust_editors.rs @@ -1000,8 +1000,10 @@ fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit { } // Spectrum bars: input hues above, adjusted below; the selected range's sliders between. ui.add_space(6.0); - let w = ui.available_width().min(300.0); + // As wide as the sliders above, whatever the panel's width (#9242). + let w = ui.available_width(); let (bars, bresp) = ui.allocate_exact_size(vec2(w, 40.0), Sense::click_and_drag()); + ui.data_mut(|d| d.insert_temp(cx.mem.with("hs-bars"), bars)); let top = Rect::from_min_size(bars.min, vec2(w, 10.0)); let bottom = Rect::from_min_size(pos2(bars.left(), bars.bottom() - 10.0), vec2(w, 10.0)); let p = ui.painter_at(bars.expand(4.0)); diff --git a/crates/ui-egui/src/adjust_editors_tests.rs b/crates/ui-egui/src/adjust_editors_tests.rs index 7f669186bb..3d0b76ab11 100644 --- a/crates/ui-egui/src/adjust_editors_tests.rs +++ b/crates/ui-egui/src/adjust_editors_tests.rs @@ -807,6 +807,37 @@ fn editor_harness(kind: &'static str, params: serde_json::Value) -> Harness<'sta h } +/// #9242: the Hue/Saturation spectrum bars stretch with the panel, like the sliders above them. +#[test] +fn hue_saturation_bars_fill_the_panel_width() { + use crate::adjust_editors::{EditorCx, editor}; + for width in [300.0, 600.0] { + let mut h = Harness::builder().with_size(vec2(width, 500.0)).build_ui_state( + |ui, values: &mut serde_json::Value| { + let cx = EditorCx { + mem: egui::Id::new("hs"), + hist: None, + gray: false, + swatches: [[0.0; 3], [1.0; 3]], + gradients: Vec::new(), + dialog: false, + dynamic_color_sliders: true, + isolated_curve: None, + }; + let avail = ui.available_width(); + editor(ui, "hueSaturation", values, &cx); + ui.data_mut(|d| d.insert_temp(egui::Id::new("hs-avail"), avail)); + }, + json!({}), + ); + PhotocraftApp::setup_context(&h.ctx, Default::default()); + h.run_steps(4); + let bars = h.ctx.data(|d| d.get_temp::(egui::Id::new("hs").with("hs-bars"))).expect("bars drawn"); + let avail = h.ctx.data(|d| d.get_temp::(egui::Id::new("hs-avail"))).unwrap(); + assert!((bars.width() - avail).abs() < 0.5, "{width}: bars {} of {avail}", bars.width()); + } +} + /// Types `text` into the `index`th number field and commits it with Enter. fn type_into_field(h: &mut Harness<'static, serde_json::Value>, index: usize, text: &str) { h.query_all_by_role(egui::accesskit::Role::SpinButton).nth(index).unwrap().click();