Added processing of a wxEVT_SYS_COLOUR_CHANGED event.

Deleted scale from ImGuiWrapper::load_svg(), because it's no needed and it makes icons bad scaled on Retina displays
This commit is contained in:
YuSanka 2020-05-21 14:17:58 +02:00
parent ae7bb123a9
commit 4348b177d6
2 changed files with 21 additions and 10 deletions

View file

@ -805,14 +805,6 @@ static const ImWchar ranges_keyboard_shortcuts[] =
std::vector<unsigned char> ImGuiWrapper::load_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height)
{
#ifdef __APPLE__
// 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.
double scale = mac_max_scaling_factor();
#else
double scale = 1.0;
#endif
std::vector<unsigned char> empty_vector;
#ifdef __WXMSW__
@ -827,8 +819,6 @@ std::vector<unsigned char> ImGuiWrapper::load_svg(const std::string& bitmap_name
if (image == nullptr)
return empty_vector;
target_height != 0 ? target_height *= scale : target_width *= scale;
float svg_scale = target_height != 0 ?
(float)target_height / image->height : target_width != 0 ?
(float)target_width / image->width : 1;

View file

@ -190,6 +190,27 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
event.Skip();
});
Bind(wxEVT_SYS_COLOUR_CHANGED, [this](wxSysColourChangedEvent& event)
{
bool recreate_gui = false;
{
// the dialog needs to be destroyed before the call to recreate_gui()
// or sometimes the application crashes into wxDialogBase() destructor
// so we put it into an inner scope
wxMessageDialog dialog(nullptr,
_L("System color mode was changed. "
"It is possible to update the Slicer in respect to the system mode.") + "\n" +
_L("You will lose content of the plater.") + "\n\n" +
_L("Do you want to proceed?"),
wxString(SLIC3R_APP_NAME) + " - " + _L("Switching system color mode"),
wxICON_QUESTION | wxOK | wxCANCEL);
recreate_gui = dialog.ShowModal() == wxID_OK;
}
if (recreate_gui)
wxGetApp().recreate_GUI(_L("Changing of an application in respect to the system mode") + dots);
event.Skip();
});
wxGetApp().persist_window_geometry(this, true);
update_ui_from_settings(); // FIXME (?)