14#include <lagrange/ui/api.h>
15#include <lagrange/ui/types/GLContext.h>
38 enum class KeyState { NONE, PRESSED, DOWN, RELEASED };
49 Keybind(ImGuiKey btn,
const std::vector<ImGuiKey>& modifier_keys = {});
50 ImGuiKey button = ImGuiKey_None;
51 int modifier_count = 0;
52 KeyState previous_state = KeyState::NONE;
53 KeyState current_state = KeyState::NONE;
54 std::array<ImGuiKey, 6> modifiers = {
66 using MapType = std::map<std::string, std::vector<Keybind>>;
76 void push_context(
const std::string& context);
93 add(
const std::string& action, ImGuiKey button,
const std::vector<ImGuiKey>& modifiers = {});
102 const std::string& action,
104 const std::vector<ImGuiKey>& modifiers = {})
114 void add(
const std::string& action,
const Keybind& keybind);
119 const MapType& get()
const;
125 bool remove(
const std::string& action);
131 bool unregister_action(
const std::string& action);
137 bool register_action(
const std::string& action);
143 bool is_pressed(
const std::string& action)
const;
148 inline bool is_pressed(ImGuiKey key_code)
const {
return ImGui::IsKeyPressed(key_code); }
153 bool is_down(
const std::string& action)
const;
158 inline bool is_down(ImGuiKey key_code)
const {
return ImGui::IsKeyDown(key_code); }
163 bool is_released(
const std::string& action)
const;
168 inline bool is_released(ImGuiKey key_code)
const {
return ImGui::IsKeyReleased(key_code); }
173 bool save(std::ostream& out)
const;
180 bool load(std::istream& in,
bool append =
false);
187 void enable(
bool enabled);
190 bool is_enabled()
const;
194 static std::string to_string(
const Keybind& keybind);
197 static std::string to_string(ImGuiKey key);
200 std::string to_string(
const std::string& action,
int limit = 1)
const;
204 bool m_enabled =
true;
205 std::vector<std::string> m_context_stack;
207 bool is_action_in_state(
const std::string& action, KeyState state)
const;
Stores keybinds for actions.
Definition: Keybinds.h:36
bool is_pressed(ImGuiKey key_code) const
Returns true if key was just pressed.
Definition: Keybinds.h:148
bool is_released(ImGuiKey key_code) const
Returns true if key was just released.
Definition: Keybinds.h:168
std::map< std::string, std::vector< Keybind > > MapType
Internal map type.
Definition: Keybinds.h:66
bool is_down(ImGuiKey key_code) const
Returns true if key is held down.
Definition: Keybinds.h:158
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
LA_UI_API void remove(Registry &r, Entity e, bool recursive=false)
Removes entity.
Definition: treenode.cpp:47
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Key/mouse shortcut.
Definition: Keybinds.h:48