raven/src/Events.hpp

74 lines
1.8 KiB
C++
Raw Normal View History

#pragma once
2022-03-08 02:25:22 +02:00
#include <stdint.h>
#include "Point.hpp"
#include "Box.hpp"
2022-03-08 02:25:22 +02:00
namespace Raven {
enum class EventType {
NoneEvent,
2022-03-08 02:25:22 +02:00
MouseButton,
MouseMove,
WidgetRepaintRequested
2022-03-08 02:25:22 +02:00
};
class Event {
private:
bool m_accepted { false };
public:
Event() {}
void accept() { m_accepted = true; }
bool is_accepted() { return m_accepted; }
virtual EventType get_type() { return EventType::NoneEvent; }
virtual const char *get_name() { return "NoneEvent"; }
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;
public:
MouseButtonEvent(bool was_left_button_pressed, bool was_right_button_pressed)
: m_was_left_button_pressed(was_left_button_pressed)
, m_was_right_button_pressed(was_right_button_pressed) {}
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; }
};
class MouseMoveEvent : public Event {
private:
Point m_point;
public:
MouseMoveEvent(Point point)
: m_point(point) {}
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; }
};
class WidgetRepaintRequestedEvent : public Event {
private:
Box m_repaint_area;
public:
WidgetRepaintRequestedEvent(Box repaint_area)
: m_repaint_area(repaint_area) {}
EventType get_type() { return EventType::WidgetRepaintRequested; }
const char *get_name() { return "WidgetRepaintRequested"; }
Box &get_repaint_area() { return m_repaint_area; }
};
}