diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 67f5cf0..ab697d4 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -55,6 +55,10 @@ struct AppWindows { std::unique_ptr settings; std::vector> picross; + struct + { + WindowLayout settings; + } layout; }; void main_menu_bar(AppWindows& windows, bool& application_should_close, bool& gui_dark_mode) @@ -185,7 +189,7 @@ int main(int argc, char *argv[]) if (windows.settings) { bool can_be_erased = false; - windows.settings->visit(can_be_erased); + windows.settings->visit(can_be_erased, windows.layout.settings); assert(can_be_erased == false); // Always ON } @@ -195,7 +199,7 @@ int main(int argc, char *argv[]) #endif // We delay the Settings window opening until after the first ImGui rendering pass so that the actual work space - // is known on first visit. This may be important for ImGui::Set* functions with ImGuiCond_Once. + // is known on first visit(). This is important for ImGui::Set* functions with flag ImGuiCond_Once. if (!windows.settings) { windows.settings = std::make_unique(settings); } // Rendering diff --git a/src/gui/src/settings_window.cpp b/src/gui/src/settings_window.cpp index 804f1c4..207eea0 100644 --- a/src/gui/src/settings_window.cpp +++ b/src/gui/src/settings_window.cpp @@ -3,6 +3,7 @@ #include "settings.h" #include +#include "imgui_helpers.h" #include @@ -13,12 +14,13 @@ SettingsWindow::SettingsWindow(Settings& settings) { } -void SettingsWindow::visit(bool& can_be_erased) +void SettingsWindow::visit(bool& can_be_erased, const WindowLayout& win_pos_sz) { can_be_erased = false; // Cannot close ImGui::SetNextWindowSizeConstraints(ImVec2(0, 300), ImVec2(FLT_MAX, 600)); + ImGui::SetNextWindowPosAndSize(win_pos_sz, ImGuiCond_Once); constexpr ImGuiWindowFlags win_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings; diff --git a/src/gui/src/settings_window.h b/src/gui/src/settings_window.h index adcfb1c..d6eb1b3 100644 --- a/src/gui/src/settings_window.h +++ b/src/gui/src/settings_window.h @@ -1,5 +1,7 @@ #pragma once +#include "window_layout.h" + #include class Settings; @@ -11,7 +13,7 @@ class SettingsWindow SettingsWindow(const SettingsWindow&) = delete; SettingsWindow& operator=(const SettingsWindow&) = delete; - void visit(bool& can_be_erased); + void visit(bool& can_be_erased, const WindowLayout& win_pos_sz); private: struct Animation