mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 22:08:42 +00:00
Merge upstream/main into feat/g13-view-snapping
Resolve the docs history-table conflicts after #9002: keep both sides' rows, newest first (the G13 2026-11-21 row now sits below main's 2026-11-23 row), and take main's Last reviewed banner in gaps.md, roadmap.md, target-app-parity.md and ui-parity.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -146,20 +146,23 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui, first: Option<&Node>, n_sel: usiz
|
||||
if anchors != crate::chrome::AnchorControls::None {
|
||||
section(tl!("Anchor Point")).show(ui, |ui, _| crate::chrome::anchor_buttons(app, ui, anchors));
|
||||
}
|
||||
let actions = quick_actions(app);
|
||||
section(tl!("Quick Actions")).show(ui, |ui, _| {
|
||||
if is_image {
|
||||
crate::panels::image_trace::trace_button(app, ui);
|
||||
}
|
||||
Grid::new(&HALVES).show(ui, |ui, _| {
|
||||
for a in &actions {
|
||||
Button::command(a.command).label(a.label).show(ui);
|
||||
}
|
||||
});
|
||||
quick_action_buttons(app, ui);
|
||||
appearance_section::global_edit_row(app, ui);
|
||||
});
|
||||
}
|
||||
|
||||
fn quick_action_buttons(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
Grid::new(&HALVES).show(ui, |ui, _| {
|
||||
for action in quick_actions(app) {
|
||||
Button::command(action.command).label(action.label).show(ui);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// The ellipsis button that shows the panel `panel` for the section's further options.
|
||||
fn more_options(ui: &mut Ui, panel: &str, tip: &'static str) {
|
||||
IconButton::command(IconId::new("ellipsis"), CommandRef::with_params("window.panel", json!({ "panel": panel }))).label(tip).show(ui);
|
||||
@@ -171,7 +174,13 @@ pub(crate) fn quick_actions(app: &mut VectorcraftApp) -> Vec<QuickAction> {
|
||||
let n_sel = super::selection_len(app);
|
||||
let first = first_selected(app);
|
||||
let kind = first.as_deref().map(|n| &n.kind);
|
||||
let is_group = matches!(kind, Some(NodeKind::Group { .. }));
|
||||
let (has_group, all_vector) = app.session.active().map_or((false, false), |st| {
|
||||
let kinds = || st.selection.objects.iter().map(|id| st.doc.node(*id).map(|node| &node.kind));
|
||||
(
|
||||
kinds().any(|kind| matches!(kind, Some(NodeKind::Group { .. }))),
|
||||
kinds().all(|kind| matches!(kind, Some(NodeKind::Path { guide: false, .. } | NodeKind::Compound { .. }))),
|
||||
)
|
||||
});
|
||||
let is_live = matches!(kind, Some(NodeKind::Path { live: Some(l), .. }) if !matches!(**l, LiveShape::Path { .. }));
|
||||
// Blend Options for one selected blend, Merge Live Paint for a Live Paint group selected with more to merge into
|
||||
// it, as the Properties panel overview lists them
|
||||
@@ -190,11 +199,12 @@ pub(crate) fn quick_actions(app: &mut VectorcraftApp) -> Vec<QuickAction> {
|
||||
};
|
||||
add(n_sel > 1, tl!("Group"), "object.group");
|
||||
add(n_sel > 1, tl!("Make Clipping Mask"), "object.clippingMask.make");
|
||||
add(n_sel > 1 && all_vector, tl!("Unite"), "object.pathfinder.unite");
|
||||
add(merge_live_paint, tl!("Merge Live Paint"), "livePaint.merge");
|
||||
add(blend_options, tl!("Blend Options"), "ui.blendOptions");
|
||||
add(repeat_options, tl!("Repeat Options"), "object.repeat.options");
|
||||
add(is_group, tl!("Ungroup"), "object.ungroup");
|
||||
add(is_group, tl!("Isolate Group"), "object.isolate");
|
||||
add(has_group, tl!("Ungroup"), "object.ungroup");
|
||||
add(n_sel == 1 && has_group, tl!("Isolate Group"), "object.isolate");
|
||||
add(is_live, tl!("Expand Shape"), "object.expandShape");
|
||||
// A dynamic symbol instance with appearance changes of its own: Reset shows the symbol's again.
|
||||
add(super::symbols::changed_instances_selected(app), tl!("Reset"), "symbol.instance.reset");
|
||||
|
||||
@@ -9,6 +9,78 @@ use super::*;
|
||||
use crate::tests::panel_harness::Panel;
|
||||
use crate::tests::synthetic::key_frame;
|
||||
|
||||
/// Two selected groups offer Ungroup and not Isolate Group. The same holds when a path is
|
||||
/// selected ahead of a group, and when a group that holds another group is selected with other art.
|
||||
#[test]
|
||||
fn two_groups_offer_ungroup_without_isolate_group() {
|
||||
let mut app = new_app();
|
||||
let (first, second) = (group_at(&mut app, 20.0), group_at(&mut app, 160.0));
|
||||
// The later group is first in the selection, so a check of only the first node still sees a group.
|
||||
app.run("select.set", json!({"ids": [second, first]})).unwrap();
|
||||
|
||||
let mut panel = Panel::new(app, quick_action_buttons);
|
||||
assert!(panel.shows("Ungroup") && !panel.shows("Isolate Group"));
|
||||
assert!(!panel.shows("Unite"), "groups are not a vector selection");
|
||||
// A path selected ahead of a group that itself holds a group.
|
||||
let inner = group_at(&mut panel.app(), 300.0);
|
||||
let beside = rect(&mut panel.app(), 380.0, 20.0, 30.0, 30.0);
|
||||
panel.app().run("select.set", json!({"ids": [inner, beside]})).unwrap();
|
||||
let outer = panel.app().run("object.group", json!({})).unwrap()["id"].clone();
|
||||
let ahead = rect(&mut panel.app(), 20.0, 120.0, 24.0, 24.0);
|
||||
panel.app().run("select.set", json!({"ids": [ahead, outer]})).unwrap();
|
||||
panel.frame();
|
||||
assert!(panel.shows("Ungroup") && !panel.shows("Isolate Group"), "path then nested group");
|
||||
assert!(panel.shows("Group") && panel.shows("Make Clipping Mask"));
|
||||
assert!(!panel.shows("Unite"), "a group in the selection");
|
||||
}
|
||||
|
||||
/// One selected group offers Ungroup and Isolate Group, including a group that holds another group.
|
||||
#[test]
|
||||
fn one_group_offers_ungroup_and_isolate_group() {
|
||||
let mut app = new_app();
|
||||
let inner = group_at(&mut app, 20.0);
|
||||
let beside = rect(&mut app, 120.0, 20.0, 30.0, 30.0);
|
||||
app.run("select.set", json!({"ids": [inner, beside]})).unwrap();
|
||||
let outer = app.run("object.group", json!({})).unwrap()["id"].clone();
|
||||
app.run("select.set", json!({"ids": [outer]})).unwrap();
|
||||
|
||||
let panel = Panel::new(app, quick_action_buttons);
|
||||
assert!(panel.shows("Ungroup") && panel.shows("Isolate Group"));
|
||||
assert!(!panel.shows("Unite") && !panel.shows("Make Clipping Mask"), "one group");
|
||||
}
|
||||
|
||||
/// Several paths, or a compound path with another path, offer Group, Make Clipping Mask and Unite.
|
||||
/// Unite joins them in one undo step. A path selected with type does not offer Unite.
|
||||
#[test]
|
||||
fn several_paths_offer_group_clipping_mask_and_unite() {
|
||||
let mut app = new_app();
|
||||
let (a, b) = (rect(&mut app, 20.0, 20.0, 40.0, 40.0), rect(&mut app, 80.0, 20.0, 40.0, 40.0));
|
||||
app.run("select.set", json!({"ids": [a, b]})).unwrap();
|
||||
|
||||
let mut panel = Panel::new(app, quick_action_buttons);
|
||||
assert!(panel.shows("Group") && panel.shows("Make Clipping Mask") && panel.shows("Unite"));
|
||||
let before = panel.app().session.active().unwrap().selection.objects.len();
|
||||
let depth = undo_depth(&panel.app());
|
||||
panel.click("Unite");
|
||||
let after = panel.app().session.active().unwrap().selection.objects.len();
|
||||
assert!(after < before, "Unite joins the paths");
|
||||
assert_eq!(undo_depth(&panel.app()), depth + 1, "one undo step");
|
||||
panel.app().run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(panel.app().session.active().unwrap().selection.objects.len(), before, "Undo restores the paths");
|
||||
// A compound path and another path.
|
||||
panel.app().run("select.set", json!({"ids": [a.clone(), b.clone()]})).unwrap();
|
||||
let compound = panel.app().run("object.compoundPath.make", json!({})).unwrap()["id"].clone();
|
||||
let c = rect(&mut panel.app(), 160.0, 20.0, 40.0, 40.0);
|
||||
panel.app().run("select.set", json!({"ids": [compound, c]})).unwrap();
|
||||
panel.frame();
|
||||
assert!(panel.shows("Group") && panel.shows("Make Clipping Mask") && panel.shows("Unite"), "compound path");
|
||||
// Type with a path is not a vector-only selection.
|
||||
let text = panel.app().run("text.create", json!({"x": 50, "y": 200, "text": "Hi"})).unwrap()["id"].clone();
|
||||
panel.app().run("select.set", json!({"ids": [c, text]})).unwrap();
|
||||
panel.frame();
|
||||
assert!(panel.shows("Group") && !panel.shows("Unite"), "path and type");
|
||||
}
|
||||
|
||||
/// One selected clip group has Edit Clipping Path and Edit Contents at the top of the panel,
|
||||
/// above the Transform section and before every other section, and they select its clipping path
|
||||
/// or its clipped art; one that clips nothing has Edit Clipping Path alone. A plain group, or a
|
||||
|
||||
+7
-2
File diff suppressed because one or more lines are too long
+4
-3
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
-3
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user