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.
This commit is contained in:
dotCooCoo committed 2026-11-28 19:53:52 -08:00
1 parent 36744f4651
commit 31444b7a3f
1 file changed
+16 -12
+16 -12
View File
@@ -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);
}