mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 13:02:50 -05:00
Merge pull request #10710 from ruchirguitar/fix/artboard-lock-menu-duplicate-rows
Artboards: avoid duplicate lock submenu rows
This commit is contained in:
4 files changed
+35
-4
No files matched your search
@@ -252,7 +252,10 @@ fn artboard_items(app: &VectorcraftApp) -> Vec<Node> {
|
||||
.collect();
|
||||
let unlock: Vec<Node> =
|
||||
[entry("Unlock Selected", sel.clone(), false), entry("Unlock All", (0..n).collect(), false)].into_iter().flatten().collect();
|
||||
for (label, items) in [("Lock Artboards", lock), ("Unlock Artboards", unlock)] {
|
||||
for (label, mut items) in [("Lock Artboards", lock), ("Unlock Artboards", unlock)] {
|
||||
// The selected and unselected targets are disjoint. If All matches a narrower row, it
|
||||
// is adjacent to it after empty rows are removed. Keep the narrower row for that command key.
|
||||
items.dedup_by(|a, b| matches!((a, b), (Node::Item(a), Node::Item(b)) if a.command == b.command));
|
||||
if !items.is_empty() {
|
||||
v.push(sub(label, items));
|
||||
}
|
||||
|
||||
@@ -1244,8 +1244,8 @@ fn the_artboard_tools_lock_entries_have_something_to_change() {
|
||||
Some(sub) => menu_labels(children_of(sub)),
|
||||
None => vec![],
|
||||
};
|
||||
assert_eq!(subs("Lock Artboards"), ["Lock All Except Selected", "Lock All"], "the selected artboard is locked already");
|
||||
assert_eq!(subs("Unlock Artboards"), ["Unlock Selected", "Unlock All"]);
|
||||
assert_eq!(subs("Lock Artboards"), ["Lock All Except Selected"], "only the unselected artboard can be locked");
|
||||
assert_eq!(subs("Unlock Artboards"), ["Unlock Selected"], "only the selected artboard can be unlocked");
|
||||
}
|
||||
|
||||
/// A right-click on an artboard that isn't selected selects it alone; on a selected one the selection
|
||||
|
||||
@@ -614,12 +614,17 @@ fn every_context_label_is_a_menu_string() {
|
||||
app.ui.context_spelling = None;
|
||||
// The Lock Artboards and Unlock Artboards submenus of the Artboard tool.
|
||||
app.run("artboard.new", json!({"x": 400, "y": 0, "width": 100, "height": 80})).unwrap();
|
||||
app.run("artboard.new", json!({"x": 520, "y": 0, "width": 100, "height": 80})).unwrap();
|
||||
app.run("artboard.setProps", json!({"index": 0, "locked": true})).unwrap();
|
||||
app.select_tool("artboard");
|
||||
shown.extend(labels(&app));
|
||||
// Lock Selected with the artboard that isn't locked active.
|
||||
crate::panels::artboards::select(&mut app, 1);
|
||||
shown.extend(labels(&app));
|
||||
// Unlock All has its own target when another locked artboard is outside the selection.
|
||||
app.run("artboard.setProps", json!({"index": 2, "locked": true})).unwrap();
|
||||
crate::panels::artboards::select(&mut app, 0);
|
||||
shown.extend(labels(&app));
|
||||
let missing: Vec<_> = shown.iter().filter(|l| !strings.contains(l.as_str())).collect();
|
||||
assert!(missing.is_empty(), "context menu labels missing from menu_strings: {missing:?}");
|
||||
for label in menus::CONTEXT_LABELS {
|
||||
@@ -681,6 +686,28 @@ impl CanvasMenu {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_artboard_lock_submenus_open_and_apply_the_available_action() {
|
||||
let mut app = app();
|
||||
app.select_tool("artboard");
|
||||
let mut canvas = CanvasMenu::new(app);
|
||||
for (submenu, action, equivalent, locked) in
|
||||
[("Lock Artboards", "Lock Selected", "Lock All", true), ("Unlock Artboards", "Unlock Selected", "Unlock All", false)]
|
||||
{
|
||||
canvas.right_click(100.0, 100.0);
|
||||
let row = canvas.fixture.by_label(submenu).expect("the canvas offers the artboard submenu");
|
||||
canvas.frame(vec![Event::PointerMoved(row.center())]);
|
||||
canvas.fixture.advance(1.0);
|
||||
canvas.frame(vec![]);
|
||||
|
||||
let row = canvas.fixture.by_label(action).expect("the submenu shows the action for the selected artboard");
|
||||
assert!(canvas.fixture.by_label(equivalent).is_none(), "the same action has only one row");
|
||||
canvas.fixture.click(&row);
|
||||
canvas.frame(vec![]);
|
||||
assert_eq!(canvas.app.borrow().session.active().unwrap().doc.artboards[0].locked, locked);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_outlines_from_the_canvas_menu_converts_selected_text_in_one_undo_step() {
|
||||
let mut app = app();
|
||||
|
||||
+2
-1
@@ -11961,7 +11961,8 @@ every artboard, and Lock All Except Selected acts on the artboards that are not
|
||||
that is not selected first selects it alone. An entry that cannot run is left out: Cut with a locked artboard or every
|
||||
artboard selected, Delete Artboards with no artboard to delete, Select All Artboards with every artboard selected, Fit
|
||||
to Artwork Bounds with no art on a selected unlocked artboard, Switch Orientation with no selected artboard to change,
|
||||
and a lock entry with no artboard to change. The menu measures the art for Delete Empty Artboards and
|
||||
and a lock entry with no artboard to change. When two lock or unlock entries would change the same artboards, the
|
||||
menu shows the more specific action. The menu measures the art for Delete Empty Artboards and
|
||||
Fit to Artwork Bounds once, at the right-click. Paste centers copied artboards on the right-click's point
|
||||
(`edit.paste {artboardsAt: [x, y]}`) and centers copied objects there too (`center`). Chosen from a menu or the command
|
||||
palette with the tool in use, `artboard.new` makes the new artboard active, `artboard.duplicate` selects the copies,
|
||||
|
||||
Reference in new issue
Block a user