Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
SelectTool.h File Reference

SelectTool is the editor's primary selection tool. It dispatches three different gestures off onMouseDown: More...

#include <cstdint>
#include <optional>
#include <span>
#include <vector>
#include "donner/base/Box.h"
#include "donner/base/EcsRegistry.h"
#include "donner/base/Transform.h"
#include "donner/base/Vector2.h"
#include "donner/editor/AttributeWriteback.h"
#include "donner/editor/SelectionTransformHandles.h"
#include "donner/editor/Tool.h"
#include "donner/svg/SVGElement.h"
Include dependency graph for SelectTool.h:
This graph shows which files directly or indirectly include this file:

Classes

class  donner::editor::SelectTool
struct  donner::editor::SelectTool::ActiveDragPreview
 Preview state for an in-progress drag, consumed by the async renderer. More...
struct  donner::editor::SelectTool::ActiveTransformBoundsPreview
 Active transform chrome state for selection bounds presentation. More...
struct  donner::editor::SelectTool::ActiveGesturePreview
 Active selection gesture state for editor UI chrome. More...
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. More...
struct  donner::editor::SelectTool::LockedRejectionFlash
 A transient "this element is locked, you can't select it" flash on the rejected element's outline. intensity fades from 1 → 0 over the flash duration. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Detailed Description

SelectTool is the editor's primary selection tool. It dispatches three different gestures off onMouseDown:

  • Click on an element → replace the selection with that element and start a drag (move on subsequent onMouseMove).
  • Shift+click on an element → toggle that element in the current selection (no drag).
  • Click on empty space → start a marquee drag. Subsequent onMouseMove events grow the marquee rect; onMouseUp resolves the rect to every geometry element it intersects and replaces (or appends-to, if Shift was held) the selection.

All DOM mutations flow through EditorApp::applyMutation() as EditorCommand::SetTransform - never directly.


Class Documentation

◆ donner::editor::SelectTool::ActiveDragPreview

struct donner::editor::SelectTool::ActiveDragPreview

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

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.

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.

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.

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.
optional< RcString > sourceTransformAttributeValue The element's transform= bytes as authored at drag start, used by the source writeback to preserve the author's function syntax instead of canonicalizing to matrix(). std::nullopt when the element had no transform attribute before the drag.
AttributeWritebackTarget target
Transform2d transform

◆ donner::editor::SelectTool::LockedRejectionFlash

struct donner::editor::SelectTool::LockedRejectionFlash

A transient "this element is locked, you can't select it" flash on the rejected element's outline. intensity fades from 1 → 0 over the flash duration.

Class Members
SVGElement element The element whose selection was rejected.
float intensity = 0.0f Fade intensity in (0, 1].