Merge pull request #9958 from dotCooCoo/fix/ui-sweep-menus-popups

Global Edit: options popover groups its options a stack gap apart
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-28 10:00:26 -08:00
commit d35b46e311
2 files changed
+64 -23

No files matched your search

@@ -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.
@@ -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]