Initial first steps in pulling the SFML event processing out of the gui::fsm so that I can handle more complex things like drag and drop.
This commit is contained in:
parent
0674908e49
commit
5aa54d875f
9 changed files with 194 additions and 146 deletions
43
gui/event_router.hpp
Normal file
43
gui/event_router.hpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
#include "events.hpp"
|
||||
#include "simplefsm.hpp"
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
namespace gui {
|
||||
namespace routing {
|
||||
enum class State {
|
||||
START,
|
||||
IDLE,
|
||||
MOUSE_ACTIVE,
|
||||
MOUSE_MOVING,
|
||||
};
|
||||
|
||||
enum class Event {
|
||||
STARTED=0,
|
||||
MOUSE_DOWN=1,
|
||||
MOUSE_UP=2,
|
||||
MOUSE_MOVE=3,
|
||||
KEY_PRESS=4
|
||||
};
|
||||
|
||||
class Router : public DeadSimpleFSM<State, Event> {
|
||||
public:
|
||||
sf::Vector2i position;
|
||||
sf::Keyboard::Scancode scancode;
|
||||
gui::Event $next_event = gui::Event::TICK;
|
||||
|
||||
void event(Event ev);
|
||||
|
||||
void START(Event ev);
|
||||
void IDLE(Event ev);
|
||||
void MOUSE_ACTIVE(Event ev);
|
||||
void MOUSE_MOVING(Event ev);
|
||||
|
||||
gui::Event process_event(std::optional<sf::Event> ev);
|
||||
|
||||
void set_event(gui::Event ev) {
|
||||
$next_event = ev;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue