Fixed rescale of the MainFrame/SettingsDialog after switching between settings layouts on the 2 monitors with different DPI
This commit is contained in:
parent
c49221c621
commit
ba87a4fd9a
@ -231,6 +231,7 @@ private:
|
||||
}
|
||||
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
|
||||
*/
|
||||
m_force_rescale = false;
|
||||
#if !wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
|
||||
// rescale fonts of all controls
|
||||
scale_controls_fonts(this, m_new_font_point_size);
|
||||
|
@ -310,8 +310,10 @@ void MainFrame::update_layout()
|
||||
m_plater_page = nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
if (m_layout == ESettingsLayout::Dlg)
|
||||
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::Mainframe);
|
||||
*/
|
||||
|
||||
clean_sizer(m_main_sizer);
|
||||
clean_sizer(m_settings_dialog.GetSizer());
|
||||
@ -347,6 +349,14 @@ void MainFrame::update_layout()
|
||||
if (m_layout != ESettingsLayout::Unknown)
|
||||
restore_to_creation();
|
||||
|
||||
enum class State {
|
||||
noUpdate,
|
||||
fromDlg,
|
||||
toDlg
|
||||
};
|
||||
State update_scaling_state = m_layout == ESettingsLayout::Dlg ? State::fromDlg :
|
||||
layout == ESettingsLayout::Dlg ? State::toDlg : State::noUpdate;
|
||||
|
||||
m_layout = layout;
|
||||
|
||||
// From the very beginning the Print settings should be selected
|
||||
@ -384,7 +394,7 @@ void MainFrame::update_layout()
|
||||
m_tabpanel->Reparent(&m_settings_dialog);
|
||||
m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND);
|
||||
|
||||
rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog);
|
||||
// rescale_dialog_after_dpi_change(*this, m_settings_dialog, ERescaleTarget::SettingsDialog);
|
||||
|
||||
m_tabpanel->Show();
|
||||
m_plater->Show();
|
||||
@ -400,6 +410,34 @@ void MainFrame::update_layout()
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
if (update_scaling_state != State::noUpdate)
|
||||
{
|
||||
int mainframe_dpi = get_dpi_for_window(this);
|
||||
int dialog_dpi = get_dpi_for_window(&m_settings_dialog);
|
||||
if (mainframe_dpi != dialog_dpi) {
|
||||
wxSize oldDPI = update_scaling_state == State::fromDlg ? wxSize(dialog_dpi, dialog_dpi) : wxSize(mainframe_dpi, mainframe_dpi);
|
||||
wxSize newDPI = update_scaling_state == State::toDlg ? wxSize(dialog_dpi, dialog_dpi) : wxSize(mainframe_dpi, mainframe_dpi);
|
||||
|
||||
if (update_scaling_state == State::fromDlg)
|
||||
this->enable_force_rescale();
|
||||
else
|
||||
(&m_settings_dialog)->enable_force_rescale();
|
||||
|
||||
wxWindow* win { nullptr };
|
||||
if (update_scaling_state == State::fromDlg)
|
||||
win = this;
|
||||
else
|
||||
win = &m_settings_dialog;
|
||||
|
||||
#if wxVERSION_EQUAL_OR_GREATER_THAN(3,1,3)
|
||||
m_tabpanel->MSWUpdateOnDPIChange(oldDPI, newDPI);
|
||||
win->GetEventHandler()->AddPendingEvent(wxDPIChangedEvent(oldDPI, newDPI));
|
||||
#else
|
||||
win->GetEventHandler()->AddPendingEvent(DpiChangedEvent(EVT_DPI_CHANGED_SLICER, newDPI, win->GetRect()));
|
||||
#endif // wxVERSION_EQUAL_OR_GREATER_THAN
|
||||
}
|
||||
}
|
||||
|
||||
//#ifdef __APPLE__
|
||||
// // Using SetMinSize() on Mac messes up the window position in some cases
|
||||
// // cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0
|
||||
|
Loading…
Reference in New Issue
Block a user