77 if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
78 ImGui::OpenPopup(
"WhichKey");
81 ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - 100),
83 ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, 100),
85 if (ImGui::BeginPopup(
"WhichKey")) {
87 if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
88 ImGui::CloseCurrentPopup();
91 const ImVec4 colors[] = {
92 ImVec4(0.8f, 0.2f, 0.2f, 1.0f),
93 ImVec4(0.2f, 0.8f, 0.2f, 1.0f),
94 ImVec4(0.2f, 0.2f, 0.8f, 1.0f),
95 ImVec4(0.8f, 0.8f, 0.2f, 1.0f),
96 ImVec4(0.8f, 0.2f, 0.8f, 1.0f),
97 ImVec4(0.2f, 0.8f, 0.8f, 1.0f)
99 const int numColors =
sizeof(colors) /
sizeof(colors[0]);
102 if (ImGui::BeginTable(
"CommandsTable",
commands_.size(),
103 ImGuiTableFlags_SizingStretchProp)) {
104 for (
const auto &[shortcut, info] :
commands_) {
105 ImGui::TableNextColumn();
106 ImGui::TextColored(colors[colorIndex],
"%c: %s",
107 info.command_info.mnemonic,
108 info.command_info.name.c_str());
109 colorIndex = (colorIndex + 1) % numColors;