From 00ba5157833e805cebe4a25922e8837ca7df7296 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Tue, 26 Jul 2022 17:28:49 +0800 Subject: [PATCH] FIX: use scaled icon in MacOS Change-Id: Ic7e89a3ff1dd92818adfcec410cc0bdcacfc0398 --- src/slic3r/GUI/Widgets/Button.cpp | 6 +++--- src/slic3r/GUI/Widgets/DropDown.cpp | 2 +- src/slic3r/GUI/Widgets/SideButton.cpp | 4 ++-- src/slic3r/GUI/Widgets/TextInput.cpp | 2 +- src/slic3r/Utils/MacDarkMode.mm | 12 ++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/Widgets/Button.cpp b/src/slic3r/GUI/Widgets/Button.cpp index 0a21b74f0..b7abb2412 100644 --- a/src/slic3r/GUI/Widgets/Button.cpp +++ b/src/slic3r/GUI/Widgets/Button.cpp @@ -162,7 +162,7 @@ void Button::render(wxDC& dc) //BBS norrow size between text and icon szContent.x += padding; } - szIcon = icon.bmp().GetSize(); + szIcon = icon.GetBmpSize(); szContent.x += szIcon.x; if (szIcon.y > szContent.y) szContent.y = szIcon.y; @@ -211,7 +211,7 @@ void Button::messureSize() //BBS norrow size between text and icon szContent.x += 5; } - wxSize szIcon = this->active_icon.bmp().GetSize(); + wxSize szIcon = this->active_icon.GetBmpSize(); szContent.x += szIcon.x; if (szIcon.y > szContent.y) szContent.y = szIcon.y; @@ -246,4 +246,4 @@ void Button::sendButtonEvent() wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId()); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); -} \ No newline at end of file +} diff --git a/src/slic3r/GUI/Widgets/DropDown.cpp b/src/slic3r/GUI/Widgets/DropDown.cpp index 9e15c77e3..a0cdc6338 100644 --- a/src/slic3r/GUI/Widgets/DropDown.cpp +++ b/src/slic3r/GUI/Widgets/DropDown.cpp @@ -233,7 +233,7 @@ void DropDown::render(wxDC &dc) rcContent.x += 5; rcContent.width -= 5; if (check_bitmap.bmp().IsOk()) { - auto szBmp = check_bitmap.bmp().GetSize(); + auto szBmp = check_bitmap.GetBmpSize(); if (selection >= 0) { wxPoint pt = rcContent.GetLeftTop(); pt.y += (rcContent.height - szBmp.y) / 2; diff --git a/src/slic3r/GUI/Widgets/SideButton.cpp b/src/slic3r/GUI/Widgets/SideButton.cpp index 4252a9913..3d85ae184 100644 --- a/src/slic3r/GUI/Widgets/SideButton.cpp +++ b/src/slic3r/GUI/Widgets/SideButton.cpp @@ -232,7 +232,7 @@ void SideButton::render(wxDC& dc) //BBS norrow size between text and icon szContent.x += 5; } - szIcon = icon.bmp().GetSize(); + szIcon = icon.GetBmpSize(); szContent.x += szIcon.x; if (szIcon.y > szContent.y) szContent.y = szIcon.y; @@ -284,7 +284,7 @@ void SideButton::messureSize() if (szContent.y > 0) { szContent.x += 5; } - wxSize szIcon = this->icon.bmp().GetSize(); + wxSize szIcon = this->icon.GetBmpSize(); szContent.x += szIcon.x; if (szIcon.y > szContent.y) szContent.y = szIcon.y; diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index 473e02c3d..a54fe984d 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -174,7 +174,7 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags) wxSize size = GetSize(); wxPoint textPos = {5, 0}; if (this->icon.bmp().IsOk()) { - wxSize szIcon = this->icon.bmp().GetSize(); + wxSize szIcon = this->icon.GetBmpSize(); textPos.x += szIcon.x; } bool align_right = GetWindowStyle() & wxRIGHT; diff --git a/src/slic3r/Utils/MacDarkMode.mm b/src/slic3r/Utils/MacDarkMode.mm index de6808328..7e7042216 100644 --- a/src/slic3r/Utils/MacDarkMode.mm +++ b/src/slic3r/Utils/MacDarkMode.mm @@ -26,12 +26,12 @@ bool mac_dark_mode() double mac_max_scaling_factor() { double scaling = 1.; -// if ([NSScreen screens] == nil) { -// scaling = [[NSScreen mainScreen] backingScaleFactor]; -// } else { -// for (int i = 0; i < [[NSScreen screens] count]; ++ i) -// scaling = std::max(scaling, [[[NSScreen screens] objectAtIndex:0] backingScaleFactor]); -// } + if ([NSScreen screens] == nil) { + scaling = [[NSScreen mainScreen] backingScaleFactor]; + } else { + for (int i = 0; i < [[NSScreen screens] count]; ++ i) + scaling = std::max(scaling, [[[NSScreen screens] objectAtIndex:0] backingScaleFactor]); + } return scaling; }