Color panel field fills its group in a custom workspace too

#2455 stretched the pro Color panel's SV field and hue strip to the dock
group's height, but only the legacy dock told the field that height. The
shared docking renderer from #3097 drew the panel without it, so once the
layout was customized the field fell back to 120 pt. Both docks now offer
the group body's height through one helper.
This commit is contained in:
aiongg committed 2026-10-18 17:04:55 +00:00
1 parent 5c7c847923
commit fa99e183b6
4 files changed
+29 -5

No files matched your search

+1 -4
View File
@@ -521,10 +521,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, shown: &[Group], mut bod
ui.set_min_height(inner);
body(app, ui, g, tab);
} else {
// The pro Color field stretches to the group's height instead of a fixed 120 pt.
if t.pro && g == Group::Color && tab == 0 {
ui.data_mut(|d| d.insert_temp(crate::panels::color_field_fill_id(), inner));
}
crate::panels::offer_color_field_fill(ui, t.pro, g, tab);
// No scroll fade: it darkens real colours, swatches and previews at the edge
// (#2726); the scroll bar already shows there is more.
ui.spacing_mut().scroll.fade.strength = 0.0;
+1
View File
@@ -547,6 +547,7 @@ fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: &str) {
if group.scrolls_itself(tab) {
crate::panels::dock_body(app, ui, *group, tab);
} else {
crate::panels::offer_color_field_fill(ui, pro, *group, tab);
egui::ScrollArea::vertical()
.id_salt(("shared-panel-body", id))
.auto_shrink([false, false])
+17
View File
@@ -585,6 +585,23 @@ fn explicit_reveal_activates_existing_tab_and_expands_custom_group() {
assert_eq!(app.ui.docking, before);
}
// #2455 in a custom workspace: the pro Color field fills a tall floating group, not 120 pt.
#[test]
fn pro_color_field_fills_a_tall_custom_group() {
let mut app = app();
app.run("window.panel.float", json!({"panel":"color","x":40,"y":60,"width":320,"height":560})).unwrap();
assert!(app.ui.docking.is_some());
let h = harness(app, vec2(1280.0, 800.0));
// The SV field and the 14 pt hue strip beside it are draggable, equally tall and 8 pt apart.
let drags: Vec<egui::Rect> =
h.ctx.viewport(|v| v.this_pass.widgets.layers().flat_map(|(_, w)| w).filter(|w| w.sense.senses_drag()).map(|w| w.rect).collect());
let field = drags
.iter()
.find(|f| drags.iter().any(|s| s.width() == 14.0 && s.top() == f.top() && s.height() == f.height() && (s.left() - f.right() - 8.0).abs() < 0.5))
.expect("Color field with its hue strip");
assert!(field.height() > 300.0, "field stays short in a 560 pt group: {field:?}");
}
// #4028: in a custom workspace too, a new adjustment layer brings Properties to the front.
#[test]
fn a_new_adjustment_layer_activates_properties_in_a_custom_workspace() {
+10 -1
View File
@@ -3794,10 +3794,19 @@ fn field_chips(app: &mut PhotocraftApp, ui: &mut egui::Ui, chips: Rect) {
}
/// Where the dock tells the Color field how tall its group body is.
pub(crate) fn color_field_fill_id() -> egui::Id {
fn color_field_fill_id() -> egui::Id {
egui::Id::new("color-field-fill-height")
}
/// The pro Color field stretches to its dock group's height instead of a fixed 120 pt: a dock
/// calls this with the group body's `ui` before drawing the tab.
pub(crate) fn offer_color_field_fill(ui: &egui::Ui, pro: bool, group: crate::dock::Group, tab: usize) {
if pro && group == crate::dock::Group::Color && tab == 0 {
let inner = ui.available_height().max(0.0);
ui.data_mut(|d| d.insert_temp(color_field_fill_id(), inner));
}
}
/// Height of the Color field: the group body's height (when docked) less the hex/RGB readout,
/// 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 {