//! The parameter rows of the effects whose dialogs are more than the generic list: Transform, Zig Zag, Roughen, //! Tweak, Pucker & Bloat, Scribble, Drop Shadow, Film Grain, Glass, Texturizer, Rough Pastels, the Pathfinder //! effects and Radial Blur. Each builder runs every pass; a row that depends on one other value says so with //! `visible_when`/`enabled_when`, one that depends on several branches here. use std::ops::RangeInclusive; use craft::behavior::Mixed; use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _}; use craft::ui::layout_components::{Row, Stack}; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, Param, ParamKind}; use craft::ui::pickers::Select; use craft::ui::primitives::ContentPainterCx; use craft::ui::runtime::env::{Label, LengthUnits, UnitKind}; use craft::ui::runtime::requests::PathKind; use craft::ui::text::{NumberField, StepArrows}; use craft::ui::value_drag::{PointPicker, SliderScale}; use egui::{Rect, Stroke, pos2}; use serde_json::{Map, Value}; use super::effect_params::{EffectCx, FILM_GRAIN_FIELDS, GLASS, SHADES, choices, generic, glass_textures, texturizer_textures}; use super::form; use super::transform_each::{self, ScaleLink}; /// A translated label; the literal stays visible to the string catalog. macro_rules! lbl { ($s:literal) => { Label::from(tl!($s).to_string()) }; } /// A label of a catalog entry whose text is data (a table of choices). fn data_label(text: &str) -> Label { Label::from(tl!(text).to_string()) } /// A whole-number slider row over `0..=100` percent. fn percent_range(key: &str, label: Label, default: f64) -> Param { count_range(key, label, default).unit(UnitKind::Percent) } /// A whole-number slider row over `0..=100` with no unit after the number. fn count_range(key: &str, label: Label, default: f64) -> Param { Param::new(key, label, ParamKind::range(0.0, 100.0, default, SliderScale::Linear)).decimals(0) } /// The row of `key` for either unit of a Relative/Absolute pair: a share of the object's size, or a distance in the /// document unit. fn sized_row(key: &str, label: Label, default: f64, relative: bool, lengths: LengthUnits) -> Param { if relative { percent_range(key, label, default) } else { Param::number(key, label, default, 1.0, 0).bounds(Some(0.0), Some(100.0)).length(lengths) } } /// The Relative/Absolute choice over the flag `relative` that decides the unit of the rows above it: its two ids are /// the flag's JSON values, which `form::json_of` writes back as a bool. pub(super) fn relative_radio(label: impl Into