Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::SelectTool Class Referencefinal
Inheritance diagram for donner::editor::SelectTool:
[legend]
Collaboration diagram for donner::editor::SelectTool:
[legend]

Classes

struct  ActiveDragPreview
 Preview state for an in-progress drag, consumed by the async renderer. More...
struct  ActiveTransformBoundsPreview
 Active transform chrome state for selection bounds presentation. More...
struct  ActiveGesturePreview
 Active selection gesture state for editor UI chrome. More...
struct  CompletedDragWriteback
 Payload needed to write a completed drag back into the source pane. For multi-element drags this is the primary; additional writeback entries are latched in extras. More...

Public Types

enum class  ActiveGestureKind {
  Move ,
  Resize ,
  Rotate
}
 Active selection gesture kind.

Public Member Functions

void onMouseDown (EditorApp &editor, const Vector2d &documentPoint, MouseModifiers modifiers) override
 Mouse button (left) was pressed at documentPoint. modifiers captures the modifier-key state at the moment of the press; implementations that don't care can ignore it. Default arguments on virtuals are banned by the style guide, so callers that don't need modifier state should pass MouseModifiers{} explicitly.
void onMouseMove (EditorApp &editor, const Vector2d &documentPoint, bool buttonHeld) override
 Mouse moved to documentPoint. buttonHeld is true while the left button is down — i.e., this is a drag continuation rather than a hover.
void onMouseMove (EditorApp &editor, const Vector2d &documentPoint, bool buttonHeld, MouseModifiers modifiers)
 Mouse-move variant that samples live modifiers during resize gestures.
void onMouseUp (EditorApp &editor, const Vector2d &documentPoint) override
 Mouse button was released at documentPoint.
bool tryStartRedragOnSelected (EditorApp &editor, const Vector2d &documentPoint, MouseModifiers modifiers, std::span< const Box2d > selectionBoundsDoc, std::span< const Box2d > occludingBoundsDoc={})
 Snapshot-safe re-drag start (design doc 0033 §M8). When the user clicks inside the bounds of the single currently-selected element, start a drag of that element WITHOUT calling EditorApp::hitTest — so the call is safe to run even while the async-renderer worker is mid-render (hitTest would race the worker's prepareDocumentForRendering).
bool clickHitsCurrentSelection (EditorApp &editor, const Vector2d &documentPoint) const
 Returns true when live hit-testing at documentPoint hits the current selection or one of its renderable descendants.
bool isDragging () const
 Whether a drag is currently in progress (button is held after a successful hit-test on mouse-down).
bool isMarqueeing () const
 Whether a marquee selection is currently in progress (button is held after a onMouseDown that hit empty space).
void beginMarquee (EditorApp &editor, const Vector2d &documentPoint, bool additive)
 Start a marquee drag from documentPoint without performing a hit-test.
std::optional< Box2dmarqueeRect () const
 The current marquee rectangle in document coordinates, or std::nullopt if no marquee drag is active. Returned even on the very first frame of a marquee (rect collapses to a single point). Used by the overlay renderer to draw the marquee chrome.
std::optional< CompletedDragWritebackconsumeCompletedDragWriteback ()
 Returns the most recent completed drag writeback request, if any. The payload is latched until consumed so the main loop can retry writeback across busy frames without depending on the current selection.
std::optional< ActiveDragPreviewactiveDragPreview () const
 Returns the current drag preview, if a drag is in progress.
std::optional< ActiveGesturePreviewactiveGesturePreview () const
 Returns the current selection gesture preview, if a drag is in progress.
std::optional< ActiveTransformBoundsPreviewactiveTransformBoundsPreview () const
 Returns active oriented-bounds chrome for in-progress rotation.
Public Member Functions inherited from donner::editor::Tool
 Tool (const Tool &)=delete
Tool & operator= (const Tool &)=delete
 Tool (Tool &&)=delete
Tool & operator= (Tool &&)=delete

Class Documentation

◆ donner::editor::SelectTool::ActiveDragPreview

struct donner::editor::SelectTool::ActiveDragPreview

Preview state for an in-progress drag, consumed by the async renderer.

Collaboration diagram for donner::editor::SelectTool::ActiveDragPreview:
[legend]
Class Members
Transform2d documentFromCachedDocument = Transform2d() Current affine transform from the cached document placement to the active preview placement.
uint64_t dragGeneration = 0 Monotonic id for one mouse-down/move/up drag gesture.
Entity entity = entt::null Entity being dragged.
vector< Entity > extraEntities Additional selected entities moving with entity in the same gesture.
Vector2d translation = Vector2d::Zero() Current drag translation in document coordinates.

◆ donner::editor::SelectTool::ActiveTransformBoundsPreview

struct donner::editor::SelectTool::ActiveTransformBoundsPreview

Active transform chrome state for selection bounds presentation.

Collaboration diagram for donner::editor::SelectTool::ActiveTransformBoundsPreview:
[legend]
Class Members
Transform2d documentFromStartDocument = Transform2d() Current transform from gesture-start document space to active document space.
Box2d startBoundsDoc Selection AABB captured when the transform gesture started.

◆ donner::editor::SelectTool::ActiveGesturePreview

struct donner::editor::SelectTool::ActiveGesturePreview

Active selection gesture state for editor UI chrome.

Collaboration diagram for donner::editor::SelectTool::ActiveGesturePreview:
[legend]
Class Members
SelectionTransformCorner corner = SelectionTransformCorner::TopLeft Transform handle corner that started the gesture.
Vector2d currentDocumentDelta = Vector2d::Zero() Current drag delta in document coordinates.
Transform2d documentFromStartDocument = Transform2d() Current transform from gesture-start document space to active document space.
bool hasMoved = false Whether the gesture has moved past the drag threshold.
ActiveGestureKind kind = ActiveGestureKind::Move Gesture kind currently being performed.
Box2d startBoundsDoc Selection bounds captured at gesture start.

◆ donner::editor::SelectTool::CompletedDragWriteback

struct donner::editor::SelectTool::CompletedDragWriteback

Payload needed to write a completed drag back into the source pane. For multi-element drags this is the primary; additional writeback entries are latched in extras.

Collaboration diagram for donner::editor::SelectTool::CompletedDragWriteback:
[legend]
Class Members
vector< CompletedDragWriteback > extras Additional writeback entries for extra elements in a multi-element drag. One per non-primary element that had a capturable writeback target. Empty for single-element drags.
AttributeWritebackTarget target
Transform2d transform

Member Function Documentation

◆ clickHitsCurrentSelection()

bool donner::editor::SelectTool::clickHitsCurrentSelection ( EditorApp & editor,
const Vector2d & documentPoint ) const
nodiscard

Returns true when live hit-testing at documentPoint hits the current selection or one of its renderable descendants.

This reads the live document through EditorApp::hitTest, so callers must only use it when the async renderer is idle. EditorShell uses this to keep clicks on already-selected elements on the immediate drag path instead of converting a held press into a marquee.

◆ onMouseDown()

void donner::editor::SelectTool::onMouseDown ( EditorApp & editor,
const Vector2d & documentPoint,
MouseModifiers modifiers )
overridevirtual

Mouse button (left) was pressed at documentPoint. modifiers captures the modifier-key state at the moment of the press; implementations that don't care can ignore it. Default arguments on virtuals are banned by the style guide, so callers that don't need modifier state should pass MouseModifiers{} explicitly.

Implements donner::editor::Tool.

◆ onMouseMove()

void donner::editor::SelectTool::onMouseMove ( EditorApp & editor,
const Vector2d & documentPoint,
bool buttonHeld )
overridevirtual

Mouse moved to documentPoint. buttonHeld is true while the left button is down — i.e., this is a drag continuation rather than a hover.

Implements donner::editor::Tool.

◆ onMouseUp()

void donner::editor::SelectTool::onMouseUp ( EditorApp & editor,
const Vector2d & documentPoint )
overridevirtual

Mouse button was released at documentPoint.

Implements donner::editor::Tool.

◆ tryStartRedragOnSelected()

bool donner::editor::SelectTool::tryStartRedragOnSelected ( EditorApp & editor,
const Vector2d & documentPoint,
MouseModifiers modifiers,
std::span< const Box2d > selectionBoundsDoc,
std::span< const Box2d > occludingBoundsDoc = {} )
nodiscard

Snapshot-safe re-drag start (design doc 0033 §M8). When the user clicks inside the bounds of the single currently-selected element, start a drag of that element WITHOUT calling EditorApp::hitTest — so the call is safe to run even while the async-renderer worker is mid-render (hitTest would race the worker's prepareDocumentForRendering).

selectionBoundsDoc and occludingBoundsDoc are caller-supplied AABB lists in document space. EditorShell passes the pre-snapshotted bounds from SelectionBoundsCache — that cache is refreshed on idle frames, so reading it during a busy render is race-free (no live SnapshotSelectionWorldBounds call inside this function). onMouseDown passes freshly-computed live selection bounds and no occlusion hints since its caller has already gated on !isBusy().

Returns true if a drag was started; false if the caller must fall back to the full onMouseDown path (multi-select, shift-click, click outside the selection's snapshotted bounds, click inside later-painted cached bounds, empty bounds span, etc.).

onMouseDown itself calls this first to avoid duplicating logic — so plain clicks on the selection always take the no-hit-test path regardless of busy state. The split exists so EditorShell can run it BEFORE checking isBusy() for the click handler.


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