Merge pull request #10243 from dotCooCoo/fix/roughen-detail-per-inch

Roughen: the Detail field shows its count per inch (10/in)
This commit is contained in:
.CooCoo authored and GitHub committed 2026-12-03 07:22:17 -08:00
commit d6e4ecfc96
2 files changed
+10 -7

No files matched your search

+5 -5
View File
@@ -757,17 +757,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");
}
}
+5 -2
View File
@@ -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()