A ColLayout is a layout that represents a single row of elements (a set of multiple columns). Each column has the same size and can contain one element only. If another element is added to the same column, the column's current element is removed from the layout.

Constructor

new(posX:Int, posY:Int, width:Int, height:Int, amountCols:Int)

Creates a new column 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

amountCols

The amount of columns

Methods

addToColumn(element:Element, column:Int, ?anchor:Anchor):Void

Adds an element to this ColLayout 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

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.

removeAtColumn(column:Int):Void

Removes the element at the given column from this layout.

Parameters:

column

The column of the element

Inherited Variables

Defined by Layout

@:value(false)absorbEvents:Bool = false

If true, this Layout does receive events and block sub-elements from receiving them.

See also:

@:value(TopLeft)defaultAnchor:Anchor = TopLeft

@:value(false)read onlyinvalidLayout:Bool = false

true if the layout needs to be recalculated before the next frame.

@:value(0)paddingBottom:Int = 0

@:value(0)paddingLeft:Int = 0

@:value(0)paddingRight:Int = 0

@:value(0)paddingTop:Int = 0

@:value(false)spreadEvents:Bool = false

If true, all elements of this layout will receive the same events as the layout itself. Individual events are not received then.

This behaviour takes effect only if Layout.absorbEvents is true.

Defined by Element

@:value(Anchor.FollowLayout)anchor:Anchor = Anchor.FollowLayout

The anchor of this element. Used for the layout.

See also:

@:value(false)disabled:Bool = false

true if the element is disabled and should not react to events. Also, elements might look different if disabled depending on the theme.

@:value(0)height:Int = 0

The height of this element.

@:value(null)layout:Null<Layout> = null

The layout this element belongs to.

@:value(null)read onlyparent:Null<Element> = null

The parent element of this element.

@:value(0)posX:Int = 0

The x position of this element.

@:value(0)posY:Int = 0

The y position of this element.

@:value(true)visible:Bool = true

If false, the element is not visible and will not react to any events.

@:value(0)width:Int = 0

The width of this element.

Inherited Methods

Defined by GridLayout

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

Defined by Layout

calcElementSize(element:Element, parentWidth:Int, parentHeight:Int):Bool

Calculates the size of the given element if the size is defined as dynamic by the element's style, taking the dimension of the parent container and the anchor point into account (the container might be a layout or a subsection for example).

Returns:

Bool Whether the element was resized

invalidateLayout():Void

Mark this layout as invalid so that it is recalculated before the next frame is drawn.

inlinesetPadding(left:Int, right:Int, top:Int, bottom:Int):Void

Sets the padding values of this layout.

Parameters:

left

The left padding

right

The right padding

top

The top padding

bottom

The bottom padding

Defined by Element

inlineaddChild(child:Element):Void

finaladdEventListener<T>(eventClass:Class<T>, callback:T ‑> Void):Void

Register a callback to be called if the given event occurs on this element.

Example:

var button = new Button("Hello!");
button.addEventListener(MouseClickEvent, (event: MouseClickEvent) -> {
	if (event.mouseButton == Left && event.getState() == ClickStart) {
		trace("Clicked!");
	}
});

Parameters:

eventClass

The class of the event, must be a subclass of koui.events.Event

callback

The callback function to call if the event occurs

getChild<T>(matchBehaviour:ElementMatchBehaviour):Null<T>

getLayoutOffset():Vector<Int>

Return the offset of the element's position to the screen.

inlinegetTID():String

inlineisAtPosition(x:Int, y:Int):Bool

Return true if this element overlaps with the given position. Used internally for event handling most of the time. Elements may override this method to provide more detailed mouse interaction. If the element is invisible, false is returned.

finalinlinelistensTo<T>(eventClass:Class<T>):Bool

Returns whether this element has a registered event listener for the given event type.

finalinlinelistensToUID<T>(eventTypeUID:String):Bool

Returns whether this element has a registered event listener for the given event type.

inlineremoveChild(child:Element):Void

finalinlinerenderElement(g:KGraphics, element:Element):Void

Setup the given element for drawing and call its draw method afterwards.

inlinesetPosition(posX:Int, posY:Int):Void

Set the position of this element. You can also change the position per axis, see posX and posY.

inlinesetSize(width:Int, height:Int):Void

Set the size of this element. You can also change the size for each individual side, see width and height.

setTID(tID:String):Void

Set the theme ID of this element.

toString():String

Return a string representation of this element: "Element: <[ClassName]>"