mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
kiritow
4630a157dc
New Event Framework Events from SDL2 will be dispatched in Frame::run(). In class Frame, events are dispatched to Board::event(), and Board with dispatched them to inner Board or Widget. If an event is not solved, the Frame will try to solve it.
41 lines
768 B
C++
41 lines
768 B
C++
#pragma once
|
|
#include "MiniEngine.h"
|
|
|
|
class EventBase
|
|
{
|
|
public:
|
|
EventBase()=default;
|
|
EventBase(SDL_Event);
|
|
protected:
|
|
SDL_Event e;
|
|
virtual void update(const EventBase&);
|
|
friend class EventHandlerBase;
|
|
};
|
|
|
|
class MouseMotionEvent : public EventBase
|
|
{
|
|
public:
|
|
int x,y;
|
|
void update(const EventBase&);
|
|
};
|
|
|
|
enum class MouseButton { Left, Middle, Right, X1, X2 };
|
|
|
|
class MouseButtonEvent : public EventBase
|
|
{
|
|
public:
|
|
int x,y;
|
|
MouseButton button;
|
|
void update(const EventBase&);
|
|
};
|
|
|
|
class EventHandlerBase
|
|
{
|
|
public:
|
|
virtual bool event(const EventBase&);
|
|
protected:
|
|
virtual bool onMouseDown(const MouseButtonEvent&);
|
|
virtual bool onMouseUp(const MouseButtonEvent&);
|
|
virtual bool onMouseMotion(const MouseMotionEvent&);
|
|
};
|