6#include "imgui/imgui.h"
8#include <sigc++/sigc++.h>
20 template<
typename Functor>
27 template<
typename Predicate,
typename Functor>
35 template<
typename Functor>
43 template<
typename Predicate,
typename Functor>
69 Group(std::string_view name,
bool menu) :
70 label(std::string(name)),
83 void DrawOverview(
const char *title,
bool *pOpen =
nullptr);
90 void DrawGroup(std::string
id) { DrawMenuInternal(m_groupStorage.at(
id),
false); }
93 void DrawMenu(std::string
id) { DrawMenuInternal(m_groupStorage.at(
id),
true); }
112 std::vector<std::string> &
GetGroups() {
return m_topLevelGroups; }
118 void BeginInternal(std::string
id,
bool menu);
121 void AddInternal(std::string
id,
ActionEntry &&entry);
123 void DrawMenuInternal(Group &group,
bool menuHeading);
125 void DrawGroupOverviewEntry(Group &group);
127 std::map<std::string, ActionEntry> m_actionStorage;
128 std::map<std::string, Group> m_groupStorage;
130 std::vector<std::string> m_topLevelGroups;
132 std::vector<std::pair<std::string, Group *>> m_activeGroupStack;
Definition: ActionBinder.h:60
std::vector< std::string > & GetGroups()
Definition: ActionBinder.h:112
void DrawGroup(std::string id)
Definition: ActionBinder.h:90
std::variant< Group *, ActionEntry * > GroupEntry
Definition: ActionBinder.h:67
ActionBinder & BeginGroup(std::string id)
Definition: ActionBinder.h:102
ActionBinder & BeginMenu(std::string id)
Definition: ActionBinder.h:103
void DrawMenuBar()
Definition: ActionBinder.cpp:93
void EndMenu()
Definition: ActionBinder.h:105
ActionBinder()
Definition: ActionBinder.cpp:22
void TriggerAction(std::string id)
Definition: ActionBinder.cpp:202
~ActionBinder()
Definition: ActionBinder.cpp:26
ActionEntry * GetAction(std::string id)
Definition: ActionBinder.cpp:194
void DrawMenu(std::string id)
Definition: ActionBinder.h:93
void Update()
Definition: ActionBinder.cpp:39
ActionBinder & AddAction(std::string id, ActionEntry &&entry)
Definition: ActionBinder.h:110
void DrawOverview(const char *title, bool *pOpen=nullptr)
Definition: ActionBinder.cpp:83
static std::string FormatShortcut(ImGuiKeyChord shortcut)
Definition: ActionBinder.cpp:31
void EndGroup()
Definition: ActionBinder.h:104
Definition: ActionBinder.h:14
Definition: ActionBinder.h:68
std::string label
Definition: ActionBinder.h:74
bool isMenu
Definition: ActionBinder.h:76
std::vector< GroupEntry > entries
Definition: ActionBinder.h:75
Group(std::string_view name, bool menu)
Definition: ActionBinder.h:69
Definition: ActionBinder.h:19
ActionEntry(std::string_view label, ImGuiKeyChord shortcut, Functor f)
Definition: ActionBinder.h:21
std::string label
Definition: ActionBinder.h:52
ImGuiKeyChord shortcut
Definition: ActionBinder.h:54
ActionEntry(std::string_view label, ImGuiKeyChord shortcut, Predicate p, Functor f)
Definition: ActionBinder.h:28
ActionEntry(std::string_view label, const char *icon, ImGuiKeyChord shortcut, Functor f)
Definition: ActionBinder.h:36
sigc::slot< void()> action
Definition: ActionBinder.h:57
const char * fontIcon
Definition: ActionBinder.h:53
ActionEntry(std::string_view label, const char *icon, ImGuiKeyChord shortcut, Predicate p, Functor f)
Definition: ActionBinder.h:44
sigc::slot< bool()> predicate
Definition: ActionBinder.h:56