summaryrefslogtreecommitdiff
path: root/plugingui/guievent.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-02-10 19:52:34 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2017-02-10 20:11:31 +0100
commitdc33f15a6b968139779c2b7d2003d3ef6e7d5748 (patch)
tree949172db6cdb9ed2b03bfe9f5051f51a683ecd19 /plugingui/guievent.h
parentf9d2d48214038689dc42085373b28b934f7fe002 (diff)
Clean up guievent.h and use EventQueue type instead if std::queue.
Diffstat (limited to 'plugingui/guievent.h')
-rw-r--r--plugingui/guievent.h66
1 files changed, 41 insertions, 25 deletions
diff --git a/plugingui/guievent.h b/plugingui/guievent.h
index 78fe0f8..2d4cc6f 100644
--- a/plugingui/guievent.h
+++ b/plugingui/guievent.h
@@ -26,18 +26,15 @@
*/
#pragma once
-#include <unistd.h>
-
#include <string>
+#include <list>
+#include <memory>
-#ifdef X11
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#endif/*X11*/
-
-namespace GUI {
+namespace GUI
+{
-enum class EventType {
+enum class EventType
+{
mouseMove,
repaint,
button,
@@ -48,18 +45,17 @@ enum class EventType {
move
};
-class Event {
+class Event
+{
public:
virtual ~Event() {}
virtual EventType type() = 0;
-
-#ifdef X11
- ::Window window_id;
-#endif/*X11*/
};
-class MouseMoveEvent : public Event {
+class MouseMoveEvent
+ : public Event
+{
public:
EventType type() { return EventType::mouseMove; }
@@ -68,18 +64,22 @@ public:
};
-enum class Direction {
+enum class Direction
+{
up,
down,
};
-enum class MouseButton {
+enum class MouseButton
+{
right,
middle,
left,
};
-class ButtonEvent : public Event {
+class ButtonEvent
+ : public Event
+{
public:
EventType type() { return EventType::button; }
@@ -92,7 +92,9 @@ public:
bool doubleClick;
};
-class ScrollEvent : public Event {
+class ScrollEvent
+ : public Event
+{
public:
EventType type() { return EventType::scroll; }
@@ -102,7 +104,9 @@ public:
int delta;
};
-class RepaintEvent : public Event {
+class RepaintEvent
+ : public Event
+{
public:
EventType type() { return EventType::repaint; }
@@ -112,7 +116,8 @@ public:
size_t height;
};
-enum class Key {
+enum class Key
+{
unknown,
left,
right,
@@ -128,7 +133,9 @@ enum class Key {
character, //!< The actual character is stored in KeyEvent::text
};
-class KeyEvent : public Event {
+class KeyEvent
+ : public Event
+{
public:
EventType type() { return EventType::key; }
@@ -138,12 +145,16 @@ public:
std::string text;
};
-class CloseEvent : public Event {
+class CloseEvent
+ : public Event
+{
public:
EventType type() { return EventType::close; }
};
-class ResizeEvent : public Event {
+class ResizeEvent
+ : public Event
+{
public:
EventType type() { return EventType::resize; }
@@ -151,7 +162,9 @@ public:
size_t height;
};
-class MoveEvent : public Event {
+class MoveEvent
+ : public Event
+{
public:
EventType type() { return EventType::move; }
@@ -159,4 +172,7 @@ public:
int y;
};
+using EventQueue = std::list<std::shared_ptr<Event>>;
+
+
} // GUI::