Removed hover on guecs::UI::mouse and now use a generic 16 bit modifier bitset. Also finally fixed Clickable so it just a simple callback with only the modifiers.
This commit is contained in:
parent
4c019048d0
commit
5d0d8b16fc
5 changed files with 29 additions and 41 deletions
|
@ -10,6 +10,7 @@
|
|||
#include "guecs/theme.hpp"
|
||||
#include "guecs/sfml/components.hpp"
|
||||
#include <cassert>
|
||||
#include <bitset>
|
||||
|
||||
namespace guecs {
|
||||
using std::shared_ptr, std::wstring, std::string;
|
||||
|
@ -24,22 +25,25 @@ namespace guecs {
|
|||
std::queue<size_t> free_indices;
|
||||
};
|
||||
|
||||
enum class ModBit {
|
||||
hover=0,
|
||||
left=1,
|
||||
right=2
|
||||
};
|
||||
|
||||
using Modifiers = std::bitset<16>;
|
||||
|
||||
struct Clickable {
|
||||
/* This is actually called by UI::mouse and passed the entity ID of the
|
||||
* button pressed so you can interact with it in the event handler.
|
||||
*/
|
||||
std::function<void(Entity ent, std::any data)> action;
|
||||
};
|
||||
|
||||
struct ActionData {
|
||||
std::any data;
|
||||
std::function<void(Modifiers mods)> action;
|
||||
};
|
||||
|
||||
struct CellName {
|
||||
string name;
|
||||
};
|
||||
|
||||
|
||||
class UI {
|
||||
public:
|
||||
Entity MAIN = 0;
|
||||
|
@ -69,9 +73,8 @@ namespace guecs {
|
|||
|
||||
void init();
|
||||
void render(sf::RenderWindow& window);
|
||||
bool mouse(float x, float y, bool hover);
|
||||
void click_on(const string& name, bool required=false);
|
||||
void click_on(Entity slot_id);
|
||||
bool mouse(float x, float y, Modifiers mods);
|
||||
void click_on(Entity slot_id, Modifiers mods);
|
||||
void debug_layout(sf::RenderWindow& window);
|
||||
|
||||
Entity entity() { return ++entity_count; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue