A simple Interactive checkbox button with a label.
Useful for fast construction of development UI, but lacks on configurability side.
Constructor
new(?parent:Object)
Create a new CheckBox instance.
Parameters:
parent | An optional parent |
---|
Variables
@:value(true)enable:Bool = true
When disabled, the user would not be able to change the checkbox state by interacting with it.
It is still possible to change the selected
state manually through the code even if checkbox is disabled.
@:value(false)selected:Bool = false
Current toggle state of the checkbox.
Note that changing the state from the code will cause CheckBox.onChange
to trigger.
Methods
dynamiconChange():Void
Sent when the CheckBox.selected
state is changed.
Can be triggered both by user interaction (when checkbox is enabled) and from the software side by changing selected
directly.
Inherited Variables
Defined by Flow
backgroundTile:Tile
Setting a background tile will create an h2d.ScaleGrid
background which uses the Flow.borderWidth
/Flow.borderHeigh
values for its borders.
It will automatically resize when the reflow is done to cover the whole Flow area.
@:value(0)borderBottom:Int = 0
Bottom border width of the Flow.backgroundTile
.
Does not affect padding by default, which can be enabled with -D flow_border
compilation flag.
If border padding is enabled, Flow.outerHeight
will be affected accordingly even if background tile is not set
and will follow the same constraint limitation as padding.
See also:
write onlyborderHeight:Int
Set the border height of the Flow.backgroundTile
's top and bottom borders.
Does not affect padding by default, which can be enabled with -D flow_border
compilation flag.
If border padding is enabled, Flow.outerHeight
will be affected accordingly even if background tile is not set
and will follow the same constraint limitation as padding.
See also:
@:value(0)borderLeft:Int = 0
Left border width of the Flow.backgroundTile
.
Does not affect padding by default, which can be enabled with -D flow_border
compilation flag.
If border padding is enabled, Flow.outerHeight
will be affected accordingly even if background tile is not set
and will follow the same constraint limitation as padding.
See also:
@:value(0)borderRight:Int = 0
Right border width of the Flow.backgroundTile
.
Does not affect padding by default, which can be enabled with -D flow_border
compilation flag.
If border padding is enabled, Flow.outerHeight
will be affected accordingly even if background tile is not set
and will follow the same constraint limitation as padding.
See also:
@:value(0)borderTop:Int = 0
Top border width of the Flow.backgroundTile
.
Does not affect padding by default, which can be enabled with -D flow_border
compilation flag.
If border padding is enabled, Flow.outerHeight
will be affected accordingly even if background tile is not set
and will follow the same constraint limitation as padding.
See also:
write onlyborderWidth:Int
Set the border width of the Flow.backgroundTile
's left and right borders.
Does not affect padding by default, which can be enabled with -D flow_border
compilation flag.
If border padding is enabled, Flow.outerWidth
will be affected accordingly even if background tile is not set
and will follow the same constraint limitation as padding.
See also:
debug:Bool
When set to true, the Flow will display a debug overlay. Red box around the flow Green box for the client space. Blue boxes for each element.
enableInteractive:Bool
Adds an h2d.Interactive
to the Flow that is accessible through Flow.interactive
field.
This Interactive is automatically resized to cover the whole Flow area.
Flow is added as a bottom-most (after the Flow.backgroundTile
) child as to not impede flow elements with Interactives.
@:value(false)fillHeight:Bool = false
When set to true, if a height constraint is present and minHeight
is null - Flow will expand to fill all the available vertical space
@:value(false)fillWidth:Bool = false
When set to true, if a width constraint is present and minWidth
is null - Flow will expand to fill all the available horizontal space
horizontalAlign:Null<FlowAlign>
Horizontal alignment of elements inside the flow.
See FlowAlign
for more details.
read onlyinnerHeight:Int
Calculate the client height, which is the inner size of the flow without the borders and padding.
See also:
read onlyinnerWidth:Int
Calculate the client width, which is the inner size of the flow without the borders and padding.
See also:
@:value(true)isInline:Bool = true
When isInline is set to false, the flow size will be reported based on its bounds instead of its calculated size.
See also:
@:value(Horizontal)layout:FlowLayout = Horizontal
The Flow item layout rules.
See FlowLayout
for specific details on each mode.
maxHeight:Null<Int>
Attempts to limit the Flow outer height to the specified height.
Used as a baseline for overflow when Flow.multiline
is enabled and Flow.layout
is Vertical
.
maxWidth:Null<Int>
Attempts to limit the Flow outer width to the specified width.
Used as a baseline for overflow when Flow.multiline
is enabled and Flow.layout
is Horizontal
.
minHeight:Null<Int>
Ensures that Flow is at least the specified outer height at all times when not null.
minWidth:Null<Int>
Ensures that Flow is at least the specified outer width at all times when not null.
@:value(false)multiline:Bool = false
When set to true, uses specified lineHeight/colWidth instead of maxWidth/maxHeight for alignment.
@:value(true)needReflow:Bool = true
If some sub element gets resized, you need to set reflow to true in order to force
the reflow of elements. You can also directly call Flow.reflow
which will immediately
update all elements positions.
If a reflow is needed, Flow.reflow
will be called before rendering the flow.
Each change in one of the flow properties or addition/removal of elements will set needReflow to true.
read onlyouterHeight:Int
Flow total height Compared to Flow.innerHeight
, it also includes paddings and, if enabled, borders (see Flow.borderHeight
).
See also:
read onlyouterWidth:Int
Flow total width. Compared to Flow.innerWidth
, it also includes paddings and, if enabled, borders (see Flow.borderWidth
).
See also:
@:value(Expand)overflow:FlowOverflow = Expand
Enabling overflow will treat maxWidth/maxHeight and lineHeight/colWidth constraints as absolute : bigger elements will overflow instead of expanding the limit.
See respective FlowOverflow
values for more details.
write onlypadding:Int
Will set all padding values at the same time.
Note that padding is applied inside the flow boundaries and included in the size constraint, shrinking available space for Flow children.
See also:
@:value(0)paddingBottom:Int = 0
Sets the extra padding along the bottom edge of the Flow.
Note that padding is applied inside the flow boundaries and included in the size constraint, shrinking available space for Flow children.
write onlypaddingHorizontal:Int
Will set Flow.paddingLeft
and Flow.paddingRight
to the given value.
Note that padding is applied inside the flow boundaries and included in the size constraint, shrinking available space for Flow children.
@:value(0)paddingLeft:Int = 0
Sets the extra padding along the left edge of the Flow.
Note that padding is applied inside the flow boundaries and included in the size constraint, shrinking available space for Flow children.
@:value(0)paddingRight:Int = 0
Sets the extra padding along the right edge of the Flow.
Note that padding is applied inside the flow boundaries and included in the size constraint, shrinking available space for Flow children.
@:value(0)paddingTop:Int = 0
Sets the extra padding along the top edge of the Flow.
Note that padding is applied inside the flow boundaries and included in the size constraint, shrinking available space for Flow children.
write onlypaddingVertical:Int
Will set Flow.paddingTop
and Flow.paddingBottom
to the given value.
Note that padding is applied inside the flow boundaries and included in the size constraint, shrinking available space for Flow children.
@:value(false)reverse:Bool = false
When set to true, children are aligned in reverse order.
Note that it does not affect render ordering, and may cause overlap of elements due to them positioned in reverse order.
@:value(0.)scrollPosY:Float = 0.
The current scrolling position for the flow content (in pixels). Only applies when overflow is Scroll or Hidden.
@:value(30.)scrollWheelSpeed:Float = 30.
The amount of scrolling that is done when using mouse wheel (in pixels).
verticalAlign:Null<FlowAlign>
Vertical alignment of elements inside the flow.
See FlowAlign
for more details.
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 Flow
addSpacing(v:Int):Void
Adds some spacing by either increasing the padding of the latest non-absolute element or the padding of the flow if there are no elements in it.
The padding affected depends on the Flow.layout
mode.
It's impossible to add spacing with a Stack
Flow layout.
getProperties(e:Object):FlowProperties
Get the per-element properties. Returns null if the element is not currently part of the Flow.
Requesting the properties will cause a reflow regardless if properties values were changed or not.
reflow():Void
Call to force all flowed elements position to be updated.
See Flow.needReflow
for more information.
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. |
private@:dox(show)calcAbsPos():Void
private@:value({ scaleY : 1., scaleX : 1. })@:dox(show)clipBounds(ctx:RenderContext, bounds:Bounds, scaleX:Float = 1., scaleY:Float = 1.):Void
h2d.Scene
note: clipBounds
will always output bounds equivalent to entire window.
This is done in order for scene to never clip out cameras as they may render virtually any area of the Scene.
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. |
---|
inlinegetAbsPos():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 |
getChildAt(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 m
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.
finalgetSize(?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.
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.