Skip to content

feat: Add Print Size action to zoom canvas to real-world physical dimensions - #483

Open
JohnPeppermint wants to merge 1 commit into
artcraft-android:mainfrom
JohnPeppermint:Zoom-canvas-to-real-world-physical-print-dimensions
Open

JohnPeppermint wants to merge 1 commit into
artcraft-android:mainfrom
JohnPeppermint:Zoom-canvas-to-real-world-physical-print-dimensions

Conversation

@JohnPeppermint

@JohnPeppermint JohnPeppermint commented Dec 1, 2026 •

Copy link
Copy Markdown

Summary

Adds a Print size action (QuickAction::PrintSize) to the Quick Menu (and Pen buttons) across core, Desktop (Windows, macOS, Linux X11/Wayland), Android, and iOS.

Similar to Actual size, Print size settles the viewport zoom around the center of the window while preserving canvas rotation, but scales the canvas so that 1 physical inch (or centimeter) on the document equals 1 physical inch (or centimeter) on the user's current display:

zoom = clamp(screen_ppi / canvas_dpi, MIN_ZOOM, MAX_ZOOM)

Real life use cases: Designing stickers, tattoo art and pins where seeing the real physical size is very useful. I already tested in on Windows and Android, works as intended. 👍

Changes

Engine & Core

  • crates/engine/src/view.rs: Added print_size_zoom(canvas_dpi, screen_ppi) with clamping to MIN_ZOOM..=MAX_ZOOM and validation for non-positive/non-finite inputs.
  • crates/core/src/quick_menu.rs: Added QuickAction::PrintSize (saved as "PRINT_SIZE", labeled "Print size" to match "Actual size"), automatically included in quick_actions_listed() and pen_button_choices().
  • crates/core/src/lib.rs: Exported CanvasSession::settle_to_print_size(screen_ppi) over UniFFI, reading the live doc.dpi and sharing settle_to_zoom with settle_to_actual_size().

Desktop

  • desktop/src/display_ppi.rs: Queries the monitor currently displaying the window on demand for window-surface pixels per physical inch:
    • Windows: MonitorFromWindow + GetDpiForMonitor(..., MDT_RAW_DPI) (falling back to MDT_EFFECTIVE_DPI and 96 * scale_factor).
    • macOS: CGDisplayScreenSize combined with backing-pixel monitor.size() via rotation-invariant diagonal PPI (handles both native Retina and macOS scaled modes).
    • Linux (Wayland): Binds the window's active wl_output on a private queue to read physical millimeter dimensions from wl_output::Event::Geometry.
    • Linux (X11): Queries XRandR GetCrtcInfo / GetOutputInfo (mm_width, mm_height) with root screen millimeter fallback.
  • desktop/Cargo.toml: Enabled Win32_UI_HiDpi on windows and randr on x11rb.
  • desktop/src/ui.rs & desktop/src/main.rs: Wired QuickAction::PrintSize through Action::PrintSize so display density is always queried for the window's current monitor.

Android

  • android/.../canvas/QuickActions.kt: Added physicalPpi(DisplayMetrics) reading xdpi/ydpi with fallback to densityDpi / 160.
  • android/.../canvas/CanvasViewModel.kt & CanvasSurfaceView.kt: Tracked the active display's screenPpi and handled QuickAction.PRINT_SIZE by calling session?.settleToPrintSize(screenPpi) and followView().

iOS / iPadOS

  • ios/ProCraft/CanvasModel.swift & QuickActions.swift: Added settleToPrintSize() and handled .printSize, deriving the active scene screen's backing PPI from built-in hardware PPI adjusted by screen.scale / screen.nativeScale for Display Zoom / More Space modes (with 96 * scale fallback for external displays).

Testing

  • cargo test -p procraft-engine --lib view (18 passed, including print_size_zoom inch/cm accuracy, clamping, and invalid inputs)
  • cargo test -p procraft-core --lib quick_menu (18 passed, verifying listing, label, persistence, and pen button choices)
  • cargo test -p procraft-core --lib print_size (1 passed, verifying live doc.dpi, center/rotation preservation, and invalid PPI handling)
  • cargo test -p procraft-desktop display_ppi (4 passed, including diagonal/rotation-invariance, axis averaging, fallback, and live Windows GetDpiForMonitor)
  • cargo clippy -p procraft-engine -p procraft-core -p procraft-desktop --all-targets -- -D warnings (passed)
  • rustfmt --edition 2024 --check on modified Rust files (passed)
  • Added Android unit test in android/app/src/test/java/io/github/artcraftandroid/procraft/canvas/PrintSizeTest.kt (Android/macOS/Linux/iOS builds to be verified in CI)

@JohnPeppermint JohnPeppermint changed the title Add Print size action to zoom canvas to real-world physical dimensions feat: Add Print size action to zoom canvas to real-world physical dimensions Dec 1, 2026
@JohnPeppermint JohnPeppermint changed the title feat: Add Print size action to zoom canvas to real-world physical dimensions feat: Add Print Size action to zoom canvas to real-world physical dimensions Dec 1, 2026
@JohnPeppermint

JohnPeppermint commented Dec 2, 2026 •

Copy link
Copy Markdown
Author

A quick video demonstration of zooming to "Print Size" on my android tablet.

https://youtube.com/shorts/KlaYN4zpScE

The measured grid was made using Procraft's Drawing Guide, set to 1 inch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant