Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55cc14e4a8 | ||
|
|
dce0f8a48d | ||
|
|
6a39ee0a1c | ||
|
|
01df2c730b | ||
|
|
dcc0de7487 | ||
|
|
0924bc16ae | ||
|
|
f18cd1c99b | ||
|
|
e92bbdbdac | ||
|
|
b61089e5c6 |
No files matched your search
+3
-3
@@ -4,7 +4,7 @@ VectorCraft is a clean-room, open-source, pure-Rust reimplementation of the Adob
|
||||
|
||||
This file tracks **how far we are and what's left**. Time estimates are wall-clock hours of continuous Claude Opus 5.5 agent work (including builds and the CI gate), given both for **one agent** and for **4–6 parallel agents** on disjoint crates. They are counted from the remaining work (see [Parity estimate](#parity-estimate)), calibrated against measured throughput, and updated as work lands.
|
||||
|
||||
_Last updated: 2026-10-09 (after placed documents (File › Place of a `.vectorcraft` file, linked), M4.14–M4.98, M8.1–M8.20, M14.4–M14.7, the MCP prompts, resource templates, completions and logging, the 2026-10-07 issue fixes, the Layers panel rework and the 2026-10-08 community contributions: Pen and shape-tool modifiers, path editing, Layers, Artboards, Swatches/Brushes and dialogs, Japanese composition and PDF text, Hebrew/Arabic type, interface languages (Spanish among them), the font menu, saved selections, MCP and EPS, the missing-font export warning (#319), open paths in the Shape Builder (#374), PDF/`.ai` import keeping strokes live and hidden and nested layers (#372), per-corner Live Corners (#381), SVG type opening at the size it draws at (#396), the Wayland clipboard with copied-file paste (#398), ruler guides that can be selected, moved and deleted (#414), two batches of Preferences options that were stored but unused (#394), skeleton reads with `document.find` for large documents over MCP (#416) and anchors dragged with Direct Selection snapping to points, segments and smart guides, clipped SVG layers opening as clipping layers (#420), PDF/`.ai` layers read on pages of tens of millions of operators (#419), Document Color Mode putting RGB greys on the black plate on request and converting pattern tiles (#421) and movable dialogs with Offset Path's Joins dropdown (#423) and numeric fields scrubbed by dragging their label (#400), stroke weight presets in the stroke unit (#426), the Appearance panel's Opacity popup (#430), type on a path brackets, flip and Type on a Path Options that keep the type in place (#429), Layers rows dragged with a ghost and dropped on the trash or New Layer (#435), tool flyouts opening on a right or corner press (#436), tool flyouts torn off into floating toolbars (#437), the Shape Builder's erase mode deleting edges too (#439), installed fonts registered outside the font folders and fonts installed while the app runs listed in the font menus (#443), alike circular corners on rectangles that aren't square (#442), tool cursors as OS cursors so the pointer no longer trails over the canvas (#444), artboards copied and pasted with their art (#446), guides dragged out of the rulers snapping to the art's side midpoints and the artboards, artboard guides (#451), the toolbar's double arrow and Window › Toolbars › Double Column switching between one and two columns in any window height (#455), the Smart Guides display options and Snapping Tolerance (#394), Font Size and Leading combo boxes with preset lists in the Character and Properties panels and the Control bar (#458), screenshots pasted from the clipboard on macOS, Windows and the web (#457), the Properties panel's Fill and Stroke matching the Control bar's, Illustrator's Window menu panel keys (Shift+F7 for Align…) and Alt-wheel zoom whatever the wheel preference (Discord feedback), the point/area type widget (Discord feedback), groups in legacy Illustrator .ai files (Discord feedback), a rotating desktop log file (#465), image controls in the Control bar and Properties panel: Image Trace with its presets, Mask, Crop Image, Embed/Unembed, and an Image Trace object's preset, Expand and Release (Discord feedback), the Pen working as the Anchor Point tool with Alt held over a selected path's handles and anchors, and anchor buttons that convert, connect and cut paths at the selected anchors (Discord feedback), Japanese hanging punctuation (burasagari, #463), Escape leaving Presentation Mode with no screen mode saved across restarts, documents dropped on the desktop app opening as tabs of their own and a note that an `.ai` file's art off its artboards isn't in the part read (#472), Add/Delete Anchor Point tool icons drawn from the Pen tool's (#479), EPS import running more of PostScript Level 3 (patterns, Type 3 fonts, mesh shadings, masked images, VM and resource probes), and a preview that stands in saying why (Discord feedback, #466, #469, #474), chords with modifiers recorded in Edit › Keyboard Shortcuts (#487), Type Object Selection by Path Only (#394), Anti-aliased Artwork (#394), Show Pixel Grid (#394), pen and touch taps pressed and lifted within one frame clicking where they tapped and the Linux/Wayland pen-tablet workaround (#491), bounding-box resizes landing on the other objects' anchors and centres with labels, and the Rotate, Scale, Shear and Reflect tools snapping their drags (#482), Shift-drag marquees that toggle the objects or anchors they reach and a Lasso whose Alt subtraction keeps the rest of the selection (#483), the mouse wheel stepping the focused numeric field, the dialogs' and preferences' drag values made such fields (#485), Show The Home Screen When No Documents Are Open (#394), Numbers Without Units Are Points (#394), Auto-Collapse Iconic Panels (#394), the Contextual Task Bar moved by its handle and its More Options menu pinning and resetting its position, a designed macOS DMG windoLine truncated
|
||||
_Last updated: 2026-10-09 (after placed documents (File › Place of a `.vectorcraft` file, linked), M4.14–M4.98, M8.1–M8.20, M14.4–M14.7, the MCP prompts, resource templates, completions and logging, the 2026-10-07 issue fixes, the Layers panel rework and the 2026-10-08 community contributions: Pen and shape-tool modifiers, path editing, Layers, Artboards, Swatches/Brushes and dialogs, Japanese composition and PDF text, Hebrew/Arabic type, interface languages (Spanish among them), the font menu, saved selections, MCP and EPS, the missing-font export warning (#319), open paths in the Shape Builder (#374), PDF/`.ai` import keeping strokes live and hidden and nested layers (#372), per-corner Live Corners (#381), SVG type opening at the size it draws at (#396), the Wayland clipboard with copied-file paste (#398), ruler guides that can be selected, moved and deleted (#414), two batches of Preferences options that were stored but unused (#394), skeleton reads with `document.find` for large documents over MCP (#416) and anchors dragged with Direct Selection snapping to points, segments and smart guides, clipped SVG layers opening as clipping layers (#420), PDF/`.ai` layers read on pages of tens of millions of operators (#419), Document Color Mode putting RGB greys on the black plate on request and converting pattern tiles (#421) and movable dialogs with Offset Path's Joins dropdown (#423) and numeric fields scrubbed by dragging their label (#400), stroke weight presets in the stroke unit (#426), the Appearance panel's Opacity popup (#430), type on a path brackets, flip and Type on a Path Options that keep the type in place (#429), Layers rows dragged with a ghost and dropped on the trash or New Layer (#435), tool flyouts opening on a right or corner press (#436), tool flyouts torn off into floating toolbars (#437), the Shape Builder's erase mode deleting edges too (#439), installed fonts registered outside the font folders and fonts installed while the app runs listed in the font menus (#443), alike circular corners on rectangles that aren't square (#442), tool cursors as OS cursors so the pointer no longer trails over the canvas (#444), artboards copied and pasted with their art (#446), guides dragged out of the rulers snapping to the art's side midpoints and the artboards, artboard guides (#451), the toolbar's double arrow and Window › Toolbars › Double Column switching between one and two columns in any window height (#455), the Smart Guides display options and Snapping Tolerance (#394), Font Size and Leading combo boxes with preset lists in the Character and Properties panels and the Control bar (#458), screenshots pasted from the clipboard on macOS, Windows and the web (#457), the Properties panel's Fill and Stroke matching the Control bar's, Illustrator's Window menu panel keys (Shift+F7 for Align…) and Alt-wheel zoom whatever the wheel preference (Discord feedback), the point/area type widget (Discord feedback), groups in legacy Illustrator .ai files (Discord feedback), a rotating desktop log file (#465), image controls in the Control bar and Properties panel: Image Trace with its presets, Mask, Crop Image, Embed/Unembed, and an Image Trace object's preset, Expand and Release (Discord feedback), the Pen working as the Anchor Point tool with Alt held over a selected path's handles and anchors, and anchor buttons that convert, connect and cut paths at the selected anchors (Discord feedback), Japanese hanging punctuation (burasagari, #463), Escape leaving Presentation Mode with no screen mode saved across restarts, documents dropped on the desktop app opening as tabs of their own and a note that an `.ai` file's art off its artboards isn't in the part read (#472), Add/Delete Anchor Point tool icons drawn from the Pen tool's (#479), EPS import running more of PostScript Level 3 (patterns, Type 3 fonts, mesh shadings, masked images, VM and resource probes), and a preview that stands in saying why (Discord feedback, #466, #469, #474), chords with modifiers recorded in Edit › Keyboard Shortcuts (#487), Type Object Selection by Path Only (#394), Anti-aliased Artwork (#394), Show Pixel Grid (#394), pen and touch taps pressed and lifted within one frame clicking where they tapped and the Linux/Wayland pen-tablet workaround (#491), bounding-box resizes landing on the other objects' anchors and centres with labels, and the Rotate, Scale, Shear and Reflect tools snapping their drags (#482), Shift-drag marquees that toggle the objects or anchors they reach and a Lasso whose Alt subtraction keeps the rest of the selection (#483), the mouse wheel stepping the focused numeric field, the dialogs' and preferences' drag values made such fields (#485), Show The Home Screen When No Documents Are Open (#394), Numbers Without Units Are Points (#394), Auto-Collapse Iconic Panels (#394), the Contextual Task Bar moved by its handle and its More Options menu pinning and resetting its position, a designed macOS DMG windoLine truncated
|
||||
|
||||
## Where we are
|
||||
|
||||
@@ -129,7 +129,7 @@ grade by behaviour against `plan/illustrator/`, not by whether a menu item exist
|
||||
- **Pen:** Alt pressed in the middle of dragging out an anchor splits its handles and keeps the curve already shaped into it (only the outgoing handle follows the pointer); Space held while dragging out an anchor moves it, handles and all. A press on the first anchor of the path being drawn closes it whatever the drag then does: the drag shapes the closing curve (symmetric handles, Alt breaks them) and the release closes the path wherever it ends (#501). Clicking the last anchor of the path being drawn retracts its outgoing handle (convert cursor), and dragging from it pulls out a new one on its own. Auto Add/Delete: over a selected path, a click on a segment adds an anchor and a click on an anchor deletes it (add and delete cursors); Shift held, or Preferences › General › Disable Auto Add/Delete, starts a new path instead. Alt held over a handle end or an anchor of a selected path (the one being drawn too) works as the Anchor Point tool, with its convert cursor: dragging a handle moves it alone, clicking a smooth anchor makes it a corner, dragging an anchor pulls out new symmetric handles, dragging a segment reshapes it; drawing then goes on. Cmd (Ctrl) held drags with the selection tool chosen last, Direct Selection until one is (handles, anchors and segments of the path being drawn or another), and the Pen then goes on drawing its path while that stays selected; the pointer shows that tool's while Cmd is held. The same holds for agents (`pointer_gesture` with `mods.cmd`), as the borrowing now lives in the engine (#494).
|
||||
- **Path editing (#494):** the handles shown are the handles that drag: Direct Selection drags those of a path selected as a whole (as the Pen leaves it), the Anchor Point tool and Pen+Alt no longer grab handles that Show handles when multiple anchors are selected hides, a handle shorter than the tolerance leaves its anchor to be picked, and the anchor tools pick within Selection & Anchor Display › Tolerance. A dragged segment keeps a smooth anchor at either end smooth. With Direct Selection, the Pen, the Curvature and the anchor tools, a path selected as a whole shows all its anchors selected, and the Control bar and the Properties panel offer Convert (corner, smooth) for them too; Remove and Cut wait for anchors direct-selected (#504). A handle drag gathers its snap targets once per drag (it took 21 ms per pointer move on a 20,000-path document, now 1 ms; `vectorcraft-cli perf` measures handle and segment drags on a 5,000-anchor path).
|
||||
- **Graphs:** Column, Stacked Column, Bar, Stacked Bar, Line, Area, Scatter, Pie and Radar graph tools with Graph Data and Graph Type.
|
||||
- **Other:** Eyedropper, Gradient annotator, Artboard (Alt-drag duplicates an artboard, and its art with Move/Copy Artwork with Artboard on; Copy, Cut and Paste take the artboard with its art, Paste right of the last artboard, Paste in Place where it was, into this or another document, #446), Measure, Type, Hand, Zoom, Rotate View.
|
||||
- **Other:** Eyedropper, Gradient annotator, Artboard (Alt-drag duplicates an artboard, and its art with Move/Copy Artwork with Artboard on; Copy, Cut and Paste take the artboard with its art, Paste right of the last artboard, Paste in Place where it was, into this or another document, #446; Object › Artboards › Rearrange All Artboards lays them out in a grid by row or by column, in one row or one column, left to right or right to left, from the menu, the Artboards panel or Properties' Rearrange All, #681), Measure, Type, Hand, Zoom, Rotate View.
|
||||
- **Editing type:** double-clicking type with a selection tool switches to the Type tool with the caret where it was clicked.
|
||||
- **Temporary tools:** Cmd with any other tool drags with the selection tool used last (Selection, Direct Selection or Group Selection). Held Space pans and Cmd+Space zooms (Cmd+Alt+Space out) whatever the tool.
|
||||
- **Panel drag and drop:** art dragged off the canvas onto the Symbols panel becomes a symbol, onto the Swatches panel a pattern swatch and onto the Brushes panel an Art brush; a symbol dragged onto the canvas places an instance where it is dropped, and a brush dragged onto a path is applied to it.
|
||||
@@ -216,7 +216,7 @@ about 1–1.5 agent-hours each, so the other rows (estimated on the older scale)
|
||||
| Type advanced | 4 | 50% | CJK composition for vertical type (ruby, mojikumi beyond Line-end Punctuation Half Width — the other sets (and their paragraph-start bracket and indent rules), kinsoku sets and the Mojikumi Settings dialog —, proportional vertical metrics, manual tate-chu-yoko), variable font axis sliders (named instances are styles), tab leaders, spell check (open dictionary), Touch Type, Retype; vertical point/area/path type and Type Orientation have initial support (beyond parity, not scored: inline symbols in text) | 20–28 |
|
||||
| Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | symbol libraries (original), dynamic symbols, envelope Anti-Alias/Preserve Shape output and warp point editing, brush interpolation in blends (M8 fidelity pass done) | 5–8 |
|
||||
| Image Trace, graphs, image tools | 3 | 70% | graph Design/Column/Marker, Create Object Mosaic, Crop Image polish (an on-canvas crop box), per-feature stroke/fill choice and varying widths in Image Trace's Create Strokes (Vector Halftone and the Image Trace View modes, Palette and Create Strokes are done) | 6–10 |
|
||||
| Layers, artboards, document setup | 5 | 82% | Layers panel: a confirmation before deleting layers that hold art, Collect for Export, row context menus, the Layer Options dialog for several rows with mixed values, Paste Remembers Layers for sublayers, drag-scrolling a long panel while dragging rows; artboard presets/rearrange polish (Document Setup, New Document and the rest of the Layers panel are done) | 4–7 |
|
||||
| Layers, artboards, document setup | 5 | 82% | Layers panel: a confirmation before deleting layers that hold art, Collect for Export, row context menus, the Layer Options dialog for several rows with mixed values, Paste Remembers Layers for sublayers, drag-scrolling a long panel while dragging rows; artboard preset polish (Rearrange All Artboards, Document Setup, New Document and the rest of the Layers panel are done) | 4–7 |
|
||||
| View & navigation | 3 | 70% | New View/Edit Views, multiple windows/arrange, Snap to Pixel/Glyph (print tiling is done) | 9–14 |
|
||||
| Guides, grids, smart guides, snapping, rulers | 3 | 85% | global/video rulers, Spacing Guides' distance readouts and spacing for resized or drawn art, Smart Guides' angle and distance readouts while drawing, Alt swapping a ruler guide's orientation, ruler guides selected together with art (marquee, Shift-click), ruler guides as Layers rows with their own lock and hide (#451: Lock Guides locks them all; Make Guides paths are Layers rows already) (dragging existing guides is done, #414; new guides snapping to side midpoints and artboards, and artboard guides, #451; the drawing tools snapping, with Construction Guides, #506; Spacing Guides for moves, #394) | 2–4 |
|
||||
| File formats | 6 | 85% | DWG (no open spec: DXF instead), PSD placement as layers, EPS checked against more real files users send (Inkscape files open as vectors; other generators' constructs are tested with programs written from the PostScript Language Reference only; CID-keyed CJK type and `CCITTFaxDecode` images not read), legacy `.ai` files saved without the prolog that defines their operators (their own operator set isn't read yet), the remaining fidelity polish; EPS, DXF, EMF/WMF, TIFF, BMP, Targa, PSD export, SVGZ, PDF security, PDF/X, PDF layers and presets are done | 6–10 |
|
||||
|
||||
@@ -247,7 +247,7 @@ fn font_list(_: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
}
|
||||
|
||||
fn rescan(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
pub(crate) fn rescan(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
let db = vectorcraft_text::FontDb::global();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let faces = db.load_system_fonts();
|
||||
@@ -283,6 +283,21 @@ fn rescan(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
/// Type › Options › Additional Fonts Folder (#683) adds its folder to the system font scan,
|
||||
/// trimmed; clearing it takes the folder out again.
|
||||
#[test]
|
||||
fn the_additional_fonts_folder_joins_the_font_scan() {
|
||||
let mut s = Session::new();
|
||||
let dir = std::env::temp_dir().join("vectorcraft-fonts-folder-pref");
|
||||
s.execute("prefs.set", &json!({"key": "fontsFolder", "value": format!(" {} ", dir.display())})).unwrap();
|
||||
assert_eq!(vectorcraft_text::user_font_dirs(), std::slice::from_ref(&dir));
|
||||
if !cfg!(target_arch = "wasm32") {
|
||||
assert!(vectorcraft_text::system_font_dirs().contains(&dir));
|
||||
}
|
||||
s.execute("prefs.set", &json!({"key": "fontsFolder", "value": ""})).unwrap();
|
||||
assert!(vectorcraft_text::user_font_dirs().is_empty() && !vectorcraft_text::system_font_dirs().contains(&dir));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn list_flag_missing_replace_and_select() {
|
||||
let mut s = Session::new();
|
||||
|
||||
@@ -156,7 +156,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Rearrange All Artboards…",
|
||||
["Object", "Artboards"],
|
||||
None,
|
||||
"{columns?: n (2), spacing?: pt (20), byColumn?: false, moveArtwork?: true (locked and hidden art only with prefs moveLockedWithArtboard)} lay artboards out in a grid",
|
||||
"{layout?: gridByRow|gridByColumn|row|column (gridByRow; byColumn?: true is gridByColumn), order?: leftToRight|rightToLeft (leftToRight: right-to-left mirrors the order along the rows), columns?: n (2; the rows for gridByColumn; row and column ignore it), spacing?: pt (20), moveArtwork?: true (locked and hidden art only with prefs moveLockedWithArtboard)} lay the artboards out in their order, the grid's top-left at the first artboard's → {artboards, rows, columns}",
|
||||
has_doc,
|
||||
rearrange_artboards
|
||||
),
|
||||
@@ -823,10 +823,32 @@ fn convert_to_artboards(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
}
|
||||
|
||||
fn rearrange_artboards(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let n_ab = s.doc()?.doc.artboards.len().max(1);
|
||||
let cols = (f64_or(p, "columns", 2.0).clamp(1.0, n_ab as f64)) as usize;
|
||||
const CMD: &str = "artboard.rearrange";
|
||||
use super::newdoc::ArtboardLayout as L;
|
||||
// A value given (not null) must be one of the names.
|
||||
let named = |key: &str| p.get(key).filter(|v| !v.is_null()).map(|v| v.as_str().unwrap_or_default());
|
||||
let layout = match named("layout") {
|
||||
Some(l) => L::parse(l).ok_or_else(|| bad(CMD, "layout must be gridByRow, gridByColumn, row or column"))?,
|
||||
None if bool_or(p, "byColumn", false) => L::GridByColumn,
|
||||
None => L::GridByRow,
|
||||
};
|
||||
let rtl = match named("order") {
|
||||
None => false,
|
||||
Some(o) if o.eq_ignore_ascii_case("leftToRight") => false,
|
||||
Some(o) if o.eq_ignore_ascii_case("rightToLeft") => true,
|
||||
Some(_) => return Err(bad(CMD, "order must be leftToRight or rightToLeft")),
|
||||
};
|
||||
let count = s.doc()?.doc.artboards.len();
|
||||
let n_ab = count.max(1);
|
||||
// Columns of a grid by row, rows of a grid by column (NaN casts to 0).
|
||||
let lines = (f64_or(p, "columns", 2.0).clamp(1.0, n_ab as f64) as usize).max(1);
|
||||
let (rows, cols) = match layout {
|
||||
L::GridByRow => (n_ab.div_ceil(lines), lines),
|
||||
L::GridByColumn => (lines, n_ab.div_ceil(lines)),
|
||||
L::Row => (1, n_ab),
|
||||
L::Column => (n_ab, 1),
|
||||
};
|
||||
let spacing = f64_or(p, "spacing", 20.0).clamp(-1.0e5, 1.0e5);
|
||||
let by_col = bool_or(p, "byColumn", false);
|
||||
let move_art = bool_or(p, "moveArtwork", true);
|
||||
let locked_and_hidden = s.prefs.move_locked_with_artboard;
|
||||
let scale_strokes = false;
|
||||
@@ -834,7 +856,7 @@ fn rearrange_artboards(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let rects: Vec<Rect> = d.artboards.iter().map(|a| a.rect).collect();
|
||||
let Some(first) = rects.first().copied() else { return Ok(()) };
|
||||
let sizes: Vec<(f64, f64)> = rects.iter().map(|r| (r.width(), r.height())).collect();
|
||||
let origins = super::newdoc::grid_origins(&sizes, first.origin(), cols, spacing, by_col, false);
|
||||
let origins = super::newdoc::grid_origins_rc(&sizes, first.origin(), (rows, cols), spacing, layout == L::GridByColumn, rtl);
|
||||
let deltas: Vec<Vec2> = rects.iter().zip(origins).map(|(r, o)| o - r.origin()).collect();
|
||||
if move_art {
|
||||
let tops: Vec<(NodeId, Point)> = d
|
||||
@@ -846,11 +868,11 @@ fn rearrange_artboards(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
.filter_map(|n| Some((n.id, n.geometric_bounds()?.center())))
|
||||
.collect();
|
||||
for (id, c) in tops {
|
||||
if let Some(i) = rects.iter().position(|r| r.contains(c))
|
||||
&& deltas[i] != Vec2::ZERO
|
||||
if let Some(&dl) = rects.iter().position(|r| r.contains(c)).and_then(|i| deltas.get(i))
|
||||
&& dl != Vec2::ZERO
|
||||
&& let Some(n) = d.node_mut(id)
|
||||
{
|
||||
n.transform(Affine::translate(deltas[i]), scale_strokes);
|
||||
n.transform(Affine::translate(dl), scale_strokes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -864,5 +886,5 @@ fn rearrange_artboards(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
ok()
|
||||
Ok(json!({ "artboards": count, "rows": rows, "columns": cols }))
|
||||
}
|
||||
@@ -345,9 +345,22 @@ pub fn color_mode_id(m: ColorMode) -> &'static str {
|
||||
/// each column as wide and each row as tall as its largest artboard; `by_column` fills columns
|
||||
/// top to bottom first, `rtl` puts the first column at the right.
|
||||
pub(crate) fn grid_origins(sizes: &[(f64, f64)], origin: Point, columns: usize, spacing: f64, by_column: bool, rtl: bool) -> Vec<Point> {
|
||||
let n = sizes.len();
|
||||
let cols = columns.clamp(1, n.max(1));
|
||||
let rows = n.div_ceil(cols).max(1);
|
||||
let n = sizes.len().max(1);
|
||||
let cols = columns.clamp(1, n);
|
||||
grid_origins_rc(sizes, origin, (n.div_ceil(cols), cols), spacing, by_column, rtl)
|
||||
}
|
||||
|
||||
/// [`grid_origins`] on a grid of `rows` × `cols` cells (at least enough for every artboard when
|
||||
/// filled the `by_column` way).
|
||||
pub(crate) fn grid_origins_rc(
|
||||
sizes: &[(f64, f64)],
|
||||
origin: Point,
|
||||
(rows, cols): (usize, usize),
|
||||
spacing: f64,
|
||||
by_column: bool,
|
||||
rtl: bool,
|
||||
) -> Vec<Point> {
|
||||
let (rows, cols) = (rows.max(1), cols.max(1));
|
||||
// Grid cell (row, column) of artboard i.
|
||||
let cell = |i: usize| {
|
||||
let (r, c) = if by_column { (i % rows, i / rows) } else { (i / cols, i % cols) };
|
||||
@@ -362,7 +375,7 @@ pub(crate) fn grid_origins(sizes: &[(f64, f64)], origin: Point, columns: usize,
|
||||
}
|
||||
}
|
||||
let offset = |spans: &[f64], k: usize| spans.iter().take(k).map(|s| s + spacing).sum::<f64>();
|
||||
(0..n)
|
||||
(0..sizes.len())
|
||||
.map(|i| {
|
||||
let (r, c) = cell(i);
|
||||
Point::new(origin.x + offset(&col_w, c), origin.y + offset(&row_h, r))
|
||||
|
||||
@@ -187,6 +187,7 @@ pub const PREF_SPECS: &[PrefSpec] = &[
|
||||
p!("missingGlyphProtection", "Type", "Options", "Enable Missing Glyph Protection", bool),
|
||||
p!("highlightAlternateGlyphs", "Type", "Options", "Highlight Alternate Glyphs", bool),
|
||||
p!("placeholderText", "Type", "Options", "Fill New Type Objects With Placeholder Text", bool),
|
||||
p!("fontsFolder", "Type", "Options", "Additional Fonts Folder", text),
|
||||
// Units
|
||||
p!("unitsGeneral", "Units", "", "General", choice(UNITS)),
|
||||
p!("unitsStroke", "Units", "", "Stroke", choice(UNITS)),
|
||||
@@ -260,7 +261,19 @@ pub const PREF_SPECS: &[PrefSpec] = &[
|
||||
"Brightness",
|
||||
choice(&[("dark", "Dark"), ("mediumDark", "Medium Dark"), ("mediumLight", "Medium Light"), ("light", "Light")])
|
||||
),
|
||||
p!("canvasColor", "User Interface", "", "Canvas Color", choice(&[("matchUi", "Match User Interface Brightness"), ("white", "White")])),
|
||||
p!(
|
||||
"canvasColor",
|
||||
"User Interface",
|
||||
"",
|
||||
"Canvas Color",
|
||||
choice(&[
|
||||
("matchUi", "Match User Interface Brightness"),
|
||||
("white", "White"),
|
||||
("lightGray", "Light Gray"),
|
||||
("mediumGray", "Medium Gray"),
|
||||
("darkGray", "Dark Gray")
|
||||
])
|
||||
),
|
||||
p!("autoCollapseIconPanels", "User Interface", "", "Auto-Collapse Iconic Panels", bool),
|
||||
p!("openDocumentsAsTabs", "User Interface", "", "Open Documents As Tabs", bool),
|
||||
p!("largeTabs", "User Interface", "", "Large Tabs", bool),
|
||||
@@ -460,7 +473,18 @@ impl Session {
|
||||
let grid_changed = p.gridline_every != self.prefs.gridline_every || p.grid_subdivisions != self.prefs.grid_subdivisions;
|
||||
let history_changed = p.history_states != self.prefs.history_states;
|
||||
let tile_edge_changed = p.pattern_tile_edge_color != self.prefs.pattern_tile_edge_color;
|
||||
let fonts_folder_changed = p.fonts_folder != self.prefs.fonts_folder;
|
||||
self.prefs = p;
|
||||
if fonts_folder_changed {
|
||||
let folder = self.prefs.fonts_folder.trim();
|
||||
vectorcraft_text::set_user_font_dirs(if folder.is_empty() { vec![] } else { vec![folder.into()] });
|
||||
// Once the fonts were scanned, scan again now: the folder's fonts appear (or go) in the
|
||||
// font menus, and type in them lays out again. The first scan reads it anyway.
|
||||
if vectorcraft_text::FontDb::global().installed_fonts_changed() {
|
||||
// Its result only counts the faces cataloged.
|
||||
let _ = super::fonts::rescan(self, &serde_json::Value::Null);
|
||||
}
|
||||
}
|
||||
vectorcraft_render::set_default_threads(u16::try_from(self.prefs.render_threads).ok());
|
||||
for st in &mut self.docs {
|
||||
if history_changed {
|
||||
|
||||
@@ -480,6 +480,9 @@ pub struct Prefs {
|
||||
// Hyphenation
|
||||
pub hyphenation_language: String,
|
||||
pub hyphenation_exceptions: String,
|
||||
/// Type › Options › Additional Fonts Folder: a folder (read with its subfolders) whose fonts
|
||||
/// are listed and used as if installed (#683); empty for none.
|
||||
pub fonts_folder: String,
|
||||
// Performance & Storage (Plug-ins & Scratch Disks)
|
||||
pub plugins_folder: String,
|
||||
pub scratch_primary: String,
|
||||
@@ -696,6 +699,7 @@ impl Default for Prefs {
|
||||
slice_line_color: s("#ff3f3f"),
|
||||
hyphenation_language: s("English: USA"),
|
||||
hyphenation_exceptions: String::new(),
|
||||
fonts_folder: String::new(),
|
||||
plugins_folder: String::new(),
|
||||
scratch_primary: s("Startup"),
|
||||
scratch_secondary: s("None"),
|
||||
|
||||
@@ -223,3 +223,63 @@ fn rearrange_keeps_its_grid() {
|
||||
s.execute("artboard.rearrange", &json!({"columns": 2, "spacing": 5})).unwrap();
|
||||
assert_eq!(boards(&s).iter().map(|r| (r.x0, r.y0)).collect::<Vec<_>>(), [(0.0, 0.0), (105.0, 0.0), (0.0, 55.0)]);
|
||||
}
|
||||
|
||||
/// #681: every layout and order of Rearrange All Artboards, five 100 × 50 artboards 10 pt apart
|
||||
/// with Columns (the rows of a grid by column) 2: each artboard lands in its (row, column) cell, the
|
||||
/// art on it rides along, and it all undoes in one step.
|
||||
#[test]
|
||||
fn rearrange_lays_out_by_layout_and_order() {
|
||||
type Cells = [(u32, u32); 5];
|
||||
let cells: [(&str, &str, Cells); 8] = [
|
||||
("gridByRow", "leftToRight", [(0, 0), (0, 1), (1, 0), (1, 1), (2, 0)]),
|
||||
("gridByRow", "rightToLeft", [(0, 1), (0, 0), (1, 1), (1, 0), (2, 1)]),
|
||||
("gridByColumn", "leftToRight", [(0, 0), (1, 0), (0, 1), (1, 1), (0, 2)]),
|
||||
("gridByColumn", "rightToLeft", [(0, 2), (1, 2), (0, 1), (1, 1), (0, 0)]),
|
||||
("row", "leftToRight", [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4)]),
|
||||
("row", "rightToLeft", [(0, 4), (0, 3), (0, 2), (0, 1), (0, 0)]),
|
||||
("column", "leftToRight", [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0)]),
|
||||
("column", "rightToLeft", [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0)]),
|
||||
];
|
||||
for (layout, order, want) in cells {
|
||||
// One row, 20 pt apart; a 10 pt square 10 pt into each artboard.
|
||||
let mut s = new_doc(json!({"width": 100, "height": 50, "artboards": 5}));
|
||||
let art: Vec<u64> = boards(&s)
|
||||
.iter()
|
||||
.map(|r| {
|
||||
s.execute("shape.rectangle", &json!({"x": r.x0 + 10.0, "y": r.y0 + 10.0, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap()
|
||||
})
|
||||
.collect();
|
||||
let before = boards(&s);
|
||||
let undo = s.doc().unwrap().history.undo.len();
|
||||
let p = json!({"layout": layout, "order": order, "columns": 2, "spacing": 10});
|
||||
let r = s.execute("artboard.rearrange", &p).unwrap();
|
||||
let (rows, cols) = want.iter().fold((0, 0), |(r, c), (wr, wc)| (r.max(wr + 1), c.max(wc + 1)));
|
||||
assert_eq!(r, json!({"artboards": 5, "rows": rows, "columns": cols}), "{layout} {order}");
|
||||
let got: Vec<(f64, f64)> = boards(&s).iter().map(|r| (r.x0, r.y0)).collect();
|
||||
let cells: Vec<(f64, f64)> = want.iter().map(|&(r, c)| (f64::from(c) * 110.0, f64::from(r) * 60.0)).collect();
|
||||
assert_eq!(got, cells, "{layout} {order}");
|
||||
assert!(boards(&s).iter().all(|r| r.width() == 100.0 && r.height() == 50.0));
|
||||
for (id, (x, y)) in art.iter().zip(&got) {
|
||||
let b = s.doc().unwrap().doc.node(NodeId(*id)).unwrap().geometric_bounds().unwrap();
|
||||
assert_eq!((b.x0, b.y0), (x + 10.0, y + 10.0), "{layout} {order}: the art moves with its artboard");
|
||||
}
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), undo + 1, "one undo step");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(boards(&s), before);
|
||||
}
|
||||
}
|
||||
|
||||
/// `byColumn: true` is Grid by Column; without `moveArtwork` the art stays; bad values are errors.
|
||||
#[test]
|
||||
fn rearrange_aliases_and_rejects_bad_values() {
|
||||
let mut s = new_doc(json!({"width": 100, "height": 50, "artboards": 3}));
|
||||
let id = s.execute("shape.rectangle", &json!({"x": 130, "y": 10, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("artboard.rearrange", &json!({"byColumn": true, "columns": 2, "spacing": 0, "moveArtwork": false})).unwrap();
|
||||
assert_eq!(boards(&s).iter().map(|r| (r.x0, r.y0)).collect::<Vec<_>>(), [(0.0, 0.0), (0.0, 50.0), (100.0, 0.0)]);
|
||||
assert_eq!(s.doc().unwrap().doc.node(NodeId(id)).unwrap().geometric_bounds().unwrap().x0, 130.0, "the art stays");
|
||||
let before = boards(&s);
|
||||
for p in [json!({"layout": "diagonal"}), json!({"order": "upward"}), json!({"layout": 3}), json!({"order": true})] {
|
||||
assert!(s.execute("artboard.rearrange", &p).is_err(), "{p}");
|
||||
}
|
||||
assert_eq!(boards(&s), before, "nothing moved");
|
||||
}
|
||||
@@ -98,13 +98,19 @@ fn known_bug(id: &str, p: &Value) -> bool {
|
||||
KNOWN_BUGS.iter().any(|(c, k)| *c == id && p.get(*k).is_some())
|
||||
}
|
||||
|
||||
/// Regression: huge column counts used to panic with `capacity overflow`.
|
||||
/// Regression: huge column counts used to panic with `capacity overflow`; in every layout and
|
||||
/// order (#681), with huge and negative spacing too.
|
||||
#[test]
|
||||
fn artboard_rearrange_huge_columns() {
|
||||
for fx in Fixture::ALL {
|
||||
for cols in [json!(u64::MAX), json!(1e308)] {
|
||||
let p = json!({ "columns": cols });
|
||||
assert_eq!(probe(fx, "artboard.rearrange", &p), None);
|
||||
for layout in ["gridByRow", "gridByColumn", "row", "column"] {
|
||||
for order in ["leftToRight", "rightToLeft"] {
|
||||
for (cols, spacing) in [(json!(u64::MAX), json!(1e308)), (json!(1e308), json!(-1e308)), (json!(0), json!(0)), (json!(-5), json!(20))]
|
||||
{
|
||||
let p = json!({ "layout": layout, "order": order, "columns": cols, "spacing": spacing });
|
||||
assert_eq!(probe(fx, "artboard.rearrange", &p), None);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -878,6 +878,31 @@ pub fn set_platform_font_files(list: PlatformFontFiles) {
|
||||
let _ = list;
|
||||
}
|
||||
|
||||
/// Folders the user adds to the font scan (Preferences › Type › Additional Fonts Folder, #683),
|
||||
/// read with their subfolders after the platform's.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
static USER_FONT_DIRS: std::sync::RwLock<Vec<PathBuf>> = std::sync::RwLock::new(Vec::new());
|
||||
|
||||
/// Have [`system_font_dirs`] also read `dirs` (#683), so the fonts in them are listed and used as
|
||||
/// if installed. The next check for installed fonts ([`FontDb::installed_fonts_changed`]) then
|
||||
/// reports the change, and a scan catalogs them.
|
||||
pub fn set_user_font_dirs(dirs: Vec<PathBuf>) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
*USER_FONT_DIRS.write().unwrap_or_else(std::sync::PoisonError::into_inner) = dirs;
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let _ = dirs;
|
||||
}
|
||||
|
||||
/// The folders [`set_user_font_dirs`] added (none on wasm).
|
||||
pub fn user_font_dirs() -> Vec<PathBuf> {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
return USER_FONT_DIRS.read().unwrap_or_else(std::sync::PoisonError::into_inner).clone();
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// The platform's font folders (the system's and the user's) and the font files known to it
|
||||
/// outside them (on Windows those registered with it, and those [`set_platform_font_files`]
|
||||
/// lists), scanned by [`FontDb::global`].
|
||||
@@ -926,6 +951,7 @@ pub fn system_font_dirs() -> Vec<PathBuf> {
|
||||
let files = fonts_outside(list(), &dirs);
|
||||
dirs.extend(files);
|
||||
}
|
||||
dirs.extend(user_font_dirs());
|
||||
dirs
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ pub mod thread;
|
||||
pub use craft_fonts::{CRAFT_FONTS, CraftFont};
|
||||
pub use features::{LIGATURE_TRACKING_LIMITS, OtFeatures, explicit_ligatures, ligatures_suppressed_by};
|
||||
pub use fontdb::{
|
||||
FALLBACK_FAMILY, FontClass, FontDb, FontFace, FontMatch, FontTraits, IcfMargins, PlatformFontFiles, set_platform_font_files, style_weight,
|
||||
system_font_dirs,
|
||||
FALLBACK_FAMILY, FontClass, FontDb, FontFace, FontMatch, FontTraits, IcfMargins, PlatformFontFiles, set_platform_font_files, set_user_font_dirs,
|
||||
style_weight, system_font_dirs, user_font_dirs,
|
||||
};
|
||||
use kurbo::{Affine, BezPath, Point, Rect, Vec2};
|
||||
pub use layout::{layout, layout_with};
|
||||
|
||||
@@ -319,6 +319,10 @@ fn tab_title(d: &vectorcraft_engine::DocState, zoom: f64, outline: bool) -> Stri
|
||||
format!("{}{} @ {} ({mode})", d.title(), if d.is_dirty() { "*" } else { "" }, zoom_label(zoom).replace('%', " %"))
|
||||
}
|
||||
|
||||
/// Whether a document tab's × comes before its title (macOS) rather than after it (Windows,
|
||||
/// Linux and the web).
|
||||
const CLOSE_BEFORE_TITLE: bool = cfg!(target_os = "macos");
|
||||
|
||||
/// Document tab strip: "Name* @ 66.67% (RGB/Preview)". User Interface › Large Tabs makes the tabs
|
||||
/// taller, with larger titles.
|
||||
pub fn doc_tabs(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
@@ -346,11 +350,13 @@ pub fn doc_tabs(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
ui.painter().rect_filled(r, 0.0, t.hover.gamma_multiply(0.4));
|
||||
}
|
||||
ui.painter().line_segment([r.right_top(), r.right_bottom()], Stroke::new(1.5, t.border));
|
||||
// × at the left like Illustrator.
|
||||
let xr = egui::Rect::from_center_size(egui::pos2(r.left() + 16.0, r.center().y), vec2(12.0, 12.0));
|
||||
// The × where each platform puts a tab's: before the title on macOS, after it elsewhere
|
||||
// (#673).
|
||||
let (x_center, title_left) = if CLOSE_BEFORE_TITLE { (r.left() + 16.0, r.left() + 32.0) } else { (r.right() - 16.0, r.left() + 14.0) };
|
||||
let xr = egui::Rect::from_center_size(egui::pos2(x_center, r.center().y), vec2(12.0, 12.0));
|
||||
let xresp = ui.interact(xr.expand(3.0), ui.id().with(("tabx", i)), Sense::click());
|
||||
icons::paint(ui, "x", xr, if xresp.hovered() { t.text_strong } else { t.text });
|
||||
ui.painter().galley(egui::pos2(r.left() + 32.0, r.center().y - galley.size().y / 2.0), galley, t.text);
|
||||
ui.painter().galley(egui::pos2(title_left, r.center().y - galley.size().y / 2.0), galley, t.text);
|
||||
if xresp.clicked() {
|
||||
close = Some(i);
|
||||
} else if resp.clicked() {
|
||||
@@ -782,6 +788,44 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A document tab's × sits where the platform puts it (#673): after the title on Windows,
|
||||
/// Linux and the web, before it on macOS; clicking it closes that document.
|
||||
#[test]
|
||||
fn a_tabs_close_box_sits_where_the_platform_puts_it() {
|
||||
let mut app = crate::VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1200.0, 200.0));
|
||||
let frame = |app: &mut crate::VectorcraftApp, events: Vec<egui::Event>| {
|
||||
let mut out = ctx.run_ui(egui::RawInput { screen_rect: Some(screen), events, ..Default::default() }, |ui| super::doc_tabs(app, ui));
|
||||
out.textures_delta.clear();
|
||||
let mut titles = vec![];
|
||||
for c in &out.shapes {
|
||||
// The titles, not the × icons.
|
||||
if let egui::Shape::Text(t) = &c.shape
|
||||
&& t.visual_bounding_rect().width() > 30.0
|
||||
{
|
||||
titles.push(t.visual_bounding_rect());
|
||||
}
|
||||
}
|
||||
titles.sort_by(|a, b| a.left().total_cmp(&b.left()));
|
||||
titles
|
||||
};
|
||||
let titles = frame(&mut app, vec![]);
|
||||
assert_eq!(titles.len(), 2, "{titles:?}");
|
||||
// The first tab's ×: 20 pt past its title's end, or 16 pt before its start.
|
||||
let first = titles[0];
|
||||
let x = if super::CLOSE_BEFORE_TITLE { first.left() - 16.0 } else { first.right() + 20.0 };
|
||||
let at = egui::pos2(x, first.center().y);
|
||||
let press = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
frame(&mut app, vec![egui::Event::PointerMoved(at), press(true)]);
|
||||
frame(&mut app, vec![press(false)]);
|
||||
assert_eq!(app.session.documents().len(), 1, "the × closed the first document");
|
||||
assert!(super::CLOSE_BEFORE_TITLE == cfg!(target_os = "macos"));
|
||||
}
|
||||
|
||||
/// One headless frame of the status bar; returns the artboard navigator's buttons, left to
|
||||
/// right: first, previous, next, last.
|
||||
fn navigator(app: &mut crate::VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> Vec<egui::Rect> {
|
||||
|
||||
@@ -24,7 +24,6 @@ fn lengths(command: &str) -> &'static [&'static str] {
|
||||
match command {
|
||||
"graph.create" => &["width", "height"],
|
||||
"shape.flare" => &["diameter", "pathLength"],
|
||||
"artboard.rearrange" => &["spacing"],
|
||||
"perspective.grid.set" => &["cell", "distance"],
|
||||
"object.repeat.options" => &["radius", "hSpacing", "vSpacing"],
|
||||
"text.areaOptions" => &["width", "height", "gutter", "inset", "firstBaselineMin"],
|
||||
|
||||
@@ -60,6 +60,7 @@ pub mod print;
|
||||
pub mod print_presets;
|
||||
mod psd_options;
|
||||
pub mod raster_effects;
|
||||
pub mod rearrange_artboards;
|
||||
pub mod recolor;
|
||||
mod recovery;
|
||||
pub mod saturate;
|
||||
@@ -278,6 +279,7 @@ registry! {
|
||||
PerspectivePlane: [perspective_plane::KIND] => perspective_plane::SPEC,
|
||||
LayerOptions: [layer_options::KIND] => layer_options::SPEC,
|
||||
LayersPanelOptions: [layers_panel_options::KIND] => layers_panel_options::SPEC,
|
||||
RearrangeArtboards: [rearrange_artboards::KIND] => rearrange_artboards::SPEC,
|
||||
}
|
||||
|
||||
/// The button labels the shared dialog frame can show (OK, discard and the fixed Cancel/Close),
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
//! Object → Artboards → Rearrange All Artboards (also the Artboards panel's button and menu, and
|
||||
//! the Properties panel's Rearrange All): Layout (a grid by row or by column, one row or one
|
||||
//! column), Layout Order (left to right or right to left), Columns (Rows for a grid by column),
|
||||
//! Spacing and Move Artwork with Artboard, with the document's artboard count. OK runs
|
||||
//! `artboard.rearrange` as one undo step (#681).
|
||||
//!
|
||||
//! Fields: `layout` (`gridByRow` | `gridByColumn` | `row` | `column`), `order` (`leftToRight` |
|
||||
//! `rightToLeft`), `columns` (the rows of a grid by column), `spacing` (pt) and `moveArtwork`.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_engine::cmd::newdoc::ArtboardLayout;
|
||||
|
||||
use super::{DialogSpec, form, run_and_close};
|
||||
use crate::state::Dialog;
|
||||
use crate::{VectorcraftApp, widgets};
|
||||
|
||||
/// The dialog kind of Rearrange All Artboards.
|
||||
pub const KIND: &str = "rearrangeArtboards";
|
||||
|
||||
const CMD: &str = "artboard.rearrange";
|
||||
|
||||
/// Width of the label column.
|
||||
const LABEL_W: f32 = 96.0;
|
||||
|
||||
pub(super) const SPEC: DialogSpec =
|
||||
DialogSpec { heading: |_| tl!("Rearrange All Artboards").into(), body, confirm, min_width: 320.0, ..DialogSpec::FORM };
|
||||
|
||||
/// The fields a fresh dialog starts with.
|
||||
pub fn fields() -> Value {
|
||||
json!({"layout": "gridByRow", "order": "leftToRight", "columns": 2, "spacing": 20, "moveArtwork": true})
|
||||
}
|
||||
|
||||
/// A layout's toggle: its tooltip and its artboards' cells (column, row) in their order, left to
|
||||
/// right.
|
||||
fn layout_glyph(l: ArtboardLayout) -> (&'static str, &'static [(u8, u8)]) {
|
||||
match l {
|
||||
ArtboardLayout::GridByRow => (tl!("Grid by Row"), &[(0, 0), (1, 0), (0, 1), (1, 1)]),
|
||||
ArtboardLayout::GridByColumn => (tl!("Grid by Column"), &[(0, 0), (0, 1), (1, 0), (1, 1)]),
|
||||
ArtboardLayout::Row => (tl!("Arrange by Row"), &[(0, 0), (1, 0), (2, 0)]),
|
||||
ArtboardLayout::Column => (tl!("Arrange by Column"), &[(0, 0), (0, 1), (0, 2)]),
|
||||
}
|
||||
}
|
||||
|
||||
/// `cells` mirrored left to right when `rtl` (the order the layout toggles preview).
|
||||
fn mirrored(cells: &[(u8, u8)], rtl: bool) -> Vec<(u8, u8)> {
|
||||
let last = cells.iter().map(|c| c.0).max().unwrap_or(0);
|
||||
cells.iter().map(|&(x, y)| (if rtl { last - x } else { x }, y)).collect()
|
||||
}
|
||||
|
||||
/// `artboard.rearrange` parameters from the fields.
|
||||
fn params(d: &Dialog) -> Value {
|
||||
json!({
|
||||
"layout": d.str("layout"), "order": d.str("order"), "columns": d.f64("columns", 2.0),
|
||||
"spacing": d.f64("spacing", 20.0), "moveArtwork": d.bool("moveArtwork"),
|
||||
})
|
||||
}
|
||||
|
||||
fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool {
|
||||
let unit = app.session.general_unit();
|
||||
let n = app.session.active().map_or(0, |doc| doc.doc.artboards.len());
|
||||
let layout = ArtboardLayout::parse(&d.str("layout")).unwrap_or_default();
|
||||
let rtl = d.str("order") == "rightToLeft";
|
||||
widgets::label_row(ui, tl!("Layout:"), LABEL_W, |ui| {
|
||||
ui.spacing_mut().item_spacing.x = 2.0;
|
||||
for l in ArtboardLayout::ALL {
|
||||
let (tip, cells) = layout_glyph(l);
|
||||
if widgets::layout_button(ui, &mirrored(cells, rtl), layout == l, tip) {
|
||||
d.fields.insert("layout".into(), json!(l.id()));
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
widgets::label_row(ui, tl!("Layout Order:"), LABEL_W, |ui| {
|
||||
ui.spacing_mut().item_spacing.x = 2.0;
|
||||
// One column reads the same either way.
|
||||
ui.add_enabled_ui(layout != ArtboardLayout::Column, |ui| {
|
||||
for (value, cells, tip) in [
|
||||
("leftToRight", [(0, 0), (1, 0)], tl!("Change to Left-to-Right Layout")),
|
||||
("rightToLeft", [(1, 0), (0, 0)], tl!("Change to Right-to-Left Layout")),
|
||||
] {
|
||||
if widgets::layout_button(ui, &cells, (value == "rightToLeft") == rtl, tip) {
|
||||
d.fields.insert("order".into(), json!(value));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
// The rows of a grid by column; one row or column has no count to set.
|
||||
let label = if layout == ArtboardLayout::GridByColumn { tl!("Rows:") } else { tl!("Columns:") };
|
||||
widgets::label_row(ui, label, LABEL_W, |ui| {
|
||||
let grid = matches!(layout, ArtboardLayout::GridByRow | ArtboardLayout::GridByColumn);
|
||||
ui.add_enabled_ui(grid, |ui| {
|
||||
let most = n.max(1) as f64;
|
||||
if let Some(v) = widgets::spin_plain(ui, "rearrange-columns", d.f64("columns", 2.0), "", 0, 76.0, 1.0, 1.0, &[]) {
|
||||
d.fields.insert("columns".into(), json!(v.round().clamp(1.0, most)));
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
widgets::label_row(ui, tl!("Spacing:"), LABEL_W, |ui| {
|
||||
form::length(ui, d, "spacing", unit, 100.0);
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
widgets::label_row(ui, tl!("Options:"), LABEL_W, |ui| {
|
||||
form::check(ui, d, "moveArtwork", tl!("Move Artwork with Artboard"));
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
widgets::dim_label(ui, &crate::i18n::fmt(tl!("Artboards: {n}"), &[("n", &n.to_string())]));
|
||||
false
|
||||
}
|
||||
|
||||
fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result<Value, String> {
|
||||
run_and_close(app, CMD, params(d))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use vectorcraft_engine::Session;
|
||||
|
||||
/// A frame of the open dialog with `events` → the texts painted. The dialog measures itself on
|
||||
/// its first frame, so a fresh context needs two.
|
||||
fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> Vec<String> {
|
||||
let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| super::super::show(app, ui.ctx()));
|
||||
out.textures_delta.clear();
|
||||
out.shapes.iter().filter_map(|s| if let egui::epaint::Shape::Text(t) = &s.shape { Some(t.galley.text().to_string()) } else { None }).collect()
|
||||
}
|
||||
|
||||
fn context() -> egui::Context {
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
ctx
|
||||
}
|
||||
|
||||
fn origins(app: &VectorcraftApp) -> Vec<(f64, f64)> {
|
||||
app.session.active().unwrap().doc.artboards.iter().map(|a| (a.rect.x0, a.rect.y0)).collect()
|
||||
}
|
||||
|
||||
/// #681: the menu item opens the dialog with the artboard count; Columns reads Rows for a grid
|
||||
/// by column; OK lays the artboards out right to left, as one undo step.
|
||||
#[test]
|
||||
fn opens_from_the_menu_and_rearranges_by_layout_and_order() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 100, "height": 50, "artboards": 3})).unwrap();
|
||||
// The menu item has no params of its own: it opens this dialog, not the generic one.
|
||||
let (id, p) = crate::menus::click_target("Rearrange All Artboards…", CMD, &Value::Null);
|
||||
crate::menus::invoke(&mut app, &id, p);
|
||||
assert_eq!(app.ui.dialog.as_ref().map(|d| d.kind.as_str()), Some(KIND));
|
||||
let ctx = context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
let texts = frame(&mut app, &ctx, vec![]);
|
||||
for want in ["Rearrange All Artboards", "Layout:", "Layout Order:", "Columns:", "Spacing:", "Move Artwork with Artboard", "Artboards: 3"] {
|
||||
assert!(texts.iter().any(|t| t == want), "{want:?} in {texts:?}");
|
||||
}
|
||||
let d = app.ui.dialog.as_mut().unwrap();
|
||||
d.fields.insert("layout".into(), json!("gridByColumn"));
|
||||
let texts = frame(&mut app, &ctx, vec![]);
|
||||
assert!(texts.iter().any(|t| t == "Rows:") && !texts.iter().any(|t| t == "Columns:"), "{texts:?}");
|
||||
// One row, right to left, 10 pt apart.
|
||||
let d = app.ui.dialog.as_mut().unwrap();
|
||||
d.fields.insert("layout".into(), json!("row"));
|
||||
d.fields.insert("order".into(), json!("rightToLeft"));
|
||||
d.fields.insert("spacing".into(), json!(10));
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
let undo = app.session.doc().unwrap().history.undo.len();
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
assert!(app.ui.dialog.is_none());
|
||||
assert_eq!(origins(&app), [(220.0, 0.0), (110.0, 0.0), (0.0, 0.0)]);
|
||||
assert_eq!(app.session.doc().unwrap().history.undo.len(), undo + 1);
|
||||
}
|
||||
|
||||
/// Clicking the layout and order toggles sets the fields (the toggles' rects from the frame).
|
||||
#[test]
|
||||
fn the_toggles_set_layout_and_order() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 100, "height": 50, "artboards": 4})).unwrap();
|
||||
app.run("ui.menuDialog", json!({ "command": CMD })).unwrap();
|
||||
let ctx = context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
// The 26-point toggles, left to right then top to bottom: four layouts, then two orders.
|
||||
let toggles: Vec<egui::Rect> = ctx.viewport(|vp| {
|
||||
let mut r: Vec<egui::Rect> = vp
|
||||
.prev_pass
|
||||
.widgets
|
||||
.layers()
|
||||
.flat_map(|(_, w)| w.iter())
|
||||
.filter(|w| w.sense.senses_click() && w.rect.width() == 26.0 && w.rect.height() == 26.0)
|
||||
.map(|w| w.rect)
|
||||
.collect();
|
||||
r.sort_by(|a, b| a.top().total_cmp(&b.top()).then(a.left().total_cmp(&b.left())));
|
||||
r
|
||||
});
|
||||
assert_eq!(toggles.len(), 6, "{toggles:?}");
|
||||
for (i, key, want) in [(3, "layout", "column"), (1, "layout", "gridByColumn"), (5, "order", "rightToLeft")] {
|
||||
let at = toggles[i].center();
|
||||
let b = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
frame(&mut app, &ctx, vec![egui::Event::PointerMoved(at), b(true)]);
|
||||
frame(&mut app, &ctx, vec![b(false)]);
|
||||
assert_eq!(app.ui.dialog.as_ref().unwrap().str(key), want);
|
||||
// A frame for the order toggles to follow the layout (one column greys them).
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
}
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
// Two rows (Columns 2 reads Rows for a grid by column), the first column at the right.
|
||||
assert_eq!(origins(&app), [(120.0, 0.0), (120.0, 70.0), (0.0, 0.0), (0.0, 70.0)]);
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,7 @@
|
||||
Add to Swatches Agregar a muestras
|
||||
Add Used Colors Agregar colores usados
|
||||
Additional Plug-ins Folder Carpeta de plugins adicionales
|
||||
Additional Fonts Folder Carpeta de fuentes adicionales
|
||||
Adjust Adjoining Width Points Ajustar puntos de anchura contiguos
|
||||
Adjust Color Balance… Ajustar equilibrio de color…
|
||||
Adjust Colors Ajustar colores
|
||||
@@ -1399,6 +1400,9 @@
|
||||
Marks and Bleed Marcas y sangrado
|
||||
Marks and Bleeds Marcas y sangrados
|
||||
Match User Interface Brightness Igualar brillo de la interfaz de usuario
|
||||
Light Gray Gris claro
|
||||
Medium Gray Gris medio
|
||||
Dark Gray Gris oscuro
|
||||
Materials… Materiales…
|
||||
Matte Mate
|
||||
Matte: Mate:
|
||||
@@ -1954,7 +1958,16 @@
|
||||
Rating: Clasificación:
|
||||
Real World: Mundo real:
|
||||
Real-time Drawing and Editing Dibujo y edición en tiempo real
|
||||
Rearrange All Artboards (on the roadmap) Reorganizar todas las mesas de trabajo (en la hoja de ruta)
|
||||
Rearrange All Artboards Reorganizar todas las mesas de trabajo
|
||||
Rearrange All Reorganizar todo
|
||||
Layout Order: Orden de diseño:
|
||||
Change to Left-to-Right Layout Cambiar a diseño de izquierda a derecha
|
||||
Grid by Row Cuadrícula por filas
|
||||
Grid by Column Cuadrícula por columnas
|
||||
Arrange by Row Organizar en una fila
|
||||
Arrange by Column Organizar en una columna
|
||||
Move Artwork with Artboard Mover la ilustración con la mesa de trabajo
|
||||
Artboards: {n} Mesas de trabajo: {n}
|
||||
Rearrange All Artboards… Reorganizar todas las mesas de trabajo…
|
||||
Recall Selection Recuperar selección
|
||||
RECENT RECIENTES
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -77,6 +77,7 @@
|
||||
Add to Swatches Ajouter au nuancier
|
||||
Add Used Colors Ajouter les couleurs utilisées
|
||||
Additional Plug-ins Folder Dossier de modules externes supplémentaires
|
||||
Additional Fonts Folder Dossier de polices supplémentaires
|
||||
Adjust Adjoining Width Points Ajuster les points de largeur adjacents
|
||||
Adjust Color Balance… Régler la balance des couleurs…
|
||||
Adjust Colors Régler les couleurs
|
||||
@@ -1398,6 +1399,9 @@
|
||||
Marks and Bleed Marques et fond perdu
|
||||
Marks and Bleeds Marques et fonds perdus
|
||||
Match User Interface Brightness Adapter à la luminosité de l’interface
|
||||
Light Gray Gris clair
|
||||
Medium Gray Gris moyen
|
||||
Dark Gray Gris foncé
|
||||
Materials… Matériaux…
|
||||
Matte Détourage
|
||||
Matte: Détourage :
|
||||
@@ -1951,7 +1955,16 @@
|
||||
Rating: Classement :
|
||||
Real World: Monde réel :
|
||||
Real-time Drawing and Editing Dessin et édition en temps réel
|
||||
Rearrange All Artboards (on the roadmap) Réorganiser tous les plans de travail (prévu)
|
||||
Rearrange All Artboards Réorganiser tous les plans de travail
|
||||
Rearrange All Tout réorganiser
|
||||
Layout Order: Ordre de disposition :
|
||||
Change to Left-to-Right Layout Passer à la disposition de gauche à droite
|
||||
Grid by Row Grille par ligne
|
||||
Grid by Column Grille par colonne
|
||||
Arrange by Row Disposer en ligne
|
||||
Arrange by Column Disposer en colonne
|
||||
Move Artwork with Artboard Déplacer l’illustration avec le plan de travail
|
||||
Artboards: {n} Plans de travail : {n}
|
||||
Rearrange All Artboards… Réorganiser tous les plans de travail…
|
||||
Recall Selection Rappeler la sélection
|
||||
RECENT RÉCENTS
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -76,6 +76,7 @@
|
||||
Add to Swatches Aggiungi ai campioni
|
||||
Add Used Colors Aggiungi colori usati
|
||||
Additional Plug-ins Folder Cartella plug-in aggiuntivi
|
||||
Additional Fonts Folder Cartella font aggiuntivi
|
||||
Adjust Adjoining Width Points Regola punti di larghezza adiacenti
|
||||
Adjust Color Balance… Regola bilanciamento colore…
|
||||
Adjust Colors Regola colori
|
||||
@@ -1399,6 +1400,9 @@
|
||||
Marks and Bleed Segni e abbondanza
|
||||
Marks and Bleeds Segni e abbondanze
|
||||
Match User Interface Brightness Adatta alla luminosità dell'interfaccia utente
|
||||
Light Gray Grigio chiaro
|
||||
Medium Gray Grigio medio
|
||||
Dark Gray Grigio scuro
|
||||
Materials… Materiali…
|
||||
Matte Colore alone
|
||||
Matte: Colore alone:
|
||||
@@ -1954,7 +1958,16 @@
|
||||
Rating: Valutazione:
|
||||
Real World: Mondo reale:
|
||||
Real-time Drawing and Editing Disegno e modifica in tempo reale
|
||||
Rearrange All Artboards (on the roadmap) Ridisponi tutte le tavole da disegno (in programma)
|
||||
Rearrange All Artboards Ridisponi tutte le tavole da disegno
|
||||
Rearrange All Ridisponi tutto
|
||||
Layout Order: Ordine del layout:
|
||||
Change to Left-to-Right Layout Passa al layout da sinistra a destra
|
||||
Grid by Row Griglia per righe
|
||||
Grid by Column Griglia per colonne
|
||||
Arrange by Row Disponi in una riga
|
||||
Arrange by Column Disponi in una colonna
|
||||
Move Artwork with Artboard Sposta la grafica con la tavola da disegno
|
||||
Artboards: {n} Tavole da disegno: {n}
|
||||
Rearrange All Artboards… Ridisponi tutte le tavole da disegno…
|
||||
Recall Selection Richiama selezione
|
||||
RECENT RECENTI
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -724,6 +724,7 @@
|
||||
Add to Selection 選択範囲に追加
|
||||
Add to Swatches スウォッチに追加
|
||||
Additional Plug-ins Folder 追加プラグインフォルダー
|
||||
Additional Fonts Folder 追加フォントフォルダー
|
||||
Adjust Adjoining Width Points 隣接する幅ポイントを調整
|
||||
Adjust Colors カラーを調整
|
||||
Adjust Options: 調整オプション:
|
||||
@@ -1576,6 +1577,9 @@
|
||||
Mark as trapped トラップ済みとしてマーク
|
||||
Marks トンボ
|
||||
Match User Interface Brightness ユーザーインターフェイスの明るさに合わせる
|
||||
Light Gray ライトグレー
|
||||
Medium Gray ミディアムグレー
|
||||
Dark Gray ダークグレー
|
||||
Matte: マット:
|
||||
Maximize 最大化
|
||||
Maximum Editability 編集機能を最大限に保持
|
||||
@@ -1984,7 +1988,16 @@
|
||||
Rating: 評価:
|
||||
Real World: 実寸:
|
||||
Real-time Drawing and Editing リアルタイム描画および編集
|
||||
Rearrange All Artboards (on the roadmap) すべてのアートボードを再配置 (今後対応予定)
|
||||
Rearrange All Artboards すべてのアートボードを再配置
|
||||
Rearrange All すべて再配置
|
||||
Layout Order: レイアウト順序:
|
||||
Change to Left-to-Right Layout 左から右のレイアウトに変更
|
||||
Grid by Row 行ごとのグリッド
|
||||
Grid by Column 列ごとのグリッド
|
||||
Arrange by Row 1 行に配置
|
||||
Arrange by Column 1 列に配置
|
||||
Move Artwork with Artboard アートボードと一緒にアートワークを移動
|
||||
Artboards: {n} アートボード: {n}
|
||||
Recall Selection 選択範囲を呼び出し
|
||||
Recent Colors 最近使用したカラー
|
||||
Recent Files 最近使ったファイル
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -138,6 +138,7 @@
|
||||
Add to Selection Adicionar à Seleção
|
||||
Add to Swatches Adicionar às Amostras
|
||||
Additional Plug-ins Folder Pasta Adicional de Plug-ins
|
||||
Additional Fonts Folder Pasta Adicional de Fontes
|
||||
Adjust Adjoining Width Points Ajustar Pontos de Largura Adjacentes
|
||||
Adjust Color Balance… Ajustar Equilíbrio de Cores…
|
||||
Adjust Colors Ajustar Cores
|
||||
@@ -1261,6 +1262,9 @@
|
||||
Marker… Marcador…
|
||||
Marks Marcas
|
||||
Match User Interface Brightness Corresponder ao Brilho da Interface do Usuário
|
||||
Light Gray Cinza Claro
|
||||
Medium Gray Cinza Médio
|
||||
Dark Gray Cinza Escuro
|
||||
Materials… Materiais…
|
||||
Matte: Fosco:
|
||||
Maximize Maximizar
|
||||
@@ -1746,7 +1750,16 @@
|
||||
Rating: Avaliação:
|
||||
Real World: Mundo Real:
|
||||
Real-time Drawing and Editing Desenho e Edição em Tempo Real
|
||||
Rearrange All Artboards (on the roadmap) Reorganizar Todas as Mesas de Trabalho (no roadmap)
|
||||
Rearrange All Artboards Reorganizar Todas as Mesas de Trabalho
|
||||
Rearrange All Reorganizar Tudo
|
||||
Layout Order: Ordem do Layout:
|
||||
Change to Left-to-Right Layout Mudar para Layout da Esquerda para a Direita
|
||||
Grid by Row Grade por Linha
|
||||
Grid by Column Grade por Coluna
|
||||
Arrange by Row Organizar em Linha
|
||||
Arrange by Column Organizar em Coluna
|
||||
Move Artwork with Artboard Mover Arte com a Mesa de Trabalho
|
||||
Artboards: {n} Mesas de Trabalho: {n}
|
||||
Rearrange All Artboards… Reorganizar Todas as Mesas de Trabalho…
|
||||
Recall Selection Relembrar Seleção
|
||||
Recent Colors Cores Recentes
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -74,6 +74,7 @@
|
||||
Add to Swatches Добавить в образцы
|
||||
Add Used Colors Добавить использованные цвета
|
||||
Additional Plug-ins Folder Папка дополнительных модулей
|
||||
Additional Fonts Folder Папка дополнительных шрифтов
|
||||
Adjust Adjoining Width Points Настроить смежные точки ширины
|
||||
Adjust Color Balance… Настроить цветовой баланс…
|
||||
Adjust Colors Настроить цвета
|
||||
@@ -1397,6 +1398,9 @@
|
||||
Marks and Bleed Метки и вылет
|
||||
Marks and Bleeds Метки и вылеты
|
||||
Match User Interface Brightness Согласовать с яркостью интерфейса
|
||||
Light Gray Светло-серый
|
||||
Medium Gray Средне-серый
|
||||
Dark Gray Тёмно-серый
|
||||
Materials… Материалы…
|
||||
Matte Мат
|
||||
Matte: Мат:
|
||||
@@ -1950,7 +1954,16 @@
|
||||
Rating: Рейтинг:
|
||||
Real World: Реальный мир:
|
||||
Real-time Drawing and Editing Рисование и редактирование в реальном времени
|
||||
Rearrange All Artboards (on the roadmap) Переставить все монтажные области (в плане развития)
|
||||
Rearrange All Artboards Переставить все монтажные области
|
||||
Rearrange All Переставить все
|
||||
Layout Order: Порядок макета:
|
||||
Change to Left-to-Right Layout Переключить на макет слева направо
|
||||
Grid by Row Сетка по строкам
|
||||
Grid by Column Сетка по столбцам
|
||||
Arrange by Row Расположить в строку
|
||||
Arrange by Column Расположить в столбец
|
||||
Move Artwork with Artboard Перемещать иллюстрацию вместе с монтажной областью
|
||||
Artboards: {n} Монтажные области: {n}
|
||||
Rearrange All Artboards… Переставить все монтажные области…
|
||||
Recall Selection Восстановить выделение
|
||||
RECENT ПОСЛЕДНИЕ
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -79,6 +79,7 @@
|
||||
Add to Swatches 添加到色板
|
||||
Add Used Colors 添加已用颜色
|
||||
Additional Plug-ins Folder 附加增效工具文件夹
|
||||
Additional Fonts Folder 附加字体文件夹
|
||||
Adjust Adjoining Width Points 调整相邻宽度点
|
||||
Adjust Color Balance… 调整色彩平衡…
|
||||
Adjust Colors 调整颜色
|
||||
@@ -1381,6 +1382,9 @@
|
||||
Marks and Bleed 标记和出血
|
||||
Marks and Bleeds 标记和出血
|
||||
Match User Interface Brightness 匹配用户界面亮度
|
||||
Light Gray 浅灰色
|
||||
Medium Gray 中灰色
|
||||
Dark Gray 深灰色
|
||||
Materials… 材质…
|
||||
Matte 杂边
|
||||
Matte: 杂边:
|
||||
@@ -1928,7 +1932,16 @@
|
||||
Rating: 等级:
|
||||
Real World: 真实世界:
|
||||
Real-time Drawing and Editing 实时绘图和编辑
|
||||
Rearrange All Artboards (on the roadmap) 重新排列所有画板 (规划中)
|
||||
Rearrange All Artboards 重新排列所有画板
|
||||
Rearrange All 全部重新排列
|
||||
Layout Order: 布局顺序:
|
||||
Change to Left-to-Right Layout 更改为由左至右版面配置
|
||||
Grid by Row 按行网格排列
|
||||
Grid by Column 按列网格排列
|
||||
Arrange by Row 排成一行
|
||||
Arrange by Column 排成一列
|
||||
Move Artwork with Artboard 随画板移动图稿
|
||||
Artboards: {n} 画板:{n}
|
||||
Rearrange All Artboards… 重新排列所有画板…
|
||||
Recall Selection 召回选区
|
||||
RECENT 最近使用
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -87,6 +87,7 @@
|
||||
Add to Swatches 新增至色票
|
||||
Add Used Colors 新增使用中的顏色
|
||||
Additional Plug-ins Folder 額外的增效模組資料夾
|
||||
Additional Fonts Folder 額外的字體資料夾
|
||||
Adjust Adjoining Width Points 調整相鄰寬度點
|
||||
Adjust Color Balance… 調整色彩平衡…
|
||||
Adjust Colors 調整顏色
|
||||
@@ -1417,6 +1418,9 @@
|
||||
Marks and Bleed 標記與出血
|
||||
Marks and Bleeds 標記與出血
|
||||
Match User Interface Brightness 符合使用者介面亮度
|
||||
Light Gray 淺灰色
|
||||
Medium Gray 中灰色
|
||||
Dark Gray 深灰色
|
||||
Materials… 材質…
|
||||
Matte 邊緣色
|
||||
Matte: 遮色:
|
||||
@@ -1974,7 +1978,16 @@
|
||||
Rating: 評等:
|
||||
Real World: 真實世界:
|
||||
Real-time Drawing and Editing 即時繪圖與編輯
|
||||
Rearrange All Artboards (on the roadmap) 重新排列所有工作區域 (規劃中)
|
||||
Rearrange All Artboards 重新排列所有工作區域
|
||||
Rearrange All 全部重新排列
|
||||
Layout Order: 版面配置順序:
|
||||
Change to Left-to-Right Layout 變更為由左至右版面配置
|
||||
Grid by Row 依列格狀排列
|
||||
Grid by Column 依欄格狀排列
|
||||
Arrange by Row 排成一列
|
||||
Arrange by Column 排成一欄
|
||||
Move Artwork with Artboard 隨工作區域移動圖稿
|
||||
Artboards: {n} 工作區域:{n}
|
||||
Rearrange All Artboards… 重新排列所有工作區域…
|
||||
Recall Selection 叫出選取範圍
|
||||
RECENT 最近使用
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -473,7 +473,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"ui.menuDialog",
|
||||
"Menu Dialog",
|
||||
"",
|
||||
"{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|object.path.offsetPath|object.path.simplify|object.path.splitIntoGrid|object.vectorHalftone|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options} open the dialog that command's menu item opens (dialog kind: move, rotate, scale, reflect, shear, transformEach, …, vectorHalftone, envelopeWarp, envelopeMesh, envelopeOptions; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected)",
|
||||
"{command: object.move|object.rotate|object.scale|object.reflect|object.shear|object.transformEach|path.average|object.path.offsetPath|object.path.simplify|object.path.splitIntoGrid|object.vectorHalftone|artboard.rearrange|object.envelope.makeWithWarp|object.envelope.resetWithWarp|object.envelope.makeWithMesh|object.envelope.resetWithMesh|object.envelope.options} open the dialog that command's menu item opens (dialog kind: move, rotate, scale, reflect, shear, transformEach, …, vectorHalftone, rearrangeArtboards, envelopeWarp, envelopeMesh, envelopeOptions; Scale and Transform Each have `corners` and `strokes`, from the preferences, which OK updates; the envelope dialogs start from the selected envelope, Make opens as Reset (`reset: true`) while one is selected)",
|
||||
),
|
||||
(
|
||||
"ui.widthPointEdit",
|
||||
@@ -2196,7 +2196,7 @@ pub fn menu_tree() -> Vec<(&'static str, Vec<Item>)> {
|
||||
"Artboards",
|
||||
vec![
|
||||
c("Convert to Artboards", "artboard.convertToArtboards"),
|
||||
cp("Rearrange All Artboards…", "artboard.rearrange", json!({"columns": 2, "spacing": 20, "moveArtwork": true})),
|
||||
c("Rearrange All Artboards…", "artboard.rearrange"),
|
||||
Sep,
|
||||
c("Fit to Artwork Bounds", "artboard.fitToArt"),
|
||||
c("Fit to Selected Art", "artboard.fitToSelection"),
|
||||
@@ -2870,6 +2870,7 @@ fn menu_dialog(id: &str) -> Option<(&'static str, Value)> {
|
||||
"object.path.simplify" => ("simplify", json!({"tolerance": "1 pt"})),
|
||||
"object.path.splitIntoGrid" => ("splitIntoGrid", json!({"rows": 2, "columns": 2, "gutter": "12 pt"})),
|
||||
"object.vectorHalftone" => (crate::dialogs::halftone::KIND, crate::dialogs::halftone::fields()),
|
||||
"artboard.rearrange" => (crate::dialogs::rearrange_artboards::KIND, crate::dialogs::rearrange_artboards::fields()),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -113,7 +113,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
});
|
||||
let n = abs.len();
|
||||
widgets::bottom_bar(ui, |ui| {
|
||||
widgets::icon_button_enabled(ui, "dc-rearrange", tl!("Rearrange All Artboards (on the roadmap)"), false, false, 24.0);
|
||||
if widgets::icon_button_enabled(ui, "dc-rearrange", tl!("Rearrange All Artboards"), false, n > 1, 24.0).clicked() {
|
||||
open_rearrange(app);
|
||||
}
|
||||
ui.add_space((ui.available_width() - 4.0 * 28.0).max(0.0));
|
||||
if widgets::icon_button_enabled(ui, "dc-arrow-up", tl!("Move Up"), false, sel > 0, 24.0).clicked()
|
||||
&& app.run("artboard.reorder", json!({"index": sel, "to": sel - 1})).is_ok()
|
||||
@@ -140,6 +142,11 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
});
|
||||
}
|
||||
|
||||
/// Open Rearrange All Artboards (#681).
|
||||
pub(crate) fn open_rearrange(app: &mut VectorcraftApp) {
|
||||
app.run("ui.menuDialog", json!({ "command": "artboard.rearrange" })).ok();
|
||||
}
|
||||
|
||||
pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let n = app.session.active().map(|d| d.doc.artboards.len()).unwrap_or(0);
|
||||
let sel = selected(app, n);
|
||||
@@ -161,7 +168,9 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
if menu_item(ui, tl!("Artboard Options…"), n > 0, false) {
|
||||
app.select_tool("artboard");
|
||||
}
|
||||
menu_item(ui, tl!("Rearrange All Artboards…"), false, false);
|
||||
if menu_item(ui, tl!("Rearrange All Artboards…"), n > 1, false) {
|
||||
open_rearrange(app);
|
||||
}
|
||||
ui.separator();
|
||||
if menu_item(ui, tl!("Fit to Artwork Bounds"), n > 0, false) {
|
||||
app.run("artboard.fitToArt", json!({"index": sel})).ok();
|
||||
|
||||
@@ -198,7 +198,8 @@ fn multi_color(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool {
|
||||
}
|
||||
|
||||
/// Edit Artboards (the Artboard tool): the active artboard's name, position and size, its preset and
|
||||
/// orientation (#671), New Artboard and Delete Artboard, and Exit back to the Selection tool (#530).
|
||||
/// orientation (#671), New Artboard and Delete Artboard, and Quick Actions: Rearrange All (#681) and
|
||||
/// Exit back to the Selection tool (#530).
|
||||
fn artboard_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let units = app.session.general_unit();
|
||||
let n = app.session.active().map_or(0, |d| d.doc.artboards.len());
|
||||
@@ -235,8 +236,18 @@ fn artboard_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
});
|
||||
divider(ui);
|
||||
section_header(ui, tl!("Quick Actions"));
|
||||
if widgets::flat_button(ui, tl!("Exit"), w).clicked() {
|
||||
app.select_tool("selection");
|
||||
ui.horizontal(|ui| {
|
||||
rearrange_button(app, ui, n, w);
|
||||
if widgets::flat_button(ui, tl!("Exit"), w).clicked() {
|
||||
app.select_tool("selection");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Rearrange All (#681): opens Rearrange All Artboards; disabled with fewer than two artboards.
|
||||
fn rearrange_button(app: &mut VectorcraftApp, ui: &mut Ui, artboards: usize, w: f32) {
|
||||
if ui.add_enabled_ui(artboards > 1, |ui| widgets::flat_button(ui, tl!("Rearrange All"), w)).inner.clicked() {
|
||||
super::artboards::open_rearrange(app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,6 +319,10 @@ fn document_sections(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
app.select_tool("artboard");
|
||||
}
|
||||
});
|
||||
let artboards = app.session.active().map_or(0, |d| d.doc.artboards.len());
|
||||
if artboards > 1 {
|
||||
rearrange_button(app, ui, artboards, w);
|
||||
}
|
||||
divider(ui);
|
||||
section_header(ui, tl!("Appearance"));
|
||||
fill_stroke_rows(app, ui);
|
||||
@@ -572,6 +587,26 @@ mod tests {
|
||||
assert_eq!(app.session.tool_id(), "selection");
|
||||
}
|
||||
|
||||
/// #681: Rearrange All opens Rearrange All Artboards in one click, from the Document section
|
||||
/// (only with several artboards) and from Edit Artboards' Quick Actions.
|
||||
#[test]
|
||||
fn rearrange_all_opens_the_dialog() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
assert!(!frame(&mut app, &ctx, vec![]).iter().any(|(t, _)| t == "Rearrange All"), "one artboard: nothing to rearrange");
|
||||
app.run("artboard.new", json!({})).unwrap();
|
||||
let texts = frame(&mut app, &ctx, vec![]);
|
||||
click(&mut app, &ctx, &texts, "Rearrange All");
|
||||
let kind = |app: &VectorcraftApp| app.ui.dialog.as_ref().map(|d| d.kind.clone());
|
||||
assert_eq!(kind(&app).as_deref(), Some(crate::dialogs::rearrange_artboards::KIND));
|
||||
app.ui.dialog = None;
|
||||
app.select_tool("artboard");
|
||||
let texts = frame(&mut app, &ctx, vec![]);
|
||||
click(&mut app, &ctx, &texts, "Rearrange All");
|
||||
assert_eq!(kind(&app).as_deref(), Some(crate::dialogs::rearrange_artboards::KIND));
|
||||
}
|
||||
|
||||
/// #671: Edit Artboards shows the artboard's preset (Custom when it matches none) and its
|
||||
/// orientation; the other orientation swaps its width and height, its corner staying put.
|
||||
#[test]
|
||||
|
||||
@@ -80,13 +80,26 @@ pub fn restore(app: &mut VectorcraftApp) {
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
struct Applied {
|
||||
brightness: Brightness,
|
||||
white_canvas: bool,
|
||||
/// User Interface › Canvas Color, unless it matches the interface brightness.
|
||||
canvas: Option<egui::Color32>,
|
||||
threads: i32,
|
||||
tool_tips: bool,
|
||||
scrub: bool,
|
||||
bare_points: bool,
|
||||
}
|
||||
|
||||
/// User Interface › Canvas Color: the canvas around the artboards, or `None` to match the
|
||||
/// interface brightness. The greys keep the white page's edge in view (#663).
|
||||
fn canvas_color(key: &str) -> Option<egui::Color32> {
|
||||
match key {
|
||||
"white" => Some(egui::Color32::WHITE),
|
||||
"lightGray" => Some(egui::Color32::from_gray(0xc8)),
|
||||
"mediumGray" => Some(egui::Color32::from_gray(0x96)),
|
||||
"darkGray" => Some(egui::Color32::from_gray(0x5a)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Per frame: push UI-side preferences into egui / the renderer when they change.
|
||||
pub fn apply_runtime(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
let p = &app.session.prefs;
|
||||
@@ -97,7 +110,7 @@ pub fn apply_runtime(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
}
|
||||
let want = Applied {
|
||||
brightness: app.ui.brightness,
|
||||
white_canvas: p.canvas_color == "white",
|
||||
canvas: canvas_color(&p.canvas_color),
|
||||
threads: p.render_threads,
|
||||
tool_tips: p.show_tool_tips,
|
||||
scrub: p.scrub_numeric_fields,
|
||||
@@ -113,9 +126,9 @@ pub fn apply_runtime(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
ctx.global_style_mut(|s| s.interaction.tooltip_delay = delay);
|
||||
crate::scrub::set_enabled(ctx, want.scrub);
|
||||
crate::widgets::set_bare_numbers_are_points(ctx, want.bare_points);
|
||||
if want.white_canvas {
|
||||
if let Some(c) = want.canvas {
|
||||
let mut t = Tokens::get(ctx);
|
||||
t.pasteboard = egui::Color32::WHITE;
|
||||
t.pasteboard = c;
|
||||
ctx.data_mut(|d| d.insert_temp(egui::Id::NULL, t));
|
||||
}
|
||||
if prev.is_some_and(|pr| pr.threads != want.threads) {
|
||||
@@ -365,6 +378,28 @@ mod tests {
|
||||
use crate::Services;
|
||||
use vectorcraft_engine::Session;
|
||||
|
||||
/// User Interface › Canvas Color (#663): White and the three greys paint the canvas around the
|
||||
/// artboards; Match User Interface Brightness keeps the theme's.
|
||||
#[test]
|
||||
fn canvas_color_choices_paint_the_pasteboard() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Services::default());
|
||||
let ctx = egui::Context::default();
|
||||
apply_runtime(&mut app, &ctx);
|
||||
let themed = Tokens::get(&ctx).pasteboard;
|
||||
for (key, want) in [
|
||||
("white", egui::Color32::WHITE),
|
||||
("lightGray", egui::Color32::from_gray(0xc8)),
|
||||
("mediumGray", egui::Color32::from_gray(0x96)),
|
||||
("darkGray", egui::Color32::from_gray(0x5a)),
|
||||
("matchUi", themed),
|
||||
] {
|
||||
app.run("prefs.set", serde_json::json!({"key": "canvasColor", "value": key})).unwrap();
|
||||
apply_runtime(&mut app, &ctx);
|
||||
assert_eq!(Tokens::get(&ctx).pasteboard, want, "{key}");
|
||||
}
|
||||
assert!(app.run("prefs.set", serde_json::json!({"key": "canvasColor", "value": "pink"})).is_err());
|
||||
}
|
||||
|
||||
fn app() -> VectorcraftApp {
|
||||
VectorcraftApp::new(Session::new(), Services::default())
|
||||
}
|
||||
|
||||
@@ -1694,6 +1694,51 @@ pub fn orientation_button(ui: &mut Ui, landscape: bool, selected: bool, tip: &st
|
||||
resp.on_hover_text(tl!(tip)).clicked()
|
||||
}
|
||||
|
||||
/// An artboard-layout toggle drawn in code (Rearrange All Artboards): small artboards in the grid
|
||||
/// cells `tiles` (column, row), tinted, and over them their order as a line from a dot on the first
|
||||
/// to an arrowhead on the last; accent-drawn in a pressed well when `selected`, greyed in a disabled
|
||||
/// `ui`. `tip` is shown as it is (the caller translates it). Returns clicked.
|
||||
pub fn layout_button(ui: &mut Ui, tiles: &[(u8, u8)], selected: bool, tip: &str) -> bool {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (rect, resp) = ui.allocate_exact_size(Vec2::splat(26.0), Sense::click());
|
||||
let enabled = ui.is_enabled();
|
||||
let bg = if selected {
|
||||
t.tool_active
|
||||
} else if resp.hovered() && enabled {
|
||||
t.hover
|
||||
} else {
|
||||
Color32::TRANSPARENT
|
||||
};
|
||||
ui.painter().rect_filled(rect, CornerRadius::same(3), bg);
|
||||
let color = if !enabled {
|
||||
t.text_disabled
|
||||
} else if selected {
|
||||
t.accent
|
||||
} else {
|
||||
t.icon
|
||||
};
|
||||
// Cells at most 10 points a side in a 20-point square: a row's artboards stand tall, a
|
||||
// column's lie flat.
|
||||
let (cols, rows) = tiles.iter().fold((1u8, 1u8), |(c, r), &(x, y)| (c.max(x.saturating_add(1)), r.max(y.saturating_add(1))));
|
||||
let cell = vec2((20.0 / f32::from(cols)).min(10.0), (20.0 / f32::from(rows)).min(10.0));
|
||||
let origin = rect.center() - vec2(f32::from(cols) * cell.x, f32::from(rows) * cell.y) / 2.0;
|
||||
let centre = |&(x, y): &(u8, u8)| origin + vec2((f32::from(x) + 0.5) * cell.x, (f32::from(y) + 0.5) * cell.y);
|
||||
for tile in tiles {
|
||||
ui.painter().rect_filled(Rect::from_center_size(centre(tile), cell - vec2(2.0, 2.0)), 1.0, color.gamma_multiply(0.35));
|
||||
}
|
||||
let path: Vec<Pos2> = tiles.iter().map(centre).collect();
|
||||
if let ([first, ..], [.., from, to]) = (path.as_slice(), path.as_slice()) {
|
||||
let (first, from, to) = (*first, *from, *to);
|
||||
let dir = (to - from).normalized();
|
||||
let side = dir.rot90() * 2.5;
|
||||
let head = vec![to + dir * 1.5, to - dir * 2.5 + side, to - dir * 2.5 - side];
|
||||
ui.painter().circle_filled(first, 1.6, color);
|
||||
ui.painter().add(egui::Shape::line(path, Stroke::new(1.2, color)));
|
||||
ui.painter().add(egui::Shape::convex_polygon(head, color, Stroke::NONE));
|
||||
}
|
||||
resp.on_hover_text(tip).clicked()
|
||||
}
|
||||
|
||||
/// `region` of `doc` rendered on white, its longest side `px` pixels, as a texture named `name`
|
||||
/// (artboard and page thumbnails).
|
||||
pub fn region_texture(
|
||||
|
||||
Reference in new issue
Block a user