A UI container for managing and rendering UI components. More...
#include <Canvas.h>
Public Member Functions | |
Canvas (const Canvas &)=delete | |
Canvas & | operator= (const Canvas &)=delete |
void | AddComponent (UIComponent *component) |
Adds a UI component to the canvas. | |
void | RemoveComponent (UIComponent *component) |
Removes a UI component from the canvas. | |
void | SetEnabled (bool e) |
Sets the canvas to be enabled or disabled. | |
bool | IsEnabled () const |
Returns whether the canvas is enabled or not. | |
Private Member Functions | |
void | OnComponentLayerChanged (UIComponent *component, int oldLayer, int newLayer) |
void | Update () override |
Updates the canvas and its child components. Called automatically by the engine each frame when registered. | |
void | Draw2D () override |
Draws the canvas and its child components. Called automatically by the engine each frame when registered. | |
void | MousePress (AZUL_MOUSE m) override |
Handles pressed AZUL mouse input. Called automatically by the engine when mouse input is detected. | |
void | MouseHeld (AZUL_MOUSE m) override |
Handles held AZUL mouse input. Called automatically by the engine when mouse input is detected. | |
void | MouseRelease (AZUL_MOUSE m) override |
Handles released AZUL mouse input. Called automatically by the engine when mouse input is detected. | |
void | HandleMouseInput () |
Handles AZUL mouse press/hover input. | |
void | HandleHeldMouseInput () |
Handles AZUL mouse scroll input. | |
void | HandleScroll () |
Handles AZUL mouse scroll input. | |
void | HandleMouseReleaseInput () |
Handles released AZUL mouse input. | |
void | HandleHover () |
Handles AZUL mouse hover input. | |
Private Attributes | |
std::vector< UIComponent * > | components |
List of UI components in this canvas. | |
std::map< int, std::vector< UIComponent * > > | layerMap |
std::map< UIComponent *, int > | componentLayerLookup |
bool | enabled |
Friends | |
class | UIAttorney |
Additional Inherited Members | |
![]() | |
Drawable (const Drawable &)=delete | |
Drawable & | operator= (const Drawable &)=delete |
void | SubmitDrawRegistration () |
Submits the draw registration for the GameObject. | |
void | SubmitDrawDeregistration () |
Submits the draw deregistration for the GameObject. | |
![]() | |
Inputable (const Inputable &)=delete | |
Inputable & | operator= (const Inputable &)=delete |
void | SubmitKeyRegistration (AZUL_KEY k, EventType e) |
Submits the key registration for the GameObject. | |
void | SubmitKeyDeregistration (AZUL_KEY k, EventType e) |
Submits the key deregistration for the GameObject. | |
void | SubmitMouseKeyRegistration (AZUL_MOUSE m, EventType e) |
Submits the mouse key registration for the GameObject. | |
void | SubmitMouseKeyDeregistration (AZUL_MOUSE m, EventType e) |
Submits the mouse key deregistration for the GameObject. | |
![]() | |
Updatable (const Updatable &)=delete | |
Updatable & | operator= (const Updatable &)=delete |
void | SubmitUpdateRegistration () |
Submits the update registration for the GameObject. | |
void | SubmitUpdateDeregistration () |
Submits the update deregistration for the GameObject. | |
A UI container for managing and rendering UI components.
The Canvas class acts as a root container for UI elements such as buttons, sliders, dropdowns, and more. It handles input, drawing, and updating of its child components, and can be added to a scene as a 2D overlay.
Typical usage:
void Canvas::AddComponent | ( | UIComponent * | component | ) |
Adds a UI component to the canvas.
component | Pointer to the UIComponent to add. |
|
overrideprivatevirtual |
Draws the canvas and its child components. Called automatically by the engine each frame when registered.
Reimplemented from Drawable.
bool Canvas::IsEnabled | ( | ) | const |
Returns whether the canvas is enabled or not.
|
overrideprivatevirtual |
Handles held AZUL mouse input. Called automatically by the engine when mouse input is detected.
Reimplemented from Inputable.
|
overrideprivatevirtual |
Handles pressed AZUL mouse input. Called automatically by the engine when mouse input is detected.
Reimplemented from Inputable.
|
overrideprivatevirtual |
Handles released AZUL mouse input. Called automatically by the engine when mouse input is detected.
Reimplemented from Inputable.
void Canvas::RemoveComponent | ( | UIComponent * | component | ) |
Removes a UI component from the canvas.
component | Pointer to the UIComponent to remove. |
void Canvas::SetEnabled | ( | bool | e | ) |
Sets the canvas to be enabled or disabled.
enabled | True to enable the canvas, false to disable it. |
|
overrideprivatevirtual |
Updates the canvas and its child components. Called automatically by the engine each frame when registered.
Reimplemented from Updatable.