diff options
author | bubnikv <bubnikv@gmail.com> | 2019-04-26 18:42:51 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2019-04-26 18:42:51 +0300 |
commit | 16560f6e27854cfb915218f7e9af22d30aa49ab1 (patch) | |
tree | c4a6390cfd4027fbd3745028a5d4281910acc46e /src/slic3r/GUI/OptionsGroup.cpp | |
parent | 6526a8fcafaf2453e5b69ef65409a1bf728b63de (diff) | |
parent | 127a78d953bcfcc5d617a42520eae9dc68db96ac (diff) |
Merge remote-tracking branch 'remotes/origin/master' into vb_wold_object_manipulation
Diffstat (limited to 'src/slic3r/GUI/OptionsGroup.cpp')
-rw-r--r-- | src/slic3r/GUI/OptionsGroup.cpp | 105 |
1 files changed, 84 insertions, 21 deletions
diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index a4686d4d2..cdcde972a 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -166,37 +166,45 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n #endif /* __WXGTK__ */ // if we have an extra column, build it - if (extra_column) - grid_sizer->Add(extra_column(this->ctrl_parent(), line), 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 3); + if (extra_column) + { + m_extra_column_item_ptrs.push_back(extra_column(this->ctrl_parent(), line)); + grid_sizer->Add(m_extra_column_item_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3); + } // Build a label if we have it wxStaticText* label=nullptr; if (label_width != 0) { if (! line.near_label_widget || ! line.label.IsEmpty()) { + // Only create the label if it is going to be displayed. long label_style = staticbox ? 0 : wxALIGN_RIGHT; - #ifdef __WXGTK__ +#ifdef __WXGTK__ // workaround for correct text align of the StaticBox on Linux // flags wxALIGN_RIGHT and wxALIGN_CENTRE don't work when Ellipsize flags are _not_ given. // Text is properly aligned only when Ellipsize is checked. label_style |= staticbox ? 0 : wxST_ELLIPSIZE_END; - #endif /* __WXGTK__ */ +#endif /* __WXGTK__ */ label = new wxStaticText(this->ctrl_parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ": "), - wxDefaultPosition, wxSize(label_width, -1), label_style); + wxDefaultPosition, wxSize(label_width*wxGetApp().em_unit(), -1), label_style); label->SetBackgroundStyle(wxBG_STYLE_PAINT); - label->SetFont(label_font); - label->Wrap(label_width); // avoid a Linux/GTK bug + label->SetFont(wxGetApp().normal_font()); + label->Wrap(label_width*wxGetApp().em_unit()); // avoid a Linux/GTK bug } - if (! line.near_label_widget) + if (!line.near_label_widget) grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, line.label.IsEmpty() ? 0 : 5); - else if (line.near_label_widget && line.label.IsEmpty()) - grid_sizer->Add(line.near_label_widget(this->ctrl_parent()), 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 7); else { - // If we're here, we have some widget near the label - // so we need a horizontal sizer to arrange these things - auto sizer = new wxBoxSizer(wxHORIZONTAL); - grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1); - sizer->Add(line.near_label_widget(this->ctrl_parent()), 0, wxRIGHT, 7); - sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5); + m_near_label_widget_ptrs.push_back(line.near_label_widget(this->ctrl_parent())); + + if (line.label.IsEmpty()) + grid_sizer->Add(m_near_label_widget_ptrs.back(), 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 7); + else { + // If we're here, we have some widget near the label + // so we need a horizontal sizer to arrange these things + auto sizer = new wxBoxSizer(wxHORIZONTAL); + grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1); + sizer->Add(m_near_label_widget_ptrs.back(), 0, wxRIGHT, 7); + sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5); + } } if (label != nullptr && line.label_tooltip != "") label->SetToolTip(line.label_tooltip); @@ -237,14 +245,13 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n wxSizer* sizer_tmp = sizer; // add label if any if (option.label != "") { -// wxString str_label = _(option.label); //! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1 wxString str_label = (option.label == "Top" || option.label == "Bottom") ? _CTX(option.label, "Layers") : _(option.label); label = new wxStaticText(this->ctrl_parent(), wxID_ANY, str_label + ": ", wxDefaultPosition, wxDefaultSize); label->SetBackgroundStyle(wxBG_STYLE_PAINT); - label->SetFont(label_font); + label->SetFont(wxGetApp().normal_font()); sizer_tmp->Add(label, 0, /*wxALIGN_RIGHT |*/ wxALIGN_CENTER_VERTICAL, 0); } @@ -269,9 +276,9 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n // add sidetext if any if (option.sidetext != "") { auto sidetext = new wxStaticText( this->ctrl_parent(), wxID_ANY, _(option.sidetext), wxDefaultPosition, - wxSize(sidetext_width, -1)/*wxDefaultSize*/, wxALIGN_LEFT); + /*wxSize(sidetext_width*wxGetApp().em_unit(), -1)*/wxDefaultSize, wxALIGN_LEFT); sidetext->SetBackgroundStyle(wxBG_STYLE_PAINT); - sidetext->SetFont(sidetext_font); + sidetext->SetFont(wxGetApp().normal_font()); sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4); field->set_side_text_ptr(sidetext); } @@ -303,7 +310,10 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = n } Line OptionsGroup::create_single_option_line(const Option& option) const { - Line retval{ _(option.opt.label), _(option.opt.tooltip) }; +// Line retval{ _(option.opt.label), _(option.opt.tooltip) }; + wxString tooltip = _(option.opt.tooltip); + edit_tooltip(tooltip); + Line retval{ _(option.opt.label), tooltip }; Option tmp(option); tmp.opt.label = std::string(""); retval.append_option(tmp); @@ -479,6 +489,59 @@ bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) { return true; } +void ConfigOptionsGroup::msw_rescale() +{ + // update bitmaps for extra column items (like "mode markers" or buttons on settings panel) + if (rescale_extra_column_item) + for (auto extra_col : m_extra_column_item_ptrs) + rescale_extra_column_item(extra_col); + + // update bitmaps for near label widgets (like "Set uniform scale" button on settings panel) + if (rescale_near_label_widget) + for (auto near_label_widget : m_near_label_widget_ptrs) + rescale_near_label_widget(near_label_widget); + + // update undo buttons : rescale bitmaps + for (const auto& field : m_fields) + field.second->msw_rescale(); + + const int em = em_unit(parent()); + + // rescale width of label column + if (!m_options_mode.empty() && label_width > 1) + { + const int cols = m_grid_sizer->GetCols(); + const int rows = m_grid_sizer->GetEffectiveRowsCount(); + const int label_col = extra_column == nullptr ? 0 : 1; + + for (int i = 0; i < rows; i++) + { + const wxSizerItem* label_item = m_grid_sizer->GetItem(i*cols+label_col); + if (label_item->IsWindow()) + { + auto label = dynamic_cast<wxStaticText*>(label_item->GetWindow()); + if (label != nullptr) { + const int label_height = int(1.5f*label->GetFont().GetPixelSize().y + 0.5f); + label->SetMinSize(wxSize(label_width*em, /*-1*/label_height)); + } + } + else if (label_item->IsSizer()) // case when we have near_label_widget + { + const wxSizerItem* l_item = label_item->GetSizer()->GetItem(1); + if (l_item->IsWindow()) + { + auto label = dynamic_cast<wxStaticText*>(l_item->GetWindow()); + if (label != nullptr) { + const int label_height = int(1.5f*label->GetFont().GetPixelSize().y + 0.5f); + label->SetMinSize(wxSize(label_width*em, /*-1*/label_height)); + } + } + } + } + m_grid_sizer->Layout(); + } +} + boost::any ConfigOptionsGroup::config_value(const std::string& opt_key, int opt_index, bool deserialize) { if (deserialize) { |