Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::editor::ViewportInteractionController Class Reference

Owns viewport/input state for the render pane: zoom/pan, pending click dispatch, and frame timing history. More...

#include "donner/editor/ViewportInteractionController.h"

Public Member Functions

ViewportState & viewport ()
 Return the viewport used for render-pane layout and pointer transforms.
const ViewportState & viewport () const
 Return the viewport used for render-pane layout and pointer transforms.
FrameHistory & frameHistory ()
 Return the bounded history of frame timings and memory samples.
const FrameHistory & frameHistory () const
 Return the bounded history of frame timings and memory samples.
void noteFrameDelta (float deltaMs)
 Append one UI-frame duration to the timing history.
void updatePaneLayout (const Vector2d &paneOrigin, const Vector2d &paneSize, const std::optional< Box2d > &documentViewBox, bool preservePaneCenterDocumentPoint=false)
 Update pane geometry and optionally retain the document point at its center.
void updateDevicePixelRatio (double devicePixelRatio)
 Update the physical-to-logical pixel ratio used by the viewport.
bool resetToActualSize ()
 Reset the viewport to 100%.
bool zoomToFit (const Box2d &fitScreenRect)
 Fit the whole document into the unobstructed canvas area.
bool resetToInitialView (const Box2d &fitScreenRect)
 Show a newly opened document at 100%, or fitted when it is larger than the canvas area.
bool applyZoom (double factor, const Vector2d &focalScreen)
 Apply a multiplicative zoom around a screen-space focal point.
bool updatePanState (bool paneHovered, bool spaceHeld, bool middleDown, bool leftDown, const ImVec2 &mousePosition)
 Update mouse-drag pan state.
bool panning () const
 Return whether a mouse-pan gesture is in progress.
ScrollConsumptionResult consumeScrollEvents (std::vector< RenderPaneScrollEvent > &events, const Box2d &paneRect, bool modalCapturingInput, double wheelZoomStep, double panPixelsPerScrollUnit)
 Consume queued trackpad/wheel events.
void bufferPendingClick (const Vector2d &documentPoint, MouseModifiers modifiers)
 Retain a document-space click until it can be dispatched.
const std::optional< PendingClick > & pendingClick () const
 Return the buffered click, if one is waiting.
void clearPendingClick ()
 Discard the buffered click.

Detailed Description

Owns viewport/input state for the render pane: zoom/pan, pending click dispatch, and frame timing history.

Member Function Documentation

◆ applyZoom()

bool donner::editor::ViewportInteractionController::applyZoom ( double factor,
const Vector2d & focalScreen )
nodiscard

Apply a multiplicative zoom around a screen-space focal point.

Parameters
factorZoom multiplier.
focalScreenScreen-space point that remains anchored.
Returns
True if the viewport mapping changed.

◆ bufferPendingClick()

void donner::editor::ViewportInteractionController::bufferPendingClick ( const Vector2d & documentPoint,
MouseModifiers modifiers )

Retain a document-space click until it can be dispatched.

Parameters
documentPointClick position in document coordinates.
modifiersKeyboard modifiers captured with the click.

◆ consumeScrollEvents()

ScrollConsumptionResult donner::editor::ViewportInteractionController::consumeScrollEvents ( std::vector< RenderPaneScrollEvent > & events,
const Box2d & paneRect,
bool modalCapturingInput,
double wheelZoomStep,
double panPixelsPerScrollUnit )
nodiscard

Consume queued trackpad/wheel events.

Returns
Viewport mutation summary for the consumed events.

◆ noteFrameDelta()

void donner::editor::ViewportInteractionController::noteFrameDelta ( float deltaMs)
inline

Append one UI-frame duration to the timing history.

Parameters
deltaMsFrame duration in milliseconds.

◆ resetToActualSize()

bool donner::editor::ViewportInteractionController::resetToActualSize ( )
nodiscard

Reset the viewport to 100%.

Returns
True if the viewport mapping changed.

◆ resetToInitialView()

bool donner::editor::ViewportInteractionController::resetToInitialView ( const Box2d & fitScreenRect)
nodiscard

Show a newly opened document at 100%, or fitted when it is larger than the canvas area.

Parameters
fitScreenRectUnobstructed canvas area, in screen pixels.
Returns
True if the viewport mapping changed.

◆ updateDevicePixelRatio()

void donner::editor::ViewportInteractionController::updateDevicePixelRatio ( double devicePixelRatio)

Update the physical-to-logical pixel ratio used by the viewport.

Parameters
devicePixelRatioCurrent display pixel ratio.

◆ updatePaneLayout()

void donner::editor::ViewportInteractionController::updatePaneLayout ( const Vector2d & paneOrigin,
const Vector2d & paneSize,
const std::optional< Box2d > & documentViewBox,
bool preservePaneCenterDocumentPoint = false )

Update pane geometry and optionally retain the document point at its center.

Parameters
paneOriginPane origin in logical screen pixels.
paneSizePane size in logical pixels.
documentViewBoxNew document viewBox, or no value to preserve the current document geometry.
preservePaneCenterDocumentPointWhether layout changes keep the center document point anchored.

◆ updatePanState()

bool donner::editor::ViewportInteractionController::updatePanState ( bool paneHovered,
bool spaceHeld,
bool middleDown,
bool leftDown,
const ImVec2 & mousePosition )
nodiscard

Update mouse-drag pan state.

Returns
True if the viewport mapping changed.

◆ zoomToFit()

bool donner::editor::ViewportInteractionController::zoomToFit ( const Box2d & fitScreenRect)
nodiscard

Fit the whole document into the unobstructed canvas area.

Parameters
fitScreenRectUnobstructed canvas area, in screen pixels.
Returns
True if the viewport mapping changed.

The documentation for this class was generated from the following file: