16 if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
17 ImGui::OpenPopup(
"WhichKey");
20 ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - 100),
22 ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, 100),
24 if (ImGui::BeginPopup(
"WhichKey")) {
26 if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
27 ImGui::CloseCurrentPopup();
30 const ImVec4 colors[] = {
31 ImVec4(0.8f, 0.2f, 0.2f, 1.0f),
32 ImVec4(0.2f, 0.8f, 0.2f, 1.0f),
33 ImVec4(0.2f, 0.2f, 0.8f, 1.0f),
34 ImVec4(0.8f, 0.8f, 0.2f, 1.0f),
35 ImVec4(0.8f, 0.2f, 0.8f, 1.0f),
36 ImVec4(0.2f, 0.8f, 0.8f, 1.0f)
38 const int numColors =
sizeof(colors) /
sizeof(colors[0]);
41 if (ImGui::BeginTable(
"CommandsTable",
commands_.size(),
42 ImGuiTableFlags_SizingStretchProp)) {
43 for (
const auto& [shortcut, group] :
commands_) {
44 ImGui::TableNextColumn();
45 ImGui::TextColored(colors[colorIndex],
"%c: %s",
46 group.main_command.mnemonic,
47 group.main_command.name.c_str());
48 colorIndex = (colorIndex + 1) % numColors;
86 ImGui::OpenPopup(
"WhichKeyHierarchical");
90 if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
95 ImGui::CloseCurrentPopup();
100 ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - 150),
102 ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, 150),
105 if (ImGui::BeginPopup(
"WhichKeyHierarchical")) {
113 ImGui::CloseCurrentPopup();
129 const ImVec4 colors[] = {
130 ImVec4(0.8f, 0.2f, 0.2f, 1.0f),
131 ImVec4(0.2f, 0.8f, 0.2f, 1.0f),
132 ImVec4(0.2f, 0.2f, 0.8f, 1.0f),
133 ImVec4(0.8f, 0.8f, 0.2f, 1.0f),
134 ImVec4(0.8f, 0.2f, 0.8f, 1.0f),
135 ImVec4(0.2f, 0.8f, 0.8f, 1.0f)
141 if (ImGui::BeginTable(
"RootCommands", 6,
142 ImGuiTableFlags_SizingStretchProp)) {
144 for (
const auto& [shortcut, group] :
commands_) {
145 ImGui::TableNextColumn();
146 ImGui::TextColored(colors[colorIndex % 6],
"%c: %s",
147 group.main_command.mnemonic,
148 group.main_command.name.c_str());
157 const auto& group = it->second;
158 if (!group.subcommands.empty()) {
159 if (ImGui::BeginTable(
"Subcommands",
160 std::min(6, (
int)group.subcommands.size()),
161 ImGuiTableFlags_SizingStretchProp)) {
163 for (
const auto& [key, cmd] : group.subcommands) {
164 ImGui::TableNextColumn();
165 ImGui::TextColored(colors[colorIndex % 6],
"%c: %s", cmd.mnemonic,
172 ImGui::TextDisabled(tr(
"No subcommands available"));