diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index abe9d9611..d0a76053f 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -74,13 +74,6 @@ Field::~Field() void Field::PostInitialize() { auto color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); -// m_Undo_btn = new RevertButton(m_parent, "bullet_white.png"); -// m_Undo_to_sys_btn = new RevertButton(m_parent, "bullet_white.png"); - -// m_Undo_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_initial_value(); })); -// m_Undo_to_sys_btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent) { on_back_to_sys_value(); })); - -// m_blinking_bmp = new BlinkingBitmap(m_parent); switch (m_opt.type) { @@ -223,10 +216,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true break; } - wxString label = m_Label->GetLabel(); - if (label.Last() == '\n') label.RemoveLast(); - while (label.Last() == ' ') label.RemoveLast(); - if (label.Last() == ':') label.RemoveLast(); + wxString label = m_opt.full_label.empty() ? _(m_opt.label) : _(m_opt.full_label); show_error(m_parent, from_u8((boost::format(_utf8(L("%s doesn't support percentage"))) % label).str())); set_value(double_to_string(m_opt.min), true); m_value = double(m_opt.min); @@ -312,29 +302,14 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } } -void Field::msw_rescale(bool rescale_sidetext) +void Field::msw_rescale() { - if (m_Undo_btn) { - m_Undo_to_sys_btn->msw_rescale(); - m_Undo_btn->msw_rescale(); - m_blinking_bmp->msw_rescale(); - } // update em_unit value m_em_unit = em_unit(m_parent); - - // update sidetext if it is needed - if (m_side_text && rescale_sidetext) - { - auto size = wxSize(def_width_thinner() * m_em_unit, -1); - m_side_text->SetSize(size); - m_side_text->SetMinSize(size); - } } void Field::sys_color_changed() { - m_Undo_to_sys_btn->msw_rescale(); - m_Undo_btn->msw_rescale(); } template @@ -560,9 +535,9 @@ boost::any& TextCtrl::get_value() return m_value; } -void TextCtrl::msw_rescale(bool rescale_sidetext/* = false*/) +void TextCtrl::msw_rescale() { - Field::msw_rescale(rescale_sidetext); + Field::msw_rescale(); auto size = wxSize(def_width() * m_em_unit, wxDefaultCoord); if (m_opt.height >= 0) @@ -667,7 +642,7 @@ boost::any& CheckBox::get_value() return m_value; } -void CheckBox::msw_rescale(bool rescale_sidetext/* = false*/) +void CheckBox::msw_rescale() { Field::msw_rescale(); @@ -805,9 +780,9 @@ void SpinCtrl::propagate_value() suppress_propagation = false; } -void SpinCtrl::msw_rescale(bool rescale_sidetext/* = false*/) +void SpinCtrl::msw_rescale() { - Field::msw_rescale(rescale_sidetext); + Field::msw_rescale(); wxSpinCtrl* field = dynamic_cast(window); if (parent_is_custom_ctrl) @@ -1170,7 +1145,7 @@ boost::any& Choice::get_value() void Choice::enable() { dynamic_cast(window)->Enable(); }; void Choice::disable() { dynamic_cast(window)->Disable(); }; -void Choice::msw_rescale(bool rescale_sidetext/* = false*/) +void Choice::msw_rescale() { Field::msw_rescale(); @@ -1297,7 +1272,7 @@ boost::any& ColourPicker::get_value() return m_value; } -void ColourPicker::msw_rescale(bool rescale_sidetext/* = false*/) +void ColourPicker::msw_rescale() { Field::msw_rescale(); @@ -1364,7 +1339,7 @@ void PointCtrl::BUILD() y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y)); } -void PointCtrl::msw_rescale(bool rescale_sidetext/* = false*/) +void PointCtrl::msw_rescale() { Field::msw_rescale(); @@ -1470,7 +1445,7 @@ void StaticText::BUILD() temp->SetToolTip(get_tooltip_text(legend)); } -void StaticText::msw_rescale(bool rescale_sidetext/* = false*/) +void StaticText::msw_rescale() { Field::msw_rescale(); diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index c223b5b12..b4bcf9f33 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -145,9 +145,6 @@ public: void field_changed() { on_change_field(); } - // set icon to "UndoToSystemValue" button according to an inheritance of preset -// void set_nonsys_btn_icon(const wxBitmap& icon); - Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {}; Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {}; virtual ~Field(); @@ -156,8 +153,6 @@ public: virtual wxSizer* getSizer() { return nullptr; } virtual wxWindow* getWindow() { return nullptr; } - wxStaticText* getLabel() { return m_Label; } - bool is_matched(const std::string& string, const std::string& pattern); void get_value_by_opt_type(wxString& str, const bool check_value = true); @@ -173,7 +168,6 @@ public: bool set_undo_bitmap(const ScalableBitmap *bmp) { if (m_undo_bitmap != bmp) { m_undo_bitmap = bmp; -// m_Undo_btn->SetBitmap_(*bmp); return true; } return false; @@ -182,33 +176,21 @@ public: bool set_undo_to_sys_bitmap(const ScalableBitmap *bmp) { if (m_undo_to_sys_bitmap != bmp) { m_undo_to_sys_bitmap = bmp; -// m_Undo_to_sys_btn->SetBitmap_(*bmp); return true; } return false; } bool set_label_colour(const wxColour *clr) { -// if (m_Label == nullptr) return false; if (m_label_color != clr) { m_label_color = clr; -// m_Label->SetForegroundColour(*clr); -// m_Label->Refresh(true); } return false; } - bool set_label_colour_force(const wxColour *clr) { - if (m_Label == nullptr) return false; -// m_Label->SetForegroundColour(*clr); -// m_Label->Refresh(true); - return false; - } - bool set_undo_tooltip(const wxString *tip) { if (m_undo_tooltip != tip) { m_undo_tooltip = tip; -// m_Undo_btn->SetToolTip(*tip); return true; } return false; @@ -217,21 +199,16 @@ public: bool set_undo_to_sys_tooltip(const wxString *tip) { if (m_undo_to_sys_tooltip != tip) { m_undo_to_sys_tooltip = tip; -// m_Undo_to_sys_btn->SetToolTip(*tip); return true; } return false; } - void set_side_text_ptr(wxStaticText* side_text) { - m_side_text = side_text; - } - bool* get_blink_ptr() { return &m_blink; } - virtual void msw_rescale(bool rescale_sidetext = false); + virtual void msw_rescale(); void sys_color_changed(); bool get_enter_pressed() const { return bEnterPressed; } @@ -242,8 +219,6 @@ public: static int def_width_wider() ; static int def_width_thinner() ; - BlinkingBitmap* blinking_bitmap() const { return m_blinking_bmp;} - const ScalableBitmap* undo_bitmap() { return m_undo_bitmap; } const wxString* undo_tooltip() { return m_undo_tooltip; } const ScalableBitmap* undo_to_sys_bitmap() { return m_undo_to_sys_bitmap; } @@ -252,25 +227,18 @@ public: const bool blink() { return m_blink; } protected: - RevertButton* m_Undo_btn = nullptr; // Bitmap and Tooltip text for m_Undo_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. const ScalableBitmap* m_undo_bitmap = nullptr; const wxString* m_undo_tooltip = nullptr; - RevertButton* m_Undo_to_sys_btn = nullptr; // Bitmap and Tooltip text for m_Undo_to_sys_btn. The wxButton will be updated only if the new wxBitmap pointer differs from the currently rendered one. const ScalableBitmap* m_undo_to_sys_bitmap = nullptr; const wxString* m_undo_to_sys_tooltip = nullptr; bool m_blink{ false }; - BlinkingBitmap* m_blinking_bmp{ nullptr }; - - wxStaticText* m_Label = nullptr; // Color for Label. The wxColour will be updated only if the new wxColour pointer differs from the currently rendered one. const wxColour* m_label_color = nullptr; - wxStaticText* m_side_text = nullptr; - // current value boost::any m_value; // last maeningful value @@ -326,7 +294,7 @@ public: boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override; void disable() override; @@ -354,7 +322,7 @@ public: void set_na_value() override; boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); } void disable() override { dynamic_cast(window)->Disable(); } @@ -397,7 +365,7 @@ public: return m_value = value; } - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); } void disable() override { dynamic_cast(window)->Disable(); } @@ -426,7 +394,7 @@ public: void set_values(const wxArrayString &values); boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override ;//{ dynamic_cast(window)->Enable(); }; void disable() override;//{ dynamic_cast(window)->Disable(); }; @@ -452,7 +420,7 @@ public: } void set_value(const boost::any& value, bool change_event = false) override; boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); }; void disable() override{ dynamic_cast(window)->Disable(); }; @@ -478,7 +446,7 @@ public: void set_value(const boost::any& value, bool change_event = false); boost::any& get_value() override; - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { x_textctrl->Enable(); @@ -513,7 +481,7 @@ public: boost::any& get_value()override { return m_value; } - void msw_rescale(bool rescale_sidetext = false) override; + void msw_rescale() override; void enable() override { dynamic_cast(window)->Enable(); }; void disable() override{ dynamic_cast(window)->Disable(); }; diff --git a/src/slic3r/GUI/OG_CustomCtrl.hpp b/src/slic3r/GUI/OG_CustomCtrl.hpp index e5e5e8eeb..d00a0027d 100644 --- a/src/slic3r/GUI/OG_CustomCtrl.hpp +++ b/src/slic3r/GUI/OG_CustomCtrl.hpp @@ -20,8 +20,6 @@ #define wxOSX false #endif -//#define BORDER(a, b) ((wxOSX ? a : b)) - namespace Slic3r { namespace GUI { // Static text shown among the options. diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 14dd477ed..fe935dce2 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -14,15 +14,15 @@ namespace Slic3r { namespace GUI { -const t_field& OptionsGroup::build_field(const Option& opt, wxStaticText* label/* = nullptr*/) { - return build_field(opt.opt_id, opt.opt, label); +const t_field& OptionsGroup::build_field(const Option& opt) { + return build_field(opt.opt_id, opt.opt); } -const t_field& OptionsGroup::build_field(const t_config_option_key& id, wxStaticText* label/* = nullptr*/) { +const t_field& OptionsGroup::build_field(const t_config_option_key& id) { const ConfigOptionDef& opt = m_options.at(id).opt; - return build_field(id, opt, label); + return build_field(id, opt); } -const t_field& OptionsGroup::build_field(const t_config_option_key& id, const ConfigOptionDef& opt, wxStaticText* label/* = nullptr*/) { +const t_field& OptionsGroup::build_field(const t_config_option_key& id, const ConfigOptionDef& opt) { // Check the gui_type field first, fall through // is the normal type. if (opt.gui_type.compare("select") == 0) { @@ -88,9 +88,7 @@ const t_field& OptionsGroup::build_field(const t_config_option_key& id, const Co this->on_set_focus(opt_id); }; field->m_parent = parent(); - - //! Label to change background color, when option is modified - field->m_Label = label; + field->m_back_to_initial_value = [this](std::string opt_id) { if (!m_disabled) this->back_to_initial_value(opt_id); @@ -113,18 +111,44 @@ OptionsGroup::OptionsGroup( wxWindow* _parent, const wxString& title, { } -void OptionsGroup::add_undo_buttons_to_sizer(wxSizer* sizer, const t_field& field) +void OptionsGroup::show_field(const t_config_option_key& opt_key, bool show/* = true*/) { - if (!m_show_modified_btns && field->m_Undo_btn) { - field->m_Undo_btn->set_as_hidden(); - field->m_Undo_to_sys_btn->set_as_hidden(); - field->m_blinking_bmp->Hide(); - return; - } + Field* field = get_field(opt_key); + if (!field) return; + wxWindow* win = field->getWindow(); + if (!win) return; + wxSizerItem* win_item = m_grid_sizer->GetItem(win, true); + if (!win_item) return; - sizer->Add(field->m_blinking_bmp, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 2); - sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL); - sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL); + const size_t cols = (size_t)m_grid_sizer->GetCols(); + const size_t rows = (size_t)m_grid_sizer->GetEffectiveRowsCount(); + + auto show_row = [this, show, cols, win_item](wxSizerItem* item, size_t row_shift) { + // check if item contanes required win + if (!item->IsWindow() || item != win_item) + return false; + // show/hide hole line contanes this window + for (size_t i = 0; i < cols; ++i) + m_grid_sizer->Show(row_shift + i, show); + return true; + }; + + size_t row_shift = 0; + for (size_t j = 0; j < rows; ++j) { + for (size_t i = 0; i < cols; ++i) { + wxSizerItem* item = m_grid_sizer->GetItem(row_shift + i); + if (!item) + continue; + if (item->IsSizer()) { + for (wxSizerItem* child_item : item->GetSizer()->GetChildren()) + if (show_row(child_item, row_shift)) + return; + } + else if (show_row(item, row_shift)) + return; + } + row_shift += cols; + } } void OptionsGroup::append_line(const Line& line) @@ -194,11 +218,6 @@ void OptionsGroup::activate_line(Line& line) const auto& option = option_set.front(); const auto& field = build_field(option); - if (!custom_ctrl) { - auto btn_sizer = new wxBoxSizer(wxHORIZONTAL); - add_undo_buttons_to_sizer(btn_sizer, field); - sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0); - } if (is_window_field(field)) sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5); if (is_sizer_field(field)) @@ -243,28 +262,18 @@ void OptionsGroup::activate_line(Line& line) } if (!line.near_label_widget) grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, line.label.IsEmpty() ? 0 : 5); - else { - 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 | wxALIGN_CENTER_VERTICAL, 7); - sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5); - } + else if (!line.label.IsEmpty()) { + // 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(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5); } if (label != nullptr && line.label_tooltip != "") label->SetToolTip(line.label_tooltip); } } - if (!custom_ctrl && line.full_Label != nullptr) - *line.full_Label = label; // Initiate the pointer to the control of the full label, if we need this one. - // If there's a widget, build it and add the result to the sizer. if (line.widget != nullptr) { auto wgt = line.widget(this->ctrl_parent()); @@ -285,14 +294,13 @@ void OptionsGroup::activate_line(Line& line) option_set.front().opt.label.empty() && option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) { const auto& option = option_set.front(); - const auto& field = build_field(option, label); + const auto& field = build_field(option); if (custom_ctrl) { if (is_window_field(field) && option.opt.full_width) field->getWindow()->SetSize(wxSize(3 * Field::def_width_wider() * wxGetApp().em_unit(), -1)); } else { - add_undo_buttons_to_sizer(sizer, field); if (is_window_field(field)) sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2); @@ -320,9 +328,8 @@ void OptionsGroup::activate_line(Line& line) // add field const Option& opt_ref = opt; - auto& field = build_field(opt_ref, label); + auto& field = build_field(opt_ref); if (!custom_ctrl) { - add_undo_buttons_to_sizer(sizer_tmp, field); if (option_set.size() == 1 && option_set.front().opt.full_width) { const auto v_sizer = new wxBoxSizer(wxVERTICAL); @@ -344,7 +351,6 @@ void OptionsGroup::activate_line(Line& line) sidetext->SetBackgroundStyle(wxBG_STYLE_PAINT); sidetext->SetFont(wxGetApp().normal_font()); sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4); - field->set_side_text_ptr(sidetext); } // add side widget if any @@ -369,11 +375,9 @@ void OptionsGroup::activate_line(Line& line) return; } - auto extra_wgt = extra_widget(this->ctrl_parent()); - if (custom_ctrl) - line.extra_widget_sizer = extra_wgt; - else - sizer->Add(extra_wgt, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4); //! requires verification + line.extra_widget_sizer = extra_widget(this->ctrl_parent()); + if (!custom_ctrl) + sizer->Add(line.extra_widget_sizer, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4); //! requires verification } } @@ -437,9 +441,6 @@ void OptionsGroup::clear(bool destroy_custom_ctrl) sizer = nullptr; for (Line& line : m_lines) { - if(line.full_Label) - *line.full_Label = nullptr; - if (line.near_label_widget_win) line.near_label_widget_win = nullptr; @@ -467,7 +468,6 @@ void OptionsGroup::clear(bool destroy_custom_ctrl) } m_extra_column_item_ptrs.clear(); - m_near_label_widget_ptrs.clear(); m_fields.clear(); } @@ -681,60 +681,44 @@ void ConfigOptionsGroup::msw_rescale() 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(sidetext_width>0); + field.second->msw_rescale(); + + auto rescale = [](wxSizer* sizer) { + for (wxSizerItem* item : sizer->GetChildren()) + if (item->IsWindow()) { + wxWindow* win = item->GetWindow(); + // check if window is ScalableButton + ScalableButton* sc_btn = dynamic_cast(win); + if (sc_btn) { + sc_btn->msw_rescale(); + sc_btn->SetSize(sc_btn->GetBestSize()); + return; + } + // check if window is wxButton + wxButton* btn = dynamic_cast(win); + if (btn) { + btn->SetSize(btn->GetBestSize()); + return; + } + } + }; + + // scale widgets and extra widgets if any exists + for (const Line& line : m_lines) { + if (line.widget_sizer) + rescale(line.widget_sizer); + if (line.extra_widget_sizer) + rescale(line.extra_widget_sizer); + } if (custom_ctrl) custom_ctrl->msw_rescale(); - - const int em = em_unit(parent()); - - // rescale width of label column - if (m_grid_sizer && !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(label_item->GetWindow()); - if (label != nullptr) { - label->SetMinSize(wxSize(label_width*em, -1)); - } - } - 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(l_item->GetWindow()); - if (label != nullptr) { - label->SetMinSize(wxSize(label_width*em, -1)); - } - } - } - } - m_grid_sizer->Layout(); - } } void ConfigOptionsGroup::sys_color_changed() { - // 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->sys_color_changed(); diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp index 18e234120..53d3b13de 100644 --- a/src/slic3r/GUI/OptionsGroup.hpp +++ b/src/slic3r/GUI/OptionsGroup.hpp @@ -31,9 +31,6 @@ class OG_CustomCtrl; /// Widget type describes a function object that returns a wxWindow (our widget) and accepts a wxWidget (parent window). using widget_t = std::function;//!std::function; -//auto default_label_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT); //GetSystemColour -//auto modified_label_clr = *new wxColour(254, 189, 101); - /// Wraps a ConfigOptionDef and adds function object for creating a side_widget. struct Option { ConfigOptionDef opt { ConfigOptionDef() }; @@ -58,7 +55,6 @@ public: wxString label_path; size_t full_width {0}; - wxStaticText** full_Label {nullptr}; wxColour* full_Label_color {nullptr}; bool blink {false}; widget_t widget {nullptr}; @@ -166,19 +162,7 @@ public: return out; } - bool set_side_text(const t_config_option_key& opt_key, const wxString& side_text) { - if (m_fields.find(opt_key) == m_fields.end()) return false; - auto st = m_fields.at(opt_key)->m_side_text; - if (!st) return false; - st->SetLabel(side_text); - return true; - } - - void show_field(const t_config_option_key& opt_key, bool show = true) { - Field* field = get_field(opt_key); - field->getWindow()->Show(show); - field->getLabel()->Show(show); - } + void show_field(const t_config_option_key& opt_key, bool show = true); void hide_field(const t_config_option_key& opt_key) { show_field(opt_key, false); } void set_name(const wxString& new_name) { @@ -202,16 +186,13 @@ public: ~OptionsGroup() { clear(true); } wxGridSizer* get_grid_sizer() { return m_grid_sizer; } - const std::vector& get_lines() { return m_lines; } - wxWindow* get_last_near_label_widget() { return m_near_label_widget_ptrs.back(); } protected: std::map m_options; wxWindow* m_parent {nullptr}; std::vector m_options_mode; std::vector m_extra_column_item_ptrs; - std::vector m_near_label_widget_ptrs; std::vector m_lines; @@ -237,10 +218,9 @@ protected: /// Generate a wxSizer or wxWindow from a configuration option /// Precondition: opt resolves to a known ConfigOption /// Postcondition: fields contains a wx gui object. - const t_field& build_field(const t_config_option_key& id, const ConfigOptionDef& opt, wxStaticText* label = nullptr); - const t_field& build_field(const t_config_option_key& id, wxStaticText* label = nullptr); - const t_field& build_field(const Option& opt, wxStaticText* label = nullptr); - void add_undo_buttons_to_sizer(wxSizer* sizer, const t_field& field); + const t_field& build_field(const t_config_option_key& id, const ConfigOptionDef& opt); + const t_field& build_field(const t_config_option_key& id); + const t_field& build_field(const Option& opt); virtual void on_kill_focus(const std::string& opt_key) {}; virtual void on_set_focus(const std::string& opt_key); @@ -319,7 +299,6 @@ private: class ogStaticText :public wxStaticText{ public: ogStaticText() {} -// ogStaticText(wxWindow* parent, const char *text) : wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize) {} ogStaticText(wxWindow* parent, const wxString& text); ~ogStaticText() {} diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 020fbbfc4..f4bd92728 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -53,69 +53,49 @@ wxDEFINE_EVENT(EVT_TAB_PRESETS_CHANGED, SimpleEvent); void Tab::Highlighter::set_timer_owner(wxEvtHandler* owner, int timerid/* = wxID_ANY*/) { - timer.SetOwner(owner, timerid); + m_timer.SetOwner(owner, timerid); } -/* -void Tab::Highlighter::init(BlinkingBitmap* bmp) -{ - if (timer.IsRunning()) - invalidate(); - if (!bmp) - return; - timer.Start(300, false); - - bbmp = bmp; - bbmp->activate(); -} -*/ void Tab::Highlighter::init(std::pair params) { - if (timer.IsRunning()) + if (m_timer.IsRunning()) invalidate(); if (!params.first || !params.second) return; - timer.Start(300, false); + m_timer.Start(300, false); - custom_ctrl = params.first; - blink_ptr = params.second; + m_custom_ctrl = params.first; + m_show_blink_ptr = params.second; - *blink_ptr = true; - custom_ctrl->Refresh(); + *m_show_blink_ptr = true; + m_custom_ctrl->Refresh(); } void Tab::Highlighter::invalidate() { - timer.Stop(); + m_timer.Stop(); - //if (bbmp) { - // bbmp->invalidate(); - // bbmp = nullptr; - //} - - if (custom_ctrl && blink_ptr) { - *blink_ptr = false; - custom_ctrl->Refresh(); - blink_ptr = nullptr; - custom_ctrl = nullptr; + if (m_custom_ctrl && m_show_blink_ptr) { + *m_show_blink_ptr = false; + m_custom_ctrl->Refresh(); + m_show_blink_ptr = nullptr; + m_custom_ctrl = nullptr; } - blink_counter = 0; + m_blink_counter = 0; } void Tab::Highlighter::blink() { - //if (!bbmp) - if (custom_ctrl && blink_ptr) { - *blink_ptr = !*blink_ptr; - custom_ctrl->Refresh(); + if (m_custom_ctrl && m_show_blink_ptr) { + *m_show_blink_ptr = !*m_show_blink_ptr; + m_custom_ctrl->Refresh(); } else return; -// bbmp->blink(); - if ((++blink_counter) == 11) + if ((++m_blink_counter) == 11) invalidate(); } @@ -374,12 +354,6 @@ void Tab::create_preset_tab() m_presets_choice->add_physical_printer(); }); - // Fill cache for mode bitmaps - m_mode_bitmap_cache.reserve(3); - m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_simple" , mode_icon_px_size())); - m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_advanced", mode_icon_px_size())); - m_mode_bitmap_cache.push_back(ScalableBitmap(this, "mode_expert" , mode_icon_px_size())); - // Initialize the DynamicPrintConfig by default keys/values. build(); @@ -444,7 +418,7 @@ Slic3r::GUI::PageShp Tab::add_options_page(const wxString& title, const std::str #else auto panel = this; #endif - PageShp page(new Page(/*panel*/m_page_view, title, icon_idx, m_mode_bitmap_cache)); + PageShp page(new Page(m_page_view, title, icon_idx)); // page->SetBackgroundStyle(wxBG_STYLE_SYSTEM); #ifdef __WINDOWS__ // page->SetDoubleBuffered(true); @@ -517,21 +491,14 @@ void Tab::update_labels_colour() } if (opt.first == "bed_shape" || opt.first == "filament_ramming_parameters" || opt.first == "compatible_prints" || opt.first == "compatible_printers" ) { - wxStaticText* label = m_colored_Labels.find(opt.first) == m_colored_Labels.end() ? nullptr : m_colored_Labels.at(opt.first); - if (label) { - label->SetForegroundColour(*color); - label->Refresh(true); - } - if (m_colored_Label_colors.find(opt.first) != m_colored_Label_colors.end()) *m_colored_Label_colors.at(opt.first) = *color; - continue; } Field* field = get_field(opt.first); if (field == nullptr) continue; - field->set_label_colour_force(color); + field->set_label_colour(color); } auto cur_item = m_treectrl->GetFirstVisibleItem(); @@ -559,21 +526,18 @@ void Tab::decorate() { for (const auto opt : m_options_list) { - wxStaticText* label = nullptr; - Field* field = nullptr; - - wxColour* colored_label_clr = nullptr; + Field* field = nullptr; + wxColour* colored_label_clr = nullptr; if (opt.first == "bed_shape" || opt.first == "filament_ramming_parameters" || - opt.first == "compatible_prints" || opt.first == "compatible_printers") { - label = (m_colored_Labels.find(opt.first) == m_colored_Labels.end()) ? nullptr : m_colored_Labels.at(opt.first); + opt.first == "compatible_prints" || opt.first == "compatible_printers") colored_label_clr = (m_colored_Label_colors.find(opt.first) == m_colored_Label_colors.end()) ? nullptr : m_colored_Label_colors.at(opt.first); - } - if (!label && !colored_label_clr) + if (!colored_label_clr) { field = get_field(opt.first); - if (!label && !colored_label_clr && !field) - continue; + if (!field) + continue; + } bool is_nonsys_value = false; bool is_modified_value = true; @@ -603,12 +567,6 @@ void Tab::decorate() icon = &m_bmp_white_bullet; tt = &m_tt_white_bullet; } - - if (label) { - label->SetForegroundColour(*color); - label->Refresh(true); - continue; - } if (colored_label_clr) { *colored_label_clr = *color; @@ -982,10 +940,6 @@ void Tab::msw_rescale() btn->msw_rescale(); for (const auto bmp : m_scaled_bitmaps) bmp->msw_rescale(); - for (const auto ikon : m_blinking_ikons) - ikon.second->msw_rescale(); - for (ScalableBitmap& bmp : m_mode_bitmap_cache) - bmp.msw_rescale(); if (m_detach_preset_btn) m_detach_preset_btn->msw_rescale(); @@ -1017,8 +971,6 @@ void Tab::sys_color_changed() btn->msw_rescale(); for (const auto bmp : m_scaled_bitmaps) bmp->msw_rescale(); -// for (ScalableBitmap& bmp : m_mode_bitmap_cache) -// bmp.msw_rescale(); // update icons for tree_ctrl for (ScalableBitmap& bmp : m_scaled_icons_list) @@ -1201,25 +1153,17 @@ void Tab::activate_option(const std::string& opt_key, const wxString& category) Field* field = get_field(opt_key); // focused selected field - if (field) { + if (field) field->getWindow()->SetFocus(); -// m_highlighter.init() -// m_highlighter.init(field->blinking_bitmap()); - } - else if (category == "Single extruder MM setup") - { + else if (category == "Single extruder MM setup") { // When we show and hide "Single extruder MM setup" page, // related options are still in the search list // So, let's hightlighte a "single_extruder_multi_material" option, // as a "way" to show hidden page again field = get_field("single_extruder_multi_material"); - if (field) { + if (field) field->getWindow()->SetFocus(); -// m_highlighter.init(field->blinking_bitmap()); - } } - //else - // m_highlighter.init(m_blinking_ikons[opt_key]); m_highlighter.init(get_custom_ctrl_with_blinking_ptr(opt_key)); } @@ -1281,7 +1225,6 @@ void Tab::build_preset_description_line(ConfigOptionsGroup* optgroup) }; auto detach_preset_btn = [this](wxWindow* parent) { - //add_scaled_button(parent, &m_detach_preset_btn, "lock_open_sys", _(L("Detach from system preset")), wxBU_LEFT | wxBU_EXACTFIT); m_detach_preset_btn = new ScalableButton(parent, wxID_ANY, "lock_open_sys", _L("Detach from system preset"), wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true); ScalableButton* btn = m_detach_preset_btn; @@ -2629,8 +2572,6 @@ void TabPrinter::build_unregular_pages() optgroup = page->new_optgroup(L("Preview")); auto reset_to_filament_color = [this, extruder_idx](wxWindow* parent) { - //add_scaled_button(parent, &m_reset_to_filament_color, "undo", - // _(L("Reset to Filament Color")), wxBU_LEFT | wxBU_EXACTFIT); m_reset_to_filament_color = new ScalableButton(parent, wxID_ANY, "undo", _L("Reset to Filament Color"), wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT, true); ScalableButton* btn = m_reset_to_filament_color; @@ -3289,8 +3230,6 @@ void Tab::clear_pages() m_compatible_prints.checkbox = nullptr; m_compatible_prints.btn = nullptr; - - m_blinking_ikons.clear(); } void Tab::update_description_lines() @@ -3579,9 +3518,6 @@ void Tab::create_line_with_widget(ConfigOptionsGroup* optgroup, const std::strin line.widget = widget; line.label_path = path; - m_colored_Labels[opt_key] = nullptr; - line.full_Label = &m_colored_Labels[opt_key]; - m_colored_Label_colors[opt_key] = &m_default_text_clr; line.full_Label_color = m_colored_Label_colors[opt_key]; @@ -3598,10 +3534,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep deps.btn->SetFont(Slic3r::GUI::wxGetApp().normal_font()); deps.btn->SetSize(deps.btn->GetBestSize()); -// BlinkingBitmap* bbmp = new BlinkingBitmap(parent); - auto sizer = new wxBoxSizer(wxHORIZONTAL); -// sizer->Add(bbmp, 0, wxALIGN_CENTER_VERTICAL); sizer->Add((deps.checkbox), 0, wxALIGN_CENTER_VERTICAL); sizer->Add((deps.btn), 0, wxALIGN_CENTER_VERTICAL); @@ -3662,11 +3595,6 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep } })); - // fill m_blinking_ikons map with options - { - // m_blinking_ikons[deps.key_list] = bbmp; - } - return sizer; } @@ -3678,10 +3606,7 @@ wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent) btn->SetFont(wxGetApp().normal_font()); btn->SetSize(btn->GetBestSize()); -// BlinkingBitmap* bbmp = new BlinkingBitmap(parent); - auto sizer = new wxBoxSizer(wxHORIZONTAL); -// sizer->Add(bbmp, 0, wxALIGN_CENTER_VERTICAL); sizer->Add(btn, 0, wxALIGN_CENTER_VERTICAL); btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) @@ -3713,12 +3638,6 @@ wxSizer* TabPrinter::create_bed_shape_widget(wxWindow* parent) searcher.add_key("bed_custom_model", gc.group, gc.category); } - // fill m_blinking_ikons map with options - { - //for (const std::string opt : {"bed_shape", "bed_custom_texture", "bed_custom_model"}) - // m_blinking_ikons[opt] = bbmp; - } - return sizer; } @@ -3831,11 +3750,10 @@ void Tab::set_tooltips_text() "Click to reset current value to the last saved preset.")); } -Page::Page(wxWindow* parent, const wxString& title, const int iconID, const std::vector& mode_bmp_cache) : +Page::Page(wxWindow* parent, const wxString& title, int iconID) : m_parent(parent), m_title(title), - m_iconID(iconID), - m_mode_bitmap_cache(mode_bmp_cache) + m_iconID(iconID) { m_vsizer = (wxBoxSizer*)parent->GetSizer(); m_item_color = &wxGetApp().get_label_clr_default(); @@ -3919,22 +3837,8 @@ bool Page::set_value(const t_config_option_key& opt_key, const boost::any& value // package Slic3r::GUI::Tab::Page; ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_label_width /*= -1*/) { - auto extra_column = [this](wxWindow* parent, const Line& line) - { - std::string bmp_name; - const std::vector