command palette show shortcuts (for actions)

This commit is contained in:
Adam Lederer 2024-08-29 20:08:29 -07:00
parent 29526d47fb
commit 639e7d11b0

View file

@ -25,6 +25,7 @@
#include <algorithm>
#include <ctype.h>
#include "../ta-log.h"
#include "util.h"
struct MatchScore {
size_t charsBeforeNeedle=0;
@ -268,6 +269,10 @@ void FurnaceGUI::drawPalette() {
navigated=true;
}
int columnCount=curPaletteType==CMDPAL_TYPE_MAIN ? 2 : 1;
if (ImGui::BeginTable("##commandPaletteTable",columnCount,ImGuiTableFlags_SizingStretchProp)) {
// ImGui::TableSetupColumn("##action",ImGuiTableColumnFlags_WidthStretch);
// ImGui::TableSetupColumn("##shortcut");
for (int i=0; i<(int)paletteSearchResults.size(); i++) {
bool current=(i==curPaletteChoice);
int id=paletteSearchResults[i].id;
@ -299,6 +304,9 @@ void FurnaceGUI::drawPalette() {
break;
};
ImGui::TableNextRow();
ImGui::TableNextColumn();
ImGui::PushID(s.c_str());
bool selectable=ImGui::Selectable("##paletteSearchItem",current,ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowOverlap);
const char* str=s.c_str();
@ -313,13 +321,23 @@ void FurnaceGUI::drawPalette() {
}
ImGui::SameLine(0.0f,0.0f);
ImGui::Text("%.*s", (int)(s.length()-chCursor), str+chCursor);
if (curPaletteType==CMDPAL_TYPE_MAIN) {
ImGui::TableNextColumn();
ImGui::TextColored(uiColors[GUI_COLOR_TEXT_DISABLED], "%s", getKeyName(actionKeys[paletteSearchResults[i].id], true).c_str());
}
if (selectable) {
curPaletteChoice=i;
accepted=true;
}
ImGui::PopID();
if ((navigated || paletteFirstFrame) && current) ImGui::SetScrollHereY();
}
ImGui::EndTable();
}
}
ImGui::EndChild();