From 9429df26b371c04c2afa65228a60ded739b5fbc2 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 25 Oct 2026 21:36:57 -0600 Subject: [PATCH] fix(ui): the layer list doesn't move with no layer selected (#9546) With no layer selected, the greyed-out Blend/Opacity and Lock/Fill rows sat in one add_enabled_ui wrapper, which added an item gap under them: in themes whose docks keep item spacing (Studio, Classic) the first layer row moved down 6 points. Each row now disables itself and is laid out as the active layer's rows are. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/layer_pct_slider_tests.rs | 20 +++++ crates/ui-egui/src/panels.rs | 95 ++++++++++---------- 2 files changed, 69 insertions(+), 46 deletions(-) diff --git a/crates/ui-egui/src/layer_pct_slider_tests.rs b/crates/ui-egui/src/layer_pct_slider_tests.rs index 1d22cd255f..e8d73d94a2 100644 --- a/crates/ui-egui/src/layer_pct_slider_tests.rs +++ b/crates/ui-egui/src/layer_pct_slider_tests.rs @@ -178,3 +178,23 @@ fn opacity_and_fill_stay_visible_but_disabled_with_no_layer_selected() { assert!(node.accesskit_node().is_disabled(), "{name}: should be greyed out"); } } + +/// #9546: the layer list starts at the same place with or without a selected layer. With none, +/// the greyed-out Blend/Opacity and Lock/Fill rows sat in one disabled wrapper, which added an +/// item gap under them: in the themes whose docks keep item spacing (Studio, Classic) the first +/// row moved down 6 points. +#[test] +fn layer_rows_do_not_move_when_no_layer_is_selected() { + for theme in [crate::theme::ThemeKind::Studio, crate::theme::ThemeKind::Classic, crate::theme::ThemeKind::ProMedium] { + let mut h = harness(); + PhotocraftApp::setup_context(&h.ctx, theme); + h.run_steps(4); + let row_top = |h: &Harness<'_, PhotocraftApp>| by_role(h, "Paint", Role::Button).map(|r| r.top()); + let selected = row_top(&h); + h.state_mut().session.execute("select.deselectLayers", json!({})).unwrap(); + h.run_steps(4); + let none = row_top(&h); + assert!(selected.is_some(), "{theme:?}: the layer row"); + assert_eq!(none, selected, "{theme:?}: the row moved with no layer selected"); + } +} diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index b86d7b2af9..c1be879f06 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -2626,56 +2626,59 @@ fn opacity_row_layout(available: f32, label_width: f32, gap: f32) -> (f32, bool) /// greyed out at Normal, 100% and unlocked, instead of removing them (#8880). Same layout as the /// active layer's rows in `layers`. fn inactive_blend_rows(ui: &mut egui::Ui, pro: bool) { - ui.add_enabled_ui(false, |ui| { - ui.horizontal(|ui| { - let opacity_label = if pro { tl!("Opacity:") } else { tl!("Opacity") }; - let (blend_width, show_opacity_label) = opacity_row_layout(ui.available_width(), body_text_width(ui, opacity_label), ui.spacing().item_spacing.x); - let mut m = BlendMode::Normal; - let options = blend_options(false, m); - widgets::dropdown_wheel_hovered(ui, "blend", tl!("Blend Mode"), &mut m, &options, blend_width); - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - let mut o = 100.0; - widgets::popup_value_field(ui, opacity_label, &mut o, 0.0..=100.0, "%", LAYER_PCT_W); - if show_opacity_label { - scrub_pct_label(ui, opacity_label, &mut o, ui.available_width()); + // Each row is disabled on its own and laid out as the active layer's rows are: a disabled + // wrapper around both added an item gap under the Fill row, which pushed the layer list down + // in the themes whose docks keep item spacing (#9546). + ui.horizontal(|ui| { + ui.disable(); + let opacity_label = if pro { tl!("Opacity:") } else { tl!("Opacity") }; + let (blend_width, show_opacity_label) = opacity_row_layout(ui.available_width(), body_text_width(ui, opacity_label), ui.spacing().item_spacing.x); + let mut m = BlendMode::Normal; + let options = blend_options(false, m); + widgets::dropdown_wheel_hovered(ui, "blend", tl!("Blend Mode"), &mut m, &options, blend_width); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + let mut o = 100.0; + widgets::popup_value_field(ui, opacity_label, &mut o, 0.0..=100.0, "%", LAYER_PCT_W); + if show_opacity_label { + scrub_pct_label(ui, opacity_label, &mut o, ui.available_width()); + } + }); + }); + ui.add_space((theme::ROW_GAP - ui.spacing().item_spacing.y).max(0.0)); + ui.horizontal(|ui| { + ui.disable(); + let lock_label = if pro { tl!("Lock:") } else { tl!("Lock") }; + let lang = crate::i18n::current(); + let fill_label = if pro { crate::i18n::tr_ctx(lang, "layers", "Fill:") } else { crate::i18n::tr_ctx(lang, "layers", "Fill") }; + let gap = ui.spacing().item_spacing.x; + let icons_w = if pro { 5.0 * 20.0 + gap } else { 22.0 + gap }; + let fits = body_text_width(ui, lock_label) + icons_w + body_text_width(ui, fill_label) + LAYER_PCT_W + 2.0 * gap <= ui.available_width(); + if fits { + label(ui, lock_label); + } + if pro { + ui.scope(|ui| { + ui.spacing_mut().item_spacing.x = 0.0; + for (icon, tip) in [ + ("grid-3x3", tl!("Lock transparent pixels")), + ("brush", tl!("Lock image pixels")), + ("move", tl!("Lock position")), + ("scan", tl!("Prevent auto-nesting in and out of Artboards and Frames")), + ("lock", tl!("Lock all")), + ] { + icons::button(ui, icon, 20.0, false, tip); } }); + } else { + icons::button(ui, "lock-open", 22.0, false, tl!("Lock layer")); + } + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + let mut f = 100.0; + widgets::popup_value_field(ui, fill_label, &mut f, 0.0..=100.0, "%", LAYER_PCT_W); + scrub_pct_label(ui, fill_label, &mut f, ui.available_width()); }); - ui.add_space((theme::ROW_GAP - ui.spacing().item_spacing.y).max(0.0)); - ui.horizontal(|ui| { - let lock_label = if pro { tl!("Lock:") } else { tl!("Lock") }; - let lang = crate::i18n::current(); - let fill_label = if pro { crate::i18n::tr_ctx(lang, "layers", "Fill:") } else { crate::i18n::tr_ctx(lang, "layers", "Fill") }; - let gap = ui.spacing().item_spacing.x; - let icons_w = if pro { 5.0 * 20.0 + gap } else { 22.0 + gap }; - let fits = body_text_width(ui, lock_label) + icons_w + body_text_width(ui, fill_label) + LAYER_PCT_W + 2.0 * gap <= ui.available_width(); - if fits { - label(ui, lock_label); - } - if pro { - ui.scope(|ui| { - ui.spacing_mut().item_spacing.x = 0.0; - for (icon, tip) in [ - ("grid-3x3", tl!("Lock transparent pixels")), - ("brush", tl!("Lock image pixels")), - ("move", tl!("Lock position")), - ("scan", tl!("Prevent auto-nesting in and out of Artboards and Frames")), - ("lock", tl!("Lock all")), - ] { - icons::button(ui, icon, 20.0, false, tip); - } - }); - } else { - icons::button(ui, "lock-open", 22.0, false, tl!("Lock layer")); - } - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - let mut f = 100.0; - widgets::popup_value_field(ui, fill_label, &mut f, 0.0..=100.0, "%", LAYER_PCT_W); - scrub_pct_label(ui, fill_label, &mut f, ui.available_width()); - }); - }); - ui.add_space(2.0); }); + ui.add_space(2.0); } fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {