Class ContainerControl
Base class for all GUI controls that can contain child controls.
Inheritance
Implements
Namespace: FlaxEngine.GUI
Assembly: FlaxEngine.CSharp.dll
Syntax
public class ContainerControl : Control, IComparable, IDrawableConstructors
ContainerControl()
ContainerControl(Float2, Float2)
Initializes a new instance of the ContainerControl class.
Declaration
public ContainerControl(Float2 location, Float2 size)Parameters
| Float2
        location 
 | 
| Float2
        size 
 | 
ContainerControl(Rectangle)
Init
Declaration
public ContainerControl(Rectangle bounds)Parameters
| Rectangle
        bounds Window bounds | 
ContainerControl(Single, Single, Single, Single)
Initializes a new instance of the ContainerControl class.
Declaration
public ContainerControl(float x, float y, float width, float height)Parameters
| System.Single
        x 
 | 
| System.Single
        y 
 | 
| System.Single
        width 
 | 
| System.Single
        height 
 | 
Fields
_children
The children collection.
Declaration
[NoSerialize]
protected readonly List<Control> _childrenField Value
| System.Collections.Generic.List<Control> 
 | 
_containsFocus
The contains focus cached flag.
Declaration
[NoSerialize]
protected bool _containsFocusField Value
| System.Boolean 
 | 
_isLayoutLocked
The layout locking flag.
Declaration
[NoSerialize]
protected bool _isLayoutLockedField Value
| System.Boolean 
 | 
Properties
Children
Gets child controls list
Declaration
public List<Control> Children { get; }Property Value
| System.Collections.Generic.List<Control> 
 | 
ChildrenCount
Gets amount of the children controls
Declaration
public int ChildrenCount { get; }Property Value
| System.Int32 
 | 
ClipChildren
Gets or sets a value indicating whether apply clipping mask on children during rendering.
Declaration
[EditorOrder(530)]
[Tooltip("If checked, control will apply clipping mask on children during rendering.")]
public bool ClipChildren { get; set; }Property Value
| System.Boolean 
 | 
ContainsFocus
Gets a value indicating whether the control, or one of its child controls, currently has the input focus.
Declaration
public override bool ContainsFocus { get; }Property Value
| System.Boolean 
 | 
Overrides
CullChildren
Gets or sets a value indicating whether perform view culling on children during rendering.
Declaration
[EditorOrder(540)]
[Tooltip("If checked, control will perform view culling on children during rendering.")]
public bool CullChildren { get; set; }Property Value
| System.Boolean 
 | 
HasChildren
Checks if container has any child controls
Declaration
public bool HasChildren { get; }Property Value
| System.Boolean 
 | 
IsTouchOver
Check if touch is over that item or its child items
Declaration
public override bool IsTouchOver { get; }Property Value
| System.Boolean 
 | 
Overrides
Methods
AddChild<T>()
Creates a new control and adds it to the container.
Declaration
public T AddChild<T>()
    where T : ControlReturns
| T The added control. | 
Type Parameters
| T 
 | 
AddChild<T>(T)
Adds the control to the container.
Declaration
public T AddChild<T>(T child)
    where T : ControlParameters
| T
        child The control to add. | 
Returns
| T The added control. | 
Type Parameters
| T 
 | 
CanNavigateChild(Control)
ClearState()
Called to clear UI state. For example, removes mouse over state or drag and drop when control gets disabled or hidden (including hierarchy).
Declaration
public override void ClearState()Overrides
ContainsPoint(ref Float2, Boolean)
Checks if this control contains given point in local Control Space.
Declaration
public override bool ContainsPoint(ref Float2 location, bool precise = false)Parameters
| Float2
        location Point location in Control Space to check | 
| System.Boolean
        precise True if perform precise intersection test against the control content (eg. with hit mask or transparency threshold). Otherwise, only simple bounds-check will be performed. | 
Returns
| System.Boolean True if point is inside control's area, otherwise false. | 
Overrides
DisposeChildren()
Removes and disposes all the child controls
Declaration
public virtual void DisposeChildren()Draw()
DrawChildren()
Draws the children. Can be overridden to provide some customizations. Draw is performed with applied clipping mask for the client area.
Declaration
protected virtual void DrawChildren()DrawSelf()
Draws the control.
Declaration
public virtual void DrawSelf()GetChild(Int32)
Gets child control at given index.
Declaration
public Control GetChild(int index)Parameters
| System.Int32
        index The control index. | 
Returns
| Control The child control. | 
GetChild<T>()
Searches for a child control of a specific type. If there are multiple controls matching the type, only the first one found is returned.
Declaration
public T GetChild<T>()
    where T : ControlReturns
| T The control instance if found, otherwise null. | 
Type Parameters
| T The type of the control to search for. Includes any controls derived from the type. | 
GetChildAt(Float2)
Tries to find any child control at given point in control local coordinates
Declaration
public Control GetChildAt(Float2 point)Parameters
| Float2
        point The local point to check. | 
Returns
| Control The found control or null. | 
GetChildAt(Float2, Func<Control, Boolean>)
Tries to find valid child control at given point in control local coordinates. Uses custom callback method to test controls to pick.
Declaration
public Control GetChildAt(Float2 point, Func<Control, bool> isValid)Parameters
| Float2
        point The local point to check. | 
| System.Func<Control, System.Boolean>
        isValid The control validation callback. | 
Returns
| Control The found control or null. | 
GetChildAtRecursive(Float2)
Tries to find lowest child control at given point in control local coordinates.
Declaration
public Control GetChildAtRecursive(Float2 point)Parameters
| Float2
        point The local point to check. | 
Returns
| Control The found control or null. | 
GetChildIndex(Control)
Gets zero-based index in the list of control children.
Declaration
public int GetChildIndex(Control child)Parameters
| Control
        child The child control. | 
Returns
| System.Int32 The zero-based index in the list of control children. | 
GetChildIndexAt(Float2)
Tries to find any child control at given point in control local coordinates.
Declaration
public int GetChildIndexAt(Float2 point)Parameters
| Float2
        point The local point to check. | 
Returns
| System.Int32 The found control index or -1 if failed. | 
GetClientArea()
Gets rectangle in local control coordinates with area for controls (without scroll bars, anchored controls, etc.).
Declaration
public Rectangle GetClientArea()Returns
| Rectangle The rectangle in local control coordinates with area for controls (without scroll bars etc.). | 
GetDesireClientArea(out Rectangle)
Gets the desire client area rectangle for all the controls.
Declaration
public virtual void GetDesireClientArea(out Rectangle rect)Parameters
| Rectangle
        rect The client area rectangle for child controls. | 
IntersectsChildContent(Control, Float2, out Float2)
Checks if given point in this container control space intersects with the child control content. Also calculates result location in child control space which can be used to feed control with event at that point.
Declaration
public virtual bool IntersectsChildContent(Control child, Float2 location, out Float2 childSpaceLocation)Parameters
| Control
        child The child control to check. | 
| Float2
        location The location in this container control space. | 
| Float2
        childSpaceLocation The output location in child control space. | 
Returns
| System.Boolean True if point is over the control content, otherwise false. | 
IsTouchPointerOver(Int32)
Determines whether the given touch pointer is over the control.
Declaration
public override bool IsTouchPointerOver(int pointerId)Parameters
| System.Int32
        pointerId The touch pointer identifier. Stable for the whole touch gesture/interaction. | 
Returns
| System.Boolean True if given touch pointer is over the control, otherwise false. | 
Overrides
LockChildrenRecursive()
Locks all child controls layout and itself.
Declaration
[NoAnimate]
public void LockChildrenRecursive()NavigationWrap(NavDirection, Float2, List<Control>, out Float2)
OnCharInput(Char)
On input character
Declaration
public override bool OnCharInput(char c)Parameters
| System.Char
        c Input character | 
Returns
| System.Boolean True if event has been handled, otherwise false | 
Overrides
OnChildrenChanged()
Called when children collection gets changed (child added or removed).
Declaration
[NoAnimate]
public virtual void OnChildrenChanged()OnChildResized(Control)
Called when child control gets resized.
Declaration
public virtual void OnChildResized(Control control)Parameters
| Control
        control The resized control. | 
OnDestroy()
Method called when managed instance should be destroyed
Declaration
public override void OnDestroy()Overrides
OnDragDrop(ref Float2, DragData)
When mouse dragging drops on control's area
Declaration
public override DragDropEffect OnDragDrop(ref Float2 location, DragData data)Parameters
| Float2
        location Mouse location in Control Space | 
| DragData
        data The data. See DragDataText and DragDataFiles. | 
Returns
| DragDropEffect The drag event result effect. | 
Overrides
OnDragEnter(ref Float2, DragData)
When mouse dragging enters control's area
Declaration
public override DragDropEffect OnDragEnter(ref Float2 location, DragData data)Parameters
| Float2
        location Mouse location in Control Space | 
| DragData
        data The data. See DragDataText and DragDataFiles. | 
Returns
| DragDropEffect The drag event result effect. | 
Overrides
OnDragLeave()
When mouse dragging leaves control's area
Declaration
public override void OnDragLeave()Overrides
OnDragMove(ref Float2, DragData)
When mouse dragging moves over control's area
Declaration
public override DragDropEffect OnDragMove(ref Float2 location, DragData data)Parameters
| Float2
        location Mouse location in Control Space | 
| DragData
        data The data. See DragDataText and DragDataFiles. | 
Returns
| DragDropEffect The drag event result effect. | 
Overrides
OnKeyDown(KeyboardKeys)
When key goes down
Declaration
public override bool OnKeyDown(KeyboardKeys key)Parameters
| KeyboardKeys
        key Key value | 
Returns
| System.Boolean True if event has been handled, otherwise false | 
Overrides
OnKeyUp(KeyboardKeys)
When key goes up
Declaration
public override void OnKeyUp(KeyboardKeys key)Parameters
| KeyboardKeys
        key Key value | 
Overrides
OnMouseDoubleClick(Float2, MouseButton)
When mouse double clicks over control's area
Declaration
public override bool OnMouseDoubleClick(Float2 location, MouseButton button)Parameters
| Float2
        location Mouse location in Control Space | 
| MouseButton
        button Mouse buttons state (flags) | 
Returns
| System.Boolean True if event has been handled, otherwise false | 
Overrides
OnMouseDown(Float2, MouseButton)
When mouse goes down over control's area
Declaration
public override bool OnMouseDown(Float2 location, MouseButton button)Parameters
| Float2
        location Mouse location in Control Space | 
| MouseButton
        button Mouse buttons state (flags) | 
Returns
| System.Boolean True if event has been handled, otherwise false | 
Overrides
OnMouseEnter(Float2)
When mouse enters control's area
Declaration
public override void OnMouseEnter(Float2 location)Parameters
| Float2
        location Mouse location in Control Space | 
Overrides
OnMouseLeave()
When mouse leaves control's area
Declaration
public override void OnMouseLeave()Overrides
OnMouseMove(Float2)
When mouse moves over control's area
Declaration
public override void OnMouseMove(Float2 location)Parameters
| Float2
        location Mouse location in Control Space | 
Overrides
OnMouseUp(Float2, MouseButton)
When mouse goes up over control's area
Declaration
public override bool OnMouseUp(Float2 location, MouseButton button)Parameters
| Float2
        location Mouse location in Control Space | 
| MouseButton
        button Mouse buttons state (flags) | 
Returns
| System.Boolean True if event has been handled, otherwise false | 
Overrides
OnMouseWheel(Float2, Single)
When mouse wheel moves
Declaration
public override bool OnMouseWheel(Float2 location, float delta)Parameters
| Float2
        location Mouse location in Control Space | 
| System.Single
        delta Mouse wheel move delta. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. Normalized to [-1;1] range. | 
Returns
| System.Boolean True if event has been handled | 
Overrides
OnNavigate(NavDirection, Float2, Control, List<Control>)
OnSizeChanged()
Called when control size gets changed.
Declaration
protected override void OnSizeChanged()Overrides
OnTouchDown(Float2, Int32)
When touch enters control's area.
Declaration
public override bool OnTouchDown(Float2 location, int pointerId)Parameters
| Float2
        location Touch location in Control Space. | 
| System.Int32
        pointerId The touch pointer identifier. Stable for the whole touch gesture/interaction. | 
Returns
| System.Boolean True if event has been handled, otherwise false. | 
Overrides
OnTouchEnter(Float2, Int32)
When touch enters control's area
Declaration
public override void OnTouchEnter(Float2 location, int pointerId)Parameters
| Float2
        location Touch location in Control Space | 
| System.Int32
        pointerId The touch pointer identifier. Stable for the whole touch gesture/interaction. | 
Overrides
OnTouchLeave(Int32)
When touch leaves control's area
Declaration
public override void OnTouchLeave(int pointerId)Parameters
| System.Int32
        pointerId The touch pointer identifier. Stable for the whole touch gesture/interaction. | 
Overrides
OnTouchMove(Float2, Int32)
When touch moves over control's area.
Declaration
public override void OnTouchMove(Float2 location, int pointerId)Parameters
| Float2
        location Touch location in Control Space. | 
| System.Int32
        pointerId The touch pointer identifier. Stable for the whole touch gesture/interaction. | 
Overrides
OnTouchUp(Float2, Int32)
When touch goes up over control's area.
Declaration
public override bool OnTouchUp(Float2 location, int pointerId)Parameters
| Float2
        location Touch location in Control Space | 
| System.Int32
        pointerId The touch pointer identifier. Stable for the whole touch gesture/interaction. | 
Returns
| System.Boolean True if event has been handled, otherwise false. | 
Overrides
PerformLayout(Boolean)
Update control layout
Declaration
public override void PerformLayout(bool force = false)Parameters
| System.Boolean
        force True if perform layout by force even if cached state wants to skip it due to optimization. | 
Overrides
PerformLayoutAfterChildren()
Perform layout for that container control after performing it for child controls.
Declaration
protected virtual void PerformLayoutAfterChildren()PerformLayoutBeforeChildren()
Perform layout for that container control before performing it for child controls.
Declaration
protected virtual void PerformLayoutBeforeChildren()RayCast(ref Float2, out Control)
Performs a raycast against UI controls hierarchy to find any intersecting control content. Uses ContainsPoint(ref Float2, Boolean) with precise check (skips transparent surfaces and empty panels).
Declaration
public override bool RayCast(ref Float2 location, out Control hit)Parameters
| Float2
        location The position to intersect UI with. | 
| Control
        hit The result control that intersects with the raycast. | 
Returns
| System.Boolean True if ray hits any matching control, otherwise false. | 
Overrides
RemoveChild(Control)
Removes control from the container.
Declaration
public void RemoveChild(Control child)Parameters
| Control
        child The control to remove. | 
RemoveChildren()
Unlinks all the child controls.
Declaration
[NoAnimate]
public virtual void RemoveChildren()SortChildren()
Sort child controls list
Declaration
[NoAnimate]
public void SortChildren()SortChildrenRecursive()
Sort children using recursion
Declaration
[NoAnimate]
public void SortChildrenRecursive()UnlockChildrenRecursive()
Unlocks all the child controls layout and itself.
Declaration
[NoAnimate]
public void UnlockChildrenRecursive()Update(Single)
Perform control update and all its children
Declaration
public override void Update(float deltaTime)Parameters
| System.Single
        deltaTime Delta time in seconds | 
Overrides
UpdateChildrenBounds()
Updates child controls bounds.
Declaration
protected void UpdateChildrenBounds()UpdateContainsFocus()
Update contain focus state and all it's children
Declaration
protected void UpdateContainsFocus()