15 if (ImGui::IsKeyPressed(ImGuiKey_Space)) {
16 ImGui::OpenPopup(
"WhichKey");
19 ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - 100),
21 ImGui::SetNextWindowSize(ImVec2(ImGui::GetIO().DisplaySize.x, 100),
23 if (ImGui::BeginPopup(
"WhichKey")) {
25 if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
26 ImGui::CloseCurrentPopup();
29 const ImVec4 colors[] = {
30 ImVec4(0.8f, 0.2f, 0.2f, 1.0f),
31 ImVec4(0.2f, 0.8f, 0.2f, 1.0f),
32 ImVec4(0.2f, 0.2f, 0.8f, 1.0f),
33 ImVec4(0.8f, 0.8f, 0.2f, 1.0f),
34 ImVec4(0.8f, 0.2f, 0.8f, 1.0f),
35 ImVec4(0.2f, 0.8f, 0.8f, 1.0f)
37 const int numColors =
sizeof(colors) /
sizeof(colors[0]);
40 if (ImGui::BeginTable(
"CommandsTable",
commands_.size(),
41 ImGuiTableFlags_SizingStretchProp)) {
42 for (
const auto &[shortcut, info] :
commands_) {
43 ImGui::TableNextColumn();
44 ImGui::TextColored(colors[colorIndex],
"%c: %s",
45 info.command_info.mnemonic,
46 info.command_info.name.c_str());
47 colorIndex = (colorIndex + 1) % numColors;