From f5afa74f1fefb6bfa6a6df36219afce64ec1c383 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 27 Nov 2026 21:32:42 -0800 Subject: [PATCH] Contextual Task Bar: the Smooth tool's Fidelity label is framework Text on its field's row The bar drew the "Fidelity:" label with a raw egui label. In a test fixture with a 700-point canvas, that label took 688 points of height in the bar's row, its text was drawn 332 points below the Fidelity field's value, and the access tree had no node for it. It is now the framework's Text, which draws it on one line on the field's baseline and gives it a label node named "Fidelity:". --- crates/ui-egui/src/canvas/task_bar.rs | 4 ++-- crates/ui-egui/src/tests/taskbar.rs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas/task_bar.rs b/crates/ui-egui/src/canvas/task_bar.rs index b3917613b8..a1613565bb 100644 --- a/crates/ui-egui/src/canvas/task_bar.rs +++ b/crates/ui-egui/src/canvas/task_bar.rs @@ -6,6 +6,7 @@ use craft::ui::buttons::{Button, IconButton}; use craft::ui::canvas::CanvasSpace; use craft::ui::canvas_controls::{TaskBar, TaskBarGrip, TaskBarHang}; use craft::ui::contract::{Bind, Gap, Props as _, Show as _, ShowContainer as _, Trigger}; +use craft::ui::display::Text; use craft::ui::menu::PanelRow; use craft::ui::popover::Popover; use craft::ui::primitives::IconSpec; @@ -465,8 +466,7 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpac if *cmd == TASK_BAR_FIDELITY { // The Smooth tool's Fidelity, labeled, sets the tool's option as it is typed or stepped. if let Some(v) = offer.fidelity { - // PLAN: assumed `freehand::fidelity_field` draws no label of its own - ui.label(*label); + Text::new(*label).show(ui); if let Some(x) = crate::dialogs::freehand::fidelity_field(ui, "task-bar-fidelity", v, "smooth").filter(|x| *x != v) { run = Some(("tool.setOption", json!({"tool": "smooth", "values": {"fidelity": x}}))); } diff --git a/crates/ui-egui/src/tests/taskbar.rs b/crates/ui-egui/src/tests/taskbar.rs index 03212221d5..3a56b8dad8 100644 --- a/crates/ui-egui/src/tests/taskbar.rs +++ b/crates/ui-egui/src/tests/taskbar.rs @@ -1584,6 +1584,26 @@ fn the_smooth_tool_shows_fidelity_and_tool_options_for_a_path() { }); } +/// The Smooth tool's "Fidelity:" label is a framework text in the bar: a label node in the access tree, drawn on one +/// line with its baseline on the Fidelity field's. +#[test] +fn the_smooth_tools_fidelity_label_is_one_line_beside_its_field() { + let mut app = app(); + let path = id(app.run("shape.ellipse", json!({"x": 60, "y": 60, "width": 120, "height": 80})).unwrap()); + select(&mut app, &[path]); + app.run("tool.select", json!({"tool": "smooth"})).unwrap(); + on_canvas(&mut app, |rig| { + let fx = rig.settle(); + let tree = fx.tree(); + let labels = tree.with_role(craft::ui::contract::Role::LABEL); + assert!(labels.iter().any(|key| tree.name_of(*key) == Some("Fidelity:")), "the label is in the access tree"); + let run = |text: &str| fx.texts().iter().find(|t| t.text == text).cloned().unwrap_or_else(|| panic!("no `{text}` painted")); + let (label, value) = (run("Fidelity:"), run("2.50 px")); + assert!(label.rect.height() < 2.0 * value.rect.height(), "the label is one line: {:?}", label.rect); + assert!((label.baseline - value.baseline).abs() <= 1.0, "the label sits on the field's baseline: {label:?} {value:?}"); + }); +} + /// After a switch to another document and back, the task bar shows the actions for the active /// document's selection: an open path's Join in the first, a rectangle's Shape Properties in the second. #[test]