Reset settings window position before it is opened

This commit is contained in:
dijunkun
2024-06-06 09:55:08 +08:00
parent 280f59f97d
commit f7fd37651e
2 changed files with 20 additions and 3 deletions

View File

@@ -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();

View File

@@ -185,6 +185,9 @@ class MainWindow {
std::atomic<bool> start_mouse_control_{false};
std::atomic<bool> screen_capture_is_started_{false};
std::atomic<bool> mouse_control_is_started_{false};
private:
bool settings_window_pos_reset_ = true;
};
#endif