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 <noreply@anthropic.com>
This commit is contained in:
DuBearteandClaude Opus 5.5 authored and GitHub committed 2026-10-25 10:17:49 -04:00
1 parent 100ff983f5
commit d931929653
2 files changed
+34 -1

No files matched your search

+3 -1
View File
@@ -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));
@@ -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::<Rect>(egui::Id::new("hs").with("hs-bars"))).expect("bars drawn");
let avail = h.ctx.data(|d| d.get_temp::<f32>(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();