From 84d8e06f8ac248963694b6f786f0a038fa64d1c4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:36:34 -0800 Subject: [PATCH] Global Edit: options popover groups its options a stack gap apart The Global Edit Options popover (Properties panel and Control bar) laid its two captions, five options and the Results line out as one flat column, so the On Artboards caption sat closer to the Size option than to its own options. Match and On Artboards are now field groups in a stack with the framework's stack gap between the groups and before the Results line. Clicks are kept and run after the stack returns. --- .../panels/properties/appearance_section.rs | 59 +++++++++++-------- crates/ui-egui/src/panels/properties/tests.rs | 28 +++++++++ 2 files changed, 64 insertions(+), 23 deletions(-) diff --git a/crates/ui-egui/src/panels/properties/appearance_section.rs b/crates/ui-egui/src/panels/properties/appearance_section.rs index bd0c4d68b2..9d31bb0385 100644 --- a/crates/ui-egui/src/panels/properties/appearance_section.rs +++ b/crates/ui-egui/src/panels/properties/appearance_section.rs @@ -5,10 +5,10 @@ use craft::behavior::IconId; use craft::keymap::CommandRef; use craft::ui::buttons::{Button, IconButton}; use craft::ui::choice::Checkbox; -use craft::ui::contract::{Bind, LabelScheme, Props as _, Show as _, ShowContainer as _, Sizing, Trigger, clicked}; +use craft::ui::contract::{Bind, Gap, LabelScheme, Props as _, Show as _, ShowContainer as _, Sizing, Trigger, clicked}; use craft::ui::display::{Elide, Shade, Text}; -use craft::ui::form::Field; -use craft::ui::layout_components::Row; +use craft::ui::form::{Field, FieldGroup}; +use craft::ui::layout_components::{Row, Stack}; use craft::ui::menu::Menu; use craft::ui::popover::Popover; use craft::ui::style::TypeRole; @@ -194,27 +194,40 @@ pub(crate) fn global_edit_options(app: &mut VectorcraftApp, ui: &mut Ui) { let caption = |ui: &mut Ui, text: &'static str| { Text::new(text).role(TypeRole::Caption).shade(Shade::Muted).show(ui); }; - caption(ui, tl!("Match")); - if let Some(on) = option_check(ui, tl!("Appearance"), o.appearance) { - set(app, json!({ "appearance": on })); + let results = global_edit_results(global_edit_count(app)); + // Each group is its caption over its options a row gap apart; the groups and the Results line are a stack gap + // apart. A click is kept and run after the stack returns. + let mut changes = Vec::new(); + Stack::new().gap(Gap::Stack).show(ui, |ui, _| { + FieldGroup::new(tl!("Match")).show(ui, |ui, _| { + caption(ui, tl!("Match")); + if let Some(on) = option_check(ui, tl!("Appearance"), o.appearance) { + changes.push(json!({ "appearance": on })); + } + if let Some(on) = option_check(ui, tl!("Size"), o.size) { + changes.push(json!({ "size": on })); + } + }); + FieldGroup::new(tl!("On Artboards")).show(ui, |ui, _| { + caption(ui, tl!("On Artboards")); + if let Some(all) = option_check(ui, tl!("All Artboards"), o.artboards.is_none()) { + changes.push(json!({ "artboards": if all { "all" } else { "1" } })); + } + if let Some(range) = &o.artboards { + let typed = Field::new(tl!("Range:")).show(ui, |ui, _| TextField::new(tl!("Range:"), Bind::given(range.clone())).show(ui)).inner; + if let Some(range) = typed.and_then(|t| t.events.committed().cloned()) { + changes.push(json!({ "artboards": range })); + } + } + if let Some(on) = option_check(ui, tl!("Include Objects On Canvas"), o.include_canvas) { + changes.push(json!({ "includeCanvas": on })); + } + }); + Text::new(results.clone()).shade(Shade::Muted).show(ui); + }); + for p in changes { + set(app, p); } - if let Some(on) = option_check(ui, tl!("Size"), o.size) { - set(app, json!({ "size": on })); - } - caption(ui, tl!("On Artboards")); - if let Some(all) = option_check(ui, tl!("All Artboards"), o.artboards.is_none()) { - set(app, json!({ "artboards": if all { "all" } else { "1" } })); - } - if let Some(range) = &o.artboards { - let typed = Field::new(tl!("Range:")).show(ui, |ui, _| TextField::new(tl!("Range:"), Bind::given(range.clone())).show(ui)).inner; - if let Some(range) = typed.and_then(|t| t.events.committed().cloned()) { - set(app, json!({ "artboards": range })); - } - } - if let Some(on) = option_check(ui, tl!("Include Objects On Canvas"), o.include_canvas) { - set(app, json!({ "includeCanvas": on })); - } - Text::new(global_edit_results(global_edit_count(app))).shade(Shade::Muted).show(ui); } /// The options' line with how many objects Start Global Edit would take, in the interface language. diff --git a/crates/ui-egui/src/panels/properties/tests.rs b/crates/ui-egui/src/panels/properties/tests.rs index ea8850d332..bb90289aef 100644 --- a/crates/ui-egui/src/panels/properties/tests.rs +++ b/crates/ui-egui/src/panels/properties/tests.rs @@ -181,6 +181,34 @@ fn global_edit_starting_closes_the_quick_action_options() { assert!(!panel.app().ui.properties_panel.global_edit_open && !panel.shows(&results), "the options stay closed once Global Edit stops"); } +/// The Global Edit Options are two groups, Match and On Artboards, and the Results line: the On Artboards caption is a +/// stack gap below the Size option, and the Results line a stack gap below Include Objects On Canvas. +#[test] +fn global_edit_options_groups_are_a_stack_gap_apart() { + use craft::ui::contract::Role; + crate::i18n::set_current(crate::i18n::Lang::EN); + let stack = std::rc::Rc::new(std::cell::Cell::new(0.0)); + let seen = std::rc::Rc::clone(&stack); + craft::ui::testing::Fixture::new(move |ui| seen.set(craft::ui::runtime::env::Env::of(ui).tokens.space.gap.stack)).frame(vec![]); + let stack = stack.get(); + assert!(stack > 0.0, "the interface resolved its stack gap"); + let mut app = new_app(); + let a = rect(&mut app, 20.0, 20.0, 40.0, 40.0); + rect(&mut app, 200.0, 20.0, 40.0, 40.0); + app.run("select.set", json!({"ids": [a]})).unwrap(); + let mut panel = Panel::new(app, super::appearance_section::global_edit_row); + panel.click("Global Edit Options"); + let results = global_edit_results(2); + assert!(panel.shows(&results), "the options open"); + let size = panel.rect_role("Size", Role::CHECK_BOX); + let caption = panel.rect_role("On Artboards", Role::LABEL); + let canvas = panel.rect_role("Include Objects On Canvas", Role::CHECK_BOX); + let line = panel.rect(&results); + let (above, below) = (caption.top() - size.bottom(), line.top() - canvas.bottom()); + assert!(above >= stack - 0.5, "On Artboards is {above} below Size, under the stack gap {stack}"); + assert!(below >= stack - 0.5, "Results is {below} below the last option, under the stack gap {stack}"); +} + /// The options' Results count is found once per document revision, options and selected /// object, not every frame; another selected object or other options find it again. #[test]