From ec51f3d03721a8e99d8478f439381b29d8d06302 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:17:57 -0800 Subject: [PATCH] Stroke: Cap, Corner, Align Stroke and Miter Limit line up with the panel rows The Stroke panel showed the stroke editor's rows with a label column of their own, so the Alignment, Caps and Corners buttons and the Miter Limit and Dash offset fields started left of the Weight, Arrowheads and Profile controls. The panel now turns on StrokeEditor::host_labels (craft-libs#4227, in the pinned craft-libs), and the editor's rows read the label column of the panel's Stroke Options group. the_panel_rows_start_their_controls_at_one_x now also checks the Alignment, Caps, Corners, Miter limit and Dash offset controls. --- crates/ui-egui/src/panels/stroke.rs | 5 +++-- crates/ui-egui/src/panels/tests_stroke.rs | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/stroke.rs b/crates/ui-egui/src/panels/stroke.rs index 7ea1db6e49..7f71d73da4 100644 --- a/crates/ui-egui/src/panels/stroke.rs +++ b/crates/ui-egui/src/panels/stroke.rs @@ -377,7 +377,7 @@ pub(crate) fn link_field(app: &mut VectorcraftApp, ui: &mut Ui, label: &'static } /// The Stroke panel: the weight, the stroke editor (cap, corner, align, dashes), arrowheads, scale, align and the -/// width profile. The panel's own rows share one label column, so their controls start at one x. +/// width profile. The panel's rows and the editor's rows share one label column, so their controls start at one x. pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { use craft::ui::runtime::env::{WordRows, WordsOverride, with_env}; @@ -411,7 +411,8 @@ fn rows(app: &mut VectorcraftApp, ui: &mut Ui) { let editor = StrokeEditor::new(tl!("Stroke"), Bind::given(style.clone())) .sections(StrokeSections::PANEL | StrokeSections::DASH_ALIGN) .closed(mixed.can_align) - .mixed(&mixed_of(&mixed)); + .mixed(&mixed_of(&mixed)) + .host_labels(true); let output = editor.show(ui); if let (Some(new), Some(field)) = (output.events.landed(), output.field) { apply_style(app, &style, new.clone(), field); diff --git a/crates/ui-egui/src/panels/tests_stroke.rs b/crates/ui-egui/src/panels/tests_stroke.rs index 8aca326b47..66cf954339 100644 --- a/crates/ui-egui/src/panels/tests_stroke.rs +++ b/crates/ui-egui/src/panels/tests_stroke.rs @@ -28,9 +28,16 @@ fn turning_dashes_on_fits_them_to_corners_and_turning_back_on_restores_the_last_ #[test] fn the_panel_rows_start_their_controls_at_one_x() { let mut panel = Panel::new(app_with_rect(), stroke::show); + // Dashes show the Dash offset row. + run(&mut panel.app(), "stroke.set", json!({"dash": [4, 2]})); panel.frame(); panel.frame(); - let starts: Vec<(&str, f32)> = ["Weight", "Start arrowhead", "Profile"].into_iter().map(|name| (name, panel.rect(name).min.x)).collect(); + let names = ["Weight", "Miter limit", "Dash offset", "Start arrowhead", "Profile"]; + let mut starts: Vec<(&str, f32)> = names.into_iter().map(|name| (name, panel.rect(name).min.x)).collect(); + // The label text of the editor's button rows has the same names as their button groups. + for name in ["Alignment", "Caps", "Corners"] { + starts.push((name, panel.rect_role(name, craft::ui::contract::Role::RADIO_GROUP).min.x)); + } let first = starts[0].1; assert!(starts.iter().all(|(_, x)| (x - first).abs() < 0.5), "controls start at {starts:?}"); }