From 077321b228814fbca66937812ea204842582f4b2 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 17 Apr 2019 21:35:53 +0200 Subject: Implemented em_unit() function for getting of em_unit value from correct parent. + Added correct em_unit to Fields --- src/slic3r/GUI/Field.cpp | 49 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'src/slic3r/GUI/Field.cpp') diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 8a98a1ed7..89310e7c3 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -65,6 +65,9 @@ void Field::PostInitialize() break; } + // initialize m_unit_value + m_em_unit = em_unit(m_parent); + BUILD(); } @@ -212,8 +215,8 @@ bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type) void TextCtrl::BUILD() { auto size = wxSize(wxDefaultSize); - if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit()); - if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit()); + if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); + if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); wxString text_value = wxString(""); @@ -361,8 +364,8 @@ void TextCtrl::rescale() { Field::rescale(); auto size = wxSize(wxDefaultSize); - if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit()); - if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit()); + if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); + if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); if (size != wxDefaultSize) { @@ -424,8 +427,8 @@ int undef_spin_val = -9999; //! Probably, It's not necessary void SpinCtrl::BUILD() { auto size = wxSize(wxDefaultSize); - if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit()); - if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit()); + if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); + if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); wxString text_value = wxString(""); int default_value = 0; @@ -529,9 +532,9 @@ void SpinCtrl::rescale() } void Choice::BUILD() { - wxSize size(m_width * wxGetApp().em_unit(), -1); - if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit()); - if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit()); + wxSize size(m_width * m_em_unit, -1); + if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); + if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); wxBitmapComboBox* temp; if (!m_opt.gui_type.empty() && m_opt.gui_type.compare("select_open") != 0) { @@ -856,8 +859,8 @@ void Choice::rescale() */ field->Clear(); wxSize size(wxDefaultSize); - if (m_opt.height >= 0) size.SetHeight(m_opt.height * wxGetApp().em_unit()); - size.SetWidth((m_opt.width > 0 ? m_opt.width : m_width) * wxGetApp().em_unit()); + if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit); + size.SetWidth((m_opt.width > 0 ? m_opt.width : m_width) * m_em_unit); field->SetSize(size); @@ -885,8 +888,8 @@ void Choice::rescale() void ColourPicker::BUILD() { auto size = wxSize(wxDefaultSize); - if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit()); - if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit()); + if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); + if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); // Validate the color wxString clr_str(static_cast(m_opt.default_value)->get_at(m_opt_idx)); @@ -921,7 +924,7 @@ void PointCtrl::BUILD() { auto temp = new wxBoxSizer(wxHORIZONTAL); - const wxSize field_size(4 * wxGetApp().em_unit(), -1); + const wxSize field_size(4 * m_em_unit, -1); auto default_pt = static_cast(m_opt.default_value)->values.at(0); double val = default_pt(0); @@ -964,6 +967,16 @@ void PointCtrl::BUILD() y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y)); } +void PointCtrl::rescale() +{ + Field::rescale(); + + const wxSize field_size(4 * m_em_unit, -1); + + x_textctrl->SetMinSize(field_size); + y_textctrl->SetMinSize(field_size); +} + void PointCtrl::propagate_value(wxTextCtrl* win) { if (!win->GetValue().empty()) @@ -1009,8 +1022,8 @@ boost::any& PointCtrl::get_value() void StaticText::BUILD() { auto size = wxSize(wxDefaultSize); - if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit()); - if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit()); + if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); + if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); const wxString legend(static_cast(m_opt.default_value)->value); auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE); @@ -1029,8 +1042,8 @@ void StaticText::rescale() Field::rescale(); auto size = wxSize(wxDefaultSize); - if (m_opt.height >= 0) size.SetHeight(m_opt.height*wxGetApp().em_unit()); - if (m_opt.width >= 0) size.SetWidth(m_opt.width*wxGetApp().em_unit()); + if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); + if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); if (size != wxDefaultSize) { -- cgit v1.2.3