SceneController class
Mutable controller that owns the scene editing state and tool logic.
The controller is the primary integration point for apps:
- It mutates scene in response to pointer input and commands.
- It exposes selection state and marquee selection rectangle.
- It emits actions for app-level undo/redo integration.
- It emits editTextRequests when a text node should be edited.
- Inheritance
-
- Object
- ChangeNotifier
- SceneController
Constructors
- SceneController({Scene? scene, PointerInputSettings? pointerSettings, double? dragStartSlop, NodeId nodeIdGenerator()?})
-
Creates a controller that edits
scene.
Properties
-
actions
→ Stream<
ActionCommitted> -
Synchronous broadcast stream of committed actions.
no setter
- debugContractsSelectionRectRevision → int
-
no setter
- debugMoveGestureBuildCount → int
-
no setter
-
debugMoveGestureNodes
→ List<
SceneNode> ? -
no setter
- debugSceneRevision → int
-
no setter
- debugSelectionRectRevision → int
-
no setter
- debugSelectionRevision → int
-
no setter
- dragStartSlop → double
-
Pointer slop threshold used to treat a drag as a move.
no setter
- drawColor → Color
-
no setter
- drawTool → DrawTool
-
no setter
-
editTextRequests
→ Stream<
EditTextRequested> -
Synchronous broadcast stream of text edit requests.
no setter
- eraserThickness ↔ double
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- hasPendingLineStart → bool
-
Whether a two-tap line start is waiting for the second tap.
no setter
- highlighterOpacity ↔ double
-
getter/setter pair
- highlighterThickness ↔ double
-
getter/setter pair
- lineThickness ↔ double
-
getter/setter pair
- mode → CanvasMode
-
no setter
- pendingLineStart → Offset?
-
Pending first point for a two-tap line gesture, if any.
no setter
- pendingLineTimestampMs → int?
-
Timestamp for the pending two-tap line start, if any.
no setter
- penThickness ↔ double
-
getter/setter pair
- pointerSettings → PointerInputSettings
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scene → Scene
-
final
-
selectedNodeIds
→ Set<
NodeId> -
Current selection snapshot.
no setter
- selectionBoundsWorld → Rect?
-
Axis-aligned world bounds of the current transformable selection.
no setter
- selectionCenterWorld → Offset?
-
Center of selectionBoundsWorld when selection is non-empty.
no setter
- selectionRect → Rect?
-
Current marquee selection rectangle in scene coordinates.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addNode(
SceneNode node, {int layerIndex = 0}) → void -
Adds
nodeto the target layer and notifies listeners. -
clearScene(
{int? timestampMs}) → void - Clears all non-background layers and emits an action.
-
clearSelection(
) → void - Clears the current selection.
-
debugSetSelection(
Iterable< NodeId> nodeIds) → void -
debugSetSelectionRect(
Rect? rect) → void -
deleteSelection(
{int? timestampMs}) → void - Deletes deletable selected nodes and emits an action.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
findNode(
NodeId id) → ({int layerIndex, SceneNode node, int nodeIndex})? -
Finds a node by
idand returns its location in the scene. -
flipSelectionHorizontal(
{int? timestampMs}) → void - Flips the transformable selection vertically around its center.
-
flipSelectionVertical(
{int? timestampMs}) → void - Flips the transformable selection horizontally around its center.
-
getNode(
NodeId id) → SceneNode? -
Returns the first node with
id, ornullif it does not exist. -
handlePointer(
PointerSample sample) → void - Handles a pointer sample and updates the controller state.
-
handlePointerSignal(
PointerSignal signal) → void - Handles pointer signals such as double-tap text edit requests.
-
moveNode(
NodeId id, {required int targetLayerIndex, int? timestampMs}) → void -
Moves a node by
idto another layer and emits an action. -
mutate(
void fn(Scene scene), {bool structural = false}) → void -
Runs
fnto mutate scene and schedules the appropriate updates. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
notifySceneChanged(
) → void - Restores minimal invariants after external mutations to scene.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeNode(
NodeId id, {int? timestampMs}) → void -
Removes a node by
id, clears its selection, and emits an action. -
requestRepaintOncePerFrame(
) → void -
rotateSelection(
{required bool clockwise, int? timestampMs}) → void - Rotates the transformable selection by 90 degrees.
-
selectAll(
{bool onlySelectable = true}) → void - Selects all nodes in the scene.
-
setBackgroundColor(
Color value) → void - Updates the scene background color.
-
setCameraOffset(
Offset value) → void - Updates the scene camera offset.
-
setDrawColor(
Color value) → void - Sets the current drawing color.
-
setDrawTool(
DrawTool tool) → void - Changes the active drawing tool and resets draw state.
-
setGridCellSize(
double value) → void - Sets the grid cell size in scene units.
-
setGridEnabled(
bool value) → void - Enables or disables the background grid.
-
setMode(
CanvasMode value) → void - Switches between move and draw modes.
-
setSelection(
Iterable< NodeId> nodeIds) → void -
Replaces the selection with
nodeIds. -
toggleSelection(
NodeId id) → void -
Toggles selection for a single node
id. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited