2021-08-15 20:04:53 +02:00
|
|
|
#ifndef BWIDGETS_EVENT_HANDLER_HPP
|
|
|
|
#define BWIDGETS_EVENT_HANDLER_HPP
|
|
|
|
|
|
|
|
#include <functional>
|
2021-08-24 00:12:57 +02:00
|
|
|
|
2021-08-15 20:04:53 +02:00
|
|
|
#include <SDL_events.h>
|
|
|
|
|
|
|
|
namespace bwidgets
|
|
|
|
{
|
|
|
|
class EventHandler
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
EventHandler() = default;
|
|
|
|
|
|
|
|
public:
|
2021-08-21 20:59:39 +02:00
|
|
|
using handler_t =
|
|
|
|
std::pair<SDL_EventType, std::function<void(const SDL_Event&)>>;
|
|
|
|
|
2021-08-15 20:04:53 +02:00
|
|
|
EventHandler(const EventHandler&) = delete;
|
|
|
|
EventHandler(EventHandler&&) = delete;
|
|
|
|
auto operator=(const EventHandler&) -> EventHandler& = delete;
|
|
|
|
auto operator=(EventHandler&&) -> EventHandler& = delete;
|
|
|
|
|
|
|
|
virtual ~EventHandler() = default;
|
|
|
|
|
2021-08-27 01:21:25 +02:00
|
|
|
// Pass the event to be handled.
|
2021-08-15 20:04:53 +02:00
|
|
|
virtual void handle_event(const SDL_Event&) = 0;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|