Application Scaling for MSW: Next big step

- Added rescale() function for the most of controls
 - Created PrusaBitmap and PrusaButton classes like a wrap to wxBitmap and wxButton accordingly
This commit is contained in:
YuSanka 2019-04-13 23:46:52 +02:00
parent a74c608c7a
commit f7ddddcff5
22 changed files with 737 additions and 250 deletions
src/slic3r/GUI

View file

@ -256,6 +256,7 @@ bool MainFrame::can_delete_all() const
return (m_plater != nullptr) ? !m_plater->model().objects.empty() : false;
}
// scale font for existing controls
static void scale(wxWindow *window, const float scale_f)
{
auto children = window->GetChildren();
@ -268,10 +269,9 @@ static void scale(wxWindow *window, const float scale_f)
// const wxSize& sz = child->GetSize();
// if (sz != wxDefaultSize)
// child->SetSize(sz*scale_f);
child->Layout();
// child->SetSize(sz*scale_f);
}
window->Layout();
}
void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
@ -286,28 +286,24 @@ void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
{
Freeze();
scale(this, new_sc_factor / old_sc_factor);
wxGetApp().scale_fonts(new_sc_factor / old_sc_factor);
const auto new_em_unit = wxGetApp().em_unit()*new_sc_factor / old_sc_factor;
scale(this, new_sc_factor / old_sc_factor/*, 1/new_em_unit*/);
wxGetApp().set_em_unit(std::max<size_t>(10, new_em_unit));
/* Load default preset bitmaps before a tabpanel initialization,
* but after filling of an em_unit value
*/
wxGetApp().preset_bundle->load_default_preset_bitmaps();
wxGetApp().preset_bundle->load_default_preset_bitmaps(this);
wxGetApp().sidebar().scrolled_panel()->SetSize(40 * wxGetApp().em_unit(), -1);
wxGetApp().sidebar().scrolled_panel()->Layout();
// update preset comboboxes on Plater
wxGetApp().sidebar().rescale();
// update preset comboboxes on Tabs
for (auto tab : wxGetApp().tabs_list)
tab->rescale();//update_tab_ui();
tab->rescale();
// update preset comboboxes on Plater
wxGetApp().sidebar().update_all_preset_comboboxes();
Refresh();
Layout();
Thaw();