em_unit initialization in one place (DPIAware constructor)
This commit is contained in:
parent
b099ca1d4e
commit
0bcb449fb4
@ -65,8 +65,8 @@ public:
|
|||||||
if (std::abs(m_scale_factor - scale_primary_display) > 1e-6)
|
if (std::abs(m_scale_factor - scale_primary_display) > 1e-6)
|
||||||
m_normal_font = m_normal_font.Scale(m_scale_factor / scale_primary_display);
|
m_normal_font = m_normal_font.Scale(m_scale_factor / scale_primary_display);
|
||||||
|
|
||||||
// An analog of em_unit value from GUI_App.
|
// 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, 10 * m_scale_factor);
|
m_em_unit = std::max<size_t>(10, this->GetTextExtent("m").x - 1/*10 * m_scale_factor*/);
|
||||||
|
|
||||||
// recalc_font();
|
// recalc_font();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
|
|||||||
this->SetFont(this->normal_font());
|
this->SetFont(this->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.
|
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
||||||
wxGetApp().set_em_unit(std::max<size_t>(10, GetTextExtent("m").x - 1));
|
// wxGetApp().set_em_unit(std::max<size_t>(10, GetTextExtent("m").x - 1));
|
||||||
|
|
||||||
// Load the icon either from the exe, or from the ico file.
|
// Load the icon either from the exe, or from the ico file.
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
@ -316,7 +316,7 @@ void MainFrame::on_dpi_changed(const wxRect &suggested_rect)
|
|||||||
wxGetApp().update_fonts();
|
wxGetApp().update_fonts();
|
||||||
this->SetFont(this->normal_font());
|
this->SetFont(this->normal_font());
|
||||||
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
// initialize default width_unit according to the width of the one symbol ("m") of the currently active font of this window.
|
||||||
wxGetApp().set_em_unit(std::max<size_t>(10, GetTextExtent("m").x - 1));
|
// wxGetApp().set_em_unit(std::max<size_t>(10, GetTextExtent("m").x - 1));
|
||||||
|
|
||||||
/* Load default preset bitmaps before a tabpanel initialization,
|
/* Load default preset bitmaps before a tabpanel initialization,
|
||||||
* but after filling of an em_unit value
|
* but after filling of an em_unit value
|
||||||
|
@ -178,7 +178,7 @@ void Tab::create_preset_tab()
|
|||||||
// Sizer with buttons for mode changing
|
// Sizer with buttons for mode changing
|
||||||
m_mode_sizer = new ModeSizer(panel);
|
m_mode_sizer = new ModeSizer(panel);
|
||||||
|
|
||||||
const float scale_factor = wxGetApp().em_unit()*0.1;// GetContentScaleFactor();
|
const float scale_factor = /*wxGetApp().*/em_unit(this)*0.1;// GetContentScaleFactor();
|
||||||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(m_hsizer, 0, wxEXPAND | wxBOTTOM, 3);
|
sizer->Add(m_hsizer, 0, wxEXPAND | wxBOTTOM, 3);
|
||||||
m_hsizer->Add(m_presets_choice, 0, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
m_hsizer->Add(m_presets_choice, 0, wxLEFT | wxRIGHT | wxTOP | wxALIGN_CENTER_VERTICAL, 3);
|
||||||
@ -212,7 +212,8 @@ void Tab::create_preset_tab()
|
|||||||
m_treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(20 * m_em_unit, -1),
|
m_treectrl = new wxTreeCtrl(panel, wxID_ANY, wxDefaultPosition, wxSize(20 * m_em_unit, -1),
|
||||||
wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_SINGLE | wxTR_NO_LINES | wxBORDER_SUNKEN | wxWANTS_CHARS);
|
||||||
m_left_sizer->Add(m_treectrl, 1, wxEXPAND);
|
m_left_sizer->Add(m_treectrl, 1, wxEXPAND);
|
||||||
m_icons = new wxImageList(int(16 * scale_factor), int(16 * scale_factor), true, 1);
|
const int img_sz = int(16 * scale_factor + 0.5f);
|
||||||
|
m_icons = new wxImageList(img_sz, img_sz, true, 1);
|
||||||
// Index of the last icon inserted into $self->{icons}.
|
// Index of the last icon inserted into $self->{icons}.
|
||||||
m_icon_count = -1;
|
m_icon_count = -1;
|
||||||
m_treectrl->AssignImageList(m_icons);
|
m_treectrl->AssignImageList(m_icons);
|
||||||
|
Loading…
Reference in New Issue
Block a user