Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::compositor::DragSession Class Reference

RAII session for a drag interaction with composited rendering. More...

#include "donner/svg/compositor/DragSession.h"

Public Member Functions

 ~DragSession ()
 Destructor. Demotes the target entity if the session is still active.
 DragSession (const DragSession &)=delete
DragSession & operator= (const DragSession &)=delete
 DragSession (DragSession &&other) noexcept
DragSession & operator= (DragSession &&other) noexcept
Entity target () const
 Returns the target entity being dragged.
bool isActive () const
 Returns true if this session is still active (entity is promoted).
void end ()
 Explicitly end the drag session, demoting the entity.

Static Public Member Functions

static std::optional< DragSession > begin (CompositorController &compositor, Entity target)
 Begin a drag session by promoting the target entity.

Detailed Description

RAII session for a drag interaction with composited rendering.

Promotes the target entity on construction and demotes it on destruction, ensuring the compositor layer lifecycle is tied to the drag gesture. Callers mutate the entity's DOM transform directly during the drag; the compositor's fast path (renderFrame) picks up pure-translation deltas and reuses the cached bitmap without re-rasterizing.

Usage:

// On pointer-down / drag start:
auto drag = DragSession::begin(compositor, hitEntity);
if (!drag) { return; } // promotion failed, fall back to full re-render
// On pointer-move:
element.setTransform(Transform2d::Translate(currentPos - startPos) * startTransform);
compositor.renderFrame(viewport);
// On pointer-up / drag end:
drag.reset(); // or let it fall out of scope
compositor.renderFrame(viewport); // re-render with entity settled at new DOM position
static std::optional< DragSession > begin(CompositorController &compositor, Entity target)
Begin a drag session by promoting the target entity.
static Transform2 Translate(const Vector2< double > &offset)
Definition Transform.h:142

Member Function Documentation

◆ begin()

std::optional< DragSession > donner::svg::compositor::DragSession::begin ( CompositorController & compositor,
Entity target )
static

Begin a drag session by promoting the target entity.

Parameters
compositorThe compositor controller managing layers.
targetThe entity to drag.
Returns
A DragSession if promotion succeeded, or std::nullopt if the entity could not be promoted (invalid entity, layer limit reached, etc.).

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