Skylicht Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
UserInterface
CUIEventManager.h
1
/*
2
!@
3
MIT License
4
5
Copyright (c) 2023 Skylicht Technology CO., LTD
6
7
Permission 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,
9
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10
subject to the following conditions:
11
12
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20
This file is part of the "Skylicht Engine".
21
https://github.com/skylicht-lab/skylicht-engine
22
!#
23
*/
24
25
#pragma once
26
27
#include "EventManager/CEventManager.h"
28
29
namespace
Skylicht
30
{
31
namespace
UI
32
{
33
class
CUIBase
;
34
35
class
CUIContainer
;
36
59
class
CUIEventManager
:
IEventProcessor
60
{
61
public
:
62
DECLARE_SINGLETON
(
CUIEventManager
)
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
:
75
CUIEventManager
();
76
78
virtual
~CUIEventManager
();
79
91
virtual
bool
OnProcessEvent
(
const
SEvent& event);
92
101
void
registerUIContainer
(
CUIContainer
* container);
102
111
void
unregisterUIContainer
(
CUIContainer
* container);
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
130
void
clearFocus
();
131
133
inline
CUIBase
*
getFocus
()
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
151
void
resetTouch
();
152
};
153
}
154
}
Skylicht::IEventProcessor
Definition
CEventManager.h:32
Skylicht::UI::CUIBase
Base wrapper class that connects a UI container and a GUI element.
Definition
CUIBase.h:63
Skylicht::UI::CUIContainer
Top-level UI container and event router.
Definition
CUIContainer.h:59
Skylicht::UI::CUIEventManager::OnProcessEvent
virtual bool OnProcessEvent(const SEvent &event)
Implementation of IEventProcessor::OnProcessEvent.
Skylicht::UI::CUIEventManager::setFocus
void setFocus(CUIBase *focus)
Set keyboard/focus to a given UI element.
Skylicht::UI::CUIEventManager::getPointerY
int getPointerY(int id)
Get the last known pointer world Y coordinate.
Definition
CUIEventManager.h:145
Skylicht::UI::CUIEventManager::registerUIContainer
void registerUIContainer(CUIContainer *container)
Register a UI container to receive routed events.
Skylicht::UI::CUIEventManager::unregisterUIContainer
void unregisterUIContainer(CUIContainer *container)
Unregister a UI container so it no longer receives events.
Skylicht::UI::CUIEventManager::getPointerX
int getPointerX(int id)
Get the last known pointer world X coordinate.
Definition
CUIEventManager.h:139
Skylicht::UI::CUIEventManager::CUIEventManager
CUIEventManager()
Constructor. Initializes internal state.
Skylicht::UI::CUIEventManager::~CUIEventManager
virtual ~CUIEventManager()
Destructor. Cleans up any state if necessary.
Skylicht::UI::CUIEventManager::resetTouch
void resetTouch()
Should call when resume application.
Skylicht::UI::CUIEventManager::getFocus
CUIBase * getFocus()
Get the element that currently has keyboard/focus.
Definition
CUIEventManager.h:133
Skylicht::UI::CUIEventManager::clearFocus
void clearFocus()
Clear current focus.
DECLARE_SINGLETON
#define DECLARE_SINGLETON(className)
Declare the standard singleton accessors for a class.
Definition
CSingleton.h:36
Skylicht::UI
Classes used to build the User Interface (UI).
Definition
CAlphaMotion.h:32
Skylicht
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition
AudioDebugLog.h:29
Generated by
1.17.0