mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Artboards: Rename opens on a selected artboard after a Ctrl/Cmd double-click or a paste
With the Artboard tool, a Ctrl/Cmd double-click on the name of an artboard that was not selected added it with the first click and took it out again with the second, so the name field renamed that artboard alone. The panel menu's Rename opened the field on the active artboard even when it was not selected. Paste with the Artboard tool leaves it outside the selection: it selects the pasted artboards and keeps the active one. Rename then renamed the active artboard alone. The second click of a Ctrl/Cmd double-click now leaves the row's artboard selected, and the field renames the selection with it. A Ctrl/Cmd double-click on a selected row works as before. When the active artboard is selected, Rename opens the field on its row; otherwise Rename opens the field on the first selected row. Docs: docs/target-app-parity.md.
This commit is contained in:
@@ -478,8 +478,13 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
set_pstate(ui.ctx(), "ab-anchor", Some(from));
|
||||
} else if resp.clicked() {
|
||||
set_pstate(ui.ctx(), "ab-anchor", Some(i));
|
||||
// The second click of a Ctrl/Cmd double-click leaves the row's artboard
|
||||
// selected. On the name, the double-click then opens the field for the
|
||||
// selection with it.
|
||||
if tool && m.command {
|
||||
toggle(app, i, abs.len());
|
||||
if !(resp.double_clicked() && picked(app, abs.len()).contains(&i)) {
|
||||
toggle(app, i, abs.len());
|
||||
}
|
||||
} else {
|
||||
select(app, i);
|
||||
}
|
||||
@@ -553,7 +558,10 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
delete_selected(app);
|
||||
}
|
||||
if menu_item(ui, tl!("Rename"), n > 0, false) {
|
||||
start_rename(ui.ctx(), app, sel);
|
||||
// When the active artboard is selected, the field opens on its row; otherwise it opens on the
|
||||
// first selected row.
|
||||
let all = picked(app, n);
|
||||
start_rename(ui.ctx(), app, if all.contains(&sel) { sel } else { all.first().copied().unwrap_or(sel) });
|
||||
}
|
||||
menu_item(ui, tl!("Delete Empty Artboards"), false, false);
|
||||
ui.separator();
|
||||
@@ -889,9 +897,49 @@ mod tests {
|
||||
assert_eq!(names(&app), ["Artboard 1", "Solo", "Artboard 3", "Artboard 4"]);
|
||||
}
|
||||
|
||||
/// Paste with the Artboard tool selects the pasted artboard and leaves the active artboard
|
||||
/// where it was. The panel menu's Rename then opens the name field on the selected artboard's
|
||||
/// row and renames that artboard, not the active one.
|
||||
#[test]
|
||||
fn the_panel_menus_rename_opens_on_a_selected_artboard() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 200, "height": 150, "artboards": 2})).unwrap();
|
||||
app.select_tool("artboard");
|
||||
select(&mut app, 1);
|
||||
app.session.execute("edit.copy", &json!({})).unwrap();
|
||||
app.session.execute("edit.paste", &json!({})).unwrap();
|
||||
assert_eq!((selected(&app, 3), picked(&app, 3)), (1, vec![2]), "Artboard 2 is active, and the pasted Artboard 3 is selected");
|
||||
let ctx = egui::Context::default();
|
||||
let screen = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(240.0, 400.0)));
|
||||
let raw = |events| egui::RawInput { events, screen_rect: screen, ..Default::default() };
|
||||
let mut out = ctx.run_ui(raw(vec![]), |ui| menu(&mut app, ui));
|
||||
out.textures_delta.clear();
|
||||
let item = out
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|c| match &c.shape {
|
||||
egui::Shape::Text(t) if t.galley.text().trim_start() == "Rename" => Some(t.visual_bounding_rect().center()),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap();
|
||||
let button = |pressed| egui::Event::PointerButton { pos: item, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
ctx.run_ui(raw(vec![egui::Event::PointerMoved(item), button(true), button(false)]), |ui| menu(&mut app, ui)).textures_delta.clear();
|
||||
assert_eq!(pstate::<Option<usize>>(&ctx, "ab-edit"), Some(2), "the field opens on Artboard 3's row");
|
||||
let mut frame = |events| ctx.run_ui(raw(events), |ui| show(&mut app, ui)).textures_delta.clear();
|
||||
let key = |key, modifiers| egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers };
|
||||
frame(vec![]);
|
||||
frame(vec![]);
|
||||
frame(vec![key(egui::Key::A, egui::Modifiers::COMMAND), egui::Event::Text("Pasted".into())]);
|
||||
frame(vec![key(egui::Key::Enter, egui::Modifiers::NONE)]);
|
||||
frame(vec![]);
|
||||
let names: Vec<String> = app.session.active().unwrap().doc.artboards.iter().map(|a| a.name.clone()).collect();
|
||||
assert_eq!(names, ["Artboard 1", "Artboard 2", "Pasted"]);
|
||||
}
|
||||
|
||||
/// With the Artboard tool, a double-click on a name with Shift or Ctrl/Cmd held that leaves
|
||||
/// several artboards selected opens the name field for all of them. A plain double-click
|
||||
/// selects the row's artboard alone and opens the field for it.
|
||||
/// several artboards selected opens the name field for all of them. A Ctrl/Cmd double-click on
|
||||
/// an unselected row's name adds its artboard to the selection, and the second click leaves it
|
||||
/// selected. A plain double-click selects the row's artboard alone and opens the field for it.
|
||||
#[test]
|
||||
fn a_shift_or_ctrl_double_click_on_a_name_renames_every_selected_artboard() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
@@ -939,6 +987,8 @@ mod tests {
|
||||
frame(&mut app, 1.0, click(1, egui::Modifiers::NONE));
|
||||
assert_eq!(double_click(&mut app, 2.0, 3, egui::Modifiers::SHIFT), (Some(2), vec![0, 1, 2]), "Shift: Artboards 1 to 3");
|
||||
assert_eq!(double_click(&mut app, 4.0, 2, egui::Modifiers::COMMAND), (Some(1), vec![0, 1, 2]), "Ctrl/Cmd on a selected one");
|
||||
assert_eq!(double_click(&mut app, 5.0, 4, egui::Modifiers::COMMAND), (Some(3), vec![0, 1, 2, 3]), "Ctrl/Cmd on another one");
|
||||
assert_eq!(picked(&app, 4), [0, 1, 2, 3], "which stays selected");
|
||||
assert_eq!(double_click(&mut app, 6.0, 4, egui::Modifiers::NONE), (Some(3), vec![3]), "a plain double-click");
|
||||
}
|
||||
|
||||
|
||||
@@ -629,7 +629,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Align to Artboard uses the active artboard, the one the Artboards panel highlights (`object.align {artboard}`). A press with a selection tool inside an artboard makes that artboard active; with the Selection tool, a Shift-click on an empty spot inside an artboard makes it active and keeps the selection. One selected object is aligned to the active artboard too, whatever Align To says (a lone object is never the key object). When an action plays, its Align to Artboard, All on Active Artboard, Paste in Place, Paste in Front and Paste in Back steps that name no artboard use the artboard that is active then.
|
||||
With the Artboard tool in use, a Shift-click on a row of the Artboards panel selects the artboards from the last row clicked without Shift to the clicked row, and the clicked row's artboard becomes the active one. When the artboard of the last row clicked without Shift is no longer selected, the range starts from the active artboard, and later Shift-clicks start from there too. A Ctrl/Cmd-click still adds or removes one artboard. A Shift-click used to add or remove one artboard as well. The public [Select artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/add-edit-artboards/select-artboards.html) page lists Shift-click in the Artboards panel for selecting several artboards.
|
||||
In the Artboards panel, a click on the active artboard's options icon, or a double-click on another row's icon, opens Artboard Options for that row's artboard, and the panel menu's Artboard Options… opens it for the active artboard (part of #1876). Both used to choose the Artboard tool instead. Opened while another tool is in use, the dialog moves the art with a new X or Y when the Artboard tool's Move Artwork with Artboard option is on.
|
||||
With several artboards selected with the Artboard tool, the Artboards panel menu's Rename opens an empty name field on the active artboard's row, and the name typed there goes to every selected artboard, numbered in panel order (abc-1, abc-2, abc-3), in one undo step (`artboard.setProps {artboards}`). A double-click on a name with Shift or Ctrl/Cmd held that leaves several artboards selected opens the same field. Both used to rename the active artboard only. With one artboard selected, Rename still gives it the name as typed. The public [Rename artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/add-edit-artboards/rename-artboards.html) page numbers the name the same way for several selected artboards.
|
||||
With several artboards selected with the Artboard tool, the Artboards panel menu's Rename opens an empty name field on the active artboard's row (on the first selected row when the active artboard is not selected), and the name typed there goes to every selected artboard, numbered in panel order (abc-1, abc-2, abc-3), in one undo step (`artboard.setProps {artboards}`). A double-click on a name with Shift or Ctrl/Cmd held that leaves several artboards selected opens the same field; a Ctrl/Cmd double-click on an unselected row's name adds its artboard to the selection first. Both used to rename the active artboard only. With one artboard selected, Rename still gives it the name as typed. The public [Rename artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/add-edit-artboards/rename-artboards.html) page numbers the name the same way for several selected artboards.
|
||||
Artboard Options has X and Y fields beside a reference point locator (#1876), so an artboard's position can be typed as well as its size. X and Y are where the reference point lies, counted from the ruler origin (#1212), as the Transform panel and the Control bar show an artboard's position, and the locator is the one they and Properties share. A typed X or Y moves the artboard so that its reference point lands there, and a new Width or Height keeps the reference point in place; OK applies everything in one undo step. The shape dialogs still keep their X and Y to themselves (the click position). Pointer and key tests in `dialogs/tests.rs` cover both. Public references: [Resize artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/add-edit-artboards/resize-artboards.html) and [Create and add new artboards](https://helpx.adobe.com/illustrator/desktop/create-manage-artboards/add-edit-artboards/add-new-artboards.html) (a reference point in a nine-point grid, then X and Y).
|
||||
Alt-clicking New Artboard in the Artboards panel opens Artboard Options for the new artboard, and OK adds it and makes it the active artboard (`ui.newArtboard`; behavior reference: [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html), Use panels). A plain click still adds the artboard at once.
|
||||
With Align to Artboard chosen, the Align panel's Distribute Objects and Distribute Spacing buttons use the active artboard (`object.distribute` and `object.distributeSpacing` with `to: "artboard"` and `artboard`). The first object's left or top edge goes to the artboard's left or top edge, and the last object's right or bottom edge goes to the artboard's right or bottom edge. Distribute Objects spaces the other objects evenly by its button's line, and two objects are enough. Distribute Spacing makes the gaps between the objects equal. With anchor points selected, the buttons space the points among themselves and do not use the artboard. When an action plays, its Distribute Objects and Distribute Spacing steps with Align to Artboard use the artboard that is active then.
|
||||
|
||||
Reference in New Issue
Block a user