Creates layout system instance.
Name | Type | Attributes | Description |
---|---|---|---|
options |
LayoutOptions |
<optional> |
Layout options |
options.id |
ID of the layout. |
||
options.styles |
Styles of the layout. List of available styles can be found in StyleController. |
||
options.content |
Content of the layout. |
||
options.globalStyles |
Global styles for layout and it's children. |
||
container |
Container |
<optional> |
Container for all layout children, will be created if not provided. |
Example
const container = new Container().initLayout();
container.layout?.setStyles({
background: 'black',
width: '100%',
height: '100%',
padding: 10,
overflow: 'hidden',
color: 'white',
}); // set styles
container.layout?.setContent({
text: 'Hello World',
}); // set content
Or alternatively:
const layoutSystem = new LayoutSystem({
id: 'root',
content: 'Hello World',
styles: {
background: 'black',
}
}); // create layout system
app.stage.addChild(layoutSystem.container); // add layout system generated container to the stage
Members
align AlignController
AlignController is a class for controlling layout and all it's children alignment.
Container for all layout children.
content ContentController
ContentController controller is a class for controlling layouts children.
Returns height of the container
Returns with of the container
Sets the height of layout.
Gets the height of layout.
ID of layout, can be used to set styles in the globalStyles object somewhere higher in hierarchal tree.
Stores isPortrait state
Returns true if root layout is in landscape mode.
size SizeController
SizeController is a class for controlling layout and all it's children sizes.
Layout styles.
Layout text styles.
Sets the width of layout.
Gets the width of layout.
_style StyleController protected
StyleController is a class for controlling styles.
Methods
Adds content to the layout and reposition/resize other elements and the layout basing on styles.
Name | Type | Description |
---|---|---|
content |
Content |
Content to be added. Can be string, Container, Layout, LayoutOptions or array of those. Also content can be an object with inner layout ids as a keys, and Content as values. |
getChildByID (id) Layout | Container | undefined
Get element from the layout child tree by it's ID
Name | Type | Description |
---|---|---|
id |
string |
id of the content to be foundS. |
Returns:
Type | Description |
---|---|
Layout | Container | undefined |
getRootLayout () LayoutSystem
Returns root layout of the layout tree.
Returns:
Type | Description |
---|---|
LayoutSystem |
Recalculate positions and sizes of layouts three.
Removes content of the layout by its id and reposition/resize other elements and the layout basing on styles.
Name | Type | Description |
---|---|---|
id |
string |
id of the content to be removed. |
Resize method should be called on every parent size change.
Name | Type | Attributes | Description |
---|---|---|---|
parentWidth |
number |
<optional> |
|
parentHeight |
number |
<optional> |
Updates the layout styles and resize/reposition it and its children basing on new styles.
Name | Type | Description |
---|---|---|
styles |
Styles & ConditionalStyles |
This is used in case if layout or some of it's children was changed and we need to update sizes and positions for all the parents tree.