Manager of interactive Control
s for an instance
of Rac
.
Contains a list of all managed controls and coordinates drawing and user interaction between them.
For controls to be functional the pointerPressed
, pointerReleased
,
and pointerDragged
methods have to be called as pointer interactions
happen. The drawControls
method handles the drawing of all controls
and the currently selected control, it is usually called at the very end
of drawing.
Also contains settings shared between all controls and used for user
interaction, like pointerStyle
to draw the pointer, controlStyle
as
a default style for drawing controls, and knobRadius
that defines the
size of the interactive element of most controls.
Constructor
new Controller(rac)
Builds a new Controller
with the given Rac
instance.
Parameters:
Name | Type | Description |
---|---|---|
rac |
Rac
|
Instance to use for drawing and creating other objects |
Classes
Members
autoAddControls :Boolean
Indicates controls to add themselves into this.controls
when
created.
This property is a shared configuration. The behaviour is implemented independently by each control constructor.
- Default Value:
-
true
-
controls :Array.<Rac.Control>
Collection of all controlls managed by the instance. Controls in this list are considered for pointer hit testing and for drawing.
- Default Value:
-
[]
-
controlStyle :Rac.Stroke|Rac.Fill|Rac.StyleContainer
Default style to apply for all controls. When set it is applied
before control drawing. The individual control style in
control.style
is applied afterwards.
- Default Value:
-
null
-
knobRadius :Number
Distance at which the pointer is considered to interact with a control knob. Also used by controls for drawing.
pointerStyle :Rac.Stroke|Rac.Fill|Rac.StyleContainer
Style object used for the visual elements related to pointer
interaction and control selection. When null
no pointer or
selection visuals are drawn.
By default contains a style that uses the current stroke configuration with no-fill.
- Default Value:
rac :Rac
Instance of Rac
used for drawing and passed along to any created
object.
(nullable) selection :Rac.Controller.Selection
Selection information for the currently selected control, or null
when there is no selection.
Methods
add(control)
Pushes control
into this.controls
, allowing the instance to handle
pointer interaction and drawing of control
.
Parameters:
Name | Type | Description |
---|---|---|
control |
Rac.Control
|
A |
drawControls()
Draws all controls contained in
controls
along the visual elements
for pointer and control selection.
Usually called at the end of drawing, as to draw controls on top of other graphics.
pointerDragged(pointerCenter)
Notifies the instance that the pointer has been dragged to the
pointerCenter
location. When there is a selected control, user
interaction is performed and the control value is updated.
This function must be called along pointer drag interaction for all managed controls to properly work.
Parameters:
Name | Type | Description |
---|---|---|
pointerCenter |
Rac.Point
|
The location where the pointer was dragged |
pointerPressed(pointerCenter)
Notifies the instance that the pointer has been pressed at the
pointerCenter
location. All controls are hit tested and the first
control to be hit is marked as selected.
This function must be called along pointer press interaction for all managed controls to properly work.
Parameters:
Name | Type | Description |
---|---|---|
pointerCenter |
Rac.Point
|
The location where the pointer was pressed |
pointerReleased(pointerCenter)
Notifies the instance that the pointer has been released at the
pointerCenter
location. When there is a selected control, user
interaction is finalized and the control selection is cleared.
This function must be called along pointer drag interaction for all managed controls to properly work.
Parameters:
Name | Type | Description |
---|---|---|
pointerCenter |
Rac.Point
|
The location where the pointer was released |