mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
Part of #394: Display Print Size at 100% Zoom drives Actual Size.
This commit is contained in:
1 parent
90818cae40
commit
a7faeb4299
6 files changed
+88
-12
No files matched your search
+2
-2
@@ -115,7 +115,7 @@ grade by behaviour against `plan/illustrator/`, not by whether a menu item exist
|
||||
- A canvas context menu: right-click selects the object under the pointer and lists what applies to the selection (Undo/Redo, clipboard, group, isolation, join, Remove Anchor Points when anchors are selected, masks, compound paths, guides, Transform, Arrange, Select, Export Selection), or the view commands on empty canvas.
|
||||
- Save / Don't Save / Cancel before closing or quitting with unsaved documents (tabs, Close, Close All, Quit, window close).
|
||||
- Four brightness themes, persistent preferences.
|
||||
- Preferences that act (#394, in part): Show Tool Tips, Double Click To Isolate, Zoom with Mouse Wheel (the wheel zooms about the pointer, Shift-wheel scrolls up and down, Cmd/Ctrl-wheel sideways; Alt/Option-wheel and a trackpad pinch zoom about the pointer either way), Use Precise Cursors; Selection & Anchor Display › Tolerance (objects, anchors and handles), Object Selection by Path Only, Command Click to Select Objects Behind (cycling down the stack), Zoom to Selection, anchor Size, Highlight anchors on mouse over; Type › Number of Recent Fonts (up to 15); Guides & Grid › guide and grid Color and Style (lines or dots) and Grids In Back. Then Snap to Point (its distance, for moves, drawn points and reference points), Move Locked and Hidden Artwork with Artboard, Enable Rubber Band for the Pen and Curvature tools, Handles style, Show handles when multiple anchors are selected, Hide Corner Widget for angles greater than; General › Transform Pattern Tiles (the transforms' and dialogs' Transform Patterns) and Select Same Tint %; Type › Size/Leading, Tracking and Baseline Shift increments (`type.step`, Cmd+Shift+. and Cmd+Shift+, for the size, the Type tool's Alt+arrows), Enable Missing Glyph Protection and Fill New Type Objects With Placeholder Text. Then Smart Guides › Color, Alignment Guides, Anchor/Path Labels, Measurement Labels, Transform Tools, Object Highlighting (with Smart Guides on) and Snapping Tolerance (4 px by default, for every smart guide snap), then Construction Guides and their Angles (#506: a drawn point near a line at one of those angles through the point it leaves from lands on it). Then Type › Type Object Selection by Path Only (type is picked on the baseline of any of its lines, area type's frame or the path of type on a path, no longer anywhere in its bounds; the Type tools and the Eyedropper still take a click among the characters). Then General › Anti-aliased Artwork (off, the canvas draws the art with hard edges). Then Guides & Grid › Show Pixel Grid (Above 600% Zoom), a line at every document pixel over the art in Pixel Preview, turning with a rotated view as the document grid now does too. Then General › Show The Home Screen When No Documents Are Open (off, closing the last document leaves an empty window; the Home button still opens the screen). Then Units › Numbers Without Units Are Points (on by default: a number typed with no unit into a field in picas is read in points, a typed unit still wins; dimmed unless a unit is Picas). Then User Interface › Auto-Collapse Iconic Panels (off by default: on, a click away from a panel popped out of the icon column puts it away). Then Performance › Animated Zoom (on, with GPU Performance, which it needs and which dims it when off: the Zoom tool dragged sideways zooms about the press, right in and left out, and held still zooms on, Alt out; off, a drag zooms to the area dragged across, now drawn as a marquee), User Interface › Large Tabs (taller document tabs) and Scale Cursor Proportional to UI (off, the tool cursors keep their size whatever the UI Scaling), and File Handling › Display Bitmaps as Anti-aliased Images in Pixel Preview (off by default: Pixel Preview draws images with each pixel taking its nearest image pixel). Type › Auto Size New Area Type works too (new area type gets Auto Size). They reach agents too (`prefs.set`, then `pointer_gesture` or `press_key`; `ui.wheel` on the control channel). Then Smart Guides › Spacing Guides (moves space the selection evenly with its row or column, see Drawing aids). Then Hyphenation › Exceptions (comma-separated words that never break, or break only at their hyphens; `prefs.set` and restore push them into the hyphenator, #394). Then Type › Show Font Names in English (off, font menus label a family by its native-language name when the font has one; documents still use the English family, #394). About 18 stored options still do nothing yet (the rest of #394: Highlight Alternate Glyphs, Display Print Size at 100% Zoom, Identify Objects By, East Asian Type units, Open Documents As Tabs, Real-time Drawing and Editing, GPU Performance beyond Animated Zoom, hyphenation language, scratch disks, the legacy clipboard, Appearance of Black, Touch Workspace).
|
||||
- Preferences that act (#394, in part): Show Tool Tips, Double Click To Isolate, Zoom with Mouse Wheel (the wheel zooms about the pointer, Shift-wheel scrolls up and down, Cmd/Ctrl-wheel sideways; Alt/Option-wheel and a trackpad pinch zoom about the pointer either way), Use Precise Cursors; Selection & Anchor Display › Tolerance (objects, anchors and handles), Object Selection by Path Only, Command Click to Select Objects Behind (cycling down the stack), Zoom to Selection, anchor Size, Highlight anchors on mouse over; Type › Number of Recent Fonts (up to 15); Guides & Grid › guide and grid Color and Style (lines or dots) and Grids In Back. Then Snap to Point (its distance, for moves, drawn points and reference points), Move Locked and Hidden Artwork with Artboard, Enable Rubber Band for the Pen and Curvature tools, Handles style, Show handles when multiple anchors are selected, Hide Corner Widget for angles greater than; General › Transform Pattern Tiles (the transforms' and dialogs' Transform Patterns) and Select Same Tint %; Type › Size/Leading, Tracking and Baseline Shift increments (`type.step`, Cmd+Shift+. and Cmd+Shift+, for the size, the Type tool's Alt+arrows), Enable Missing Glyph Protection and Fill New Type Objects With Placeholder Text. Then Smart Guides › Color, Alignment Guides, Anchor/Path Labels, Measurement Labels, Transform Tools, Object Highlighting (with Smart Guides on) and Snapping Tolerance (4 px by default, for every smart guide snap), then Construction Guides and their Angles (#506: a drawn point near a line at one of those angles through the point it leaves from lands on it). Then Type › Type Object Selection by Path Only (type is picked on the baseline of any of its lines, area type's frame or the path of type on a path, no longer anywhere in its bounds; the Type tools and the Eyedropper still take a click among the characters). Then General › Anti-aliased Artwork (off, the canvas draws the art with hard edges). Then Guides & Grid › Show Pixel Grid (Above 600% Zoom), a line at every document pixel over the art in Pixel Preview, turning with a rotated view as the document grid now does too. Then General › Show The Home Screen When No Documents Are Open (off, closing the last document leaves an empty window; the Home button still opens the screen). Then Units › Numbers Without Units Are Points (on by default: a number typed with no unit into a field in picas is read in points, a typed unit still wins; dimmed unless a unit is Picas). Then User Interface › Auto-Collapse Iconic Panels (off by default: on, a click away from a panel popped out of the icon column puts it away). Then Performance › Animated Zoom (on, with GPU Performance, which it needs and which dims it when off: the Zoom tool dragged sideways zooms about the press, right in and left out, and held still zooms on, Alt out; off, a drag zooms to the area dragged across, now drawn as a marquee), User Interface › Large Tabs (taller document tabs) and Scale Cursor Proportional to UI (off, the tool cursors keep their size whatever the UI Scaling), and File Handling › Display Bitmaps as Anti-aliased Images in Pixel Preview (off by default: Pixel Preview draws images with each pixel taking its nearest image pixel). Type › Auto Size New Area Type works too (new area type gets Auto Size). They reach agents too (`prefs.set`, then `pointer_gesture` or `press_key`; `ui.wheel` on the control channel). Then Smart Guides › Spacing Guides (moves space the selection evenly with its row or column, see Drawing aids). Then Hyphenation › Exceptions (comma-separated words that never break, or break only at their hyphens; `prefs.set` and restore push them into the hyphenator, #394). Then Type › Show Font Names in English (off, font menus label a family by its native-language name when the font has one; documents still use the English family, #394). Then General › Display Print Size at 100% Zoom (off by default: View › Actual Size is one document point per screen point; on, one document inch fills 96 screen points, an inch at the reference density display scaling is set against; `view.actualSize` / `prefs.set`, #394). About 17 stored options still do nothing yet (the rest of #394: Highlight Alternate Glyphs, Identify Objects By, East Asian Type units, Open Documents As Tabs, Real-time Drawing and Editing, GPU Performance beyond Animated Zoom, hyphenation language, scratch disks, the legacy clipboard, Appearance of Black, Touch Workspace).
|
||||
- Dialogs move by dragging their heading (the band down from the top edge, as a title bar), stay on screen and keep where they were moved for the session; the form dialogs' choices are dropdowns (Offset Path's Joins, Average's and Shear's and Reflect's axis), and Offset Path lists Offset, Joins, Miter Limit and previews (#423).
|
||||
- Dialogs open with their first field focused and its value selected: type a value and press Enter (Move, Rotate, Scale…). Number fields in panels, the Control bar and dialogs (preferences too) step with Up/Down, or with the mouse wheel over the focused field (#485: a notch a step; the panel under it then stays put, and an unfocused field leaves the wheel to scrolling) (Shift: ten, Ctrl/Cmd: a tenth of their unit), applied at once.
|
||||
- Scrubby labels (#400, beyond Illustrator, as in Photoshop): dragging a numeric field's label left or right (the ↔ cursor shows over it) steps the value one unit every 2 points (Shift: ten, Ctrl/Cmd: a tenth; counts stay whole), in the field's unit and within its limits, applied live as the art follows; the whole drag is one undo step and Escape puts the value back. A click on the label focuses the field; the text box itself never scrubs, and a field with no label doesn't. Text labels before a field (Transform, Properties, Control bar, Stroke, Transparency, form rows in dialogs) and the Character and Paragraph panels' icons act as labels. Preferences › General › Scrub Numeric Fields by Dragging (on by default) turns it off.
|
||||
@@ -234,7 +234,7 @@ about 1–1.5 agent-hours each, so the other rows (estimated on the older scale)
|
||||
| Export for Screens, Asset Export, slices, Save for Web | 3 | 85% | polish only (all four are done) | 2–4 |
|
||||
| Print, colour management, separations, flattener | 3 | 80% | print preview fidelity (flattener presets in PDF and print, overprint in PDF and composite print, Print dialog, presets, PostScript, marks, separations, Print Tiling, print overprint/flattener/bitmap options and printer profile are done) | 1–2 |
|
||||
| Automation | 3 | 60% | Variables (data merge), scripting surface, batch | 8–12 |
|
||||
| UI chrome (panels, contextual Properties, workspaces, prefs) | 6 | 78% | macOS native menu dismissal fixed (M14.8); remaining: Variables, SVG Interactivity, Properties per context, Consolidate All Windows, floating panels outside the app window and docked into any group, context menus beyond the canvas (Links, Asset Export, CSS Properties, Attributes and the canvas context menu are done), about 18 Preferences options stored but not yet acted on (#394: Highlight Alternate Glyphs, Display Print Size, Open Documents As Tabs, Real-time Drawing, hyphenation language, Appearance of Black, devices…) | 14–22 |
|
||||
| UI chrome (panels, contextual Properties, workspaces, prefs) | 6 | 78% | macOS native menu dismissal fixed (M14.8); remaining: Variables, SVG Interactivity, Properties per context, Consolidate All Windows, floating panels outside the app window and docked into any group, context menus beyond the canvas (Links, Asset Export, CSS Properties, Attributes and the canvas context menu are done), about 17 Preferences options stored but not yet acted on (#394: Highlight Alternate Glyphs, Open Documents As Tabs, Real-time Drawing, hyphenation language, Appearance of Black, devices…) | 14–22 |
|
||||
| Libraries, Links, Package | 2 | 80% | the Libraries panel is local only (no cloud by design: libraries are files on this machine) and has no shared libraries, linked graphics or gradients and patterns as items yet; its graphics, colours and text styles are done (#745); Links and Package are done; placed VectorCraft documents are done (linked by default, vectors in every output, previews, Break Link, Expand, Edit Original, refresh on save) | 2–3 |
|
||||
| **Feature parity** | **103** | **~75%** | | **~210–330** |
|
||||
| Interaction-fidelity pass (side by side with Illustrator: every tool modifier, cursor, dialog, Properties context) | | | | 60–90 |
|
||||
|
||||
@@ -50,3 +50,8 @@ sync_github_name = true
|
||||
real_name = "Vikram Bhaskaran"
|
||||
display_name = "Vikram Bhaskaran"
|
||||
sync_github_name = false
|
||||
|
||||
[people.Messhias]
|
||||
real_name = "Fabio William Conceição"
|
||||
display_name = "Messhias"
|
||||
sync_github_name = false
|
||||
@@ -137,19 +137,21 @@ pub fn fit(app: &mut VectorcraftApp, how: &str) {
|
||||
_ => st.doc.artboards.get(current).or(st.doc.artboards.first()).map(|a| a.rect),
|
||||
};
|
||||
let Some(target) = target else { return };
|
||||
let Some(v) = app.view_mut() else { return };
|
||||
v.center = target.center();
|
||||
v.fitted = true;
|
||||
if how == "view.actualSize" {
|
||||
v.zoom = 1.0;
|
||||
let zoom = if how == "view.actualSize" {
|
||||
actual_size_zoom(app.session.prefs.display_print_size, app.screen_ppi, app.pixels_per_point)
|
||||
} else {
|
||||
let zx = (rect.width() as f64 - 60.0) / target.width().max(1.0);
|
||||
let zy = (rect.height() as f64 - 60.0) / target.height().max(1.0);
|
||||
v.zoom = zx.min(zy).clamp(0.0313, 640.0);
|
||||
}
|
||||
zx.min(zy).clamp(0.0313, 640.0)
|
||||
};
|
||||
let Some(v) = app.view_mut() else { return };
|
||||
v.center = target.center();
|
||||
v.fitted = true;
|
||||
v.zoom = zoom;
|
||||
}
|
||||
|
||||
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
app.pixels_per_point = f64::from(ui.ctx().pixels_per_point());
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let full = ui.available_rect_before_wrap();
|
||||
// A document that opened, closed or became active since Home was chosen replaces it.
|
||||
@@ -747,6 +749,27 @@ pub(crate) fn animated_zoom(p: &vectorcraft_engine::Prefs) -> bool {
|
||||
p.animated_zoom && p.gpu_performance
|
||||
}
|
||||
|
||||
/// Zoom for View → Actual Size (`view.actualSize`).
|
||||
///
|
||||
/// With Preferences › General › Display Print Size at 100% Zoom off, one document point is one
|
||||
/// screen point (zoom 1). With it on, one document inch (72 pt) fills one physical inch on the
|
||||
/// screen: `screen_ppi / (72 × pixels_per_point)`, clamped to the zoom range.
|
||||
///
|
||||
/// `screen_ppi` is the assumed monitor density (CSS reference 96 by default; tests may inject a
|
||||
/// measured value). `pixels_per_point` is egui's scale factor.
|
||||
///
|
||||
/// Public behaviour matches Adobe's preference of the same name
|
||||
/// (<https://helpx.adobe.com/illustrator/using/setting-preferences.html> and the CC 2019 notes on
|
||||
/// Actual Size / Display Print Size).
|
||||
pub(crate) fn actual_size_zoom(display_print_size: bool, screen_ppi: f64, pixels_per_point: f64) -> f64 {
|
||||
if !display_print_size {
|
||||
return 1.0;
|
||||
}
|
||||
let ppp = if pixels_per_point.is_finite() && pixels_per_point > 0.0 { pixels_per_point } else { 1.0 };
|
||||
let ppi = if screen_ppi.is_finite() && screen_ppi > 0.0 { screen_ppi } else { 96.0 };
|
||||
(ppi / (72.0 * ppp)).clamp(0.0313, 640.0)
|
||||
}
|
||||
|
||||
/// Zoom view `vm` of the canvas `rect` to `zoom` (clamped to the zoom range), keeping the document
|
||||
/// point under screen point `p` where it is.
|
||||
fn zoom_about(vm: &mut View, rect: egui::Rect, p: Pos2, zoom: f64) {
|
||||
@@ -2957,6 +2980,38 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// General › Display Print Size at 100% Zoom (#394): off, Actual Size is 1 document point per
|
||||
/// screen point; on, one document inch fills one physical inch (`screen_ppi / (72 × ppp)`).
|
||||
#[test]
|
||||
fn actual_size_zoom_follows_display_print_size() {
|
||||
assert_eq!(actual_size_zoom(false, 96.0, 1.0), 1.0);
|
||||
assert_eq!(actual_size_zoom(false, 220.0, 2.0), 1.0);
|
||||
assert!((actual_size_zoom(true, 96.0, 1.0) - 96.0 / 72.0).abs() < 1e-12);
|
||||
assert!((actual_size_zoom(true, 220.0, 2.0) - 220.0 / (72.0 * 2.0)).abs() < 1e-12);
|
||||
assert_eq!(actual_size_zoom(true, f64::NAN, 0.0), actual_size_zoom(true, 96.0, 1.0));
|
||||
}
|
||||
|
||||
/// `view.actualSize` reads Preferences › Display Print Size at 100% Zoom and the host's screen
|
||||
/// density (#394).
|
||||
#[test]
|
||||
fn view_actual_size_follows_display_print_size() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 200, "height": 100})).unwrap();
|
||||
app.canvas_rect = Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(460.0, 260.0)));
|
||||
app.screen_ppi = 96.0;
|
||||
app.pixels_per_point = 1.0;
|
||||
app.run("view.setZoom", json!({"zoom": 250})).unwrap();
|
||||
app.run("view.actualSize", json!({})).unwrap();
|
||||
assert!((app.view().unwrap().zoom - 1.0).abs() < 1e-12, "default pref keeps 100% = 1:1");
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": true})).unwrap();
|
||||
app.run("view.actualSize", json!({})).unwrap();
|
||||
assert!((app.view().unwrap().zoom - 96.0 / 72.0).abs() < 1e-12, "print size uses screen PPI");
|
||||
app.pixels_per_point = 2.0;
|
||||
app.screen_ppi = 220.0;
|
||||
app.run("view.actualSize", json!({})).unwrap();
|
||||
assert!((app.view().unwrap().zoom - 220.0 / 144.0).abs() < 1e-12);
|
||||
}
|
||||
|
||||
/// Performance › Animated Zoom (#394): the Zoom tool dragged sideways zooms about where it was
|
||||
/// pressed (right in, left out), held still it zooms on, and a click still steps. Off, or with
|
||||
/// GPU Performance off, a drag zooms to the area dragged across.
|
||||
|
||||
@@ -336,6 +336,13 @@ pub struct VectorcraftApp {
|
||||
last_time: f64,
|
||||
/// Canvas rect of the last frame (screen points), for control-channel coordinate mapping.
|
||||
pub canvas_rect: Option<egui::Rect>,
|
||||
/// Physical pixels per inch assumed for View → Actual Size when Preferences › Display Print
|
||||
/// Size at 100% Zoom is on. Defaults to the CSS reference density (96). Tests (and a future
|
||||
/// safe host probe) may set a measured value.
|
||||
pub screen_ppi: f64,
|
||||
/// Last canvas `pixels_per_point` (egui's scale factor). Paired with [`Self::screen_ppi`] for
|
||||
/// Actual Size under Display Print Size.
|
||||
pub pixels_per_point: f64,
|
||||
/// Hover position in document coordinates.
|
||||
pub hover_doc: Option<vectorcraft_geom::Point>,
|
||||
/// System clipboard: SVG to publish next frame, the last SVG we published (so pasting it back
|
||||
@@ -437,6 +444,8 @@ impl VectorcraftApp {
|
||||
frame: 0,
|
||||
last_time: 0.0,
|
||||
canvas_rect: None,
|
||||
screen_ppi: 96.0,
|
||||
pixels_per_point: 1.0,
|
||||
hover_doc: None,
|
||||
custom_titlebar: false,
|
||||
graphics_adapter: None,
|
||||
|
||||
@@ -205,7 +205,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
("view.zoomOut", "Zoom Out", "Cmd+-", "{}"),
|
||||
("view.fitArtboard", "Fit Artboard in Window", "Cmd+0", "{}"),
|
||||
("view.fitAll", "Fit All in Window", "Cmd+Alt+0", "{}"),
|
||||
("view.actualSize", "Actual Size", "Cmd+1", "{}"),
|
||||
(
|
||||
"view.actualSize",
|
||||
"Actual Size",
|
||||
"Cmd+1",
|
||||
"{} 100%: with Display Print Size at 100% Zoom off, one document point per screen point; on, one document inch fills one physical inch on the screen (screen PPI / (72 × pixels_per_point))",
|
||||
),
|
||||
("view.setZoom", "Set Zoom", "", "{zoom: percent, center?: [x,y]}"),
|
||||
(
|
||||
"view.goToArtboard",
|
||||
|
||||
+4
-2
@@ -1430,8 +1430,10 @@ painted when the art covers at least half of it — while raster effects and pat
|
||||
their own Anti-aliasing option),
|
||||
`scrubNumericFields` (on: a horizontal drag on a numeric field's label steps the field, one undo step per drag; the
|
||||
control channel's `ui.drag` scrubs), `showHomeScreen` (on by default: the Home screen while no document is open;
|
||||
off, an empty window, and the Home button or `app.home` still shows the screen) and `autoCollapseIconPanels` (off by
|
||||
default: on, a click away from a panel popped out of the icon column puts it away).
|
||||
off, an empty window, and the Home button or `app.home` still shows the screen), `autoCollapseIconPanels` (off by
|
||||
default: on, a click away from a panel popped out of the icon column puts it away) and `displayPrintSize` (off by
|
||||
default: View › Actual Size / `view.actualSize` is one document point per screen point; on, one document inch fills
|
||||
one physical inch using the CSS reference density of 96 ppi).
|
||||
|
||||
The Smart Guides preferences (Preferences › Smart Guides) apply to `pointer_gesture` with Smart Guides on (the
|
||||
default view) and to the mouse; they change what the tools show and how far a target pulls, and only Construction
|
||||
|
||||
Reference in new issue
Block a user