ScenePainter class
The ScenePainter
class is responsible for rendering and managing the
GraphX scene. It is a mixin that can be used with a custom painter to draw
graphics within a Flutter widget. This class contains methods and properties
to handle updates, rendering, and mouse input events. It also manages the
Stage
instance, which is the root of the display list for the GraphX
scene.
By default, the ScenePainter
will repaint the custom painter on every tick
of the animation loop. This behavior can be overridden by setting
autoUpdateAndRender
to false
. You can also manually trigger a repaint
using the requestRender()
method.
- Mixed in types
Constructors
- ScenePainter(SceneController core, GSprite root)
-
Creates a new
ScenePainter
with the givenSceneController
and root.
Properties
- $accumulatedFrameDeltaTime ↔ double
-
(Internal usage)
The accumulated frame delta timestamp (in milliseconds).
getter/setter pair
- $canvas ↔ Canvas
-
(Internal usage)
The current canvas being drawn on by the ScenePainter.
getter/setter pair
- $currentFrameDeltaTime ↔ double
-
(Internal usage)
The current frame delta timestamp (in milliseconds).
getter/setter pair
- $currentFrameId ↔ int
-
(Internal usage)
The current frame ID.
getter/setter pair
- $runTime ↔ double
-
(Internal usage)
The current runtime.
getter/setter pair
- autoUpdateAndRender ↔ bool
-
Automatically manages the
tick()
andrender()
requests. Overrides needsRepaint.getter/setter pair - core ↔ SceneController
-
The
SceneController
that thisScenePainter
belongs to.getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- isReady → bool
-
Returns a boolean value indicating whether the GraphX scene is ready and
the stage is accessible to the GraphX root. Returns true if the scene is
ready, false otherwise. Runs on the first "render".
no setter
- maxFrameTime ↔ double
-
The maximum time of a frame.
getter/setter pair
- needsRepaint ↔ bool
-
Indicates whether the internal
CustomPainter
needs repainting on each tick. The flags allow the$render()
process to know if it has to requestRender() or not.getter/setter pair -
onUpdate
→ EventSignal<
double> -
Dispatched when the frame is updated.
no setter
- root ↔ GSprite
-
The root
DisplayObject
that initializes the Scene layer.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size ↔ Size
-
The size of the area available in
CustomPainter::paint()
.getter/setter pair - stage → Stage?
-
Returns the Stage instance associated with this ScenePainter.
The Stage is the root display object for the GraphX scene.
no setter
- useOwnCanvas ↔ bool
-
Warning: Experimental state
getter/setter pair
Methods
-
$render(
) → void - Requests a new frame.
-
$setup(
) → void - This method is called from the SceneController's ScenePainter's constructor, and sets up the autoUpdateAndRender flag to the value of SceneConfig autoUpdateRender. It also sets the current ScenePainter instance to this instance.
-
$update(
double deltaTime) → void -
(Internal usage)
This method updates the display list and detects any mouse movement.
Tickers entry point (aka
enterFrame
). -
addListener(
VoidCallback listener) → void -
To be comply with Listenable.
inherited
-
buildPainter(
) → CustomPainter -
Returns a new instance of CustomPainter that delegates to this
ScenePainter instance by wrapping it in a
_GraphicsPainter
. This is the painter that is used to draw the graphics within a Flutter widget and is responsible for rendering the GraphX scene. -
dispose(
) → void -
Reset the state of the ScenePainter object
override
-
makeCurrent(
) → void - This method sets the ScenePainter.current to this instance. Currently not used.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notify(
) → void -
Notifies all registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
To be comply with Listenable.
inherited
-
requestRender(
) → void -
Direct way to ask painter invalidation.
Can be called manually, without the need for a
tick()
event. Might be useful for re-paint theCustomPainter
on keyboard on pointer signals. -
shouldRepaint(
) → bool - See CustomPainter.shouldRepaint
-
tick(
double time) → void - This method is called every tick() and updates the display list if autoUpdateAndRender is true, and calls _onUpdate?.dispatch(time). It then calls $render(), and if useOwnCanvas is true, sets _ownCanvasNeedsRepaint to true.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- current ↔ ScenePainter
-
The currently processed painter.
getter/setter pair