MiniEngine/MiniEngine_Event.h
kiritow 4630a157dc [Big Update] New Widget with new event framework
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.
2017-04-06 21:53:53 +08:00

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&);
};