[fix] fix UpdateNotificationWindow dpi scaling

This commit is contained in:
dijunkun
2025-12-01 13:52:39 +08:00
parent 131b4f1795
commit 8d09bf53c3
4 changed files with 3085 additions and 3073 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -77,13 +77,7 @@
#define SELF_HOSTED_SERVER_CONFIG_OK_BUTTON_PADDING_EN 91 * dpi_scale_ #define SELF_HOSTED_SERVER_CONFIG_OK_BUTTON_PADDING_EN 91 * dpi_scale_
#define UPDATE_NOTIFICATION_OK_BUTTON_PADDING_CN 162 * dpi_scale_ #define UPDATE_NOTIFICATION_OK_BUTTON_PADDING_CN 162 * dpi_scale_
#define UPDATE_NOTIFICATION_OK_BUTTON_PADDING_EN 146 * dpi_scale_ #define UPDATE_NOTIFICATION_OK_BUTTON_PADDING_EN 146 * dpi_scale_
#ifdef _WIN32 #define UPDATE_NOTIFICATION_RESERVED_HEIGHT 120 * dpi_scale_
#define UPDATE_NOTIFICATION_RESERVED_HEIGHT 130 * dpi_scale_
#elif __APPLE__
#define UPDATE_NOTIFICATION_RESERVED_HEIGHT 100 * dpi_scale_
#else
#define UPDATE_NOTIFICATION_RESERVED_HEIGHT 100 * dpi_scale_
#endif
#define REQUEST_PERMISSION_WINDOW_WIDTH_CN 130 * dpi_scale_ #define REQUEST_PERMISSION_WINDOW_WIDTH_CN 130 * dpi_scale_
#define REQUEST_PERMISSION_WINDOW_HEIGHT_CN 125 * dpi_scale_ #define REQUEST_PERMISSION_WINDOW_HEIGHT_CN 125 * dpi_scale_
#define REQUEST_PERMISSION_WINDOW_WIDTH_EN 260 * dpi_scale_ #define REQUEST_PERMISSION_WINDOW_WIDTH_EN 260 * dpi_scale_

View File

@@ -37,7 +37,7 @@ int Render::RecentConnectionsWindow() {
} }
int Render::ShowRecentConnections() { int Render::ShowRecentConnections() {
ImGui::SetCursorPosX(25.0f); ImGui::SetCursorPosX(25.0f * dpi_scale_);
ImVec2 sub_window_pos = ImGui::GetCursorPos(); ImVec2 sub_window_pos = ImGui::GetCursorPos();
std::map<std::string, ImVec2> sub_containers_pos; std::map<std::string, ImVec2> sub_containers_pos;
float recent_connection_sub_container_width = float recent_connection_sub_container_width =
@@ -115,10 +115,11 @@ int Render::ShowRecentConnections() {
it.second.remote_host_name = "unknown"; it.second.remote_host_name = "unknown";
} }
ImVec2 image_screen_pos = ImVec2(ImGui::GetCursorScreenPos().x + 5.0f, ImVec2 image_screen_pos =
ImGui::GetCursorScreenPos().y + 5.0f); ImVec2(ImGui::GetCursorScreenPos().x + 5.0f * dpi_scale_,
ImVec2 image_pos = ImGui::GetCursorScreenPos().y + 5.0f * dpi_scale_);
ImVec2(ImGui::GetCursorPosX() + 5.0f, ImGui::GetCursorPosY() + 5.0f); ImVec2 image_pos = ImVec2(ImGui::GetCursorPosX() + 5.0f * dpi_scale_,
ImGui::GetCursorPosY() + 5.0f * dpi_scale_);
ImGui::SetCursorPos(image_pos); ImGui::SetCursorPos(image_pos);
ImGui::Image((ImTextureID)(intptr_t)it.second.texture, ImGui::Image((ImTextureID)(intptr_t)it.second.texture,
ImVec2((float)recent_connection_image_width_, ImVec2((float)recent_connection_image_width_,
@@ -208,11 +209,11 @@ int Render::ShowRecentConnections() {
if (count != recent_connections_count - 1) { if (count != recent_connections_count - 1) {
ImVec2 line_start = ImVec2 line_start =
ImVec2(image_screen_pos.x + recent_connection_image_width_ + ImVec2(image_screen_pos.x + recent_connection_image_width_ +
20.0f * dpi_scale_, 25.0f * dpi_scale_,
image_screen_pos.y); image_screen_pos.y);
ImVec2 line_end = ImVec2( ImVec2 line_end = ImVec2(
image_screen_pos.x + recent_connection_image_width_ + image_screen_pos.x + recent_connection_image_width_ +
20.0f * dpi_scale_, 25.0f * dpi_scale_,
image_screen_pos.y + recent_connection_image_height_ + button_height); image_screen_pos.y + recent_connection_image_height_ + button_height);
ImGui::GetWindowDrawList()->AddLine(line_start, line_end, ImGui::GetWindowDrawList()->AddLine(line_start, line_end,
IM_COL32(0, 0, 0, 122), 1.0f); IM_COL32(0, 0, 0, 122), 1.0f);
@@ -220,7 +221,7 @@ int Render::ShowRecentConnections() {
count++; count++;
ImGui::SameLine( ImGui::SameLine(
0, count != recent_connections_count ? 26.0f * dpi_scale_ : 0.0f); 0, count != recent_connections_count ? (35.0f * dpi_scale_) : 0.0f);
} }
ImGui::EndChild(); ImGui::EndChild();

View File

@@ -85,10 +85,6 @@ int Render::UpdateNotificationWindow() {
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar); ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar);
if (system_chinese_font_ != nullptr) {
ImGui::PushFont(system_chinese_font_);
}
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + window_height * 0.05f); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + window_height * 0.05f);
// title: new version available // title: new version available
@@ -115,6 +111,9 @@ int Render::UpdateNotificationWindow() {
float scrollable_height = float scrollable_height =
window_height - UPDATE_NOTIFICATION_RESERVED_HEIGHT; window_height - UPDATE_NOTIFICATION_RESERVED_HEIGHT;
if (system_chinese_font_ != nullptr) {
ImGui::PushFont(system_chinese_font_);
}
// scrollable content area // scrollable content area
ImGui::SetCursorPosX(window_width * 0.05f); ImGui::SetCursorPosX(window_width * 0.05f);
ImGui::BeginChild("ScrollableContent", ImGui::BeginChild("ScrollableContent",
@@ -163,6 +162,11 @@ int Render::UpdateNotificationWindow() {
ImGui::EndChild(); ImGui::EndChild();
// pop system font
if (system_chinese_font_ != nullptr) {
ImGui::PopFont();
}
ImGui::Spacing(); ImGui::Spacing();
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) { if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
@@ -199,11 +203,6 @@ int Render::UpdateNotificationWindow() {
ImGui::SetWindowFontScale(1.0f); ImGui::SetWindowFontScale(1.0f);
// pop system font
if (system_chinese_font_ != nullptr) {
ImGui::PopFont();
}
ImGui::End(); ImGui::End();
ImGui::PopStyleVar(3); ImGui::PopStyleVar(3);
ImGui::PopStyleColor(); ImGui::PopStyleColor();