class GridLayout
package koui.elements.layouts
extends Layout › Element
extended by ColLayout, RowLayout
A GridLayout
is a Layout
that places elements into equal-sized grid
cells.
Each cell can contain one element only. If another element is added, the cell's current element is removed from the layout.
Constructor
new(posX:Int, posY:Int, width:Int, height:Int, amountRows:Int, amountCols:Int)
Creates a new grid layout.
Parameters:
posX | The x position of the layout |
---|---|
posY | The y position of the layout |
width | The width of the layout |
height | The height of the layout |
amountRows | The amount of rows in this layout |
amountCols | The amount of columns in this layout |
Methods
add(element:Element, row:Int, column:Int, ?anchor:Anchor):Void
Adds an element to this GridLayout
at the given position. Please note
that if an element already exists at that position, it is removed from
the layout.
If the given position does not exist, an error is raised and the element is not added to this layout.
Parameters:
element | The given element |
---|---|
row | The row this element should be placed in |
column | The column this element should be placed in |
anchor | (Optional) The anchor of the element. If not given, use the elements default anchor. Otherwise, the element's anchor setting is overwritten. |
getElementAtPosition(x:Int, y:Int):Null<Element>
Returns the element at the given position in window coordinates or null
if no element exists at that position.
Parameters:
x | The x position |
---|---|
y | The y position |
remove(element:Element):Void
Removes the given element from this layout.
Parameters:
element | The element |
---|
removeAtPosition(row:Int, column:Int):Void
Removes the element at the given position from this layout.
Parameters:
row | The row of the element |
---|---|
column | The column of the element |
resize(width:Int, height:Int):Void
Resizes this layout. Used internally and will likely be replaced with a property setter override.
Parameters:
width | The new width of this layout |
---|---|
height | The new height of this layout |