2022-03-09 03:46:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-03-08 02:25:22 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include "Point.hpp"
|
2022-03-09 20:02:18 +02:00
|
|
|
#include "Box.hpp"
|
2022-03-08 02:25:22 +02:00
|
|
|
|
|
|
|
namespace Raven {
|
|
|
|
|
|
|
|
enum class EventType {
|
2022-03-09 03:46:27 +02:00
|
|
|
NoneEvent,
|
2022-03-08 02:25:22 +02:00
|
|
|
|
|
|
|
MouseButton,
|
2022-03-09 03:46:27 +02:00
|
|
|
MouseMove,
|
2022-05-12 17:05:16 +03:00
|
|
|
Reflow,
|
2022-03-18 02:49:16 +02:00
|
|
|
FocusUpdate,
|
2022-04-02 21:41:35 +03:00
|
|
|
ActivationUpdate,
|
2022-05-12 17:05:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class ReflowType {
|
2022-06-04 12:12:41 +03:00
|
|
|
RepaintRect,
|
|
|
|
RelayoutRect
|
2022-05-12 17:05:16 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class ReflowGrouping {
|
|
|
|
Yes,
|
|
|
|
No
|
2022-03-08 02:25:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Event {
|
|
|
|
private:
|
|
|
|
bool m_accepted { false };
|
|
|
|
public:
|
|
|
|
Event() {}
|
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
virtual EventType type() { return EventType::NoneEvent; }
|
|
|
|
virtual const char *name() { return "NoneEvent"; }
|
2022-03-09 03:46:27 +02:00
|
|
|
|
2022-03-18 02:49:16 +02:00
|
|
|
void accept() { m_accepted = true; }
|
2022-04-30 09:40:09 +03:00
|
|
|
bool accepted() { return m_accepted; }
|
2022-03-18 02:49:16 +02:00
|
|
|
|
2022-03-09 03:46:27 +02:00
|
|
|
virtual ~Event() = default;
|
2022-03-08 02:25:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MouseButtonEvent : public Event {
|
|
|
|
private:
|
|
|
|
bool m_was_left_button_pressed;
|
|
|
|
bool m_was_right_button_pressed;
|
2022-03-20 02:47:15 +02:00
|
|
|
Point m_point;
|
2022-03-08 02:25:22 +02:00
|
|
|
public:
|
2022-03-20 02:47:15 +02:00
|
|
|
MouseButtonEvent(bool was_left_button_pressed, bool was_right_button_pressed, Point point)
|
2022-03-08 02:25:22 +02:00
|
|
|
: m_was_left_button_pressed(was_left_button_pressed)
|
2022-03-20 02:47:15 +02:00
|
|
|
, m_was_right_button_pressed(was_right_button_pressed)
|
|
|
|
, m_point(point) {}
|
2022-03-08 02:25:22 +02:00
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
EventType type() { return EventType::MouseButton; }
|
|
|
|
const char *name() { return "MouseButton"; }
|
2022-03-08 02:25:22 +02:00
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
bool was_left_button_pressed() { return m_was_left_button_pressed; }
|
|
|
|
bool was_right_button_pressed() { return m_was_right_button_pressed; }
|
2022-03-20 02:47:15 +02:00
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
Point &point() { return m_point; }
|
2022-03-08 02:25:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MouseMoveEvent : public Event {
|
|
|
|
private:
|
|
|
|
Point m_point;
|
|
|
|
public:
|
|
|
|
MouseMoveEvent(Point point)
|
|
|
|
: m_point(point) {}
|
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
EventType type() { return EventType::MouseMove; }
|
|
|
|
const char *name() { return "MouseMove"; }
|
2022-03-08 02:25:22 +02:00
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
Point &point() { return m_point; }
|
2022-03-08 02:25:22 +02:00
|
|
|
};
|
|
|
|
|
2022-05-12 17:05:16 +03:00
|
|
|
class ReflowEvent: public Event {
|
2022-03-09 20:02:18 +02:00
|
|
|
private:
|
2022-05-12 17:05:16 +03:00
|
|
|
ReflowType m_reflow_type;
|
2022-06-04 12:12:41 +03:00
|
|
|
ReflowGrouping m_grouping;
|
|
|
|
Box m_box;
|
2022-03-09 03:46:27 +02:00
|
|
|
public:
|
2022-06-04 12:12:41 +03:00
|
|
|
ReflowEvent(ReflowType type, ReflowGrouping grouping, Box box)
|
2022-05-12 17:05:16 +03:00
|
|
|
: m_reflow_type(type)
|
2022-06-04 12:12:41 +03:00
|
|
|
, m_grouping(grouping)
|
|
|
|
, m_box(box) {}
|
2022-03-09 03:46:27 +02:00
|
|
|
|
2022-05-12 17:05:16 +03:00
|
|
|
EventType type() { return EventType::Reflow; }
|
|
|
|
const char *name() { return "Reflow"; }
|
2022-03-09 20:02:18 +02:00
|
|
|
|
2022-05-12 17:05:16 +03:00
|
|
|
ReflowType reflow_type() { return m_reflow_type; }
|
2022-06-04 12:12:41 +03:00
|
|
|
ReflowGrouping grouping() { return m_grouping; }
|
|
|
|
Box &box() { return m_box; }
|
2022-04-02 21:41:35 +03:00
|
|
|
|
2022-06-04 12:12:41 +03:00
|
|
|
void set_grouping(ReflowGrouping grouping) { m_grouping = grouping; }
|
|
|
|
void set_reflow_type(ReflowType type) { m_reflow_type = type; }
|
|
|
|
void set_box(Box box) { m_box = box; }
|
2022-04-02 21:41:35 +03:00
|
|
|
};
|
|
|
|
|
2022-03-18 02:49:16 +02:00
|
|
|
class FocusUpdateEvent : public Event {
|
|
|
|
private:
|
|
|
|
bool m_focus_status;
|
|
|
|
public:
|
|
|
|
FocusUpdateEvent(bool focus_status)
|
|
|
|
: m_focus_status(focus_status) {}
|
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
EventType type() { return EventType::FocusUpdate; }
|
|
|
|
const char *name() { return "FocusUpdate"; }
|
2022-03-18 02:49:16 +02:00
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
bool focus_status() { return m_focus_status; }
|
2022-03-18 02:49:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class ActivationUpdateEvent : public Event {
|
|
|
|
private:
|
|
|
|
bool m_activation_status;
|
|
|
|
public:
|
|
|
|
ActivationUpdateEvent(bool activation_status)
|
|
|
|
: m_activation_status(activation_status) {}
|
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
EventType type() { return EventType::ActivationUpdate; }
|
|
|
|
const char *name() { return "ActivationUpdate"; }
|
2022-03-18 02:49:16 +02:00
|
|
|
|
2022-04-30 09:40:09 +03:00
|
|
|
bool activation_status() { return m_activation_status; }
|
2022-03-18 02:49:16 +02:00
|
|
|
};
|
|
|
|
|
2022-03-09 03:46:27 +02:00
|
|
|
}
|