27#include "Graphics2D/GUI/CGUIElement.h"
28#include "Graphics2D/CCanvas.h"
30#include "Motion/CMotion.h"
31#include "Motion/CColorMotion.h"
32#include "Motion/CAlphaMotion.h"
33#include "Motion/CPositionMotion.h"
34#include "Motion/CScaleMotion.h"
35#include "Motion/CRotationMotion.h"
36#include "Motion/CFrameMotion.h"
37#include "Motion/CVisibleMotion.h"
70 std::vector<CMotion*> m_motions[(int)EMotionEvent::NumEvent];
75 bool m_isPointerHover;
78 bool m_skipPointerEventWhenDrag;
79 bool m_continueGameEvent;
80 bool m_continueKeyEvent;
91 std::function<void(
int,
float,
float)> OnPointerHover;
92 std::function<void(
int,
float,
float)> OnPointerOut;
93 std::function<void(
int,
float,
float)> OnPointerDown;
94 std::function<void(
int,
float,
float)> OnPointerUp;
95 std::function<void(
int,
float,
float,
bool)> OnPointerMove;
97 std::function<void(
CUIBase*)> OnPressed;
98 std::function<void(
CUIBase*)> OnFocus;
99 std::function<void(
CUIBase*)> OnLostFocus;
102 std::function<void(
CUIBase*, EMotionEvent)> OnMotionFinish[(int)EMotionEvent::NumEvent];
122 virtual void update();
169 m_continueGameEvent = b;
175 return m_continueGameEvent;
178 inline bool isContinueKeyEvent()
180 return m_continueKeyEvent;
189 m_skipPointerEventWhenDrag = b;
195 return m_isPointerHover;
201 return m_isPointerDown;
216 return m_element->getCanvas();
245 virtual void onPointerOut(
int pointerId,
float pointerX,
float pointerY);
261 virtual void onPointerUp(
int pointerId,
float pointerX,
float pointerY);
346 return m_motions[(int)event];
401 m_soundId[slot] = soundId;
411 return m_soundId[slot];
This class manages GUI components, including creating and deleting images and sprites.
Definition CCanvas.h:79
This is the base object class from which other GUIs inherit. It's an empty GUI and can contain child ...
Definition CGUIElement.h:51
virtual CMotion * addMotion(EMotionEvent event, CGUIElement *element, CMotion *motion)
Add a CMotion instance bound to a specific CGUIElement for the given event.
void convertToUICoordinate(float &pointerX, float &pointerY)
Convert screen pointer coordinates to this UI object's local UI coordinates.
virtual void onPointerDown(int pointerId, float pointerX, float pointerY)
Called when pointer is pressed down on the element.
virtual void onPressed()
Called when the element is considered "pressed" (high-level event). Subclasses may trigger OnPressed ...
virtual ~CUIBase()
Virtual destructor.
virtual void setVisible(bool b)
Set visibility of this UI object.
int getSoundId(int slot)
Get the sound id associated with this UI object.
Definition CUIBase.h:409
CUIBase(CUIContainer *container, CGUIElement *element)
Constructor.
virtual void onPointerMove(int pointerId, float pointerX, float pointerY)
Called when pointer moves while over or dragging the element.
virtual bool acceptDragFocus()
Whether this UI element should accept drag-focus when the pointer is already down and the user drags ...
Definition CUIBase.h:385
CUIContainer * getContainer()
Get parent container.
Definition CUIBase.h:221
void removeMotions(EMotionEvent event)
Remove all motions attached to the specified event.
void convertWorldToLocal(CGUIElement *element, float &x, float &y)
Convert world coordinates to the local coordinate space of a CGUIElement.
void remove()
Remove this UI object from its container and perform cleanup.
void startMotion(EMotionEvent event)
Start motions associated with a specific motion event.
bool isVisible()
Returns true if the object is visible.
Definition CUIBase.h:143
virtual void onFocus()
Called when element receives focus.
void resetTouch()
Reset pointer internal state (hover/down).
void setSoundId(int slot, int soundId)
Set the sound id associated with this UI object.
Definition CUIBase.h:399
virtual void onLostFocus()
Called when element loses focus.
int getPointerId()
Get the pointer ID associated with this UI object.
Definition CUIBase.h:149
void convertLocalToWorld(CGUIElement *element, float &x, float &y)
Convert local coordinates of a CGUIElement to world coordinates.
core::vector3df * getRectTransform()
Returns a pointer to the internal rect transform (4 corners).
virtual void onPointerHover(int pointerId, float pointerX, float pointerY)
Called when pointer enters or hovers over the element.
bool isMotionPlaying(EMotionEvent event)
Query whether any motion is currently playing for the given event.
bool isEnable()
Returns true if the object is enabled.
Definition CUIBase.h:137
void stopMotion(EMotionEvent event)
Stop motions associated with a specific motion event.
std::vector< CMotion * > & getMotions(EMotionEvent event)
Access the motion vector for a specific event.
Definition CUIBase.h:344
bool removeMotion(EMotionEvent event, CMotion *motion)
Remove a motion instance from the given event list.
void setSkipPointerEventWhenDrag(bool b)
When true pointer events will be skipped while dragging.
Definition CUIBase.h:187
bool isPointerHover()
Returns true if pointer is hovering this object.
Definition CUIBase.h:193
CGUIElement * getElement()
Get the underlying CGUIElement pointer.
Definition CUIBase.h:205
void setUserData(void *data)
Attach an application-defined pointer to this UI object.
Definition CUIBase.h:423
virtual void setEnable(bool b)
Enable or disable this UI object.
bool isPointerDown()
Returns true if pointer is down on this object.
Definition CUIBase.h:199
void setPointerId(int id)
Set the pointer ID for this UI object.
Definition CUIBase.h:155
CCanvas * getCanvas()
Retrieve the canvas that the underlying element belongs to.
Definition CUIBase.h:213
virtual void onPointerUp(int pointerId, float pointerX, float pointerY)
Called when pointer is released over the element.
void setContinueGameEvent(bool b)
Control whether input events continue to the game layer.
Definition CUIBase.h:167
virtual void onPointerOut(int pointerId, float pointerX, float pointerY)
Called when pointer leaves the element.
void * getUserData()
Retrieve the pointer previously set via setUserData.
Definition CUIBase.h:433
virtual void onKeyEvent(const SEvent &event)
Called when a keyboard event is delivered to this element.
virtual CMotion * addMotion(EMotionEvent event, CMotion *motion)
Add a CMotion instance to the list for the given event. The motion will be initialized and managed by...
bool isContinueGameEvent()
Returns true when events are allowed to continue to the game layer.
Definition CUIBase.h:173
Top-level UI container and event router.
Definition CUIContainer.h:59
Classes used to build the User Interface (UI).
Definition CAlphaMotion.h:32
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
Definition IEventReceiver.h:273