MiniEngine/MiniEngine_Event.h

60 lines
1.1 KiB
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
2017-04-25 10:15:12 +08:00
namespace MiniEngine
{
namespace EventSystem
{
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&);
};
2017-04-25 12:09:35 +08:00
class KeyEvent : public EventBase
2017-04-25 10:18:26 +08:00
{
public:
int key;
void update(const EventBase&);
};
2017-04-05 08:34:01 +08:00
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-25 10:18:26 +08:00
virtual bool onKeyDown(const KeyEvent&);
virtual bool onKeyUp(const KeyEvent&);
2017-04-04 21:56:19 +08:00
};
2017-04-25 10:15:12 +08:00
}/// End of namespace MiniEngine::EventSystem
}/// End of namespace MiniEngine