mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-03 15:21:17 -05:00
Roughen: the Detail field shows its count per inch (10/in)
Roughen's Detail sets how many points the effect adds per inch of path, but its row in the effect dialog and in the Appearance panel's inline editor showed a bare number. The row now uses UnitKind::PerInch, so it reads 10/in. Zig Zag's Ridges per segment stays a plain count, and Size with Relative stays a percentage.
This commit is contained in:
@@ -752,17 +752,17 @@ mod tests {
|
||||
assert_eq!((pa["detail"].as_f64(), pb["detail"].as_f64()), (Some(3.0), Some(8.0)), "each keeps its untouched value");
|
||||
}
|
||||
|
||||
/// Zig Zag's Ridges per segment and Roughen's Detail are counts: their rows show no percent sign, while Size
|
||||
/// with Relative, a share of the object's size, shows one.
|
||||
/// Zig Zag's Ridges per segment is a plain count and Roughen's Detail a count per inch: neither row shows a
|
||||
/// percent sign, while Size with Relative, a share of the object's size, shows one.
|
||||
#[test]
|
||||
fn zig_zag_ridges_and_roughen_detail_show_no_percent_sign() {
|
||||
fn zig_zag_ridges_and_roughen_detail_show_their_count_units() {
|
||||
use craft::ui::runtime::env::UnitKind;
|
||||
let app = app();
|
||||
for (effect, key) in [("distort.zigZag", "ridges"), ("distort.roughen", "detail")] {
|
||||
for (effect, key, expected) in [("distort.zigZag", "ridges", None), ("distort.roughen", "detail", Some(UnitKind::PerInch))] {
|
||||
let cx = EffectCx::new(&app, effect, false);
|
||||
let rows = super::super::effect_rows::distort(&cx, &DialogFields::new());
|
||||
let unit = |k: &str| rows.iter().find(|p| p.key == k).map(|p| p.unit);
|
||||
assert_eq!(unit(key), Some(None), "{effect} {key}");
|
||||
assert_eq!(unit(key), Some(expected), "{effect} {key}");
|
||||
assert_eq!(unit("size"), Some(Some(UnitKind::Percent)), "{effect} size");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +88,11 @@ pub(super) fn transform(cx: &EffectCx, _fields: &DialogFields) -> Vec<Param> {
|
||||
/// Zig Zag and Roughen.
|
||||
pub(super) fn distort(cx: &EffectCx, fields: &DialogFields) -> Vec<Param> {
|
||||
let roughen = cx.id == "distort.roughen";
|
||||
// PLAN: production suffixes Detail with "/in"; `Param::unit` takes a `UnitKind` and none stands for it
|
||||
let second = if roughen { count_range("detail", lbl!("Detail:"), 10.0) } else { count_range("ridges", lbl!("Ridges per segment:"), 4.0) };
|
||||
let second = if roughen {
|
||||
count_range("detail", lbl!("Detail:"), 10.0).unit(UnitKind::PerInch)
|
||||
} else {
|
||||
count_range("ridges", lbl!("Ridges per segment:"), 4.0)
|
||||
};
|
||||
let points: Vec<(String, Label)> = choices(&cx.id, "points")
|
||||
.unwrap_or_default()
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user