mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-06 07:39:37 +08:00
Use mac_max_scaling_factor() in create_scaled_bitmap()
This commit is contained in:
parent
5161dc43d6
commit
b234a1b7a7
@ -1,6 +1,7 @@
|
|||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "libslic3r/Utils.hpp"
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "libslic3r/Model.hpp"
|
#include "libslic3r/Model.hpp"
|
||||||
@ -19,6 +20,7 @@
|
|||||||
#include "libslic3r/GCode/PreviewData.hpp"
|
#include "libslic3r/GCode/PreviewData.hpp"
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
|
#include "../Utils/MacDarkMode.hpp"
|
||||||
|
|
||||||
using Slic3r::GUI::from_u8;
|
using Slic3r::GUI::from_u8;
|
||||||
|
|
||||||
@ -389,7 +391,15 @@ wxBitmap create_scaled_bitmap(wxWindow *win, const std::string& bmp_name_in,
|
|||||||
static Slic3r::GUI::BitmapCache cache;
|
static Slic3r::GUI::BitmapCache cache;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
const float scale_factor = win != nullptr ? win->GetContentScaleFactor() : 1.0f;
|
// Note: win->GetContentScaleFactor() is not used anymore here because it tends to
|
||||||
|
// return bogus results quite often (such as 1.0 on Retina or even 0.0).
|
||||||
|
// We're using the max scaling factor across all screens because it's very likely to be good enough.
|
||||||
|
|
||||||
|
static float max_scaling_factor = NAN;
|
||||||
|
if (std::isnan(max_scaling_factor)) {
|
||||||
|
max_scaling_factor = Slic3r::GUI::mac_max_scaling_factor();
|
||||||
|
}
|
||||||
|
const float scale_factor = win != nullptr ? max_scaling_factor : 1.0f;
|
||||||
#else
|
#else
|
||||||
(void)(win);
|
(void)(win);
|
||||||
const float scale_factor = 1.0f;
|
const float scale_factor = 1.0f;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#import "MacDarkMode.hpp"
|
#import "MacDarkMode.hpp"
|
||||||
|
|
||||||
|
#import <algorithm>
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <AppKit/NSScreen.h>
|
||||||
|
|
||||||
|
|
||||||
@implementation MacDarkMode
|
@implementation MacDarkMode
|
||||||
@ -19,12 +22,12 @@ double mac_max_scaling_factor()
|
|||||||
{
|
{
|
||||||
double scaling = 1.;
|
double scaling = 1.;
|
||||||
if ([NSScreen screens] == nil) {
|
if ([NSScreen screens] == nil) {
|
||||||
scalign = [[NSScreen mainScreen] backingScaleFactor];
|
scaling = [[NSScreen mainScreen] backingScaleFactor];
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < [[NSScreen screens] count]; ++ i)
|
for (int i = 0; i < [[NSScreen screens] count]; ++ i)
|
||||||
scaling = std::max<double>(scaling, [[[NSScreen screens] objectAtIndex:0] backingScaleFactor]);
|
scaling = std::max<double>(scaling, [[[NSScreen screens] objectAtIndex:0] backingScaleFactor]);
|
||||||
}
|
}
|
||||||
return scalign;
|
return scaling;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user