command palette: (breaking) attempt to center the window

This commit is contained in:
YohananDiamond 2023-07-03 16:01:46 -03:00
parent e454433199
commit 60de8b0e90
2 changed files with 7 additions and 2 deletions

View file

@ -51,7 +51,9 @@ void FurnaceGUI::drawPalette() {
if (paletteFirstFrame) if (paletteFirstFrame)
ImGui::SetKeyboardFocusHere(); ImGui::SetKeyboardFocusHere();
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); int width=ImGui::GetContentRegionAvail().x;
ImGui::SetNextItemWidth(width);
if (ImGui::InputTextWithHint("##CommandPaletteSearch","Search...",&paletteQuery) || paletteFirstFrame) { if (ImGui::InputTextWithHint("##CommandPaletteSearch","Search...",&paletteQuery) || paletteFirstFrame) {
paletteSearchResults.clear(); 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; bool navigated=false;
if (ImGui::IsKeyPressed(ImGuiKey_UpArrow) && curPaletteChoice>0) { if (ImGui::IsKeyPressed(ImGuiKey_UpArrow) && curPaletteChoice>0) {
curPaletteChoice-=1; curPaletteChoice-=1;

View file

@ -5137,6 +5137,9 @@ bool FurnaceGUI::loop() {
} }
if (ImGui::BeginPopup("Command Palette",ImGuiWindowFlags_NoMove|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings)) { 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(); drawPalette();
ImGui::EndPopup(); ImGui::EndPopup();
} }