mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-28 03:37:00 -06:00
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3198abe2fd
commit
1ba987ee7a
@@ -158,6 +158,8 @@ fn choices(effect: &str, key: &str) -> Option<form::Choices> {
|
||||
("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<Value, String> {
|
||||
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<String> = choices(effect, key).unwrap().iter().map(|(_, v)| format!("\"{v}\"")).collect();
|
||||
assert_eq!(values.join("|"), listed, "{effect} {key}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -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
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2379,6 +2379,9 @@
|
||||
Smart Guides (View → Smart Guides) スマートガイド (表示 → スマートガイド)
|
||||
Smart Guides (⌘U) スマートガイド (⌘U)
|
||||
Smooth スムーズ
|
||||
Corner コーナー
|
||||
Relative 相対
|
||||
Absolute 絶対
|
||||
Smooth Tool スムーズツール
|
||||
Snap Curves To Lines 曲線を直線にスナップ
|
||||
View: 表示:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2560,6 +2560,9 @@
|
||||
Smart Guides (⌘U) Умные направляющие (⌘U)
|
||||
Smart Punctuation… Умная пунктуация…
|
||||
Smooth Сгладить
|
||||
Corner Угол
|
||||
Relative Относительно
|
||||
Absolute Абсолютно
|
||||
Smooth Color Сглаженный цвет
|
||||
Smooth Tool Инструмент «Сглаживание»
|
||||
Snap Curves To Lines Привязывать кривые к линиям
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2556,6 +2556,9 @@
|
||||
Smart Guides (⌘U) Розумні напрямні (⌘U)
|
||||
Smart Punctuation… Розумна пунктуація…
|
||||
Smooth Згладити
|
||||
Corner Кут
|
||||
Relative Відносно
|
||||
Absolute Абсолютно
|
||||
Smooth Color Згладжений колір
|
||||
Smooth Tool Інструмент «Згладжування»
|
||||
Snap Curves To Lines Прив’язувати криві до ліній
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 632 and column 40.
|
@@ -2481,6 +2481,9 @@
|
||||
Smart Guides (⌘U) 智能参考线 (⌘U)
|
||||
Smart Punctuation… 智能标点…
|
||||
Smooth 平滑
|
||||
Corner 尖角
|
||||
Relative 相对
|
||||
Absolute 绝对
|
||||
Smooth Color 平滑颜色
|
||||
Smooth Tool 平滑工具
|
||||
Snap Curves To Lines 将曲线对齐到直线
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2567,6 +2567,9 @@
|
||||
Smart Guides (⌘U) 智慧型參考線 (⌘U)
|
||||
Smart Punctuation… 智慧型標點…
|
||||
Smooth 平滑
|
||||
Corner 角點
|
||||
Relative 相對
|
||||
Absolute 絕對
|
||||
Smooth Color 平滑顏色
|
||||
Smooth Tool 平滑工具
|
||||
Snap Curves To Lines 將曲線靠齊線條
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
Reference in New Issue
Block a user