Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
Event.h
Go to the documentation of this file.
1#pragma once
2
3#include <Common/primitive_type.h>
4#include <Common/assertion.h>
5#include <Math/math.h>
6#include <Utility/utility.h>
7
8#include <string>
9
10namespace ph::editor
11{
12
13enum class EEventType
14{
15 Unknown = 0,
16
17 // TODO: distanguish between main window and window (child/internal)?
18
24
26
27 AppTick,
30
31 KeyDown,
32 KeyUp,
33 KeyHit,
34
40};
41
42enum class EEventSource : uint32f
43{
44 Unknown = 0,
45
46 App = math::flag_bit<uint32f, 0>(),
47 Input = math::flag_bit<uint32f, 1>(),
48 Keyboard = math::flag_bit<uint32f, 2>(),
49 Mouse = math::flag_bit<uint32f, 3>(),
50 MouseButton = math::flag_bit<uint32f, 4>(),
51};
52
58class Event
59{
60// Hide special members as this class is not intended to be used polymorphically.
61// It is derived class's choice to expose them (by defining them in public) or not.
62protected:
64
65public:
66 /*inline Event() = default;
67 inline virtual ~Event() = default;*/
68
69 /*virtual EEventType getDynamicType() const = 0;
70 virtual EEventSource getSourceType() const = 0;
71 virtual std::string toString() const = 0;*/
72
73 void consume();
74 bool isConsumed() const;
75 //bool isFromSource(EEventSource fromSourceType) const;
76
77private:
78 uint8 m_isConsumed : 1 = false;
79};
80
81inline void Event::consume()
82{
83 PH_ASSERT_MSG(!m_isConsumed, "Consuming already-consumed editor event.");
84
85 m_isConsumed = true;
86}
87
88inline bool Event::isConsumed() const
89{
90 return m_isConsumed;
91}
92
93}// end namespace ph::editor
Base of all event types. Derived classes should strive to keep the size of the object small,...
Definition Event.h:59
void consume()
Definition Event.h:81
bool isConsumed() const
Definition Event.h:88
PH_DEFINE_INLINE_RULE_OF_5_MEMBERS(Event)
Definition ph_editor.h:10
EEventSource
Definition Event.h:43
EEventType
Definition Event.h:14