Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::UI::CUIContainer Class Reference

Top-level UI container and event router. More...

#include <UserInterface/CUIContainer.h>

Inheritance diagram for Skylicht::UI::CUIContainer:
Skylicht::CComponentSystem Skylicht::IActivatorObject

Public Member Functions

virtual void initComponent ()
virtual void updateComponent ()
void resetTouch ()
CCanvasgetCanvas ()
 Get the associated canvas.
void addChild (CUIBase *base)
 Add a child UI object to the container.
bool removeChild (CUIBase *base)
 Remove a child UI object from the container.
void removeChildsByGUI (CGUIElement *element)
 Remove all children that are backed by the specified GUI element.
CUIBasegetChildByGUI (CGUIElement *element)
 Find a child by its underlying GUI element.
virtual CUIBaseOnProcessEvent (const SEvent &event)
 Process an input event and forward it to the appropriate child.
virtual CUIBaseOnProcessEvent (const SEvent &event, CUIBase *capture)
 Process an input event with an explicit capture hint.
virtual void onPointerOut (int pointerId, float x, float y)
 Notify container that pointer left the given position.
virtual void cancelPointerDown (CUIBase *base, int pointerId, float pointerX, float pointerY)
 Cancel an active pointer down on a child.
void startInMotion ()
 Start the "in" motion sequence and set internal state.
void startOutMotion ()
 Start the "out" motion sequence and set internal state.
void setEnable (bool b)
 Enable or disable the container processing.
bool isEnable ()
 Enable or disable the container processing.
bool isPointerDown (int id)
 Check the pointer id is down.
Public Member Functions inherited from Skylicht::CComponentSystem
const char * getName ()
virtual void reset ()
virtual void startComponent ()
virtual void endUpdate ()
virtual void onEnable (bool b)
virtual void onUpdateCullingLayer (u32 mask)
virtual CObjectSerializablecreateSerializable ()
virtual void loadSerializable (CObjectSerializable *object)
void setEnable (bool b)
bool isEnable ()
CGameObject * getGameObject ()
void setEnableSerializable (bool b)
bool isSerializable ()
void addLinkComponent (CComponentSystem *comp)
void removeAllLink ()
Public Member Functions inherited from Skylicht::IActivatorObject
virtual ~IActivatorObject ()
 Virtual destructor for polymorphic activator objects.

Public Attributes

std::function< void(CUIBase *)> OnPressed
std::function< void(CUIBase *)> OnHover
std::function< void()> OnMotionInFinish
 Callback invoked when in-motion sequence finishes.
std::function< void()> OnMotionOutFinish
 Callback invoked when out-motion sequence finishes.

Protected Attributes

bool m_enable
std::vector< CUIBase * > m_arrayUIObjects
std::vector< CUIBase * > m_raycastUIObjects
std::vector< CUIBase * > m_removed
CUIBasem_skip
CUIBasem_hover
CCanvasm_canvas
bool m_inMotion
bool m_outMotion
std::map< int, bool > m_pointerDown
Protected Attributes inherited from Skylicht::CComponentSystem
CGameObject * m_gameObject
bool m_enable
bool m_serializable
std::vector< CComponentSystem * > m_linkComponent

Additional Inherited Members

Static Public Member Functions inherited from Skylicht::CComponentSystem
static int useComponent (CComponentSystem *used)
Protected Member Functions inherited from Skylicht::CComponentSystem
void setOwner (CGameObject *obj)

Detailed Description

Top-level UI container and event router.

CUIContainer manages a collection of CUIBase objects and acts as the bridge between low-level input events (irrlicht SEvent) and high-level UI interactions. Responsibilities include:

  • owning and updating child UI objects,
  • performing hit/raycast ordering through m_raycastUIObjects,
  • forwarding pointer and keyboard events to the appropriate child,
  • managing focus/capture semantics via CUIEventManager,
  • controlling simple motion sequences (in/out) and invoking finish callbacks.

The container is itself a CComponentSystem so it integrates with the engine update loop through initComponent() and updateComponent().

Note
Most UI controls are created as CUIBase subclasses and attached to a container with addChild(). Event processing is done through OnProcessEvent() which returns the CUIBase* that handled the event (or NULL if none).

Member Function Documentation

◆ addChild()

void Skylicht::UI::CUIContainer::addChild ( CUIBase * base)

Add a child UI object to the container.

Parameters
baseCUIBase* to add. The container will own and update it.

◆ cancelPointerDown()

virtual void Skylicht::UI::CUIContainer::cancelPointerDown ( CUIBase * base,
int pointerId,
float pointerX,
float pointerY )
virtual

Cancel an active pointer down on a child.

Parameters
basePointer to the child where pointer down should be cancelled.
pointerIdID of the pointer to cancel.
pointerXLast known pointer X (world).
pointerYLast known pointer Y (world).

This is used to abort press interactions when another system needs to interrupt the ongoing pointer down state.

◆ getCanvas()

CCanvas * Skylicht::UI::CUIContainer::getCanvas ( )

Get the associated canvas.

Returns
Pointer to the CCanvas used by this container.

◆ getChildByGUI()

CUIBase * Skylicht::UI::CUIContainer::getChildByGUI ( CGUIElement * element)

Find a child by its underlying GUI element.

Parameters
elementGUI element to search for.
Returns
Pointer to the CUIBase that wraps the element or NULL if not found.

◆ initComponent()

virtual void Skylicht::UI::CUIContainer::initComponent ( )
virtual

◆ isEnable()

bool Skylicht::UI::CUIContainer::isEnable ( )
inline

Enable or disable the container processing.

When set to false the container will ignore pointer/touch events and stop routing input to its child UI objects. OnProcessEvent() returns NULL while disabled, so pointer and mouse events are effectively ignored.

◆ onPointerOut()

virtual void Skylicht::UI::CUIContainer::onPointerOut ( int pointerId,
float x,
float y )
virtual

Notify container that pointer left the given position.

Parameters
pointerIdID of the pointer that moved out.
xWorld X coordinate of pointer out.
yWorld Y coordinate of pointer out.

This will clear hover state and forward onPointerOut to the previously hovered child if any.

◆ OnProcessEvent() [1/2]

virtual CUIBase * Skylicht::UI::CUIContainer::OnProcessEvent ( const SEvent & event)
virtual

Process an input event and forward it to the appropriate child.

Parameters
eventLow-level input SEvent.
Returns
The CUIBase* that handled the event, or NULL if none handled it.

This overload resolves events using the container's internal capture/focus state.

◆ OnProcessEvent() [2/2]

virtual CUIBase * Skylicht::UI::CUIContainer::OnProcessEvent ( const SEvent & event,
CUIBase * capture )
virtual

Process an input event with an explicit capture hint.

Parameters
eventLow-level input SEvent.
captureCUIBase* currently capturing input (may be NULL).
Returns
The CUIBase* that handled the event, or NULL if none handled it.

Use this overload when event routing should respect a specific capture target.

◆ removeChild()

bool Skylicht::UI::CUIContainer::removeChild ( CUIBase * base)

Remove a child UI object from the container.

Parameters
baseCUIBase* to remove.
Returns
true if the child was found and removed; false otherwise.

◆ removeChildsByGUI()

void Skylicht::UI::CUIContainer::removeChildsByGUI ( CGUIElement * element)

Remove all children that are backed by the specified GUI element.

Parameters
elementCGUIElement* whose associated UI objects will be removed.

◆ updateComponent()

virtual void Skylicht::UI::CUIContainer::updateComponent ( )
virtual

Member Data Documentation

◆ OnMotionInFinish

std::function<void()> Skylicht::UI::CUIContainer::OnMotionInFinish

Callback invoked when in-motion sequence finishes.

Used by UI transitions that require a post-animation action.

◆ OnMotionOutFinish

std::function<void()> Skylicht::UI::CUIContainer::OnMotionOutFinish

Callback invoked when out-motion sequence finishes.

Used by UI transitions that require teardown or state change after hiding.


The documentation for this class was generated from the following file: