Component - LiruJ/GuiCookie GitHub Wiki
An element may have multiple components to determine its behaviour. Components ensure that the design of elements is as modular as possible, and that behaviours can be reused across many elements.
Any class that extends Component 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 Components to see all default components available in GuiCookie.
The element that contains the component.
Bounds
The bounds of the containing element.
The root layout that the element is part of.
StyleStateMachine
The StyleStateMachine of the element.
The current style of the element.
The current style variant of the element.
public, virtual, void
Called after the component has been added to an element.
The element itself will not be done setting up, and its children are therefore very likely to be null, although other components will exist and can be safely saved.
public, virtual, void
Called after the component's element has been fully set up.
The element's children will all exist when this function is called and can be safely saved.
public, virtual, void
Called after OnSetup().
This can be used to access components after they have set themselves up.
protected, virtual, void
Is called immediately after the element's size was changed.
public, virtual, bool
Is called immediately before OnSizeChanged() and allows the component to refuse a size change.
If this function returns false, it should also set the size of the bounds to what it believes is valid.
if it is to return true, no changes are needed.
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, virtual, void
Called every update cycle, even if the element is disabled.
public, virtual, void
Called once per frame, as long as the element is visible.