Fixed Scale on Linux
This commit is contained in:
parent
9ce3086f02
commit
07499ff9d0
2 changed files with 12 additions and 8 deletions
|
@ -77,9 +77,11 @@ namespace GUI {
|
||||||
|
|
||||||
class MainFrame;
|
class MainFrame;
|
||||||
|
|
||||||
// ysFIXME
|
|
||||||
static float get_scale_for_main_display()
|
static float get_scale_for_main_display()
|
||||||
{
|
{
|
||||||
|
// ysFIXME : Workaround :
|
||||||
|
// wxFrame is created on the main monitor, so we can take a scale factor from this one
|
||||||
|
// before The Application and the Mainframe are created
|
||||||
wxFrame fr(nullptr, wxID_ANY, wxEmptyString);
|
wxFrame fr(nullptr, wxID_ANY, wxEmptyString);
|
||||||
|
|
||||||
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && !defined(__WXGTK__)
|
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && !defined(__WXGTK__)
|
||||||
|
@ -118,7 +120,9 @@ static float scale_bitmap(wxBitmap& bmp)
|
||||||
|
|
||||||
static void word_wrap_string(wxString& input, int line_px_len, float scalef)
|
static void word_wrap_string(wxString& input, int line_px_len, float scalef)
|
||||||
{
|
{
|
||||||
|
// calculate count od symbols in one line according to the scale
|
||||||
int line_len = std::roundf( (float)line_px_len / (scalef * 10)) + 10;
|
int line_len = std::roundf( (float)line_px_len / (scalef * 10)) + 10;
|
||||||
|
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
int cur_len = 0;
|
int cur_len = 0;
|
||||||
for (size_t i = 0; i < input.Len(); i++)
|
for (size_t i = 0; i < input.Len(); i++)
|
||||||
|
@ -176,7 +180,6 @@ static void DecorateSplashScreen(wxBitmap& bmp)
|
||||||
_L("PrusaSlicer is based on Slic3r by Alessandro Ranellucci and the RepRap community.") + "\n\n" +
|
_L("PrusaSlicer is based on Slic3r by Alessandro Ranellucci and the RepRap community.") + "\n\n" +
|
||||||
_L("Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others.");
|
_L("Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others.");
|
||||||
|
|
||||||
// word_wrap_string(copyright_string, 50);
|
|
||||||
word_wrap_string(copyright_string, banner_width, scale_factor);
|
word_wrap_string(copyright_string, banner_width, scale_factor);
|
||||||
|
|
||||||
wxCoord margin = int(scale_factor * 20);
|
wxCoord margin = int(scale_factor * 20);
|
||||||
|
@ -198,14 +201,12 @@ class SplashScreen : public wxSplashScreen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent)
|
SplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent)
|
||||||
: wxSplashScreen(bitmap, splashStyle, milliseconds, parent, wxID_ANY)
|
: wxSplashScreen(bitmap, splashStyle, milliseconds, parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxSIMPLE_BORDER | wxFRAME_NO_TASKBAR)
|
||||||
{
|
{
|
||||||
wxASSERT(bitmap.IsOk());
|
wxASSERT(bitmap.IsOk());
|
||||||
m_main_bitmap = bitmap;
|
m_main_bitmap = bitmap;
|
||||||
|
|
||||||
/* int dpi = get_dpi_for_main_display();
|
|
||||||
if (dpi != DPI_DEFAULT)
|
|
||||||
m_scale_factor = (float)dpi / DPI_DEFAULT; */
|
|
||||||
m_scale_factor = get_scale_for_main_display();
|
m_scale_factor = get_scale_for_main_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,10 +92,13 @@ public:
|
||||||
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
|
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
|
||||||
this->SetFont(m_normal_font);
|
this->SetFont(m_normal_font);
|
||||||
#endif
|
#endif
|
||||||
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
|
||||||
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
// Linux specific issue : get_dpi_for_window(this) still doesn't responce to the Display's scale in new wxWidgets(3.1.3).
|
||||||
|
// So, calculate the m_em_unit value from the font size, as before
|
||||||
|
#if ENABLE_WX_3_1_3_DPI_CHANGED_EVENT && !defined(__WXGTK__)
|
||||||
m_em_unit = std::max<size_t>(10, 10.0f * m_scale_factor);
|
m_em_unit = std::max<size_t>(10, 10.0f * m_scale_factor);
|
||||||
#else
|
#else
|
||||||
|
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
||||||
m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
|
m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1);
|
||||||
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
#endif // ENABLE_WX_3_1_3_DPI_CHANGED_EVENT
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue