Skylicht Engine
Loading...
Searching...
No Matches
CUIEventManager.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 "EventManager/CEventManager.h"
28
29namespace Skylicht
30{
31 namespace UI
32 {
33 class CUIBase;
34
35 class CUIContainer;
36
60 {
61 public:
63
64 protected:
65 std::vector<CUIContainer*> m_containers;
66
67 CUIBase* m_focus;
68
69 std::map<int, CUIBase*> m_multiTouchCapture;
70 std::map<int, core::vector2di> m_pointers;
71
72
73 public:
76
79
91 virtual bool OnProcessEvent(const SEvent& event);
92
102
112
113 void setMultiTouchCapture(int pointerId, CUIBase* base);
114
115 inline void setCapture(int pointerId, CUIBase* base)
116 {
117 setMultiTouchCapture(pointerId, base);
118 }
119
127 void setFocus(CUIBase* focus);
128
131
134 {
135 return m_focus;
136 }
137
139 inline int getPointerX(int id)
140 {
141 return m_pointers[id].X;
142 }
143
145 inline int getPointerY(int id)
146 {
147 return m_pointers[id].Y;
148 }
149
152 };
153 }
154}
Definition CEventManager.h:32
Base wrapper class that connects a UI container and a GUI element.
Definition CUIBase.h:63
Top-level UI container and event router.
Definition CUIContainer.h:59
virtual bool OnProcessEvent(const SEvent &event)
Implementation of IEventProcessor::OnProcessEvent.
void setFocus(CUIBase *focus)
Set keyboard/focus to a given UI element.
int getPointerY(int id)
Get the last known pointer world Y coordinate.
Definition CUIEventManager.h:145
void registerUIContainer(CUIContainer *container)
Register a UI container to receive routed events.
void unregisterUIContainer(CUIContainer *container)
Unregister a UI container so it no longer receives events.
int getPointerX(int id)
Get the last known pointer world X coordinate.
Definition CUIEventManager.h:139
CUIEventManager()
Constructor. Initializes internal state.
virtual ~CUIEventManager()
Destructor. Cleans up any state if necessary.
void resetTouch()
Should call when resume application.
CUIBase * getFocus()
Get the element that currently has keyboard/focus.
Definition CUIEventManager.h:133
void clearFocus()
Clear current focus.
#define DECLARE_SINGLETON(className)
Declare the standard singleton accessors for a class.
Definition CSingleton.h:36
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