No behaviour change: every command keeps its id, label, menu, shortcut and params doc. - Engine: swatch.* -> cmd/swatch.rs, graphicStyle.* -> cmd/style.rs, appearance.* (incl. copyFrom) -> cmd/appearance.rs, stroke.set/setAdvanced -> cmd/stroke.rs, paint.editGradient/setGradientGeom -> cmd/gradient.rs. Shared helpers in cmd/mod.rs: leaf_targets/paint_targets (replacing three copies) and unique_name (swatch and graphic style naming). - UI: dialogs.rs -> dialogs/ with one file per dialog and a DialogSpec registry (one DialogKind row per dialog); shared field widgets in dialogs/form.rs. Headless frame tests draw and confirm every dialog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
717 B
Rust
27 lines
717 B
Rust
//! The generic parameter dialog (`ui.paramDialog`): edits a command's parameters (`__command`,
|
|
//! headed `__label`) and runs it on OK.
|
|
|
|
use serde_json::Value;
|
|
|
|
use super::{DialogSpec, form};
|
|
use crate::VectorcraftApp;
|
|
use crate::state::Dialog;
|
|
|
|
pub(super) const SPEC: DialogSpec = DialogSpec {
|
|
heading: |d| d.str("__label"),
|
|
body: |_, ui, d| {
|
|
form::param_fields(ui, d);
|
|
false
|
|
},
|
|
confirm,
|
|
..DialogSpec::FORM
|
|
};
|
|
|
|
/// Closes before running, so a dialog the command opens stays open.
|
|
fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result<Value, String> {
|
|
let cmd = d.str("__command");
|
|
let params = form::params(d);
|
|
app.ui.dialog = None;
|
|
app.run(&cmd, params)
|
|
}
|