mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 02:35:37 +01:00
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:".
This commit is contained in:
1 parent
edc4fe00fa
commit
f5afa74f1f
2 files changed
+22
-2
No files matched your search
@@ -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}})));
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in new issue
Block a user