From f14bdb7fe8d242fd35749f220f4b73897974d55d Mon Sep 17 00:00:00 2001 From: dijunkun Date: Thu, 27 Nov 2025 03:07:55 +0800 Subject: [PATCH] [feat] optimize UpdateNotificationWindow UI appearance --- src/gui/assets/layouts/layout.h | 7 +++++ .../windows/update_notification_window.cpp | 26 +++++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/gui/assets/layouts/layout.h b/src/gui/assets/layouts/layout.h index 193a788..55de48c 100644 --- a/src/gui/assets/layouts/layout.h +++ b/src/gui/assets/layouts/layout.h @@ -75,6 +75,13 @@ #define SELF_HOSTED_SERVER_CONFIG_OK_BUTTON_PADDING_EN 91 #define UPDATE_NOTIFICATION_OK_BUTTON_PADDING_CN 162 #define UPDATE_NOTIFICATION_OK_BUTTON_PADDING_EN 146 +#ifdef _WIN32 +#define UPDATE_NOTIFICATION_RESERVED_HEIGHT 130 +#elif __APPLE__ +#define UPDATE_NOTIFICATION_RESERVED_HEIGHT 100 +#else +#define UPDATE_NOTIFICATION_RESERVED_HEIGHT 100 +#endif #define REQUEST_PERMISSION_WINDOW_WIDTH_CN 130 #define REQUEST_PERMISSION_WINDOW_HEIGHT_CN 125 #define REQUEST_PERMISSION_WINDOW_WIDTH_EN 260 diff --git a/src/gui/windows/update_notification_window.cpp b/src/gui/windows/update_notification_window.cpp index 655e2ba..fe92570 100644 --- a/src/gui/windows/update_notification_window.cpp +++ b/src/gui/windows/update_notification_window.cpp @@ -58,6 +58,12 @@ int Render::UpdateNotificationWindow() { float window_width = update_notification_window_width_; float window_height = update_notification_window_height_; +#ifdef __APPLE__ + float font_scale = 0.3f; +#else + float font_scale = 0.5f; +#endif + ImGui::SetNextWindowPos( ImVec2( (viewport->WorkSize.x - viewport->WorkPos.x - window_width) / 2, @@ -70,29 +76,27 @@ int Render::UpdateNotificationWindow() { ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 5.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); - ImGui::SetWindowFontScale(0.5f); ImGui::Begin( localization::notification[localization_language_index_].c_str(), nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | - ImGuiWindowFlags_NoSavedSettings); + ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar); - ImGui::SetWindowFontScale(1.0f); - ImGui::SetWindowFontScale(0.5f); - - // use system Chinese font if (system_chinese_font_ != nullptr) { ImGui::PushFont(system_chinese_font_); } + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + ImGui::GetTextLineHeight() + + 5.0f); + // title: new version available ImGui::SetCursorPosX(window_width * 0.1f); - ImGui::SetWindowFontScale(0.7f); + ImGui::SetWindowFontScale(font_scale + 0.2f); std::string title = localization::new_version_available[localization_language_index_] + ": v" + latest_version_; ImGui::Text("%s", title.c_str()); - ImGui::SetWindowFontScale(0.5f); + ImGui::SetWindowFontScale(font_scale); ImGui::Spacing(); @@ -104,8 +108,8 @@ int Render::UpdateNotificationWindow() { ImGui::Spacing(); - float reserved_height = 140.0f; - float scrollable_height = window_height - reserved_height; + float scrollable_height = + window_height - UPDATE_NOTIFICATION_RESERVED_HEIGHT; // scrollable content area ImGui::SetCursorPosX(window_width * 0.05f); @@ -187,7 +191,7 @@ int Render::UpdateNotificationWindow() { } ImGui::SetWindowFontScale(1.0f); - ImGui::SetWindowFontScale(0.5f); + ImGui::SetWindowFontScale(font_scale); // pop system font if (system_chinese_font_ != nullptr) {