Layout

extendsDisplayObject โ†’ Object

Primitive widget with ability to contain another widgets. Widget developers use this to create widget which can include another widgets inside as example below.

...
<SeriesLayout
orientation="vertical"
alignContents="center"
spacing="16dp">
<Label
text="Hello User!"/>
<Button
text="Hi!"/>
</SeriesLayout>
...

Properties#

nameTypeDefault ValueDescription
alignContentsstring""Align contents of this widget. See alignment guide.
widthstring or number"content"Can be number, number with unit, "content", or "container". see sizing guide.
heightstring or number"content"Can be number, number with unit, "content", or "container". see sizing guide.

Inherited from DisplayObject#

nameTypeDefault ValueDescription
idstring(8-digit random)Identifies widget. Set this to make it searchable.
xstring or number0Can be either plain number or number with unit.
ystring or number0Can be either plain number or number with unit.
scaleXnumber1.0Fraction of number. This will multiply width.
scaleYnumber1.0Fraction of number. This will multiply height.
scalenumber1.0Set this to change both scaleX and scaleY at once.
alphanumber1.00.0 means transparent and 1.0 is fully opaque.
anglenumber00.0 means transparent and 1.0 is fully opaque.
elevationstring or number0Can be either plain number or number with unit.
cornerRadiusstring or number0Can be either plain number or number with unit.
presencebooleantrueIf true, this widget will affects other widgets' position and size.
visiblebooleantrueIf true, this widget will be drawn.
clippingbooleantrueIf true, content of this widget will be cropped if exceed the boundary.
suspendUpdatebooleantrueSet true to temporarily prevent update trigger.
backgroundColornumberapp.res.style.backgroundColorUse app.colors.* to set the color.
foregroundColornumberapp.res.style.foregroundColorUse app.colors.* to set the color.
borderColornumberthis.foregroundColorUse app.colors.* to set the color.
borderSizestring or number0Can be either plain number or number with unit.
paddingTopstring or number0Can be either plain number or number with unit.
paddingBottomstring or number0Can be either plain number or number with unit.
paddingLeftstring or number0Can be either plain number or number with unit.
paddingRightstring or number0Can be either plain number or number with unit.
paddingHorizontalstring or number0Set this to write both paddingLeft and paddingRight at once.
paddingVerticalstring or number0Set this to write both paddingTop and paddingBottom at once.
paddingsstring or number0Set this to write paddingTop, paddingBottom, paddingLeft and paddingRight.
borderSizestring or number0Can be either plain number or number with unit.
marginTopstring or number0Can be either plain number or number with unit.
marginBottomstring or number0Can be either plain number or number with unit.
marginLeftstring or number0Can be either plain number or number with unit.
marginRightstring or number0Can be either plain number or number with unit.
marginHorizontalstring or number0Set this to write both marginLeft and marginRight at once.
marginVerticalstring or number0Set this to write both marginTop and marginBottom at once.
marginsstring or number0Set this to write marginTop, marginBottom, marginLeft and marginRight.
alignSelfstring""Align position of this widget. See alignment guide.
hookTopToTopOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookTopToBottomOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookBottomToBottomOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookBottomToTopOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookLeftToLeftOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookLeftToRightOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookRightToRightOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookRightToLeftOfstring""ID of targeted widget. Only works if currently content of HookLayout.
onDrawfunction(empty function)Event listeners that you could set on .fiwl layout.
onUpdatefunction(empty function)Event listeners that you could set on .fiwl layout.
onSelectfunction(empty function)Event listeners that you could set on .fiwl layout.
onOptionfunction(empty function)Event listeners that you could set on .fiwl layout.
onScrollfunction(empty function)Event listeners that you could set on .fiwl layout.
onDragStartfunction(empty function)Event listeners that you could set on .fiwl layout.
onDragMovefunction(empty function)Event listeners that you could set on .fiwl layout.
onDragEndfunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverStartfunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverMovefunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverEndfunction(empty function)Event listeners that you could set on .fiwl layout.
onAsyncCreatefunction(empty function)Event listeners that you could set on .fiwl layout.
onReadyfunction(empty function)Event listeners that you could set on .fiwl layout.
onSuspendfunction(empty function)Event listeners that you could set on .fiwl layout.
onDestroyfunction(empty function)Event listeners that you could set on .fiwl layout.

Read-only Properties#

nameTypeDescription
contentsArray<DisplayObject>Get this instance's contents. See Layout Principle.
lengthnumberCount of contents.
measuredContentsWidthnumberMeasured "contents" width value.
measuredContentsHeightnumberMeasured "contents" height value.

Inherited from DisplayObject#

NameTypeDescription
containerobjectGet this instance's container. See Layout Principle.
globalXnumberGet pre-calculated absolute horizontal position.
globalYnumberGet pre-calculated absolute vertical position.
measuredWidthnumberGet pre-calculated absolute width.
measuredHeightnumberGet pre-calculated absolute height.

Methods#

NameReturn TypeDescription
findContentDisplayObjectGet content by its ID.
measureEachContentXnumberHelp its contents where should be located in X axis.
measureEachContentYnumberHelp its contents where should be located in Y axis.
measureEachContentWidthnumberHelp its contents resolve maximum width, especially when width = "container".
measureEachContentHeightnumberHelp its contents resolve maximum height, especially when height = "container".

Inherited from DisplayObject#

NameReturn TypeDescription
requestUpdatevoidManually request to re-render.
addEventListenervoidCalls app.event.addEventListener with this widget as context.
removeEventListenervoidCalls app.event.removeEventListener with this widget as context.

findContent#

findContent(id, isRecrusive?);

Get content by its ID. Very useful especially if you have some widgets that randomly swap its index or moving to another container.

Parameters:

  1. id: (string type) ID of targeted widget instance.
  2. isRecrusive: (boolean type, Optional) If set true, this function will also find inside of content of contents. Keep in mind this is heavy operation.

Return: DisplayObject or its inheritance. null if not found.


measureEachContentX#

measureEachContentX(id);

Help its contents where should be located in X axis. As example inside horizontal-oriented SeriesLayout, the second widget can understand where is the right of first widget.

Parameters:

  1. id: (string type) ID of targeted widget instance.

Return: number, in pixels.


measureEachContentY#

measureEachContentY(id);

Help its contents where should be located in Y axis. As example inside vertical-oriented SeriesLayout, the second widget can understand where is the bottom of first widget.

Parameters:

  1. id: (string type) ID of targeted widget instance.

Return: number, in pixels.


measureEachContentWidth#

measureEachContentWidth(id);

Help its contents resolve maximum width, especially when width = "container".

Parameters:

  1. id: (string type) ID of targeted widget instance.

Return: number, in pixels.


measureEachContentHeight#

measureEachContentHeight(id);

Help its contents resolve maximum height, especially when height = "container".

Parameters:

  1. id: (string type) ID of targeted widget instance.

Return: number, in pixels.