From d0670de8cec51b1fa07837e1d5010c6c1aafc2bb Mon Sep 17 00:00:00 2001 From: Julian Zahnow <54999052+Enthendor@users.noreply.github.com> Date: Sat, 24 Oct 2026 15:50:00 +0200 Subject: [PATCH 1/2] fix(ui): wrap the Edit header buttons instead of letting Reset cover HDR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reset was laid out right-to-left in whatever width Auto, B&W and HDR left, so a long label drew over HDR: German Zurücksetzen in the default panel, and 16 of the 18 languages at some panel width. A button that doesn't fit now starts the next row; Reset stays right-aligned. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/edit.rs | 154 +++++++++++++++++++++++++----- crates/ui-egui/src/widgets.rs | 14 ++- 2 files changed, 141 insertions(+), 27 deletions(-) diff --git a/crates/ui-egui/src/panels/edit.rs b/crates/ui-egui/src/panels/edit.rs index 1a770ebd8ac..dd8fa7db53b 100644 --- a/crates/ui-egui/src/panels/edit.rs +++ b/crates/ui-egui/src/panels/edit.rs @@ -107,32 +107,19 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) { let (hr, _) = ui.allocate_exact_size(vec2(ui.available_width(), 40.0), Sense::hover()); ui.painter().text(pos2(hr.left() + 24.0, hr.bottom() - 10.0), Align2::LEFT_CENTER, crate::i18n::tr("Edit"), t.semibold(15.0), t.text); egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 8, bottom: 14 }).show(ui, |ui| { - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = 8.0; - if text_button(ui, "auto", crate::i18n::tr("Auto"), false).clicked() { - let _ = app.run("develop.auto", json!({})); - app.toast(ui.ctx(), crate::i18n::tr("Auto settings applied")); - } - let bw = crate::is_bw(&d); - if text_button(ui, "bw", crate::i18n::tr("B&W"), bw).clicked() { - let _ = app.run("develop.treatment", json!({})); - } - // HDR editing, next to B&W as Lightroom has it - if text_button(ui, "hdr", crate::i18n::tr("HDR"), d.hdr.enabled) - .on_hover_text(crate::i18n::tr("Edit in HDR: highlights above SDR white, for HDR exports and displays")) - .clicked() - { - let _ = app.run("develop.hdr", json!({"enabled": !d.hdr.enabled})); - } - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - if text_button(ui, "reset", crate::i18n::tr("Reset"), false) - .on_hover_text(reset_tip(&app.ui.settings.keymap, ui.ctx().os() == egui::os::OperatingSystem::Mac)) - .clicked() - { - reset_clicked = true; - } - }); - }); + let tip = reset_tip(&app.ui.settings.keymap, ui.ctx().os() == egui::os::OperatingSystem::Mac); + let clicks = header_buttons(ui, crate::is_bw(&d), d.hdr.enabled, &tip); + if clicks.auto { + let _ = app.run("develop.auto", json!({})); + app.toast(ui.ctx(), crate::i18n::tr("Auto settings applied")); + } + if clicks.bw { + let _ = app.run("develop.treatment", json!({})); + } + if clicks.hdr { + let _ = app.run("develop.hdr", json!({"enabled": !d.hdr.enabled})); + } + reset_clicked = clicks.reset; }); if let Some(why) = &preview_only { let reload = egui::Frame::NONE @@ -1932,6 +1919,75 @@ pub(crate) fn reload_preview_only(app: &mut LightcraftApp, ctx: &egui::Context, } /// The Reset button's tooltip with the reset shortcut as this platform writes it (issue #1751). +/// Which of the Edit header's buttons were clicked. +#[derive(Default)] +struct HeaderClicks { + auto: bool, + bw: bool, + hdr: bool, + reset: bool, +} + +/// The Edit header's buttons: Auto, B&W and HDR on the left, Reset on the right. A button that doesn't fit on the +/// row starts the next one (long translations in a narrow panel, such as German *Zurücksetzen* beside HDR), so none +/// covers another; Reset stays right-aligned on whichever row it lands. +fn header_buttons(ui: &mut egui::Ui, bw: bool, hdr: bool, reset_tip: &str) -> HeaderClicks { + const GAP: f32 = 8.0; + let mut clicks = HeaderClicks::default(); + let avail = ui.available_width(); + let left = [("auto", "Auto", false), ("bw", "B&W", bw), ("hdr", "HDR", hdr)]; + // rows of `left` indices, filled greedily; `used` is the width taken on the current (last) row + let mut rows: Vec> = Vec::new(); + let mut row: Vec = Vec::new(); + let mut used = 0.0; + for (i, (_, label, _)) in left.iter().enumerate() { + let w = crate::widgets::text_button_size(ui, label); + if row.is_empty() { + used = w; + } else if used + GAP + w > avail { + rows.push(std::mem::take(&mut row)); + used = w; + } else { + used += GAP + w; + } + row.push(i); + } + rows.push(row); + let reset_on_last = used + GAP + crate::widgets::text_button_size(ui, "Reset") <= avail; + let reset = |ui: &mut egui::Ui, clicks: &mut HeaderClicks| { + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + clicks.reset = text_button(ui, "reset", crate::i18n::tr("Reset"), false).on_hover_text(reset_tip).clicked(); + }); + }; + let last = rows.len() - 1; + for (r, row) in rows.iter().enumerate() { + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = GAP; + for &i in row { + let (id, label, active) = left[i]; + let mut resp = text_button(ui, id, crate::i18n::tr(label), active); + if id == "hdr" { + // HDR editing, next to B&W as Lightroom has it + resp = resp.on_hover_text(crate::i18n::tr("Edit in HDR: highlights above SDR white, for HDR exports and displays")); + } + let clicked = resp.clicked(); + match id { + "auto" => clicks.auto = clicked, + "bw" => clicks.bw = clicked, + _ => clicks.hdr = clicked, + } + } + if r == last && reset_on_last { + reset(ui, &mut clicks); + } + }); + } + if !reset_on_last { + ui.horizontal(|ui| reset(ui, &mut clicks)); + } + clicks +} + fn reset_tip(keymap: &crate::shortcuts::Keymap, mac: bool) -> String { let base = crate::i18n::tr("Reset all edits"); match crate::shortcuts::shortcut_of(keymap, "develop.reset") { @@ -1969,6 +2025,52 @@ mod curve_histogram_tests { mod tests { use super::*; + /// The Edit header's buttons never cover each other or run past the panel, in any language: a button that doesn't + /// fit starts the next row, and Reset stays right-aligned. Before, Reset covered HDR in 11 of the 18 languages at + /// the default 222 pt (German *Zurücksetzen* among them) and in all but the two Chinese ones at some width. 200 pt + /// is about the narrowest panel (`RIGHT_WIDTH.min` less the margins). + #[test] + fn edit_header_buttons_do_not_overlap_in_any_language() { + use crate::i18n::Locale; + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + crate::theme::apply(&ctx); + let mut wrapped = Vec::new(); + for &locale in Locale::ALL { + crate::i18n::set_language(locale); + for width in [200.0, 222.0, 260.0, 400.0] { + let mut rects = Vec::new(); + for frame in 0..2 { + let raw = crate::headless::HeadlessView::raw_input(vec2(width, 200.0), 1.0, frame as f64 / 60.0, vec![]); + let mut out = ctx.run_ui(raw, |ui| { + egui::CentralPanel::default().frame(egui::Frame::NONE).show(ui, |ui| { + header_buttons(ui, false, false, ""); + }); + }); + out.textures_delta.clear(); + rects = crate::widgets::take_registry(&ctx); + } + let get = |id: &str| rects.iter().find(|(i, _)| i == id).map(|(_, r)| *r).unwrap(); + let buttons = ["button:auto", "button:bw", "button:hdr", "button:reset"].map(get); + for (i, a) in buttons.iter().enumerate() { + assert!(a.right() <= width + 0.5, "{locale:?} {width}: button {i} past the edge: {a:?}"); + for b in &buttons[i + 1..] { + assert!(!a.intersects(b.shrink(0.5)), "{locale:?} {width}: {a:?} overlaps {b:?}"); + } + } + let [_, _, hdr, reset] = buttons; + assert!((reset.right() - width).abs() < 0.5, "{locale:?} {width}: Reset stays right-aligned: {reset:?}"); + if reset.top() > hdr.top() { + wrapped.push((locale, width)); + } + } + } + crate::i18n::set_language(Locale::En); + assert!(wrapped.contains(&(Locale::De, 222.0)), "German wraps in the default panel: {wrapped:?}"); + // English keeps its single row from the default width up + assert!(!wrapped.iter().any(|&(l, w)| l == Locale::En && w >= 222.0), "{wrapped:?}"); + } + #[test] fn an_hdr_edit_keeps_its_hdr_histogram_through_8_bit_renders() { let ctx = egui::Context::default(); diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index 01d5b65f8c8..1f1987d3bfa 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -694,7 +694,7 @@ pub fn text_button(ui: &mut Ui, id: &str, label: &str, active: bool) -> Response let t = Tokens::get(ui.ctx()); let font = t.semibold(11.5); let galley = ui.painter().layout_no_wrap(label.to_string(), font, t.text); - let size = vec2((galley.size().x + 18.0).max(37.0), 24.0); + let size = vec2(text_button_width(galley.size().x), 24.0); let (r, resp) = ui.allocate_exact_size(size, Sense::click()); resp.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, true, active, label)); register(ui.ctx(), format!("button:{id}"), r); @@ -711,6 +711,18 @@ pub fn text_button(ui: &mut Ui, id: &str, label: &str, active: bool) -> Response resp } +/// The width of a [`text_button`] whose label is `text_width` wide. +fn text_button_width(text_width: f32) -> f32 { + (text_width + 18.0).max(37.0) +} + +/// The width [`text_button`] takes for `label` (translated as it would be), to plan a row before drawing it. +pub fn text_button_size(ui: &Ui, label: &str) -> f32 { + let t = Tokens::get(ui.ctx()); + let galley = ui.painter().layout_no_wrap(crate::i18n::tr(label).to_string(), t.semibold(11.5), t.text); + text_button_width(galley.size().x) +} + /// A segmented control: `labels` share the available width equally, `per_row` per row. Each segment is /// addressable as `button:{id}-{key}` (keys parallel to labels). Returns the clicked index. pub fn segmented(ui: &mut Ui, id: &str, items: &[(&str, &str)], active: Option, per_row: usize) -> Option { From d87ee41c6114d9b98846693bf9d7b9697115b29a Mon Sep 17 00:00:00 2001 From: EduardoAndradeMachado <119344097+EduardoAndradeMachado@users.noreply.github.com> Date: Sun, 25 Oct 2026 00:53:53 -0300 Subject: [PATCH 2/2] LR-BEHAV-LOCALIZE: the Color section's rows no longer widen the Edit panel In longer languages the Color Mixer's Hue / Saturation / Luminance row, the White Balance row and the colour swatches were wider than the panel. egui grows the content to its widest row, so the sliders and buttons below them ran past the panel's right edge, under the tool strip. - Targeted-adjustment row: the gaps narrow (6 down to 2 pt) before a button wraps, and a wrapped row starts after the target icon like the first. English keeps its single row in the default panel. - White Balance row: label and mode are cut short with an ellipsis before the eyedropper, the label first (down to 40 pt) so the mode stays whole where it can. The row never wraps, so its layout doesn't change with the mode. - Swatches: the gaps narrow only when the eight don't fit. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/edit.rs | 84 ++++++++++++----- crates/ui-egui/src/tests_edit_layout.rs | 114 ++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 20 deletions(-) diff --git a/crates/ui-egui/src/panels/edit.rs b/crates/ui-egui/src/panels/edit.rs index dd8fa7db53b..8d29cbacd25 100644 --- a/crates/ui-egui/src/panels/edit.rs +++ b/crates/ui-egui/src/panels/edit.rs @@ -223,9 +223,20 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) { section(app, ui, &d, "color", "Color", |app, ui, d| { // White balance row egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 2, bottom: 2 }).show(ui, |ui| { + // a wider row widens the whole panel's content, so label and mode are cut short before the eyedropper, like + // the profile row. The label gives way first (down to `LABEL_MIN`), so the mode, which says what is set, + // stays whole where it can; both show their full text on hover. The row never wraps: a layout that changed + // with the mode would move the menu under the pointer. + const LABEL_MIN: f32 = 40.0; ui.horizontal(|ui| { - ui.label(egui::RichText::new(crate::i18n::tr("White Balance")).font(t.font(13.0)).color(t.text_dim)); - let r = crate::widgets::dropdown(ui, "wbMode", crate::i18n::tr(d.wb.mode.label()), t.font(14.0), t.text_label); + let gap = ui.spacing().item_spacing.x; + let title = crate::i18n::tr("White Balance"); + let mode = crate::i18n::tr(d.wb.mode.label()); + let mode_w = ui.painter().layout_no_wrap(mode.to_string(), t.font(14.0), t.text_label).size().x + 20.0; + let label_max = (ui.available_width() - 28.0 - 2.0 * gap - mode_w).max(LABEL_MIN); + ui.label(crate::widgets::one_line(ui.painter(), title, t.font(13.0), t.text_dim, label_max)); + let max = ui.available_width() - 28.0 - gap; + let r = crate::widgets::dropdown_within(ui, "wbMode", mode, t.font(14.0), t.text_label, max); egui::Popup::menu(&r).show(|ui| { for m in WbMode::ALL { if m == WbMode::Custom { @@ -1282,8 +1293,11 @@ fn mixer(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings) { let bands = lightcraft_develop::MIXER_BANDS; let sel = bands.iter().position(|b| *b == app.ui.mixer_mode).unwrap_or(0); egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 8, bottom: 4 }).show(ui, |ui| { + // the gaps narrow before the swatches would run into the margin (the narrowest panel) + let n = bands.len() as f32; + let gap = ((ui.available_width() - 22.0 * n) / (n - 1.0).max(1.0)).clamp(0.0, 5.0); ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = 5.0; + ui.spacing_mut().item_spacing.x = gap; for (i, b) in bands.iter().enumerate() { let (r, resp) = ui.allocate_exact_size(vec2(22.0, 22.0), Sense::click()); crate::widgets::announce(&resp, crate::i18n::tr(b)); @@ -1299,25 +1313,55 @@ fn mixer(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings) { } }); }); - // targeted adjustment: pick the attribute, then drag on the photo + // targeted adjustment: pick the attribute, then drag on the photo. A wider row would widen the whole panel's + // content, so the gaps narrow first (English keeps one row in the default panel), then a button that still doesn't + // fit starts the next row, aligned after the target icon, as in the Edit header. egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 2, bottom: 2 }).show(ui, |ui| { - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = 6.0; - let (r, _) = ui.allocate_exact_size(vec2(20.0, 20.0), Sense::hover()); - paint(ui.painter(), r, Icon::Target, t.icon); - let items: &[(&str, &str)] = - if crate::is_bw(d) { &[("lum", "B&W Mix")] } else { &[("hue", "Hue"), ("sat", "Saturation"), ("lum", "Luminance")] }; - for (k, label) in items { - let tool = format!("tat:{k}"); - let active = app.ui.tool == tool; - if text_button(ui, &format!("tatMixer-{k}"), crate::i18n::tr(label), active) - .on_hover_text(crate::i18n::tr("Targeted adjustment: drag up/down on the photo to adjust the colours there")) - .clicked() - { - set_tat(app, ui.ctx(), &tool, active); - } + const GAP: f32 = 6.0; + const MIN_GAP: f32 = 2.0; + const ICON: f32 = 20.0; + let items: &[(&str, &str)] = + if crate::is_bw(d) { &[("lum", "B&W Mix")] } else { &[("hue", "Hue"), ("sat", "Saturation"), ("lum", "Luminance")] }; + let widths: Vec = items.iter().map(|(_, label)| crate::widgets::text_button_size(ui, label)).collect(); + let full = ui.available_width(); + let buttons: f32 = widths.iter().sum(); + let gaps = items.len() as f32; + let gap = ((full - ICON - buttons) / gaps).clamp(MIN_GAP, GAP); + // (half a point of slack: the gap that exactly fills the row must not wrap on rounding) + let gap = if ICON + buttons + gaps * gap <= full + 0.5 { gap } else { GAP }; + let avail = full - ICON - gap; + let mut rows: Vec> = Vec::new(); + let mut row = Vec::new(); + let mut used = 0.0; + for (&(k, label), &w) in items.iter().zip(&widths) { + if !row.is_empty() && used + gap + w > avail + 0.5 { + rows.push(std::mem::take(&mut row)); } - }); + used = if row.is_empty() { w } else { used + gap + w }; + row.push((k, label)); + } + rows.push(row); + for (r, row) in rows.iter().enumerate() { + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = gap; + if r == 0 { + let (icon, _) = ui.allocate_exact_size(vec2(ICON, ICON), Sense::hover()); + paint(ui.painter(), icon, Icon::Target, t.icon); + } else { + ui.add_space(ICON + gap); + } + for &(k, label) in row { + let tool = format!("tat:{k}"); + let active = app.ui.tool == tool; + if text_button(ui, &format!("tatMixer-{k}"), crate::i18n::tr(label), active) + .on_hover_text(crate::i18n::tr("Targeted adjustment: drag up/down on the photo to adjust the colours there")) + .clicked() + { + set_tat(app, ui.ctx(), &tool, active); + } + } + }); + } }); let b = bands[sel]; if crate::is_bw(d) { diff --git a/crates/ui-egui/src/tests_edit_layout.rs b/crates/ui-egui/src/tests_edit_layout.rs index 7c6d79ff097..b27aea43812 100644 --- a/crates/ui-egui/src/tests_edit_layout.rs +++ b/crates/ui-egui/src/tests_edit_layout.rs @@ -1,6 +1,7 @@ //! The Edit panel at its narrowest with a long profile applied: the profile row fits (#1759). use egui::{Rect, vec2}; +use lightcraft_develop::WbMode; use serde_json::json; use crate::{LightcraftApp, Services, headless::HeadlessView}; @@ -48,6 +49,119 @@ fn panel(width: f32) -> (Vec, Vec<(String, Rect)>) { (texts, widgets) } +/// Every widget and text the Color and Effects sections draw, with the Color Mixer open and white balance `mode`, in a +/// `width` pt right panel: drawn through `right::show`, so its border and scroll area take their share of the width as +/// in the app. The last item is the White Balance label's full width, before any cutting short. +fn color_panel(width: f32, mode: WbMode) -> (Vec<(String, Rect)>, Vec, f32) { + let mut app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services::default()); + app.ui.right = crate::state::RightPanel::Edit; + app.ui.toggle_section("color"); + app.ui.toggle_section("effects"); + app.ui.toggle_flyout("mixer"); + app.run("develop.wb", json!({"mode": serde_json::to_value(mode).unwrap()})).unwrap(); + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + crate::theme::apply(&ctx); + let mut widgets = Vec::new(); + let mut texts = Vec::new(); + for frame in 0..3 { + let raw = HeadlessView::raw_input(vec2(width, 4000.0), 1.0, frame as f64 / 60.0, vec![]); + let mut out = ctx.run_ui(raw, |ui| { + egui::CentralPanel::default().frame(egui::Frame::NONE).show(ui, |ui| { + crate::panels::right::show(&mut app, ui); + }); + }); + out.textures_delta.clear(); + texts.clear(); + for shape in &out.shapes { + text_shapes(&shape.shape, &mut texts); + } + widgets = crate::widgets::take_registry(&ctx); + } + let t = crate::theme::Tokens::get(&ctx); + let painter = egui::Painter::new(ctx.clone(), egui::LayerId::background(), Rect::EVERYTHING); + let label_w = painter.layout_no_wrap(crate::i18n::tr("White Balance").to_string(), t.font(13.0), t.text_dim).size().x; + (widgets, texts, label_w) +} + +/// A row wider than the panel widens everything below it (egui grows the content to its widest row), so the sliders +/// and buttons run past the right edge. The Color Mixer's Hue / Saturation / Luminance row did that in longer +/// languages, Portuguese *Matiz / Saturação / Luminância* among them, and the White Balance row with a long mode. +#[test] +fn the_color_section_leaves_the_edit_panel_its_width_in_every_language() { + use crate::i18n::Locale; + let mut past = Vec::new(); + let mut wrapped = Vec::new(); + for &locale in Locale::ALL { + crate::i18n::set_language(locale); + for width in [crate::state::RIGHT_WIDTH.min, crate::state::RIGHT_WIDTH.default] { + // Custom included: the menu doesn't offer it, but dragging Temp or Tint sets it + for mode in WbMode::ALL { + let at = format!("{locale:?} {width} {mode:?}"); + let (widgets, texts, label_full) = color_panel(width, mode); + let rect = |id: &str| widgets.iter().find(|(w, _)| w == id).unwrap_or_else(|| panic!("{at}: {id} not drawn")).1; + let text = |s: &str| texts.iter().find(|t| t.galley.job.text == s).unwrap_or_else(|| panic!("{at}: {s} not drawn")); + for (id, r) in &widgets { + if r.right() > width + 0.5 { + past.push(format!("{at}: {id} ends at {}", r.right())); + } + } + // White Balance: label, mode and eyedropper stay on one row whatever the mode, and the label gives way + // before the mode is cut short + let (menu, picker) = (rect("dropdown:wbMode"), rect("icon:wbPicker")); + assert!(menu.right() <= picker.left(), "{at}: the white balance menu {menu:?} runs under its eyedropper {picker:?}"); + let label = text(crate::i18n::tr("White Balance")); + let label_rect = label.visual_bounding_rect(); + assert!(menu.y_range().contains(label_rect.center().y), "{at}: the label {label_rect:?} left the menu's row {menu:?}"); + assert!(menu.y_range().contains(picker.center().y), "{at}: the eyedropper {picker:?} left the menu's row {menu:?}"); + // the mode's text inside its menu (the Edit header also has an Auto) + let shown = texts + .iter() + .find(|t| t.galley.job.text == crate::i18n::tr(mode.label()) && menu.contains_rect(t.visual_bounding_rect())) + .unwrap_or_else(|| panic!("{at}: the mode is not drawn inside its menu {menu:?}")); + // the mode is cut short only once the label is down to its 40 pt floor, and the label only when its whole + // text, the menu and the eyedropper (6 pt item gaps, `theme::apply`) don't fit the row + if shown.galley.elided { + assert!(label_rect.width() <= 40.5, "{at}: the mode is cut short while its label {label_rect:?} has room to give"); + } + if label.galley.elided { + let needed = label_full + 6.0 + menu.width() + 6.0 + picker.width(); + let row = picker.right() - label_rect.left(); + assert!(needed > row - 0.5, "{at}: the label is cut short though {needed} pt fits the {row} pt row"); + } + if locale == Locale::En && width == crate::state::RIGHT_WIDTH.default { + assert!(!shown.galley.elided, "{at}: English modes show whole in the default panel"); + if mode == WbMode::AsShot { + assert!(!label.galley.elided, "{at}: English As Shot keeps its whole label"); + } + } + if mode != WbMode::AsShot { + continue; + } + // Color Mixer: the targeted-adjustment row wraps, each later row starting after the icon like the first + let buttons = ["button:tatMixer-hue", "button:tatMixer-sat", "button:tatMixer-lum"].map(rect); + let first = buttons[0]; + for b in buttons.iter().filter(|b| b.top() > first.top()) { + let row_start = buttons.iter().filter(|o| (o.top() - b.top()).abs() < 0.5).map(|o| o.left()).fold(f32::INFINITY, f32::min); + assert!( + (row_start - first.left()).abs() < 0.5, + "{at}: a wrapped row starts at {row_start}, not after the icon at {}", + first.left() + ); + } + if buttons[2].top() > first.top() { + wrapped.push((locale, width)); + } + } + } + } + crate::i18n::set_language(Locale::En); + assert!(past.is_empty(), "widgets past the panel's right edge:\n{}", past.join("\n")); + // the gaps narrow before a button wraps: English keeps one row in the default panel, Portuguese wraps in the narrowest + assert!(!wrapped.contains(&(Locale::En, crate::state::RIGHT_WIDTH.default)), "{wrapped:?}"); + assert!(wrapped.contains(&(Locale::PtBr, crate::state::RIGHT_WIDTH.min)), "{wrapped:?}"); +} + #[test] fn a_long_profile_name_leaves_the_edit_panel_its_width() { let width = crate::state::RIGHT_WIDTH.min;