A simple interactive horizontal numerical slider.
Constructor
@:value({ height : 10, width : 50 })new(width:Int = 50, height:Int = 10, ?parent:Object)
Create a new Slider width specified dimensions and parent.
Parameters:
width | The width of the Slider interactive area. |
---|---|
height | The height of the Slider interactive area. |
parent | An optional parent |
Variables
cursorTile:Tile
Tile of the slider current position caret.
Defaults to the monocolor #CCCCCC Tile with the size of 5 x Slider.height
.
tile:Tile
The slider background tile.
If Tile width does not match with Slider width, it will be resized through Tile.setSize
to match the Slider width.
Defaults to the monocolor 0x808080 Tile with the size of Slider.width x 4
and centered vertically within Slider.height
.
@:value(0)value:Float = 0
Current value of the Slider.
When set, will be clamped to minValue <= value <= maxValue
.
Methods
dynamiconChange():Void
Sent when slider value is changed by user.
Not sent if value is set manually from software side.
Inherited Variables
Defined by Interactive
backgroundColor:Null<Int>
If set, Interactive will draw a Tile
with [width, height]
dimensions of specified color (including alpha).
@:value(false)enableRightButton:Bool = false
When enabled, interacting with secondary mouse buttons (right button/wheel) will cause onPush
, onClick
, onRelease
and onReleaseOutside
callbacks.
Otherwise those callbacks will only be triggered with primary mouse button (left button).
Note that Interactive remembers only the last pressed button when pressing on it, hence pressing Interactive with the left button and then the right button
would not cause onClick
on either when releasing left button first, as pressed state is reset internally.
isEllipse:Bool
Performs an elliptic hit-test instead of rectangular one based on Interactive.width
and height
. Ignored if Interactive.shape
is set.
Defined by Drawable
color:Vector
The color multiplier for the drawable. Can be used to adjust individually each of the four channels R,G,B,A (default [1,1,1,1])
colorAdd:Null<Vector>
Setting colorAdd will add the amount of color of each channel R,G,B,A to the object pixels.
colorKey:Null<Int>
Setting a colorKey color value will discard all pixels that have this exact color in the tile.
colorMatrix:Null<Matrix>
Setting a colorMatrix will apply a color transformation. See also adjustColor
.
smooth:Null<Bool>
By enabling smoothing, scaling the object up or down will use hardware bilinear filtering resulting in a less crisp aspect.
By default smooth is null
in which case Scene.defaultSmooth
value is used.
tileWrap:Bool
Enables texture uv wrap for this Drawable, causing tiles with uv exceeding the texture size to repeat instead of clamping on edges.
Note that tileWrap
does not use the Tile
region as a wrapping area but instead uses underlying h3d.mat.Texture
size.
This is due to implementation specifics, as it just sets the Texture.wrap
to either Repeat
or Clamp
.
Because of that, proper Tile tiling can be expected only when the tile covers an entire Texture area.
Defined by Object
private@:dox(show)allocated:Bool
A flag that indicates whether the object was allocated or not.
When adding children to allocated objects, onAdd
is being called immediately,
otherwise it's delayed until the whole tree is added to a currently active Scene
.
@:value(Alpha)blendMode:BlendMode = Alpha
The blending mode of the object.
If there is no Object.filter
active, only applies to the current object (not inherited by children).
Otherwise tells how the filter is blended with background.
filter:Filter
The post process filter for this object.
When set, Object.alpha
value affects both filter and object transparency (use Drawable.color.a
to set transparency only for the object).
name:String
The name of the object. Can be used to retrieve an object within a tree by using Object.getObjectByName
.
private@:dox(show)parentContainer:Object
The parent container of this object.
See Object.contentChanged
for more details.
private@:dox(show)posChanged:Bool
A flag that indicates that the object transform was modified and absolute position recalculation is required.
Automatically cleared on Object.sync
and can be manually synced with the Object.syncPos
.
Inherited Methods
Defined by Interactive
blur():Void
Removes focus from interactive if it's focused.
If Interactive is currently focused - onFocusLost
event will be sent.
Interactive won't lose focus if during onFocusLost
call it will set Event.cancel
to true
.
focus():Void
Sets focus on this Interactive
.
If Interactive was not already focused and it receives focus - onFocus
event is sent.
Interactive won't become focused if during onFocus
call it will set Event.cancel
to true
.
dynamiconCheck(e:Event):Void
Sent every frame when user hovers an Interactive but does not move the mouse.
See Interactive.onMove
for event when user moves the mouse.
Cancelling the Event
will prevent interactive from becoming overed,
causing Interactive.onOut
if it was overed previously.
Interactive would be treated as not overed as long as event is cancelled even if mouse is within the hitbox area.
dynamiconClick(e:Event):Void
Sent when the Interactive is clicked by the user.
Can be prevented to fire by calling Interactive.preventClick
during or after Interactive.onPush
event.
Interactive.onRelease
is sent with Event.kind
being ERelease
just before this event.
dynamiconFocus(e:Event):Void
Sent when Interactive receives focus during Interactive.focus
call.
Cancelling the Event
will prevent the Interactive from becoming focused.
dynamiconFocusLost(e:Event):Void
Sent when Interactive lost focus either via Interactive.blur
call or when user clicks on another Interactive/outside this Interactive hitbox area.
Cancelling the Event
will prevent the Interactive from losing focus.
dynamiconKeyDown(e:Event):Void
Sent when this Interactive is focused and user pressed a keyboard key.
Pressed key can be accessed through Event.keyCode
.
dynamiconKeyUp(e:Event):Void
Sent when this Interactive is focused and user unpressed a keyboard key.
Unpressed key can be accessed through Event.keyCode
.
dynamiconMove(e:Event):Void
Sent when user moves within the Interactive hitbox area.
See Interactive.onCheck
for event when user does not move the mouse.
Cancelling the Event
will prevent interactive from becoming overed,
causing Interactive.onOut
if it was overed previously.
Interactive would be treated as not overed as long as event is cancelled even if mouse is within the hitbox area.
dynamiconOut(e:Event):Void
Sent when mouse exits Interactive hitbox area.
Event.propagate
and Event.cancel
are ignored during onOut
.
dynamiconOver(e:Event):Void
Sent when mouse enters Interactive hitbox area.
Event.propagate
and Event.cancel
are ignored during onOver
.
Propagation can be set with onMove
event, as well as cancelling onMove
will prevent onOver
.
dynamiconRelease(e:Event):Void
Sent when Interactive is unpressed under multiple circumstances. Always sent if user releases mouse while it is inside Interactive hitbox area.
This happens regardless if that Interactive was pressed prior or not,
and due to that it's not guaranteed that `Interactive.onPush` would precede this event.
`Event.kind` is set to `ERelease` during this event.
Sent before Interactive.onReleaseOutside
if this Interactive was pressed, but released outside its hitbox area.
`Event.kind` is set to `EReleaseOutside` during this event.
See `Interactive.onClick` and `Interactive.onReleaseOutside` methods for separate events that trigger only when user interacts with this particular Interactive.
dynamiconReleaseOutside(e:Event):Void
Sent when user presses the Interactive, moves the mouse outside its hitbox area and releases the mouse button.
Can be prevented to fire by calling Interactive.preventClick
during or after Interactive.onPush
event.
Interactive.onRelease
is sent with Event.kind
being EReleaseOutside
just before this event.
dynamiconTextInput(e:Event):Void
Sent when this Interactive is focused and user inputs text. Character added can be accessed through Event.charCode
.
dynamiconWheel(e:Event):Void
Sent when user scrolls mouse wheel above the Interactive. Wheel delta can be obtained through the Event.wheelDelta
.
preventClick():Void
Reset current pressed state of the Interactive, preventing the onClick
or onReleaseOutside
being triggered when user releases mouse button.
startCapture(callb:Event ‑> Void, ?onCancel:() ‑> Void, ?touchId:Int):Void
Starts input events capture and redirects them to callb
method until Interactive.stopCapture
is called.
While the method name may imply that only mouse events would be captured: This is not the case,
as it will also capture all other input events, including keyboard events.
Starting event capture through Interactive.startCapture
will convert Event.relX
and relY
to local coordinates
of the Interactive and will restore them after invoking callb
.
In order to receive coordinates in scene coordinate space use Scene.startCapture
.
Parameters:
callb | A callback method that receives |
---|---|
onCancel | An optional callback that is invoked when |
Defined by Drawable
addShader<T>(s:T):T
Add a shader to the drawable shaders.
Keep in mind, that as stated before, drawable children do not inherit Drawable properties, which includes shaders.
adjustColor(?col:Null<ColorAdjust>):Void
Set the Drawable.colorMatrix
value by specifying which effects to apply.
Calling adjustColor()
without arguments will reset the colorMatrix to null
.
@:value({ toHxsl : true })getDebugShaderCode(toHxsl:Bool = true):String
Returns the built shader code, can be used for debugging shader assembly
Parameters:
toHxsl | Whether return an HXSL shader or the native shading language of the backend. |
---|
getShader<T>(stype:Class<T>):T
Returns the first shader of the given shader class among the drawable shaders.
Parameters:
stype | The class of the shader to look up. |
---|
removeShader(s:Shader):Bool
Remove a shader from the drawable shaders, returns true if found or false if it was not part of our shaders.
Defined by Object
private@:dox(show)addBounds(relativeTo:Object, out:Bounds, dx:Float, dy:Float, width:Float, height:Float):Void
Adds specified area in local coordinate space to the bounds. Expected to be used within Object.getBoundsRec
.
Parameters:
relativeTo | An object relative to which the Object bounds coordinates should be. If not set, coordinates are in absolute coordinate space. |
---|---|
out | An output Bounds instance. |
dx | The top-left X offset of the added bounds rectangle. |
dy | The top-left Y offset of the added bounds rectangle. |
width | The width of the added bounds rectangle. |
height | The height of the added bounds rectangle. |
addChildAt(s:Object, pos:Int):Void
Insert a child object at the specified position of the children list.
private@:dox(show)calcAbsPos():Void
private@:dox(show)clipBounds(ctx:RenderContext, bounds:Bounds):Void
private@:dox(show)constraintSize(maxWidth:Float, maxHeight:Float):Void
For example, Text
constraints it's maximum width, causing word-wrap to occur within constrained area.
See also:
private@:dox(show)contentChanged(s:Object):Void
private@:dox(show)draw(ctx:RenderContext):Void
Override this method in order to add custom graphics rendering to your Object.
draw
is invoked before rendering of the object children.
drawToTextures(texs:Array<Texture>, outputs:Array<Output>):Void
Draw the object and all its children into the given Textures.
private@:dox(show)emitTile(ctx:RenderContext, tile:Tile):Void
Draws single Tile instance with this Object transform.
find<T>(f:Object ‑> Null<T>):Null<T>
Find a single object in the tree by calling f
on each and returning the first not-null value returned, or null if not found.
findAll<T>(f:Object ‑> Null<T>, ?arr:Array<T>):Array<T>
Find several objects in the tree by calling f
on each and returning all the not-null values returned.
Parameters:
arr | An optional array instance to fill results with. Allocates a new array if not set. |
---|
getAbsPos():Matrix
Returns the updated absolute position matrix. See Object.getMatrix
for current matrix values.
getBounds(?relativeTo:Object, ?out:Bounds):Bounds
Return the bounds of the object for its whole content, recursively.
Parameters:
relativeTo | An optional object relative to coordinates of which bounds are returned. Returns bounds in the absolute coordinates if not set. |
---|---|
out | An optional bounds instance to fill. Allocates new Bounds instance and returns it if not set. |
private@:dox(show)getBoundsRec(relativeTo:Object, out:Bounds, forSize:Bool):Void
Override this method in order to expand the reported bounds of an object. Object.addBounds
can be used to add bounds with respect to relativeTo
.
Do not remove the super call.
Parameters:
relativeTo | An object relative to which the Object bounds coordinates should be. |
---|---|
out | An output Bounds instance. |
forSize | Whether it's being called for |
inlinegetChildAt(n:Int):Object
Return the n
th element among the immediate children list of this object, or null
if there is no Object at this position.
getChildIndex(o:Object):Int
Return the index of the object o
within the immediate children list of this object, or -1
if it is not part of the children list.
private@:dox(show)getMatrix(m:Matrix):Void
Populates Matrix with current absolute object transform values. See Object.getAbsPos
for up-to-date values.
getObjectByName(name:String):Object
Search for an object recursively by name, return null
if not found.
getScene():Scene
Returns an h2d.Scene
down the hierarchy tree or null
if object is not added to Scene.
getSize(?out:Bounds):Bounds
Similar to getBounds(parent)
, but instead of the full content, it will return
the size based on the alignment of the object. For instance for a text, Object.getBounds
will return
the full glyphs size whereas getSize
will ignore the pixels under the baseline.
Parameters:
out | An optional bounds instance to fill. Allocates new Bounds instance and returns it if not set. |
---|
globalToLocal(pt:Point):Point
Convert an absolute screen position into a local position relative to the object origin, applying all the inherited transforms.
Parameters:
pt | A position to convert and return. Modifies the Point instance as is. |
---|
localToGlobal(?pt:Point):Point
Convert a local position (or [0,0]
if pt
is null) relative to the object origin into an absolute screen position, applying all the inherited transforms.
Parameters:
pt | An optional position to convert and return. Allocates new Point at 0,0 position if not set. Modifies the Point instance as is. |
---|
move(dx:Float, dy:Float):Void
Move the object by the specified amount along its current direction (Object.rotation
angle).
private@:dox(show)onAdd():Void
Sent when object is being added to an allocated scene.
Do not remove the super call when overriding.
private@:dox(show)inlineonContentChanged():Void
Should be called when Object content was changed in order to notify parent container. See Object.contentChanged
.
private@:dox(show)onHierarchyMoved(parentChanged:Bool):Void
Sent when object was already allocated and moved within scene object tree hierarchy.
Do not remove the super call when overriding.
Parameters:
parentChanged | Whether Object was moved withing same parent (through |
---|
private@:dox(show)onRemove():Void
Sent when object is removed from the allocated scene.
Do not remove the super call when overriding.
removeChild(s:Object):Void
Remove the given object from the immediate children list of the object if it's part of it.
private@:dox(show)setParentContainer(c:Object):Void
Sets the parent container for this Object and it's children.
See Object.contentChanged
for more details.
private@:dox(show)sync(ctx:RenderContext):Void
Performs a sync of data for rendering (such as absolute position recalculation). While this method can be used as a substitute to an update loop, it's primary purpose it to prepare the Object to be rendered.
Do not remove the super call when overriding.