Element - LiruJ/GuiCookie GitHub Wiki
A controller is a base behaviour for an element and, as the name implies, acts as a controller to bring the behaviour of an element's components together.
The Element class is the default controller for every element within GuiCookie. If a controller is not specified for an element, this class will be used.
Any class that extends Element can add the following as arguments to its constructor and GuiCookie will handle finding the relevant object:
- GraphicsDevice
- ContentManager
- GameWindow
- InputManager
- DragAndDropManager
- TemplateManager
- ResourceManager
- StyleManager
- ComponentManager
- ElementManager
- Anything passed into the UIManager's CreateUIRoot function when the layout was created
- Anything passed into the ElementManager's CreateElement functions when the element was created
See the List of Default Controllers to see all default controllers available in GuiCookie.
This class is quite large, so this page is still a work in progress.
public, virtual, void
This is called immediately after the element was created and Component.OnCreated() has been called for each component.
Child elements will not exist at this point, although all attributes will be available and all components will at the very least exist.
public, virtual, void
This is called after OnCreated(), meaning that the children of the element will at least exist and will have called OnCreated(). This is mostly useful for getting access to child elements, although none of them would have called OnFullSetup() yet, so may not have fully set up.
public, virtual, void
This is called immediately after OnFullSetup(), meaning that every child of the element should be more or less set up. This is useful if a child's child is needed.
protected, virtual, void
protected, virtual, void
Is called immediately after the element's size was changed.
public, virtual, void
Is called when the element's StyleStateMachine's Style was changed.
protected, virtual, void
Is called immediately before the element is removed from the layout.
Note that it is incredibly important to set any references to the element to null so that C#'s garbage collector can clean it up. The element will be removed from the layout, but cannot unset itself anywhere else.
public, bool
Returns true if the element contains the given element; otherwise false.
public, T
Returns the first child element that is of the given type T, or null if no such child exists.
public, T
Returns the first child element that implements the given type T, or null if no such child exists or the given type is not an interface.
public, bool
Finds the first child element that implements the given type T and sets the out parameter to it. Returns true if the element was found; otherwise false.
public, Element
Finds and returns the child element with the given name. If the given boolean value is true, then each child element will be recursively searched for an element with the given name. If no child exists with the given name, null is returned.
If the given name is null or empty, an ArgumentException will be thrown.
This function searches recursively breadth-first.
public, T
Calls the GetChildByName function, but casts the result to the given type T before returning.
public, T
Calls the GetChildByName function and casts the result to the given T. Returns null if no child was found, or the given T was not an interface.
public, bool
Finds the first child element with the given name that implements the given type T and sets the out parameter to it. Returns true if the element was found; otherwise false.
public, Element
Finds and returns the child at the given index. This will throw an IndexOutOfRangeException if the index is out of range.
public, T
Calls the GetChildByIndex(int) function and returns the result cast to the given type T.
public, bool
Adds the given element as a child, returning true if the addition was a success; otherwise false.
Note that for performance reasons, there are no checks to ensure validity of the element hierarchy as a whole. This means that it is possible to add an element as a child of one of its grandchildren. Care should be taken to ensure this does not happen.
public, bool
Removes the given element from a child, returning true if the removal was a success; otherwise false.
public, void
public, IEnumerator<Element>
public, T
public, bool
public, T
public, bool
protected, void
public, void
public, void
public, void