14 if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
15 ImGui::OpenPopup(
"WhichKey");
18 ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - 100),
20 ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, 100),
22 if (ImGui::BeginPopup(
"WhichKey")) {
24 if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
25 ImGui::CloseCurrentPopup();
28 const ImVec4 colors[] = {
29 ImVec4(0.8f, 0.2f, 0.2f, 1.0f),
30 ImVec4(0.2f, 0.8f, 0.2f, 1.0f),
31 ImVec4(0.2f, 0.2f, 0.8f, 1.0f),
32 ImVec4(0.8f, 0.8f, 0.2f, 1.0f),
33 ImVec4(0.8f, 0.2f, 0.8f, 1.0f),
34 ImVec4(0.2f, 0.8f, 0.8f, 1.0f)
36 const int numColors =
sizeof(colors) /
sizeof(colors[0]);
39 if (ImGui::BeginTable(
"CommandsTable",
commands_.size(),
40 ImGuiTableFlags_SizingStretchProp)) {
41 for (
const auto& [shortcut, group] :
commands_) {
42 ImGui::TableNextColumn();
43 ImGui::TextColored(colors[colorIndex],
"%c: %s",
44 group.main_command.mnemonic,
45 group.main_command.name.c_str());
46 colorIndex = (colorIndex + 1) % numColors;
84 ImGui::OpenPopup(
"WhichKeyHierarchical");
88 if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
93 ImGui::CloseCurrentPopup();
98 ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - 150),
100 ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, 150),
103 if (ImGui::BeginPopup(
"WhichKeyHierarchical")) {
111 ImGui::CloseCurrentPopup();
118 ImGui::TextColored(ImVec4(0.5f, 0.8f, 1.0f, 1.0f),
"Space > %s",
122 ImGui::TextColored(ImVec4(0.5f, 0.8f, 1.0f, 1.0f),
"Space > ...");
127 const ImVec4 colors[] = {
128 ImVec4(0.8f, 0.2f, 0.2f, 1.0f),
129 ImVec4(0.2f, 0.8f, 0.2f, 1.0f),
130 ImVec4(0.2f, 0.2f, 0.8f, 1.0f),
131 ImVec4(0.8f, 0.8f, 0.2f, 1.0f),
132 ImVec4(0.8f, 0.2f, 0.8f, 1.0f),
133 ImVec4(0.2f, 0.8f, 0.8f, 1.0f)
139 if (ImGui::BeginTable(
"RootCommands", 6,
140 ImGuiTableFlags_SizingStretchProp)) {
142 for (
const auto& [shortcut, group] :
commands_) {
143 ImGui::TableNextColumn();
144 ImGui::TextColored(colors[colorIndex % 6],
"%c: %s",
145 group.main_command.mnemonic,
146 group.main_command.name.c_str());
155 const auto& group = it->second;
156 if (!group.subcommands.empty()) {
157 if (ImGui::BeginTable(
"Subcommands",
158 std::min(6, (
int)group.subcommands.size()),
159 ImGuiTableFlags_SizingStretchProp)) {
161 for (
const auto& [key, cmd] : group.subcommands) {
162 ImGui::TableNextColumn();
163 ImGui::TextColored(colors[colorIndex % 6],
"%c: %s", cmd.mnemonic,
170 ImGui::TextDisabled(
"No subcommands available");