Files
2026-06-08 19:58:35 +08:00

64 lines
1.1 KiB
C++

#pragma once
#include <frostbite2D/types/type_alias.h>
namespace frostbite2D {
class Actor;
enum class EventType : int32 {
None = 0,
WindowClose,
WindowResize,
WindowFocus,
WindowMinimize,
WindowMaximize,
WindowRestore,
KeyDown,
KeyUp,
KeyText,
MouseMove,
MouseButtonDown,
MouseButtonUp,
MouseWheel,
TouchDown,
TouchUp,
TouchMove,
JoystickAxis,
JoystickBall,
JoystickHat,
JoystickButtonDown,
JoystickButtonUp,
Custom
};
class Event {
public:
virtual ~Event() = default;
virtual EventType getType() const = 0;
bool isHandled() const { return handled_; }
void setHandled(bool handled) { handled_ = handled; }
bool isPropagationStopped() const { return propagationStopped_; }
void stopPropagation() { propagationStopped_ = true; }
Actor* getSource() const { return source_; }
void setSource(Actor* actor) { source_ = actor; }
uint32 getTimestamp() const { return timestamp_; }
protected:
Event() = default;
Event(uint32 timestamp)
: timestamp_(timestamp) {}
bool handled_ = false;
bool propagationStopped_ = false;
Actor* source_ = nullptr;
uint32 timestamp_ = 0;
};
}