#pragma once #include #include "Point.hpp" #include "Box.hpp" namespace Raven { enum class EventType { NoneEvent, MouseButton, MouseMove, Reflow, FocusUpdate, ActivationUpdate, }; enum class ReflowType { RepaintRect, RelayoutRect }; enum class ReflowGrouping { Yes, No }; class Event { private: bool m_accepted { false }; public: Event() {} virtual EventType type() { return EventType::NoneEvent; } virtual const char *name() { return "NoneEvent"; } void accept() { m_accepted = true; } bool accepted() { return m_accepted; } virtual ~Event() = default; }; class MouseButtonEvent : public Event { private: bool m_was_left_button_pressed; bool m_was_right_button_pressed; Point m_point; public: MouseButtonEvent(bool was_left_button_pressed, bool was_right_button_pressed, Point point) : m_was_left_button_pressed(was_left_button_pressed) , m_was_right_button_pressed(was_right_button_pressed) , m_point(point) {} EventType type() { return EventType::MouseButton; } const char *name() { return "MouseButton"; } bool was_left_button_pressed() { return m_was_left_button_pressed; } bool was_right_button_pressed() { return m_was_right_button_pressed; } Point &point() { return m_point; } }; class MouseMoveEvent : public Event { private: Point m_point; public: MouseMoveEvent(Point point) : m_point(point) {} EventType type() { return EventType::MouseMove; } const char *name() { return "MouseMove"; } Point &point() { return m_point; } }; class ReflowEvent: public Event { private: ReflowType m_reflow_type; ReflowGrouping m_grouping; Box m_box; public: ReflowEvent(ReflowType type, ReflowGrouping grouping, Box box) : m_reflow_type(type) , m_grouping(grouping) , m_box(box) {} EventType type() { return EventType::Reflow; } const char *name() { return "Reflow"; } ReflowType reflow_type() { return m_reflow_type; } ReflowGrouping grouping() { return m_grouping; } Box &box() { return m_box; } 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; } }; class FocusUpdateEvent : public Event { private: bool m_focus_status; public: FocusUpdateEvent(bool focus_status) : m_focus_status(focus_status) {} EventType type() { return EventType::FocusUpdate; } const char *name() { return "FocusUpdate"; } bool focus_status() { return m_focus_status; } }; class ActivationUpdateEvent : public Event { private: bool m_activation_status; public: ActivationUpdateEvent(bool activation_status) : m_activation_status(activation_status) {} EventType type() { return EventType::ActivationUpdate; } const char *name() { return "ActivationUpdate"; } bool activation_status() { return m_activation_status; } }; }