diff --git a/src/main_window/main_window.cpp b/src/main_window/main_window.cpp index c1245bf..7a6ca68 100644 --- a/src/main_window/main_window.cpp +++ b/src/main_window/main_window.cpp @@ -519,12 +519,24 @@ int MainWindow::Run() { if (ImGui::Button(settings_button_label_.c_str())) { settings_button_pressed_ = !settings_button_pressed_; + settings_window_pos_reset_ = true; } if (settings_button_pressed_) { - ImGui::SetNextWindowSize(ImVec2( - localization::settings_window_width[localization_language_index_], - 190)); + if (settings_window_pos_reset_) { + const ImGuiViewport *viewport = ImGui::GetMainViewport(); + ImGui::SetNextWindowPos( + ImVec2((viewport->WorkSize.x - viewport->WorkPos.x - + localization::settings_window_width + [localization_language_index_]) / + 2, + (viewport->WorkSize.y - viewport->WorkPos.y - 190) / 2)); + + ImGui::SetNextWindowSize(ImVec2( + localization::settings_window_width[localization_language_index_], + 190)); + settings_window_pos_reset_ = false; + } ImGui::Begin( localization::settings[localization_language_index_].c_str(), @@ -657,6 +669,7 @@ int MainWindow::Run() { SaveSettingsIntoCacheFile(); // To do: set encode resolution + settings_window_pos_reset_ = true; } ImGui::SameLine(); // Cancel @@ -676,6 +689,7 @@ int MainWindow::Run() { video_video_encode_format_button_value_ = video_video_encode_format_button_value_last_; } + settings_window_pos_reset_ = true; } ImGui::End(); diff --git a/src/main_window/main_window.h b/src/main_window/main_window.h index e225a9b..f81a979 100644 --- a/src/main_window/main_window.h +++ b/src/main_window/main_window.h @@ -185,6 +185,9 @@ class MainWindow { std::atomic start_mouse_control_{false}; std::atomic screen_capture_is_started_{false}; std::atomic mouse_control_is_started_{false}; + + private: + bool settings_window_pos_reset_ = true; }; #endif \ No newline at end of file