Repository navigation
feat: Add Print Size action to zoom canvas to real-world physical dimensions - #483
Open
JohnPeppermint wants to merge 1 commit into
Conversation
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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: Addedprint_size_zoom(canvas_dpi, screen_ppi)with clamping toMIN_ZOOM..=MAX_ZOOMand validation for non-positive/non-finite inputs.crates/core/src/quick_menu.rs: AddedQuickAction::PrintSize(saved as"PRINT_SIZE", labeled"Print size"to match"Actual size"), automatically included inquick_actions_listed()andpen_button_choices().crates/core/src/lib.rs: ExportedCanvasSession::settle_to_print_size(screen_ppi)over UniFFI, reading the livedoc.dpiand sharingsettle_to_zoomwithsettle_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:MonitorFromWindow+GetDpiForMonitor(..., MDT_RAW_DPI)(falling back toMDT_EFFECTIVE_DPIand96 * scale_factor).CGDisplayScreenSizecombined with backing-pixelmonitor.size()via rotation-invariant diagonal PPI (handles both native Retina and macOS scaled modes).wl_outputon a private queue to read physical millimeter dimensions fromwl_output::Event::Geometry.GetCrtcInfo/GetOutputInfo(mm_width,mm_height) with root screen millimeter fallback.desktop/Cargo.toml: EnabledWin32_UI_HiDpionwindowsandrandronx11rb.desktop/src/ui.rs&desktop/src/main.rs: WiredQuickAction::PrintSizethroughAction::PrintSizeso display density is always queried for the window's current monitor.Android
android/.../canvas/QuickActions.kt: AddedphysicalPpi(DisplayMetrics)readingxdpi/ydpiwith fallback todensityDpi/160.android/.../canvas/CanvasViewModel.kt&CanvasSurfaceView.kt: Tracked the active display'sscreenPpiand handledQuickAction.PRINT_SIZEby callingsession?.settleToPrintSize(screenPpi)andfollowView().iOS / iPadOS
ios/ProCraft/CanvasModel.swift&QuickActions.swift: AddedsettleToPrintSize()and handled.printSize, deriving the active scene screen's backing PPI from built-in hardware PPI adjusted byscreen.scale / screen.nativeScalefor Display Zoom / More Space modes (with96 * scalefallback for external displays).Testing
cargo test -p procraft-engine --lib view(18 passed, includingprint_size_zoominch/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 livedoc.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 WindowsGetDpiForMonitor)cargo clippy -p procraft-engine -p procraft-core -p procraft-desktop --all-targets -- -D warnings(passed)rustfmt --edition 2024 --checkon modified Rust files (passed)android/app/src/test/java/io/github/artcraftandroid/procraft/canvas/PrintSizeTest.kt(Android/macOS/Linux/iOS builds to be verified in CI)