载入中...
搜索中...
未找到
src
modules
ui
EventSink.cpp
浏览该文件的文档.
1
// Lets ImGui see platform events before anything else claims them.
2
//
3
// The SDL event pump used to call UI::processEvent directly, which was one of
4
// the eight modules it had to know about.
5
6
#include "
common/Capability.h
"
7
#include "
common/Module.h
"
8
#include "
event/PlatformEventSink.h
"
9
#include "
ui/UI.h
"
10
11
#include <SDL2/SDL_events.h>
12
13
namespace
eve::ui
{
14
namespace
{
15
16
class
UIEventSink :
public
eve::event::IPlatformEventSink
{
17
public
:
18
bool
observePlatformEvent(
const
void
*nativeEvent)
override
{
19
if
(
auto
*ui = eve::ModuleManager::getInstance<UI>(
"UI"
))
20
ui->processEvent(
static_cast<
const
SDL_Event *
>
(nativeEvent));
21
// ImGui records the event for its own state but does not claim it; the
22
// game still receives the matching message.
23
return
false
;
24
}
25
};
26
27
struct
Register {
28
Register() {
29
static
UIEventSink sink;
30
eve::cap::addListener<eve::event::IPlatformEventSink>
(
31
&sink,
eve::event::IPlatformEventSink::kObserver
);
32
}
33
} g_register;
34
35
}
// namespace
36
}
// namespace eve::ui
Capability.h
Module.h
PlatformEventSink.h
UI.h
eve::event::IPlatformEventSink
Definition
PlatformEventSink.h:30
eve::event::IPlatformEventSink::kObserver
@ kObserver
Definition
PlatformEventSink.h:34
eve::cap::query
I * query()
Definition
Capability.h:77
eve::ui
Definition
Component.cpp:5