diff options
Diffstat (limited to 'source/EditorCommandPalette.hpp')
-rw-r--r-- | source/EditorCommandPalette.hpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/source/EditorCommandPalette.hpp b/source/EditorCommandPalette.hpp new file mode 100644 index 0000000..1603f41 --- /dev/null +++ b/source/EditorCommandPalette.hpp @@ -0,0 +1,49 @@ +#pragma once + +#include <imgui.h> +#include <cstddef> +#include <cstdint> +#include <functional> +#include <string> +#include <vector> + +enum ImCmdTextType { + ImCmdTextType_Regular, + ImCmdTextType_Highlight, + ImCmdTextType_COUNT, +}; + +namespace ImCmd { +struct Command { + const char* Name; + std::function<void()> InitialCallback; + std::function<void(int selected_option)> SubsequentCallback; + std::function<void()> TerminatingCallback; +}; + +// Command management +void AddCommand(Command command); +void RemoveCommand(const char* name); + +// Styling +void SetStyleFont(ImCmdTextType type, ImFont* font); +void SetStyleColor(ImCmdTextType type, ImU32 color); +void ClearStyleColor(ImCmdTextType type); //< Clear the style color for the given type, defaulting to ImGuiCol_Text + +// Command palette widget +void SetNextCommandPaletteSearch(const char* text); +void SetNextCommandPaletteSearchBoxFocused(); +void ShowCommandPalette(const char* name); +bool IsAnyItemSelected(); + +void RemoveCache(const char* name); +void RemoveAllCaches(); + +// Command palette widget in a window helper +void SetNextWindowAffixedTop(ImGuiCond cond = 0); +void ShowCommandPaletteWindow(const char* name, bool* p_open); + +// Command responses, only call these in command callbacks (except TerminatingCallback) +void Prompt(std::vector<std::string> options); + +} // namespace ImCmd |