Skylicht Engine
Loading...
Searching...
No Matches
CUIContainer.h
1/*
2!@
3MIT License
4
5Copyright (c) 2023 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "CUIEventManager.h"
28#include "Components/CComponentSystem.h"
29
30#include "CUIBase.h"
31
32namespace Skylicht
33{
34 namespace UI
35 {
58 class CUIContainer : public CComponentSystem
59 {
60 protected:
61 bool m_enable;
62
63 std::vector<CUIBase*> m_arrayUIObjects;
64 std::vector<CUIBase*> m_raycastUIObjects;
65 std::vector<CUIBase*> m_removed;
66
67 CUIBase* m_skip;
68 CUIBase* m_hover;
69 CCanvas* m_canvas;
70
71 bool m_inMotion;
72 bool m_outMotion;
73
74 std::map<int, bool>m_pointerDown;
75
76 public:
77 std::function<void(CUIBase*)> OnPressed;
78 std::function<void(CUIBase*)> OnHover;
79
80 public:
86 std::function<void()> OnMotionInFinish;
87
93 std::function<void()> OnMotionOutFinish;
94
95 public:
96 CUIContainer();
97
98 virtual ~CUIContainer();
99
100 virtual void initComponent();
101
102 virtual void updateComponent();
103
104 void resetTouch();
105
111
116 void addChild(CUIBase* base);
117
123 bool removeChild(CUIBase* base);
124
130
137
145 virtual CUIBase* OnProcessEvent(const SEvent& event);
146
155 virtual CUIBase* OnProcessEvent(const SEvent& event, CUIBase* capture);
156
166 virtual void onPointerOut(int pointerId, float x, float y);
167
178 virtual void cancelPointerDown(CUIBase* base, int pointerId, float pointerX, float pointerY);
179
182
185
187 inline void setEnable(bool b)
188 {
189 m_enable = b;
190 }
191
199 inline bool isEnable()
200 {
201 return m_enable;
202 }
203
205 inline bool isPointerDown(int id);
206 };
207 }
208}
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
Base wrapper class that connects a UI container and a GUI element.
Definition CUIBase.h:63
virtual void onPointerOut(int pointerId, float x, float y)
Notify container that pointer left the given position.
virtual CUIBase * OnProcessEvent(const SEvent &event, CUIBase *capture)
Process an input event with an explicit capture hint.
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.
virtual void cancelPointerDown(CUIBase *base, int pointerId, float pointerX, float pointerY)
Cancel an active pointer down on a child.
virtual CUIBase * OnProcessEvent(const SEvent &event)
Process an input event and forward it to the appropriate child.
std::function< void()> OnMotionInFinish
Callback invoked when in-motion sequence finishes.
Definition CUIContainer.h:86
std::function< void()> OnMotionOutFinish
Callback invoked when out-motion sequence finishes.
Definition CUIContainer.h:93
CCanvas * getCanvas()
Get the associated canvas.
bool isEnable()
Enable or disable the container processing.
Definition CUIContainer.h:199
void startInMotion()
Start the "in" motion sequence and set internal state.
void startOutMotion()
Start the "out" motion sequence and set internal state.
void addChild(CUIBase *base)
Add a child UI object to the container.
void setEnable(bool b)
Enable or disable the container processing.
Definition CUIContainer.h:187
CUIBase * getChildByGUI(CGUIElement *element)
Find a child by its underlying GUI element.
bool isPointerDown(int id)
Check the pointer id is down.
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
SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
Definition IEventReceiver.h:273