From 6f590e2e77894cd8105668b2a0c8ec5dc45c0953 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:26:46 +0000 Subject: [PATCH 1/4] Selection pane: eye and padlock on every row, up before down The eye and lock cells showed their off icon only under the pointer, so an unlocked shape offered no padlock to lock it and a hidden group showed no eye. Both cells now show in every row. The move buttons read Bring Forward then Send Backward. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/selpane.rs | 6 ++--- crates/ui-egui/src/panels/selpane/ui_tests.rs | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/selpane.rs b/crates/ui-egui/src/panels/selpane.rs index b14240e00..e1c481869 100644 --- a/crates/ui-egui/src/panels/selpane.rs +++ b/crates/ui-egui/src/panels/selpane.rs @@ -144,7 +144,7 @@ fn toolbar(ui: &mut Ui, has_selection: bool, commands: &mut Vec) { Bar::new("Selection actions", BarKind::Tool) .trailing(|ui, _| { for (icon, label, command) in - [(Icon::ChevronDown, "Send Backward", "arrange.sendBackward"), (Icon::ChevronUp, "Bring Forward", "arrange.bringForward")] + [(Icon::ChevronUp, "Bring Forward", "arrange.bringForward"), (Icon::ChevronDown, "Send Backward", "arrange.sendBackward")] { if IconButton::new(icon.id()).label(label).enabled(has_selection).show(ui).clicked() { trailing.push((command, json!({}))); @@ -196,8 +196,8 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) { let mut line = ListRow::new(row.name.clone()) .depth(row.depth) .cells(icx.cells()) - .toggle(ToggleCell::eye(EYE, !row.hidden).name(if row.hidden { "Show {row}" } else { "Hide {row}" })) - .toggle(ToggleCell::lock(LOCK, row.locked).name(if row.locked { "Unlock {row}" } else { "Lock {row}" })); + .toggle(ToggleCell::eye(EYE, !row.hidden).name(if row.hidden { "Show {row}" } else { "Hide {row}" }).always_visible()) + .toggle(ToggleCell::lock(LOCK, row.locked).name(if row.locked { "Unlock {row}" } else { "Lock {row}" }).always_visible()); if row.group { line = line.group(icx.row.open); } diff --git a/crates/ui-egui/src/panels/selpane/ui_tests.rs b/crates/ui-egui/src/panels/selpane/ui_tests.rs index 2296f5238..5e77278e8 100644 --- a/crates/ui-egui/src/panels/selpane/ui_tests.rs +++ b/crates/ui-egui/src/panels/selpane/ui_tests.rs @@ -79,6 +79,32 @@ fn lists_front_most_first_with_groups_expanded() { assert!(h.query_by_label("Hide A").is_some() && h.query_by_label("Lock A").is_some()); } +/// Whether something is painted inside the node named `label`. +fn paints_inside(h: &Harness<'_, SlideApp>, label: &str) -> bool { + fn any(shape: &egui::Shape, within: egui::Rect) -> bool { + match shape { + egui::Shape::Vec(shapes) => shapes.iter().any(|shape| any(shape, within)), + shape => { + let bounds = shape.visual_bounding_rect(); + bounds.is_positive() && within.expand(0.5).contains_rect(bounds) + } + } + } + let cell = h.get_by_label(label).rect(); + h.output().shapes.iter().any(|shape| any(&shape.shape, cell)) +} + +#[test] +fn an_unlocked_row_and_a_hidden_group_show_their_toggles_without_the_pointer() { + let (mut h, ids) = harness(); + h.state_mut().run("shape.visible", json!({"id": ids[5], "visible": false})).unwrap(); + h.run_steps(3); + h.hover_at(Pos2::new(1.0, 1.0)); + h.run_steps(2); + assert!(paints_inside(&h, "Lock A"), "an unlocked shape shows the padlock it is locked with"); + assert!(paints_inside(&h, "Show G"), "a hidden group shows its struck eye"); +} + #[test] fn click_ctrl_click_and_shift_click_select() { let (mut h, _) = harness(); From 9877e57f7e9fb91a9183058ba245f4dc45b00ace Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:26:49 +0000 Subject: [PATCH 2/4] Format panes: one slider column, wrapping button rows, production precision The picture sliders sit in one field group, so their tracks share one column. The Columns row and Format Background's Apply/Reset row wrap in a narrow pane instead of cutting a button. Transparency reads to a tenth of a percent and effect amounts in whole units, as production shows them (the Half reflection's blur reads 0 pt). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/background.rs | 7 ++- crates/ui-egui/src/panels/format_shape.rs | 49 +++++++++++++------ .../src/panels/format_shape/effects.rs | 11 ++++- .../ui-egui/src/panels/format_shape_tests.rs | 17 +++++++ 4 files changed, 66 insertions(+), 18 deletions(-) diff --git a/crates/ui-egui/src/panels/background.rs b/crates/ui-egui/src/panels/background.rs index 412c4fd0a..49a361ad7 100644 --- a/crates/ui-egui/src/panels/background.rs +++ b/crates/ui-egui/src/panels/background.rs @@ -110,7 +110,7 @@ pub(super) fn background(app: &mut SlideApp, ui: &mut Ui) { _ => None, }; let picture = matches!(fill, Some(Fill::Picture(_))); - let mut buttons = Row::new().show(ui, |ui, _| { + let mut buttons = Row::new().wrap(true).show(ui, |ui, _| { let apply = Button::new(Word::plain("Apply to All")).enabled(current.is_some() || picture).show(ui).clicked(); let reset = Button::new(Word::plain("Reset Background")).show(ui).clicked(); (apply, reset) @@ -130,7 +130,10 @@ pub(super) fn background(app: &mut SlideApp, ui: &mut Ui) { } fn transparency(ui: &mut Ui, alpha: f64) -> Option { - let result = SliderField::new(Word::plain("Transparency"), Bind::given((1.0 - alpha) * 100.0), 0.0..=100.0).unit_kind(UnitKind::Percent).show(ui); + let result = SliderField::new(Word::plain("Transparency"), Bind::given((1.0 - alpha) * 100.0), 0.0..=100.0) + .unit_kind(UnitKind::Percent) + .field_decimals(super::format_shape::TRANSPARENCY_DECIMALS) + .show(ui); result.events.committed().map(|value| json!({"transparency": value / 100.0})) } diff --git a/crates/ui-egui/src/panels/format_shape.rs b/crates/ui-egui/src/panels/format_shape.rs index 6b4fee305..d55fb5010 100644 --- a/crates/ui-egui/src/panels/format_shape.rs +++ b/crates/ui-egui/src/panels/format_shape.rs @@ -9,7 +9,7 @@ use craft::ui::buttons::{Button, IconButton}; use craft::ui::choice::{Checkbox, Radio, RadioGroup, Segmented}; use craft::ui::contract::{Bind, Entry, FieldLayout, Props as _, Show as _, ShowContainer as _}; use craft::ui::display::{Divider, Shade, Text}; -use craft::ui::form::{Field, SliderField, SliderFieldLayout}; +use craft::ui::form::{Field, FieldDecimals, FieldGroup, SliderField, SliderFieldLayout}; use craft::ui::layout_components::{Row, Stack}; use craft::ui::pickers::Select; use craft::ui::primitives::IconSpec; @@ -24,6 +24,9 @@ use super::color_row::color_row; use super::{SlideApp, cref_param, run}; use crate::icons::Icon; +/// A transparency reads to a tenth of a percent ("0.0%"). +pub(crate) const TRANSPARENCY_DECIMALS: FieldDecimals = FieldDecimals::Fixed(1); + /// The formatting pane scale bases and reference options. #[derive(Default)] pub struct FormatPaneState { @@ -98,9 +101,20 @@ fn selection_takes_background_fill(app: &SlideApp) -> bool { ok } -fn slider(ui: &mut Ui, label: &'static str, value: f64, range: std::ops::RangeInclusive, unit: UnitKind) -> Option { +fn slider( + ui: &mut Ui, + label: &'static str, + value: f64, + range: std::ops::RangeInclusive, + unit: UnitKind, + decimals: FieldDecimals, +) -> Option { let mut field = Field::new(Word::plain(label)).layout(FieldLayout::Beside).id_salt(label).show(ui, |ui, _| { - SliderField::new(Word::plain(label), Bind::given(value), range.clone()).layout(SliderFieldLayout::Inline).unit_kind(unit).show(ui) + SliderField::new(Word::plain(label), Bind::given(value), range.clone()) + .layout(SliderFieldLayout::Inline) + .unit_kind(unit) + .field_decimals(decimals) + .show(ui) }); field.settle(|_, output| output.events.committed().copied()).flatten().filter(|shown| *shown != value) } @@ -288,7 +302,7 @@ fn fill_options(app: &mut SlideApp, ui: &mut Ui, sh: &Shape) { Some(Fill::Picture(pf)) => ((1.0 - pf.alpha.unwrap_or(1.0)) * 100.0) as f32, fill => solid_fill_transparency_percent(fill.as_ref()), }; - if let Some(shown) = slider(ui, "Transparency", f64::from(seed), 0.0..=100.0, UnitKind::Percent) + if let Some(shown) = slider(ui, "Transparency", f64::from(seed), 0.0..=100.0, UnitKind::Percent, TRANSPARENCY_DECIMALS) && let Some(value) = fill_transparency_to_apply(shown as f32, seed) { run(app, "shape.fill", json!({"transparency": value})); @@ -511,7 +525,7 @@ fn text_tab(app: &mut SlideApp, ui: &mut Ui, sh: &Shape) { } }); let mut columns = Field::new(Word::plain("Columns")).layout(FieldLayout::Beside).show(ui, |ui, _| { - let mut row = Row::new().show(ui, |ui, _| { + let mut row = Row::new().wrap(true).show(ui, |ui, _| { let mut picked = None; for count in 1..=3 { if Button::new(count.to_string()).show(ui).clicked() { @@ -535,15 +549,22 @@ fn text_tab(app: &mut SlideApp, ui: &mut Ui, sh: &Shape) { fn picture_tab(app: &mut SlideApp, ui: &mut Ui, sh: &Shape) { let ShapeKind::Picture { fill } = &sh.kind else { return }; - for (label, key, value, range) in [ - ("Brightness", "brightness", fill.adjust.brightness * 100.0, -100.0..=100.0), - ("Contrast", "contrast", fill.adjust.contrast * 100.0, -100.0..=100.0), - ("Saturation", "saturation", fill.adjust.saturation.unwrap_or(1.0) * 100.0, 0.0..=400.0), - ("Transparency", "transparency", (1.0 - fill.alpha.unwrap_or(1.0)) * 100.0, 0.0..=100.0), - ] { - if let Some(value) = slider(ui, label, value, range, UnitKind::Percent) { - run(app, "picture.adjust", json!({key: value / 100.0})); + // One label column for the four sliders, so their tracks line up. + let mut adjusts = Vec::new(); + FieldGroup::new(Word::plain("Picture Corrections")).show(ui, |ui, _| { + for (label, key, value, range) in [ + ("Brightness", "brightness", fill.adjust.brightness * 100.0, -100.0..=100.0), + ("Contrast", "contrast", fill.adjust.contrast * 100.0, -100.0..=100.0), + ("Saturation", "saturation", fill.adjust.saturation.unwrap_or(1.0) * 100.0, 0.0..=400.0), + ("Transparency", "transparency", (1.0 - fill.alpha.unwrap_or(1.0)) * 100.0, 0.0..=100.0), + ] { + if let Some(value) = slider(ui, label, value, range, UnitKind::Percent, FieldDecimals::Look) { + adjusts.push(json!({key: value / 100.0})); + } } + }); + for params in adjusts { + run(app, "picture.adjust", params); } if Button::new(Word::plain("Reset Picture")).show(ui).clicked() { run(app, "picture.reset", json!({})); @@ -562,7 +583,7 @@ pub(crate) fn text_transparency_of(sh: &deckcraft_model::Shape) -> f64 { /// Edits the selected text's transparency without a draft shared across shapes. pub(crate) fn text_transparency_slider(app: &mut SlideApp, ui: &mut Ui, sh: &deckcraft_model::Shape) { - if let Some(value) = slider(ui, "Transparency", text_transparency_of(sh) * 100.0, 0.0..=100.0, UnitKind::Percent) { + if let Some(value) = slider(ui, "Transparency", text_transparency_of(sh) * 100.0, 0.0..=100.0, UnitKind::Percent, TRANSPARENCY_DECIMALS) { run(app, "format.textTransparency", json!({"value": value / 100.0})); } } diff --git a/crates/ui-egui/src/panels/format_shape/effects.rs b/crates/ui-egui/src/panels/format_shape/effects.rs index 90fedb63e..4e839693b 100644 --- a/crates/ui-egui/src/panels/format_shape/effects.rs +++ b/crates/ui-egui/src/panels/format_shape/effects.rs @@ -4,7 +4,7 @@ use craft::i18n::Word; use craft::ui::buttons::Button; use craft::ui::choice::Segmented; use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _}; -use craft::ui::form::{Field, SliderField}; +use craft::ui::form::{Field, FieldDecimals, SliderField}; use craft::ui::pickers::Select; use craft::ui::runtime::env::UnitKind; use craft::ui::sections::Section; @@ -103,8 +103,15 @@ pub(super) fn tab(app: &mut SlideApp, ui: &mut Ui, sh: &deckcraft_model::Shape) } } +/// An effect amount reads in whole units, so a preset's half-point blur reads "0 pt". fn slider(ui: &mut Ui, label: &'static str, value: f64, range: std::ops::RangeInclusive, unit: UnitKind) -> Option { - SliderField::new(Word::plain(label), Bind::given(value), range).unit_kind(unit).show(ui).events.committed().copied() + SliderField::new(Word::plain(label), Bind::given(value), range) + .unit_kind(unit) + .field_decimals(FieldDecimals::Fixed(0)) + .show(ui) + .events + .committed() + .copied() } /// Camel-case preset ids are file-format names; the field presents readable words. diff --git a/crates/ui-egui/src/panels/format_shape_tests.rs b/crates/ui-egui/src/panels/format_shape_tests.rs index a14381117..c3026bcd6 100644 --- a/crates/ui-egui/src/panels/format_shape_tests.rs +++ b/crates/ui-egui/src/panels/format_shape_tests.rs @@ -279,3 +279,20 @@ fn dash_samples_and_direction_buttons_set_what_they_show() -> TestResult { assert!((angle - 180.0).abs() < 0.5, "the 180° button turns the gradient to 180°: {angle}"); Ok(()) } + +#[test] +fn picture_sliders_share_one_column() -> TestResult { + let mut session = Session::with_new(); + session.execute("slide.new", &json!({"layout": "blank"}))?; + let result = session.execute("insert.picture", &json!({"data": picture_data(), "name": "generated.png"}))?; + session.execute("edit.select", &json!({"ids": [result["id"]]}))?; + let mut h = pane(session); + h.state_mut().ui.format_tab = "picture".into(); + h.run_steps(3); + let starts: Vec = ["Brightness", "Contrast", "Saturation", "Transparency"] + .iter() + .map(|label| h.get_by_role_and_label(Role::Slider, label).rect().left()) + .collect(); + assert!(starts.windows(2).all(|pair| (pair[0] - pair[1]).abs() < 0.5), "the sliders start in one column: {starts:?}"); + Ok(()) +} From f50ee30a7be5ff4c9c7fa28463198ca5ea77e277 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:26:52 +0000 Subject: [PATCH 3/4] Pattern fill: the Foreground and Background openers show their colour The pattern's colour openers read Color with no swatch, so the picked colours could not be seen. They now show the current colour as a chip. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/color_row.rs | 39 ++++++++++++++++++- crates/ui-egui/src/panels/fillui.rs | 9 +++-- .../ui-egui/src/panels/pattern_fill_tests.rs | 15 +++++++ 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/panels/color_row.rs b/crates/ui-egui/src/panels/color_row.rs index b6b5d2283..1cfdd6fe1 100644 --- a/crates/ui-egui/src/panels/color_row.rs +++ b/crates/ui-egui/src/panels/color_row.rs @@ -1,11 +1,13 @@ //! Colour rows share the same conversion and delayed eyedropper route as ribbon menus. use craft::color_ui::ui::{ColorPick, ThemeColorMenu}; +use craft::theme::Srgba; use craft::ui::buttons::Button; use craft::ui::contract::{Bind, BodyCx, FieldLayout, Props as _, Show as _, ShowContainer as _, Trigger}; use craft::ui::controls::disclosure::DisclosureGlyph; use craft::ui::form::Field; use craft::ui::popover::Popover; +use craft::ui::primitives::IconSpec; use craft::ui::runtime::env::{Env, Label, Word}; use deckcraft_model::ColorRef; use egui::Ui; @@ -61,6 +63,19 @@ pub(crate) fn color_row( color_row_named(app, ui, key, label, label == "Color", none, on_pick); } +/// Like [`color_row`], with the opener showing `current` as a chip in place of its word: a colour that is always set +/// (a pattern's foreground and background). +pub(crate) fn color_row_showing( + app: &mut SlideApp, + ui: &mut Ui, + key: &str, + label: &str, + current: Srgba, + on_pick: impl FnOnce(&mut SlideApp, Option), +) { + color_opener(app, ui, key, label, Face::Chip(current), on_pick); +} + /// Like [`color_row`], with the opener named by its label alone (`plain`) or as "{label} color". pub(crate) fn color_row_named( app: &mut SlideApp, @@ -71,12 +86,34 @@ pub(crate) fn color_row_named( none: Option<&str>, on_pick: impl FnOnce(&mut SlideApp, Option), ) { + color_opener(app, ui, key, label, Face::Word { plain, none }, on_pick); +} + +/// What a colour opener shows. +#[derive(Clone, Copy)] +enum Face<'a> { + /// The word "Color", the opener named by its label alone (`plain`) or as "{label} color"; the menu offers `none`. + Word { plain: bool, none: Option<&'a str> }, + /// The current colour as a chip, the opener named "{label} color". + Chip(Srgba), +} + +fn color_opener(app: &mut SlideApp, ui: &mut Ui, key: &str, label: &str, face: Face<'_>, on_pick: impl FnOnce(&mut SlideApp, Option)) { let Some(uid) = app.session.active().map(|st| st.uid) else { return }; let key = format!("fmt-color:{uid}:{key}"); + let (plain, none) = match face { + Face::Word { plain, none } => (plain, none), + Face::Chip(_) => (false, None), + }; let name = if plain { Label::from(Word::plain("Color")) } else { Label::from(Env::of(ui).words::().named.fill(&[("label", label)])) }; let mut field = Field::new(label.to_owned()).layout(FieldLayout::Beside).id_salt(&key).show(ui, |ui, _| { - Button::new(name.clone()).painted(Word::plain("Color")).keeps_name(true).trailing_icon(DisclosureGlyph::dropdown()).show(ui) + let button = Button::new(name.clone()).keeps_name(true).trailing_icon(DisclosureGlyph::dropdown()); + match face { + Face::Chip(color) => button.icon(IconSpec::swatch(color)).painted(Label::Empty), + Face::Word { .. } => button.painted(Word::plain("Color")), + } + .show(ui) }); field.settle(|_, output| { let mut popup = Popover::new(Word::plain("Color"), Bind::kept().reset(false)) diff --git a/crates/ui-egui/src/panels/fillui.rs b/crates/ui-egui/src/panels/fillui.rs index a84924777..70d1ded36 100644 --- a/crates/ui-egui/src/panels/fillui.rs +++ b/crates/ui-egui/src/panels/fillui.rs @@ -5,7 +5,7 @@ use craft::color_ui::gradient::{ColorStop, GradientStops, StopRows, StopRules}; use craft::color_ui::ui::gradient::{GradientEditor, StopFields}; use craft::i18n::Word; -use craft::theme::Srgba; +use craft::theme::{Rgba, Srgba}; use craft::ui::buttons::IconButton; use craft::ui::contract::overlay::Anchor; use craft::ui::contract::{Bind, Entry, FieldLayout, Props as _, Show as _, ShowContainer as _, clicked}; @@ -25,7 +25,7 @@ use deckcraft_model::style::{Gradient, GradientFlip, GradientShape, GradientStop use egui::{Color32, CornerRadius, Rect, Ui, vec2}; use serde_json::{Value, json}; -use super::color_row::{color_menu, color_row, take_color_answer}; +use super::color_row::{color_menu, color_row_showing, take_color_answer}; use super::preset_grid::preset_grid; use crate::ribbon::cref_param; use crate::theme; @@ -456,8 +456,9 @@ pub(crate) fn pattern_editor(app: &mut crate::SlideApp, ui: &mut Ui, p: &Pattern if let Some(preset) = grid.settle(|_, picked| picked.take()).flatten().filter(|preset| preset != &pt.preset) { out = Some(PatternFill { preset, ..pt.clone() }); } - for (label, foreground) in [("Foreground", true), ("Background", false)] { - color_row(app, ui, if foreground { "pattern-foreground" } else { "pattern-background" }, label, None, |_, picked| { + for (label, foreground, current) in [("Foreground", true, fg), ("Background", false, bg)] { + let chip = Srgba::from(Rgba(current.to_srgba_unmultiplied())); + color_row_showing(app, ui, if foreground { "pattern-foreground" } else { "pattern-background" }, label, chip, |_, picked| { if let Some(color) = picked { let pattern = out.get_or_insert_with(|| pt.clone()); if foreground { diff --git a/crates/ui-egui/src/panels/pattern_fill_tests.rs b/crates/ui-egui/src/panels/pattern_fill_tests.rs index a33e8b718..f9633cd2f 100644 --- a/crates/ui-egui/src/panels/pattern_fill_tests.rs +++ b/crates/ui-egui/src/panels/pattern_fill_tests.rs @@ -99,5 +99,20 @@ fn shape_pattern_fill_keeps_preset_and_system_colors() { assert_eq!(recolored.fg, ColorRef::rgb(Rgba::from_hex("00FF00").unwrap()), "the hex submission reached the foreground"); assert_eq!(recolored.bg, before.bg, "a foreground edit keeps the system background"); assert_eq!(recolored.preset, picked.preset, "a foreground edit keeps the chosen pattern"); + assert!(paints_color(&h, "Foreground color", egui::Color32::from_rgb(0, 255, 0)), "the opener shows the colour picked"); } } + +/// Whether the button `label` paints `color` inside itself. +fn paints_color(h: &Harness<'_, SlideApp>, label: &str, color: egui::Color32) -> bool { + fn any(shape: &egui::Shape, within: egui::Rect, color: egui::Color32) -> bool { + match shape { + egui::Shape::Vec(shapes) => shapes.iter().any(|shape| any(shape, within, color)), + egui::Shape::Rect(rect) => rect.fill == color && within.contains_rect(rect.rect), + egui::Shape::Mesh(mesh) => mesh.vertices.iter().any(|vertex| vertex.color == color && within.contains(vertex.pos)), + _ => false, + } + } + let button = h.get_by_role_and_label(Role::Button, label).rect().expand(0.5); + h.output().shapes.iter().any(|shape| any(&shape.shape, button, color)) +} From 64c1a82d2e088cd5c4aa03b5d2787d5c4a802046 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:30:15 +0000 Subject: [PATCH 4/4] Animation pane: the timeline keeps its share of the row The name column took its content width and the timeline the rest, so the longest name squeezed the axis until its labels ran together, and a long name pushed the timeline out of the pane. Name and timeline now share the row by weight: the name elides and the axis stays readable. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/animpane_tests.rs | 11 +++++++++++ crates/ui-egui/src/panels/animation.rs | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/animpane_tests.rs b/crates/ui-egui/src/animpane_tests.rs index 856b1627b..0c2855577 100644 --- a/crates/ui-egui/src/animpane_tests.rs +++ b/crates/ui-egui/src/animpane_tests.rs @@ -58,6 +58,17 @@ fn after_previous_bar_starts_where_the_first_ends() { assert!((b.width() - 2.0 * a.width()).abs() < 1.5, "2 s bar twice the 1 s bar"); } +#[test] +fn a_long_name_keeps_the_timeline_column() { + let mut h = harness(); + let before = h.get_by_role_and_label(egui::accesskit::Role::Slider, "Timing bar 1").rect(); + let id = h.state().session.active().unwrap().current_slide().unwrap().animations[0].shape.0; + h.state_mut().run("shape.rename", json!({"id": id, "name": "Aurora borealis over the northern lakes at midnight in winter"})).unwrap(); + h.run_steps(3); + let after = h.query_by_role_and_label(egui::accesskit::Role::Slider, "Timing bar 1").map(|node| node.rect()); + assert!(after.is_some_and(|after| after.width() >= before.width() - 0.5), "{before:?} {after:?}"); +} + #[test] fn dragging_a_bar_sets_the_delay_and_undoes() { let mut h = harness(); diff --git a/crates/ui-egui/src/panels/animation.rs b/crates/ui-egui/src/panels/animation.rs index e6396e085..d0e8fea8f 100644 --- a/crates/ui-egui/src/panels/animation.rs +++ b/crates/ui-egui/src/panels/animation.rs @@ -113,10 +113,11 @@ pub(super) fn animation(app: &mut SlideApp, ui: &mut Ui) { let seconds = animtimeline::ruler_seconds(&bars); let range = 0.0..=f64::from(seconds); let every = (seconds / 6).max(1); + // The name and the timeline share the row, so a long name elides and the timeline keeps its column. let columns = vec![ craft::ui::contract::ColumnSpec::new(CLICK, Label::Empty, ColumnWidth::Content), - craft::ui::contract::ColumnSpec::new(NAME, Label::Empty, ColumnWidth::Content), - craft::ui::contract::ColumnSpec::new(TIMING, Label::Empty, ColumnWidth::fill(1.0)).at_least(Env::of(ui).tokens.size.length.track), + craft::ui::contract::ColumnSpec::new(NAME, Label::Empty, ColumnWidth::fill(2.0)), + craft::ui::contract::ColumnSpec::new(TIMING, Label::Empty, ColumnWidth::fill(3.0)).at_least(Env::of(ui).tokens.size.length.track), craft::ui::contract::ColumnSpec::new(REPEAT, Label::Empty, ColumnWidth::Controls(1.0)), ]; let commits = RefCell::new(Vec::new());