command palette: now a modal + proper sizing&centering

This commit is contained in:
YohananDiamond 2023-07-03 16:38:08 -03:00
parent 60de8b0e90
commit b19f7cfdd8
2 changed files with 7 additions and 5 deletions

View file

@ -52,7 +52,6 @@ void FurnaceGUI::drawPalette() {
ImGui::SetKeyboardFocusHere(); ImGui::SetKeyboardFocusHere();
int width=ImGui::GetContentRegionAvail().x; int width=ImGui::GetContentRegionAvail().x;
ImGui::SetNextItemWidth(width); ImGui::SetNextItemWidth(width);
if (ImGui::InputTextWithHint("##CommandPaletteSearch","Search...",&paletteQuery) || paletteFirstFrame) { if (ImGui::InputTextWithHint("##CommandPaletteSearch","Search...",&paletteQuery) || paletteFirstFrame) {
@ -83,7 +82,10 @@ void FurnaceGUI::drawPalette() {
}; };
} }
if (ImGui::BeginChild("CommandPaletteList",ImVec2(width,canvasH*0.3),false,0)) { ImVec2 avail=ImGui::GetContentRegionAvail();
avail.y-=ImGui::GetFrameHeightWithSpacing();
if (ImGui::BeginChild("CommandPaletteList",avail,false,0)) {
bool navigated=false; bool navigated=false;
if (ImGui::IsKeyPressed(ImGuiKey_UpArrow) && curPaletteChoice>0) { if (ImGui::IsKeyPressed(ImGuiKey_UpArrow) && curPaletteChoice>0) {
curPaletteChoice-=1; curPaletteChoice-=1;

View file

@ -5136,10 +5136,10 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup(); ImGui::EndPopup();
} }
if (ImGui::BeginPopup("Command Palette",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) { if (ImGui::BeginPopupModal("Command Palette",NULL,ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings)) {
ImVec2 wsize=ImVec2(canvasW*0.8,canvasH*0.4); ImVec2 wsize=ImVec2(canvasW*0.9,canvasH*0.4);
ImGui::SetWindowPos(ImVec2((canvasW-wsize.x)*0.5,50*dpiScale));
ImGui::SetWindowSize(wsize,ImGuiCond_Always); ImGui::SetWindowSize(wsize,ImGuiCond_Always);
ImGui::SetWindowPos(ImVec2((canvasW-wsize.x)*0.5,100*dpiScale));
drawPalette(); drawPalette();
ImGui::EndPopup(); ImGui::EndPopup();
} }