From 1ba987ee7a03a14236348048130df7e5243a88a5 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 10 Oct 2026 06:08:16 +0700 Subject: [PATCH] Fix #828: Offset Path's Joins and Zig Zag's Points are dropdowns The effect versions of Offset Path, Zig Zag and Roughen showed Joins and Points as free text fields. They now pick Miter, Round or Bevel and Smooth or Corner, as Object > Path > Offset Path does. A size's Relative / Absolute (Roughen, Zig Zag, Tweak) is a pair of radio buttons, and the effect dialogs' other on/off options are checkboxes that show when they are off too (they were invisible unchecked). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/dialogs/effect.rs | 18 ++++++++++++++++++ crates/ui-egui/src/dialogs/form.rs | 20 ++++++++++++++++---- crates/ui-egui/src/i18n/es.tsv | 3 +++ crates/ui-egui/src/i18n/fr.tsv | 3 +++ crates/ui-egui/src/i18n/it.tsv | 3 +++ crates/ui-egui/src/i18n/ja.tsv | 3 +++ crates/ui-egui/src/i18n/ru.tsv | 3 +++ crates/ui-egui/src/i18n/uk.tsv | 3 +++ crates/ui-egui/src/i18n/zh-hans.tsv | 3 +++ crates/ui-egui/src/i18n/zh-hant.tsv | 3 +++ 10 files changed, 58 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/dialogs/effect.rs b/crates/ui-egui/src/dialogs/effect.rs index d02e8eb0..c8a44c1c 100644 --- a/crates/ui-egui/src/dialogs/effect.rs +++ b/crates/ui-egui/src/dialogs/effect.rs @@ -158,6 +158,8 @@ fn choices(effect: &str, key: &str) -> Option { ("blur.radial", "method") => Some(&[("Spin", "spin"), ("Zoom", "zoom")]), ("blur.radial", "quality") => Some(&[("Draft", "draft"), ("Good", "good"), ("Best", "best")]), ("blur.smart", "quality") => Some(&[("Low", "low"), ("Medium", "medium"), ("High", "high")]), + ("path.offsetPath", "joins") => Some(&[("Miter", "miter"), ("Round", "round"), ("Bevel", "bevel")]), + ("distort.roughen" | "distort.zigZag", "points") => Some(&[("Smooth", "smooth"), ("Corner", "corner")]), _ => None, } } @@ -371,3 +373,19 @@ fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result { app.ui.dialog = None; r } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn fields_that_pick_a_value_are_dropdowns_of_its_values() { + // The values come from the effect's parameter documentation (`joins: "miter"|"round"|…`). + for (effect, key) in [("path.offsetPath", "joins"), ("distort.zigZag", "points"), ("distort.roughen", "points")] { + let doc = vectorcraft_effects::effect_info(effect).unwrap().params; + let listed = doc.split(&format!("{key}: ")).nth(1).unwrap().split([',', '}', ' ']).next().unwrap().to_string(); + let values: Vec = choices(effect, key).unwrap().iter().map(|(_, v)| format!("\"{v}\"")).collect(); + assert_eq!(values.join("|"), listed, "{effect} {key}"); + } + } +} diff --git a/crates/ui-egui/src/dialogs/form.rs b/crates/ui-egui/src/dialogs/form.rs index 73ee6cad..b18dec07 100644 --- a/crates/ui-egui/src/dialogs/form.rs +++ b/crates/ui-egui/src/dialogs/form.rs @@ -215,7 +215,9 @@ pub(super) fn param_fields( d.fields.iter().filter(|(k, _)| !k.starts_with("__") && k.as_str() != "preview").map(|(k, v)| (k.clone(), v.clone())).collect(); keys.sort_by_key(|(k, _)| rank(k)); for (k, v) in keys { - ui.label(egui::RichText::new(humanized(&k)).color(t.text)); + // A size's Relative / Absolute pair (Roughen, Zig Zag, Tweak) is its own label. + let relative = k == "relative" && v.is_boolean(); + ui.label(egui::RichText::new(if relative { String::new() } else { humanized(&k) }).color(t.text)); if let Some(cur) = crate::widgets::blend_param(&k, &v) { if let Some(m) = crate::widgets::blend_param_dropdown(ui, ("fx-blend", &k), cur) { d.fields.insert(k, m); @@ -247,9 +249,19 @@ pub(super) fn param_fields( changed = true; } } - Value::Bool(mut b) => { - if ui.checkbox(&mut b, "").changed() { - d.fields.insert(k, json!(b)); + Value::Bool(b) if relative => { + ui.horizontal(|ui| { + for (label, on) in [(tl!("Relative"), true), (tl!("Absolute"), false)] { + if crate::widgets::radio(ui, label, b == on, true) && b != on { + d.fields.insert(k.clone(), json!(on)); + changed = true; + } + } + }); + } + Value::Bool(b) => { + if crate::widgets::check(ui, "", b, true) { + d.fields.insert(k, json!(!b)); changed = true; } } diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index cd1d11e4..8476f913 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2564,6 +2564,9 @@ Smart Guides (⌘U) Guías inteligentes (⌘U) Smart Punctuation… Puntuación inteligente… Smooth Suavizar + Corner Vértice + Relative Relativo + Absolute Absoluto Smooth Color Color suavizado Smooth Tool Herramienta Suavizar Snap Curves To Lines Ajustar curvas a líneas diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 873fc3cf..b8260122 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2561,6 +2561,9 @@ Smart Guides (⌘U) Repères commandés (⌘U) Smart Punctuation… Ponctuation typographique… Smooth Lisser + Corner Angle + Relative Relatif + Absolute Absolu Smooth Color Couleur lissée Smooth Tool Outil Arrondi Snap Curves To Lines Aimanter les courbes aux lignes diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 2545208c..aa5edeb5 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2564,6 +2564,9 @@ Smart Guides (⌘U) Guide sensibili (⌘U) Smart Punctuation… Punteggiatura intelligente… Smooth Smussa + Corner Angolo + Relative Relativo + Absolute Assoluto Smooth Color Colore graduale Smooth Tool Strumento Smussa Snap Curves To Lines Aggancia curve a linee diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index d3744f32..80e8c16b 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -2379,6 +2379,9 @@ Smart Guides (View → Smart Guides) スマートガイド (表示 → スマートガイド) Smart Guides (⌘U) スマートガイド (⌘U) Smooth スムーズ + Corner コーナー + Relative 相対 + Absolute 絶対 Smooth Tool スムーズツール Snap Curves To Lines 曲線を直線にスナップ View: 表示: diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 542731c6..a3ebf7d4 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2560,6 +2560,9 @@ Smart Guides (⌘U) Умные направляющие (⌘U) Smart Punctuation… Умная пунктуация… Smooth Сгладить + Corner Угол + Relative Относительно + Absolute Абсолютно Smooth Color Сглаженный цвет Smooth Tool Инструмент «Сглаживание» Snap Curves To Lines Привязывать кривые к линиям diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 058cc687..cb6f3a11 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2556,6 +2556,9 @@ Smart Guides (⌘U) Розумні напрямні (⌘U) Smart Punctuation… Розумна пунктуація… Smooth Згладити + Corner Кут + Relative Відносно + Absolute Абсолютно Smooth Color Згладжений колір Smooth Tool Інструмент «Згладжування» Snap Curves To Lines Прив’язувати криві до ліній diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index bcf90783..de889f02 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2481,6 +2481,9 @@ Smart Guides (⌘U) 智能参考线 (⌘U) Smart Punctuation… 智能标点… Smooth 平滑 + Corner 尖角 + Relative 相对 + Absolute 绝对 Smooth Color 平滑颜色 Smooth Tool 平滑工具 Snap Curves To Lines 将曲线对齐到直线 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index e0657d72..f4dc6efc 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2567,6 +2567,9 @@ Smart Guides (⌘U) 智慧型參考線 (⌘U) Smart Punctuation… 智慧型標點… Smooth 平滑 + Corner 角點 + Relative 相對 + Absolute 絕對 Smooth Color 平滑顏色 Smooth Tool 平滑工具 Snap Curves To Lines 將曲線靠齊線條