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-03-18 02:49:16 +02:00
|
|
|
WidgetRepaintRequested,
|
|
|
|
FocusUpdate,
|
|
|
|
ActivationUpdate
|
2022-03-08 02:25:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Event {
|
|
|
|
private:
|
|
|
|
bool m_accepted { false };
|
|
|
|
public:
|
|
|
|
Event() {}
|
|
|
|
|
2022-03-09 03:46:27 +02:00
|
|
|
virtual EventType get_type() { return EventType::NoneEvent; }
|
|
|
|
virtual const char *get_name() { return "NoneEvent"; }
|
|
|
|
|
2022-03-18 02:49:16 +02:00
|
|
|
void accept() { m_accepted = true; }
|
|
|
|
bool get_accepted() { return m_accepted; }
|
|
|
|
|
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-03-09 03:46:27 +02:00
|
|
|
EventType get_type() { return EventType::MouseButton; }
|
|
|
|
const char *get_name() { return "MouseButton"; }
|
2022-03-08 02:25:22 +02:00
|
|
|
|
|
|
|
bool get_was_left_button_pressed() { return m_was_left_button_pressed; }
|
|
|
|
bool get_was_right_button_pressed() { return m_was_right_button_pressed; }
|
2022-03-20 02:47:15 +02:00
|
|
|
|
|
|
|
Point &get_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-03-09 03:46:27 +02:00
|
|
|
EventType get_type() { return EventType::MouseMove; }
|
|
|
|
const char *get_name() { return "MouseMove"; }
|
2022-03-08 02:25:22 +02:00
|
|
|
|
|
|
|
Point &get_point() { return m_point; }
|
|
|
|
};
|
|
|
|
|
2022-03-09 03:46:27 +02:00
|
|
|
class WidgetRepaintRequestedEvent : public Event {
|
2022-03-09 20:02:18 +02:00
|
|
|
private:
|
|
|
|
Box m_repaint_area;
|
2022-03-09 03:46:27 +02:00
|
|
|
public:
|
2022-03-09 20:02:18 +02:00
|
|
|
WidgetRepaintRequestedEvent(Box repaint_area)
|
|
|
|
: m_repaint_area(repaint_area) {}
|
2022-03-09 03:46:27 +02:00
|
|
|
|
|
|
|
EventType get_type() { return EventType::WidgetRepaintRequested; }
|
|
|
|
const char *get_name() { return "WidgetRepaintRequested"; }
|
2022-03-09 20:02:18 +02:00
|
|
|
|
|
|
|
Box &get_repaint_area() { return m_repaint_area; }
|
2022-03-09 03:46:27 +02: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) {}
|
|
|
|
|
|
|
|
EventType get_type() { return EventType::FocusUpdate; }
|
|
|
|
const char *get_name() { return "FocusUpdate"; }
|
|
|
|
|
|
|
|
bool get_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 get_type() { return EventType::ActivationUpdate; }
|
|
|
|
const char *get_name() { return "ActivationUpdate"; }
|
|
|
|
|
|
|
|
bool get_activation_status() { return m_activation_status; }
|
|
|
|
};
|
|
|
|
|
2022-03-09 03:46:27 +02:00
|
|
|
}
|