mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
Artboards: the Artboard tool starts on the active artboard
Each tool switch builds a new tool, and a new Artboard tool started on Artboard 1 whatever artboard was active. With Artboard 2 active, after the tool was chosen with Shift+O, its toolbar button, Edit Artboards in Properties or Document Setup, or the Artboards panel menu's Artboard Options…, the canvas outlined Artboard 1, and Delete, Cut, Copy, the Transform panel and Artboard Options acted on Artboard 1. The first pointer event over the canvas, a hover included, then made Artboard 1 the active artboard for Align to Artboard and Paste in Place too. VectorcraftApp::select_tool now starts a newly chosen Artboard tool on the active artboard, as the Artboards panel row's Options button does. Choosing the tool again while it is in use leaves it as it was, and the artboards Shift-clicked into its selection stay selected. The test makes Artboard 2 active, chooses the tool with tool.select, and checks the tool's active option, Artboard Options, a hover over Artboard 1 and Delete. It then presses Shift+O with two artboards selected and checks that both stay selected. Docs: docs/mcp.md (tool.select), docs/target-app-parity.md.
This commit is contained in:
1 parent
a40454a4a0
commit
f8f40e7902
4 files changed
+43
-1
No files matched your search
@@ -666,9 +666,17 @@ impl VectorcraftApp {
|
||||
/// Select a tool (also used by the toolbar and shortcuts).
|
||||
pub fn select_tool(&mut self, id: &str) {
|
||||
let v = self.view_info();
|
||||
let before = self.session.tool_id();
|
||||
if let Err(e) = self.session.select_tool(id, v) {
|
||||
self.ui.status = e.to_string();
|
||||
}
|
||||
// A newly chosen Artboard tool starts on the active artboard (the view's).
|
||||
if before != "artboard"
|
||||
&& self.session.tool_id() == "artboard"
|
||||
&& let Some(n) = self.session.active().map(|d| d.doc.artboards.len())
|
||||
{
|
||||
panels::artboards::select(self, panels::artboards::selected(self, n));
|
||||
}
|
||||
if let Some(g) = vectorcraft_tools::catalog::group_of(id)
|
||||
&& let Some(slot) = self.ui.group_tool.get_mut(g)
|
||||
{
|
||||
|
||||
@@ -405,6 +405,38 @@ mod tests {
|
||||
assert_eq!((app.session.tool_options()["active"].clone(), selected(&app, 2)), (json!(0), 0));
|
||||
}
|
||||
|
||||
/// Choosing the Artboard tool starts it on the active artboard, the one the panel highlights:
|
||||
/// Artboard Options shows that artboard, the pointer moving over another artboard leaves it
|
||||
/// active, and Delete removes it. Shift+O while the tool is in use keeps the artboards it has
|
||||
/// selected.
|
||||
#[test]
|
||||
fn choosing_the_artboard_tool_starts_it_on_the_active_artboard() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 200, "height": 150})).unwrap();
|
||||
for x in [400, 800] {
|
||||
app.session.execute("artboard.new", &json!({"x": x, "y": 0, "width": 200, "height": 150})).unwrap();
|
||||
}
|
||||
select(&mut app, 1);
|
||||
app.run("tool.select", json!({"tool": "artboard"})).unwrap();
|
||||
assert_eq!(app.session.tool_options()["active"], json!(1));
|
||||
app.run("tool.options", json!({"tool": "artboard"})).unwrap();
|
||||
assert_eq!(app.ui.dialog.take().unwrap().str("name"), "Artboard 2");
|
||||
let view = app.view_info();
|
||||
crate::canvas::dispatch(&mut app, &vectorcraft_tools::PointerEvent::new(vectorcraft_tools::PointerKind::Move, 100.0, 75.0), view);
|
||||
assert_eq!(selected(&app, 3), 1, "the pointer over Artboard 1 leaves Artboard 2 active");
|
||||
let r = app.session.tool_key(vectorcraft_tools::ToolKey::Delete, Default::default(), view);
|
||||
crate::canvas::apply_requests(&mut app, r);
|
||||
let names: Vec<String> = app.session.active().unwrap().doc.artboards.iter().map(|a| a.name.clone()).collect();
|
||||
assert_eq!(names, ["Artboard 1", "Artboard 3"], "Delete removes Artboard 2");
|
||||
// Shift+O while the tool is in use keeps the artboards it has selected.
|
||||
app.session.set_tool_option("selected", &json!([0, 1]));
|
||||
let ctx = egui::Context::default();
|
||||
let shift_o = vec![egui::Event::ModifiersChanged(egui::Modifiers::SHIFT), egui::Event::Text("O".into())];
|
||||
let mut out = ctx.run_ui(egui::RawInput { events: shift_o, ..Default::default() }, |ui| crate::shortcuts::handle(&mut app, ui.ctx()));
|
||||
out.textures_delta.clear();
|
||||
assert_eq!((app.session.tool_id(), picked(&app, 2)), ("artboard", vec![0, 1]));
|
||||
}
|
||||
|
||||
/// A row dragged onto New Artboard duplicates its artboard with its art (#446), outlining the
|
||||
/// button while it is held over it, and the copy becomes the active artboard.
|
||||
#[test]
|
||||
|
||||
+2
-1
@@ -1517,7 +1517,8 @@ remote mode, MCP's `run_command` calls and each step of the `command_batch` tool
|
||||
Actions panel plays an action as a `command.batch`. An action recorded in the Actions panel leaves the artboard out,
|
||||
and its steps of these commands get the artboard that is active when the action plays. A press with the Selection,
|
||||
Direct Selection or Group Selection tool inside an artboard makes that artboard the active one; with the Selection
|
||||
tool, a Shift-click on an empty spot inside an artboard makes it active and keeps the selection.
|
||||
tool, a Shift-click on an empty spot inside an artboard makes it active and keeps the selection. Choosing the Artboard
|
||||
tool (`tool.select {tool: "artboard"}`) starts it on the active artboard: its `active` option is that artboard's index.
|
||||
|
||||
```json
|
||||
{"name":"run_command","arguments":{"command":"object.align","params":{"horizontal":"left","to":"artboard","artboard":1}}}
|
||||
|
||||
@@ -453,6 +453,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- **Drawing aids:** Smart Guides and snapping (moving, with the Selection, Group Selection or Direct Selection tool, and resizing by the bounding-box handles with the Selection or Free Transform tool, Shift and Alt too: the dragged corner or side lands on the other objects' anchors and centres ("anchor", "center") or lines up with their edges and centres (a line and "align"); with Smart Guides › Spacing Guides, a moved selection that lines up with nothing along an axis lands as far from its neighbour as two other objects of its row or column are apart, or halfway between its two neighbours, the equal gaps marked; with View › Snap to Grid on, a moved selection lands on the grid instead, by whichever of its edges or its centre is nearest a gridline on each axis, #740; the Rotate, Scale, Shear and Reflect tools drag from the anchor they grab and snap the pointer the same way, so a corner dragged onto another object's anchor scales exactly onto it, #482; anchors dragged with Direct Selection: the one pressed on lands on other anchors, its own path's that stay put among them, on path segments or in line with them, the others following, Shift keeps 45° steps, and with Smart Guides off Snap to Point pulls it onto anchors; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H; drawn points, #506: hovering shows where the press goes, the point lands on the other objects' anchors, centres and paths ("anchor", "center", "path") or lines up with their anchors, edges and centres ("align"), the Pen's on the path being drawn too, near a construction guide through the anchor before it on that guide (Preferences › Smart Guides › Construction Guides and Angles), and with Shift kept to its 45° step or a square's diagonal it slides along that way into line; the targets are gathered once per document state, from the art in the window, and the anchors, centres and lines near the pointer are found by bisection, so hovering never rescans the document), guides dragged out of the rulers (#451: they snap as moved guides do, Shift to the ruler's ticks; with the Artboard tool they are artboard guides, which run across their artboard only and move, copy and delete with it, `guide.add {artboard}`) that the Selection, Direct Selection and Group Selection tools then pick and drag (#414: the selected guides highlight and move together, Alt copies them, Shift snaps the dragged one to the ticks, otherwise it snaps to pixels, the grid or the edges, centres (so the sides' midpoints) and anchors of the art and the artboards, or with Smart Guides off Snap to Point pulls it onto anchors; Shift-clicked they join the selected art, and Shift-added art keeps them, so guides and art are selected together in either order, Delete then deleting both in one step; the arrow keys nudge them, Delete deletes them, dragging one back onto its ruler deletes it, Lock Guides and Hide Guides leave them alone; `guide.list`, `guide.select`, `guide.move` and `guide.remove` reach agents), a right-click on either ruler or the origin box to pick the document's units (the current one checked; `document.setUnits`, one undo step, #528), and Draw Normal / Behind / Inside modes.
|
||||
- **Views:** the status bar's artboard navigator (first, previous, next, last; `view.goToArtboard`) goes to an artboard and fits it, and Fit Artboard in Window and Actual Size show the navigator's artboard. The Artboards panel highlights that active artboard: clicking a row makes it active (the Artboard tool's too, while it is chosen) as does clicking an artboard with the Artboard tool, double-clicking its number also fits it in the window and double-clicking its name renames it. Duplicate Artboards, or a row dragged onto New Artboard, copies the artboard with its art (#446). Escape leaves Presentation Mode, F from it goes back to Normal Screen Mode, and the screen mode isn't saved with the preferences: the app always starts in Normal Screen Mode with its menus and panels (#472). View › Pixel Preview shows the art as the document pixels it rasterizes to, one per point and hard-edged when magnified, turning with a rotated view (it used to draw the smooth vectors, with only the pixel grid over them).
|
||||
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.
|
||||
Choosing the Artboard tool (Shift+O, its toolbar button, Edit Artboards in Properties or Document Setup, or the Artboards panel menu's Artboard Options…) starts it on the active artboard: the canvas outlines that artboard, and Delete, Cut, Copy, the Transform panel and Artboard Options act on it.
|
||||
- **Geometry and effects:**
|
||||
- Pathfinder (10 exact curve booleans), Offset, Outline Stroke, Simplify, Clean Up, Split Into Grid, Divide Objects Below. Object › Path › Remove Anchor Points (`path.removeAnchors`) removes the direct-selected anchors without opening their paths (the Delete key still deletes them with their segments): the neighbours keep their handle directions and their facing handles are refitted so one cubic follows the two old segments, and straight sides stay straight. The Delete Anchor Point tool uses the same refit. The Control bar, the contextual task bar, the Properties quick actions and the canvas context menu offer it when anchors are selected. With anchors selected, the Control bar and the Properties panel also convert them to corner or smooth (`path.convertAnchors`), connect end points (Join) and cut the path at them (`path.cutAtAnchors`, also on the task bar and the context menu): a closed path opens there and an open one becomes one path per piece, each cut leaving one of its two coincident anchors selected so a drag pulls the path apart.
|
||||
- Initial live Revolve (#605, #846): a portable geometry and shading crate (`three-d`), editable path and compound profiles, compact options with artboard rotation and light gizmos, SVG/PDF vector output and Expand Appearance that can trim covered faces. Open ends are uncapped, shading is flat with one light, and intersecting surfaces' visibility is approximate ([revolve.md](revolve.md)).
|
||||
|
||||
Reference in new issue
Block a user