From 60de8b0e909017a4c5424df31fe4bbfa763542b3 Mon Sep 17 00:00:00 2001 From: YohananDiamond Date: Mon, 3 Jul 2023 16:01:46 -0300 Subject: [PATCH] command palette: (breaking) attempt to center the window --- src/gui/commandPalette.cpp | 6 ++++-- src/gui/gui.cpp | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/commandPalette.cpp b/src/gui/commandPalette.cpp index b30468313..bd36b3eb0 100644 --- a/src/gui/commandPalette.cpp +++ b/src/gui/commandPalette.cpp @@ -51,7 +51,9 @@ void FurnaceGUI::drawPalette() { if (paletteFirstFrame) ImGui::SetKeyboardFocusHere(); - ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + int width=ImGui::GetContentRegionAvail().x; + + ImGui::SetNextItemWidth(width); if (ImGui::InputTextWithHint("##CommandPaletteSearch","Search...",&paletteQuery) || paletteFirstFrame) { paletteSearchResults.clear(); @@ -81,7 +83,7 @@ void FurnaceGUI::drawPalette() { }; } - if (ImGui::BeginChild("CommandPaletteList",ImVec2(312,216),false,0)) { + if (ImGui::BeginChild("CommandPaletteList",ImVec2(width,canvasH*0.3),false,0)) { bool navigated=false; if (ImGui::IsKeyPressed(ImGuiKey_UpArrow) && curPaletteChoice>0) { curPaletteChoice-=1; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 105599dc2..b89406b76 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -5137,6 +5137,9 @@ bool FurnaceGUI::loop() { } if (ImGui::BeginPopup("Command Palette",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) { + ImVec2 wsize=ImVec2(canvasW*0.8,canvasH*0.4); + ImGui::SetWindowSize(wsize,ImGuiCond_Always); + ImGui::SetWindowPos(ImVec2((canvasW-wsize.x)*0.5,100*dpiScale)); drawPalette(); ImGui::EndPopup(); }