All viewport state for a single frame of the render pane. Plain data, side-effect-free, copyable, ~80 bytes.
More...
|
|
double | pixelsPerDocUnit () const |
| | Screen pixels per document unit at the current zoom. With the "zoom is in screen-pixels-per-doc-unit" convention this is just zoom; the accessor exists so callers don't reach for the raw field and the definition can grow if "100%" ever stops meaning "1:1".
|
|
double | devicePixelsPerDocUnit () const |
| | Device pixels per document unit. Used by desiredCanvasSize and the renderer's RenderViewport.devicePixelRatio.
|
|
Vector2d | documentToScreen (const Vector2d &docPoint) const |
| | Map a document point to a screen-pixel point.
|
|
Vector2d | screenToDocument (const Vector2d &screenPoint) const |
| | Map a screen-pixel point to a document point.
|
|
Box2d | documentToScreen (const Box2d &docBox) const |
| | Map a document-space box to its screen-pixel AABB.
|
|
Box2d | screenToDocument (const Box2d &screenBox) const |
| | Map a screen-pixel box to its document-space AABB.
|
|
Box2d | imageScreenRect () const |
| | On-screen rectangle of the displayed document image, in screen pixels. Equal to documentToScreen(documentViewBox). Used by the AddImage call so the image always lands at the right place regardless of texture resolution.
|
|
EditorRasterViewport | rasterViewport () const |
| | Raster viewport the SVG renderer should produce for this editor view.
|
| EditorRasterViewport | selectedPrewarmRasterViewport () const |
| | Raster viewport for idle selected-layer prewarms.
|
| EditorRasterViewport | overviewInfillRasterViewport () const |
| | Low-resolution full-document raster used underneath viewport-bounded tiles.
|
|
Vector2i | desiredCanvasSize () const |
| | Output canvas size (in device pixels) the SVG renderer should produce. Equivalent to rasterViewport().outputSizePx.
|
| void | zoomAround (double newZoom, const Vector2d &focalScreen) |
| | Set the zoom factor while holding focalScreen fixed: after this call, the document point that was previously under focalScreen is still under focalScreen. Use for Cmd+wheel, Cmd+Plus / Cmd+Minus, menu-driven zoom, and pinch-to-zoom.
|
|
void | panBy (const Vector2d &screenDelta) |
| | Pan by screenDelta screen pixels. After this call, every document point that was previously visible is at its previous screen position + screenDelta.
|
|
void | resetTo100Percent () |
| | Reset to 100%, with the document viewBox center anchored at the pane center. After this call, pixelsPerDocUnit() == 1.0 and documentToScreen(documentViewBoxCenter()) == paneCenter. This is the target of Cmd+1 / View → Actual Size.
|
| void | zoomToFit (const Box2d &fitScreenRect) |
| | Zoom so the whole document viewBox fills fitScreenRect as closely as its aspect ratio allows, centered in that rectangle. This is the target of Cmd+0 / View → Zoom to Fit. The zoom is clamped to [kMinZoom, kMaxZoom]; an empty document or rectangle resets to 100%.
|
| bool | documentFitsAtActualSize (const Box2d &fitScreenRect) const |
| | Whether the whole document viewBox fits inside fitScreenRect at 100%.
|
| void | resetToInitialView (const Box2d &fitScreenRect) |
| | Show a newly opened document: at 100% when it fits fitScreenRect, otherwise fitted to it.
|
|
Vector2d | paneCenter () const |
| | Center of the render pane in screen pixels.
|
|
Vector2d | documentViewBoxCenter () const |
| | Center of the document viewBox in document coordinates.
|
|
|
Vector2d | paneOrigin = Vector2d::Zero() |
| | Top-left of the render pane's content region in screen pixels.
|
|
Vector2d | paneSize = Vector2d::Zero() |
| | Size of the render pane's content region in screen pixels.
|
|
Box2d | documentViewBox |
| | SVG document viewBox in document coordinates.
|
|
double | devicePixelRatio = 1.0 |
| | OS device pixel ratio (1.0 on standard displays, 2.0 on Retina). Read via glfwGetWindowContentScale.
|
|
double | zoom = 1.0 |
| | Zoom factor in screen pixels per document unit. 1.0 means "100%": one SVG viewBox unit takes exactly one screen pixel, regardless of how many physical device pixels that is.
|
|
Vector2d | panDocPoint = Vector2d::Zero() |
| | Document point that should appear at panScreenPoint. Together with panScreenPoint and zoom, this fully determines the screen↔document map.
|
|
Vector2d | panScreenPoint = Vector2d::Zero() |
| | Screen point at which panDocPoint is anchored.
|
|
|
static constexpr double | kMinZoom = 0.1 |
| | Minimum allowed zoom (10%).
|
|
static constexpr double | kMaxZoom = 32.0 |
| | Maximum allowed zoom (3200%).
|
|
static constexpr int | kMaxCanvasDim = 8192 |
| | Hard cap on the rasterized canvas dimension on either axis. A 32x zoom on a 4K display would otherwise rasterize a multi-GB bitmap; this clamp keeps us in a safe place.
|
|
static constexpr int | kHighZoomRasterMarginScreenPx = 128 |
| | Extra logical pixels around the pane that may be included in a high-zoom raster target. This keeps small pans from immediately needing a larger target while avoiding whole-document rasters at extreme zoom.
|
|
static constexpr int | kSelectedPrewarmMinOverdrawScreenPx = 256 |
| | Minimum logical-pixel overdraw margin for selected-layer prewarm rasters.
|
|
static constexpr double | kSelectedPrewarmOverdrawPaneFraction = 0.25 |
| | Per-axis pane fraction added on each side for selected-layer prewarm overdraw.
|
|
static constexpr int | kOverviewInfillMaxCanvasDim = 1536 |
| | Maximum output dimension for low-resolution full-document overview infill.
|
All viewport state for a single frame of the render pane. Plain data, side-effect-free, copyable, ~80 bytes.
| void donner::editor::ViewportState::zoomAround |
( |
double | newZoom, |
|
|
const Vector2d & | focalScreen ) |
Set the zoom factor while holding focalScreen fixed: after this call, the document point that was previously under focalScreen is still under focalScreen. Use for Cmd+wheel, Cmd+Plus / Cmd+Minus, menu-driven zoom, and pinch-to-zoom.
newZoom is clamped to [kMinZoom, kMaxZoom].