MiniEngine/MiniEngine_Event.h

41 lines
768 B
C
Raw Normal View History

2017-04-04 09:49:18 +08:00
#pragma once
#include "MiniEngine.h"
2017-04-04 21:56:19 +08:00
class EventBase
{
public:
EventBase()=default;
EventBase(SDL_Event);
2017-04-04 21:56:19 +08:00
protected:
SDL_Event e;
2017-04-05 08:34:01 +08:00
virtual void update(const EventBase&);
friend class EventHandlerBase;
2017-04-04 21:56:19 +08:00
};
2017-04-05 08:34:01 +08:00
class MouseMotionEvent : public EventBase
2017-04-04 21:56:19 +08:00
{
public:
2017-04-05 08:34:01 +08:00
int x,y;
void update(const EventBase&);
};
enum class MouseButton { Left, Middle, Right, X1, X2 };
2017-04-05 08:34:01 +08:00
class MouseButtonEvent : public EventBase
{
public:
int x,y;
MouseButton button;
2017-04-05 08:34:01 +08:00
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&);
2017-04-04 21:56:19 +08:00
};