From 8270b4f982140affc839c8722a0fc0278edb1ae6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 18:01:58 -0800 Subject: [PATCH 1/2] Stroke: the panel's rows share one label column The Weight, Arrowheads, Scale, Align and Profile rows each sized their own label column, so their controls started at different x positions. The panel now shows its rows in one FieldGroup, and they share the widest label. --- crates/ui-egui/src/panels/stroke.rs | 9 +++++++-- crates/ui-egui/src/panels/tests_stroke.rs | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/stroke.rs b/crates/ui-egui/src/panels/stroke.rs index e51b4b9072..1d8ee506a8 100644 --- a/crates/ui-egui/src/panels/stroke.rs +++ b/crates/ui-egui/src/panels/stroke.rs @@ -12,7 +12,7 @@ use craft::ui::buttons::IconButton; use craft::ui::choice::Segmented; use craft::ui::contract::{Bind, Entry, FieldLabelRole, Props as _, Show as _, ShowContainer as _, SideLabel, Sizing, TooltipSpec}; use craft::ui::display::Divider; -use craft::ui::form::Field; +use craft::ui::form::{Field, FieldGroup}; use craft::ui::layout_components::{Grid, Row}; use craft::ui::list::ThumbAspect; use craft::ui::menu::PanelRow; @@ -362,8 +362,13 @@ 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. +/// width profile. The panel's own rows share one label column, so their controls start at one x. pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { + FieldGroup::new(tl!("Stroke Options")).show(ui, |ui, _| rows(app, ui)); +} + +/// The rows of [`show`]. +fn rows(app: &mut VectorcraftApp, ui: &mut Ui) { use craft::ui::runtime::env::{WordRows, WordsOverride, with_env}; let st = current_stroke(app); diff --git a/crates/ui-egui/src/panels/tests_stroke.rs b/crates/ui-egui/src/panels/tests_stroke.rs index 7ab142266f..8aca326b47 100644 --- a/crates/ui-egui/src/panels/tests_stroke.rs +++ b/crates/ui-egui/src/panels/tests_stroke.rs @@ -24,3 +24,13 @@ fn turning_dashes_on_fits_them_to_corners_and_turning_back_on_restores_the_last_ let d = toggle_dashes(&mut panel).expect("dashes on"); assert_eq!((d.pattern, d.align_corners), (vec![4.0, 2.0], false)); } + +#[test] +fn the_panel_rows_start_their_controls_at_one_x() { + let mut panel = Panel::new(app_with_rect(), stroke::show); + 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 first = starts[0].1; + assert!(starts.iter().all(|(_, x)| (x - first).abs() < 0.5), "controls start at {starts:?}"); +} From 31444b7a3f562a781aa562a62a341e9832127fb5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 19:53:52 -0800 Subject: [PATCH 2/2] Stroke: set the Miter Limit word outside the panel's label group The label group runs its rows once to measure them, and that run may not set the interface words, so the word override now wraps the group. --- crates/ui-egui/src/panels/stroke.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/panels/stroke.rs b/crates/ui-egui/src/panels/stroke.rs index 1d8ee506a8..15b3e438cc 100644 --- a/crates/ui-egui/src/panels/stroke.rs +++ b/crates/ui-egui/src/panels/stroke.rs @@ -364,13 +364,25 @@ 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. pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { - FieldGroup::new(tl!("Stroke Options")).show(ui, |ui, _| rows(app, ui)); + use craft::ui::runtime::env::{WordRows, WordsOverride, with_env}; + + // VectorCraft's catalog calls the editor's "Miter limit" field "Miter Limit". The words are set outside the + // group, whose measuring run may not set them. + let word = craft::i18n::Word::keyed("strokeEditor.miterLimit", "Miter limit"); + let lang = app.ui_language(); + let translated = crate::i18n::tr(lang, "Miter Limit"); + let group = |app: &mut VectorcraftApp, ui: &mut Ui| { + FieldGroup::new(tl!("Stroke Options")).show(ui, |ui, _| rows(app, ui)); + }; + if translated != "Miter Limit" && crate::i18n::tr_id(lang, word.id, word.english) == word.english { + with_env(ui, |env| env.words = Some(WordsOverride::Overlay(WordRows::new().row(word, translated))), |ui| group(app, ui)); + } else { + group(app, ui); + } } /// The rows of [`show`]. fn rows(app: &mut VectorcraftApp, ui: &mut Ui) { - use craft::ui::runtime::env::{WordRows, WordsOverride, with_env}; - let st = current_stroke(app); let mixed = stroke_mixed(app, ui.ctx()); let weight = shown_weight(app, st.as_ref(), &mixed); @@ -385,15 +397,7 @@ fn rows(app: &mut VectorcraftApp, ui: &mut Ui) { .sections(StrokeSections::PANEL | StrokeSections::DASH_ALIGN) .closed(mixed.can_align) .mixed(&mixed_of(&mixed)); - // VectorCraft's catalog calls this field "Miter Limit". - let word = craft::i18n::Word::keyed("strokeEditor.miterLimit", "Miter limit"); - let lang = app.ui_language(); - let translated = crate::i18n::tr(lang, "Miter Limit"); - let output = if translated != "Miter Limit" && crate::i18n::tr_id(lang, word.id, word.english) == word.english { - with_env(ui, |env| env.words = Some(WordsOverride::Overlay(WordRows::new().row(word, translated))), |ui| editor.show(ui)) - } else { - editor.show(ui) - }; + let output = editor.show(ui); if let (Some(new), Some(field)) = (output.events.landed(), output.field) { apply_style(app, &style, new.clone(), field); }