diff --git a/crates/ui-egui/src/dialogs/char_style_options.rs b/crates/ui-egui/src/dialogs/char_style_options.rs index 9fcb532c33..25c7891020 100644 --- a/crates/ui-egui/src/dialogs/char_style_options.rs +++ b/crates/ui-egui/src/dialogs/char_style_options.rs @@ -8,8 +8,9 @@ use std::sync::Arc; use craft::behavior::Mixed; use craft::ui::choice::Checkbox; -use craft::ui::contract::{Bind, Entry, Outcome as _, Props as _, Show as _}; +use craft::ui::contract::{Bind, Entry, Outcome as _, Props as _, Show as _, ShowContainer as _}; use craft::ui::dialog::{DialogResult, FieldRefusal}; +use craft::ui::layout_components::Row; use craft::ui::patterns::form_dialogs::{ DialogFields, FieldValue, HostedPropertiesDialog, Param, ParamKind, PropertiesDialog, PropertiesTab, PropertyRow, TabLayout, }; @@ -843,7 +844,9 @@ fn sets_row() -> Param { .and_then(|v| v.as_array().map(|tags| tags.iter().filter_map(Value::as_str).map(str::to_string).collect())) .unwrap_or_default(); let mut clicked = None; - let line = ui.horizontal_wrapped(|ui| { + let line = Row::new().wrap(true).show(ui, |ui, _| { + // The row's body may run more than once in a pass: the last run's click applies. + clicked = None; for set in &vectorcraft_text::EXTRA_FEATURES[..20] { let current = listed.iter().find(|t| bare(t) == *set).map(|t| !t.starts_with('-')); if let (_, Some(next)) = tri_box(ui, current, Some(Label::from(set.to_string())), set) { @@ -864,7 +867,7 @@ fn sets_row() -> Param { fields.set("ot_sets", FieldValue::Json(json!(listed))); } } - line.response + line.output }) } diff --git a/crates/ui-egui/src/dialogs/color_balance.rs b/crates/ui-egui/src/dialogs/color_balance.rs index 5dfeb4e018..c82918426b 100644 --- a/crates/ui-egui/src/dialogs/color_balance.rs +++ b/crates/ui-egui/src/dialogs/color_balance.rs @@ -199,12 +199,11 @@ fn track(key: &str, x: f32) -> Srgba { /// The channel rows of the current mode. fn channels(ui: &mut egui::Ui, fields: &mut DialogFields, _cx: &mut CustomContext) -> egui::Response { - ui.vertical(|ui| { + super::form::stacked(ui, fields, |ui, fields| { for (key, label) in mode(fields).channels { percent_row(ui, fields, key, label, |x| track(key, x)); } }) - .response } fn rows() -> Vec { diff --git a/crates/ui-egui/src/dialogs/color_guide_options.rs b/crates/ui-egui/src/dialogs/color_guide_options.rs index 37836565e4..721064005b 100644 --- a/crates/ui-egui/src/dialogs/color_guide_options.rs +++ b/crates/ui-egui/src/dialogs/color_guide_options.rs @@ -32,12 +32,11 @@ pub fn open(app: &mut VectorcraftApp) { fields.set("steps", f64::from(current.steps)); fields.set("amount", f64::from(current.amount)); let steps = Param::custom("steps", field_label(tl!("Steps:")), |ui, fields, _| { - ui.vertical(|ui| { + super::form::stacked(ui, fields, |ui, fields| { slider(ui, fields, "steps", tl!("Steps:"), 1.0..=f64::from(GuideOptions::MAX_STEPS), None); let ends = [(0.0, tl!("Less").to_owned()), (100.0, tl!("More").to_owned())]; slider(ui, fields, "amount", tl!("Variation:"), 0.0..=100.0, Some(ends)); }) - .response }) .companions(["amount"]); let variations = Param::custom("variations", field_label(tl!("Variations:")), move |ui, fields, _| { diff --git a/crates/ui-egui/src/dialogs/form.rs b/crates/ui-egui/src/dialogs/form.rs index 538141fc11..6d81d18214 100644 --- a/crates/ui-egui/src/dialogs/form.rs +++ b/crates/ui-egui/src/dialogs/form.rs @@ -4,9 +4,11 @@ use std::collections::HashMap; -use craft::ui::contract::{Bind, Show as _}; +use craft::ui::contract::{Bind, Show as _, ShowContainer as _}; +use craft::ui::layout_components::Stack; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, Param, ParamKind, encode}; use craft::ui::runtime::env::{Label, LengthUnits, UnitKind}; +use craft::ui::runtime::measure; use craft::ui::text::TextField; use craft::ui::value_drag::SliderScale; use serde_json::{Map, Value, json}; @@ -200,6 +202,25 @@ pub(crate) fn fields_of(params: &[Param], json: &Map) -> DialogFi fields } +/// Shows `body` in a `Stack` as rows of a custom dialog row that edit `fields`. The stack may run its body more than +/// once in a pass: every run edits a copy of the values as they stand here, and the copy of the run that is not a +/// measuring run replaces them after the stack. +pub(super) fn stacked(ui: &mut egui::Ui, fields: &mut DialogFields, mut body: impl FnMut(&mut egui::Ui, &mut DialogFields)) -> egui::Response { + let before = fields.clone(); + let mut edited = None; + let shown = Stack::new().show(ui, |ui, _| { + let mut run = before.clone(); + body(ui, &mut run); + if measure::effect(ui.ctx(), "dialog rows edit their values") { + edited = Some(run); + } + }); + if let Some(edited) = edited { + *fields = edited; + } + shown.output +} + /// The command or effect parameters of the dialog values `fields`: the UI-only keys (`__*`, `preview`) are dropped. pub(crate) fn json_of(params: &[Param], fields: &DialogFields) -> Map { fields diff --git a/crates/ui-egui/src/dialogs/hpgl_options.rs b/crates/ui-egui/src/dialogs/hpgl_options.rs index 3cfe0ecdfc..50eab143f5 100644 --- a/crates/ui-egui/src/dialogs/hpgl_options.rs +++ b/crates/ui-egui/src/dialogs/hpgl_options.rs @@ -18,7 +18,7 @@ use craft::ui::choice::{Radio, RadioGroup, Swatch}; use craft::ui::contract::{Bind, Props as _, Scroll, Show as _, ShowContainer as _}; use craft::ui::dialog::DialogId; use craft::ui::layout_components::{Row, Stack}; -use craft::ui::patterns::form_dialogs::{CustomContext, DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog}; +use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog}; use craft::ui::runtime::env::Env; use craft::ui::style::rgba_color; use craft::ui::text::TextField; @@ -143,18 +143,13 @@ fn pen_key(i: usize) -> String { fn pens_param() -> Param { Param::custom("pens", tl!("Pens:"), |ui, fields, cx| { take_picked_pens(fields); - // The rows draw from the values as they stand here and the edits apply after them: the stack's body may run - // twice in a pass. - let mut drawn = fields.clone(); + // The stack's body may run more than once in a pass: every run draws from the values as they stand here, and + // what the last run asked for applies after the stack. let mut asked = PensAsked::default(); - let shown = Stack::new().show(ui, |ui, _| { - asked = pens_ui(ui, &drawn, cx); - if let Some(p) = &asked.pens { - drawn.set("pens", FieldValue::Json(Value::Array(p.clone()))); - } - }); - // An edit of the rows in any run of the body is in `drawn`; a switch of Pen Table drops it. - let edited = table(&drawn).filter(|p| asked.table.is_none() && table(fields).as_ref() != Some(p)); + let shown = Stack::new().show(ui, |ui, _| asked = pens_ui(ui, fields)); + if let Some((i, color)) = asked.pick { + cx.pick_color(&pen_key(i), color); + } match asked.table { Some(true) => cx.request_action("penTable"), Some(false) => { @@ -163,7 +158,7 @@ fn pens_param() -> Param { } None => {} } - if let Some(pens) = edited { + if let Some(pens) = asked.pens { fields.set("pens", FieldValue::Json(Value::Array(pens))); } shown.output @@ -179,11 +174,13 @@ struct PensAsked { table: Option, /// The pen table after an edit of its rows. pens: Option>, + /// The pen whose swatch was pressed, with its color: the picker opens on it. + pick: Option<(usize, Srgba)>, } /// Writes the colors the picker answered into the pen table. fn take_picked_pens(fields: &mut DialogFields) { - let Some(mut pens) = table(fields).filter(|a| a.len() <= MAX_PENS) else { return }; + let Some(mut pens) = table(fields) else { return }; let mut changed = false; for (i, pen) in pens.iter_mut().enumerate() { if let Some([r, g, b]) = fields.color(&pen_key(i)) { @@ -200,7 +197,7 @@ fn take_picked_pens(fields: &mut DialogFields) { /// The pens row. Switching to Pen Table asks the host (`penTable`): the table starts from the document's pens, which /// this draw cannot reach. -fn pens_ui(ui: &mut egui::Ui, fields: &DialogFields, cx: &mut CustomContext) -> PensAsked { +fn pens_ui(ui: &mut egui::Ui, fields: &DialogFields) -> PensAsked { let mut asked = PensAsked::default(); let list = table(fields); let mut on = list.is_some(); @@ -219,29 +216,35 @@ fn pens_ui(ui: &mut egui::Ui, fields: &DialogFields, cx: &mut CustomContext) -> let Some(mut pens) = list.filter(|a| asked.table.is_none() && a.len() <= MAX_PENS) else { return asked }; let mut changed = false; let n = pens.len(); + // What the rows asked for: a typed color per pen, the pen whose swatch or Remove was pressed. Each run of the + // stack's body starts them afresh from the same pens. + let mut typed: Vec> = vec![None; n]; let mut remove = None; Stack::new().scroll(Scroll::vertical()).room_height(180.0).show(ui, |ui, _| { - for (i, pen) in pens.iter_mut().enumerate() { + typed.iter_mut().for_each(|t| *t = None); + (remove, asked.pick) = (None, None); + for (i, pen) in pens.iter().enumerate() { Row::new().id_salt(("hpgl-pen-row", i)).show(ui, |ui, _| { ui.label((i + 1).to_string()); let mut color = pen.as_str().and_then(Rgba::from_hex).unwrap_or(Rgba::rgb(0, 0, 0)); if Swatch::new(tl!("Pen color"), Srgba::from(color)).show(ui).clicked { - cx.pick_color(&pen_key(i), Srgba::from(color)); + asked.pick = Some((i, Srgba::from(color))); } let before = color; TextField::hex(tl!("Pen color"), Bind::bound(&mut color)).id_salt(("hpgl-pen", i)).show(ui); - if color != before - && let Some(typed) = pen_color(&color.to_hex()) - { - *pen = json!(typed); - changed = true; - } + typed[i] = (color != before).then(|| pen_color(&color.to_hex())).flatten(); if IconButton::new(IconId::new("trash")).label(tl!("Remove")).enabled(n > 1).show(ui).clicks > 0 { remove = Some(i); } }); } }); + for (pen, typed) in pens.iter_mut().zip(typed) { + if let Some(typed) = typed { + *pen = json!(typed); + changed = true; + } + } if Button::new(tl!("Add")).enabled(n < MAX_PENS).show(ui).clicks > 0 { // A new pen starts as the last one's color, ready to be changed. pens.push(pens.last().cloned().unwrap_or_else(|| json!("#000000"))); diff --git a/crates/ui-egui/src/dialogs/revolve.rs b/crates/ui-egui/src/dialogs/revolve.rs index 3804c4ea3a..a61190970e 100644 --- a/crates/ui-egui/src/dialogs/revolve.rs +++ b/crates/ui-egui/src/dialogs/revolve.rs @@ -9,7 +9,8 @@ use craft::behavior::{DisplayOrder, ItemSource, SelectionChange}; use craft::theme::Srgba; use craft::ui::buttons::Button; use craft::ui::contract::Entry; -use craft::ui::contract::{Bind, CollectionEvent, Props as _, Show as _, ShowCollection as _, clicked}; +use craft::ui::contract::{Bind, CollectionEvent, Props as _, Show as _, ShowCollection as _, ShowContainer as _, clicked}; +use craft::ui::layout_components::Row; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamKind, ParamRows}; use craft::ui::pickers::Select; use craft::ui::runtime::env::LengthUnits; @@ -369,19 +370,23 @@ pub(crate) fn bevel_row(data: &Data, effect: &str, place: Place) -> Param { }; let default_at = options[..builtin].iter().position(|(_, v, _)| *v == default); let titles: Vec = options.iter().map(|(l, _, _)| l.clone()).collect(); - ui.horizontal(|ui| { - if let Some((_, v, c)) = pick(ui, c3("Bevel Shape"), &titles, current, default_at).and_then(|i| options.get(i)) { - set_value(fields, "bevel", v); - if let Some((n, p)) = c { - set_value(fields, BEVEL_NAME, &json!(n)); - set_value(fields, BEVEL_PROFILE, p); - } + // The row's body may run more than once in a pass: it reports the pick and the press, which apply after it. + let (mut picked, mut edit) = (None, false); + let row = Row::new().show(ui, |ui, _| { + picked = pick(ui, c3("Bevel Shape"), &titles, current, default_at); + edit = place == Place::Panel && pressed(ui, tl!("Edit Bevels…"), file, None); + }); + if let Some((_, v, c)) = picked.and_then(|i| options.get(i)) { + set_value(fields, "bevel", v); + if let Some((n, p)) = c { + set_value(fields, BEVEL_NAME, &json!(n)); + set_value(fields, BEVEL_PROFILE, p); } - if place == Place::Panel && pressed(ui, tl!("Edit Bevels…"), file, None) { - fields.set("__editBevels", true); - } - }) - .response + } + if edit { + fields.set("__editBevels", true); + } + row.output }) .companions([BEVEL_NAME, BEVEL_PROFILE, "__editBevels"]) } @@ -675,12 +680,13 @@ fn light_color_row() -> Param { Param::custom("lightColor", tl!("Color"), |ui, fields, cx| { let hex = fields.text("lightColor").unwrap_or("#ffffff").to_owned(); let color = Srgba::from_hex(&hex).unwrap_or(Srgba::rgb(1.0, 1.0, 1.0)); - ui.horizontal(|ui| { - if pressed(ui, &hex.to_uppercase(), true, Some(tl!("Color"))) { - cx.pick_color("__lightPick", color); - } - }) - .response + // The row's body may run more than once in a pass: the picker opens after it. + let mut ask = false; + let row = Row::new().show(ui, |ui, _| ask = pressed(ui, &hex.to_uppercase(), true, Some(tl!("Color")))); + if ask { + cx.pick_color("__lightPick", color); + } + row.output }) .opens_with("#ffffff") } @@ -711,11 +717,11 @@ pub(crate) fn light_editor(_data: &Data, place: Place, classic: bool) -> Param { // The classic effects' lights have no colour. let settings: Vec = settings.into_iter().filter(|p| !(classic && p.key == "lightColor")).collect(); Param::custom("lights", tl!("Lights"), move |ui, fields, cx| { + if let Some(Value::String(hex)) = fields.color("__lightPick").map(|c| json!(Srgba::from_rgb_array(c).to_hex())) { + fields.remove("__lightPick"); + set_light_value(fields, "lightColor", json!(hex)); + } ui.vertical(|ui| { - if let Some(Value::String(hex)) = fields.color("__lightPick").map(|c| json!(Srgba::from_rgb_array(c).to_hex())) { - fields.remove("__lightPick"); - set_light_value(fields, "lightColor", json!(hex)); - } let mut list = explicit_lights(fields).unwrap_or_else(|| vec![light_record(fields)]); let mut index = light_index(fields, list.len()); let titles: Vec = (1..=list.len()).map(|i| format!("{} {i}", c3("Light"))).collect(); @@ -724,27 +730,31 @@ pub(crate) fn light_editor(_data: &Data, place: Place, classic: bool) -> Param { } // Add Light is off while a setting of the single light is mixed. let mixed = explicit_lights(fields).is_none() && LIGHT_KEYS.iter().any(|(_, key)| fields.is_mixed(key)); - ui.horizontal(|ui| { - if pressed(ui, tl!("Add Light"), list.len() < vectorcraft_three_d::MAX_LIGHTS && !mixed, None) { - let mut added = selected_light(fields); - let defaults = vectorcraft_effects::default_params(fields.text("__effect").unwrap_or_default()).unwrap_or(json!({})); - for (_, key) in LIGHT_KEYS { - if let Some(value) = defaults.get(key) { - set_value(&mut added, key, value); - } - } - set_value(&mut added, "lightRotation", &json!(0.0)); - set_value(&mut added, "lightHeight", &json!(90.0)); - list.push(light_record(&added)); - index = list.len() - 1; - fields.set("lights", FieldValue::Json(Value::Array(list.clone()))); - } - if pressed(ui, tl!("Delete Light"), list.len() > 1, None) && index < list.len() { - list.remove(index); - index = index.min(list.len().saturating_sub(1)); - fields.set("lights", FieldValue::Json(Value::Array(list.clone()))); - } + // The row's body may run more than once in a pass: it reports the presses, which apply after it. + let (mut add, mut delete) = (false, false); + Row::new().show(ui, |ui, _| { + add = pressed(ui, tl!("Add Light"), list.len() < vectorcraft_three_d::MAX_LIGHTS && !mixed, None); + delete = pressed(ui, tl!("Delete Light"), list.len() > 1, None); }); + if add { + let mut added = selected_light(fields); + let defaults = vectorcraft_effects::default_params(fields.text("__effect").unwrap_or_default()).unwrap_or(json!({})); + for (_, key) in LIGHT_KEYS { + if let Some(value) = defaults.get(key) { + set_value(&mut added, key, value); + } + } + set_value(&mut added, "lightRotation", &json!(0.0)); + set_value(&mut added, "lightHeight", &json!(90.0)); + list.push(light_record(&added)); + index = list.len() - 1; + fields.set("lights", FieldValue::Json(Value::Array(list.clone()))); + } + if delete && index < list.len() { + list.remove(index); + index = index.min(list.len().saturating_sub(1)); + fields.set("lights", FieldValue::Json(Value::Array(list.clone()))); + } fields.set("__light", i64::try_from(index).unwrap_or(0)); if place == Place::Panel || classic { super::revolve_lights::sphere(ui, fields, cx, classic); diff --git a/crates/ui-egui/src/dialogs/tests_hpgl.rs b/crates/ui-egui/src/dialogs/tests_hpgl.rs index dab1dbe8c6..0330cd7521 100644 --- a/crates/ui-egui/src/dialogs/tests_hpgl.rs +++ b/crates/ui-egui/src/dialogs/tests_hpgl.rs @@ -160,8 +160,9 @@ fn pen_table_starts_from_the_art_s_pens_and_comes_back() { assert_eq!(pens(&fields(&app)), json!(automatic)); } -/// A press of Add adds one pen and a press of One Pen per Color sets the table aside, though the rows' body may run -/// twice in the pass that reads the press. +/// A press of Add adds one pen, a press of a pen's Remove removes that pen, a press of a pen's swatch opens one picker +/// whose color that pen takes, and a press of One Pen per Color sets the table aside, though the rows' bodies run more +/// than once in the pass that reads the press. #[test] fn pen_rows_apply_each_press_once() { let (mut app, _) = app(1); @@ -171,11 +172,24 @@ fn pen_rows_apply_each_press_once() { press_control(&mut app, json!({"name": "Add", "role": "Button"})); frame(&mut app); assert_eq!(pens(&fields(&app)), json!(["#ff0000", "#000000", "#000000"])); + press_control(&mut app, json!({"name": "Remove", "role": "Button", "index": 0})); + frame(&mut app); + assert_eq!(pens(&fields(&app)), json!(["#000000", "#000000"])); + // The second pen's swatch opens the picker over the dialog; its OK colors that pen alone. + press_control(&mut app, json!({"name": "Pen color", "role": "ColorWell", "index": 1})); + frame(&mut app); + let open = |app: &VectorcraftApp| app.dialogs().map_or(0, |d| d.with(|h| h.open_dialogs().len())); + assert_eq!(open(&app), 2, "one picker opens on the dialog"); + set(&mut app, "color", json!("#00ff00")); + confirm(&mut app); + frame(&mut app); + assert_eq!((open(&app), kind(&app).as_deref()), (1, Some("hpglOptions"))); + assert_eq!(pens(&fields(&app)), json!(["#000000", "#00ff00"])); press_control(&mut app, json!({"name": "One Pen per Color", "role": "RadioButton"})); frame(&mut app); let d = fields(&app); assert!(pens(&d).is_null()); - assert_eq!(serde_json::to_value(d.get("__pens")).unwrap(), json!(["#ff0000", "#000000", "#000000"])); + assert_eq!(serde_json::to_value(d.get("__pens")).unwrap(), json!(["#000000", "#00ff00"])); } /// Pen Table with options the export refuses keeps One Pen per Color and says why, rather than diff --git a/crates/ui-egui/src/dialogs/three_d_classic.rs b/crates/ui-egui/src/dialogs/three_d_classic.rs index 390c536503..70fc5871ed 100644 --- a/crates/ui-egui/src/dialogs/three_d_classic.rs +++ b/crates/ui-egui/src/dialogs/three_d_classic.rs @@ -14,6 +14,7 @@ use craft::ui::canvas::{CanvasSpace, canvas_space}; use craft::ui::canvas_controls::SelectionOutline; use craft::ui::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _}; use craft::ui::display::Picture; +use craft::ui::layout_components::Row; use craft::ui::list::ThumbAspect; use craft::ui::patterns::form_dialogs::{CustomContext, DialogFields, FieldValue, HostedParamDialog, Param, ParamKind}; use craft::ui::pickers::Select; @@ -288,7 +289,9 @@ fn navigator(count: usize, seen: Vec) -> Param { Param::custom(MAP_SURFACE, tl!("Surface"), move |ui, fields, _| { let current = shown_surface(fields, count); let mut next = None; - let row = ui.horizontal(|ui| { + let row = Row::new().show(ui, |ui, _| { + // The row's body may run more than once in a pass: the last run's step applies. + next = None; for (icon, tip, target, enabled) in [ ("chevrons_left", tl!("First Surface"), 1, current > 1), ("chevron_left", tl!("Previous Surface"), current.saturating_sub(1), current > 1), @@ -318,7 +321,7 @@ fn navigator(count: usize, seen: Vec) -> Param { if fields.number(MAP_SURFACE) != Some(shown as f64) { fields.set(MAP_SURFACE, shown as f64); } - row.response + row.output }) } @@ -428,21 +431,25 @@ fn map_actions(flat: Flat, has_map: bool, any_map: bool) -> Param { Param::custom("__mapActions", "", move |ui, fields, _| { let surface = surface_number(fields); let map = maps_of(fields).into_iter().find(|m| m.surface == surface); - ui.horizontal(|ui| { - let fit = Button::new(tl!("Scale to Fit")).enabled(has_map && flat.art.is_some()).show(ui); - if let (true, Some(m), Some(art)) = (fit.clicked(), map.as_ref(), flat.art) { - let art = vectorcraft_geom::Rect::new(0.0, 0.0, art.0, art.1); - let (scale_x, scale_y) = m.fitting_scales(art, (flat.width, flat.height)).unwrap_or((m.scale_x, m.scale_y)); - store_map(fields, surface, Some(&SurfaceMap { x: 0.0, y: 0.0, scale_x, scale_y, ..m.clone() })); - } - if Button::new(tl!("Clear")).enabled(has_map).show(ui).clicked() { - store_map(fields, surface, None); - } - if Button::new(tl!("Clear All")).enabled(any_map).show(ui).clicked() { - fields.set(MAP_ART, FieldValue::Json(json!([]))); - } - }) - .response + // The row's body may run more than once in a pass: it reports the presses, which apply after it. + let (mut fit, mut clear, mut clear_all) = (false, false, false); + let row = Row::new().show(ui, |ui, _| { + fit = Button::new(tl!("Scale to Fit")).enabled(has_map && flat.art.is_some()).show(ui).clicked(); + clear = Button::new(tl!("Clear")).enabled(has_map).show(ui).clicked(); + clear_all = Button::new(tl!("Clear All")).enabled(any_map).show(ui).clicked(); + }); + if let (true, Some(m), Some(art)) = (fit, map.as_ref(), flat.art) { + let art = vectorcraft_geom::Rect::new(0.0, 0.0, art.0, art.1); + let (scale_x, scale_y) = m.fitting_scales(art, (flat.width, flat.height)).unwrap_or((m.scale_x, m.scale_y)); + store_map(fields, surface, Some(&SurfaceMap { x: 0.0, y: 0.0, scale_x, scale_y, ..m.clone() })); + } + if clear { + store_map(fields, surface, None); + } + if clear_all { + fields.set(MAP_ART, FieldValue::Json(json!([]))); + } + row.output }) .full_width() // The page's maps: automation sets them whole, as the rows above edit them one surface at a time.