|
|
Donner 0.5.1
Embeddable browser-grade SVG2 engine
|
All viewport state for a single frame of the render pane. Plain data, side-effect-free, copyable, ~80 bytes. More...
#include "donner/editor/ViewportState.h"
Public Member Functions | |
| 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. | |
| Vector2i | desiredCanvasSize () const |
| Canvas size (in device pixels) the SVG renderer should produce for the current zoom and DPR. Equal to documentViewBox.size() * zoom * devicePixelRatio, clamped to [1, kMaxCanvasDim] per axis. | |
| 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 initial state when the editor opens, and the target of Cmd+0 / View → Reset Zoom / View → Actual Size. | |
| Vector2d | paneCenter () const |
| Center of the render pane in screen pixels. | |
| Vector2d | documentViewBoxCenter () const |
| Center of the document viewBox in document coordinates. | |
Public Attributes | |
| 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. | |
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 ) |