diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 4548fd391..d7b9b92f1 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -2061,6 +2061,7 @@ sub on_extruders_change { $choices->[-1]->Destroy; pop @$choices; } + $self->{right_panel}->Layout; $self->Layout; } diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index 66436abc3..1820af155 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -870,8 +870,11 @@ void update_settings_list() { auto opt_key = (line.get_options())[0].opt_id; //we assume that we have one option per line - auto btn = new wxBitmapButton(parent, wxID_ANY, wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("erase.png")), wxBITMAP_TYPE_PNG), + auto btn = new wxBitmapButton(parent, wxID_ANY, wxBitmap(from_u8(var("colorchange_delete_on.png")), wxBITMAP_TYPE_PNG), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); +#ifdef __WXMSW__ + btn->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif // __WXMSW__ btn->Bind(wxEVT_BUTTON, [opt_key](wxEvent &event){ (*m_config)->erase(opt_key); wxTheApp->CallAfter([]() { update_settings_list(); }); @@ -928,8 +931,8 @@ void update_settings_list() no_updates.reset(nullptr); #endif - /*get_right_panel()*/parent->Layout(); - get_right_panel()->GetParent()->GetParent()->Layout(); + parent->Layout(); + get_right_panel()->GetParent()->Layout(); } void get_settings_choice(wxMenu *menu, int id, bool is_part) @@ -982,6 +985,16 @@ void get_settings_choice(wxMenu *menu, int id, bool is_part) (*m_config)->set_key_value(opt_key, m_default_config.get()->option(opt_key)->clone()); } + + // *** EXPERIMINT *** +// const auto item = m_objects_ctrl->GetSelection(); +// if (item) +// { +// if (!m_objects_model->HasSettings(item)) +// m_objects_model->AddSettingsChild(item); +// } + // ******************** + update_settings_list(); } @@ -1108,17 +1121,13 @@ wxMenu *create_add_settings_popupmenu(bool is_part) void show_context_menu() { - auto item = m_objects_ctrl->GetSelection(); + const auto item = m_objects_ctrl->GetSelection(); if (item) { - if (m_objects_model->GetParent(item) == wxDataViewItem(0)) { - auto menu = create_add_part_popupmenu(); - get_tab_panel()->GetPage(0)->PopupMenu(menu); - } - else { - auto menu = create_part_settings_popupmenu(); - get_tab_panel()->GetPage(0)->PopupMenu(menu); - } + const auto menu = m_objects_model->GetParent(item) == wxDataViewItem(0) ? + create_add_part_popupmenu() : + create_part_settings_popupmenu(); + get_tab_panel()->GetPage(0)->PopupMenu(menu); } } @@ -1319,6 +1328,9 @@ void on_btn_split(const bool split_part) false); m_objects_ctrl->Expand(item); } + + m_parts_changed = true; + parts_changed(m_selected_object_id); } void on_btn_move_up(){ @@ -1659,6 +1671,9 @@ void on_drop(wxDataViewEvent &event) for (int id = from_volume_id; cnt < abs(from_volume_id - to_volume_id); id+=delta, cnt++) std::swap(volumes[id], volumes[id +delta]); + m_parts_changed = true; + parts_changed(m_selected_object_id); + g_prevent_list_events = false; } diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 73e6f0877..2588dd3d6 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -357,6 +357,10 @@ void PrusaObjectDataViewModelNode::set_part_action_icon() { m_action_icon = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("cog.png")), wxBITMAP_TYPE_PNG); } +void PrusaObjectDataViewModelNode::set_settings_list_icon(const wxIcon& icon) { + m_icon = icon; +} + // ***************************************************************************** // ---------------------------------------------------------------------------- // PrusaObjectDataViewModel @@ -414,6 +418,19 @@ wxDataViewItem PrusaObjectDataViewModel::AddChild( const wxDataViewItem &parent_ return child; } +wxDataViewItem PrusaObjectDataViewModel::AddSettingsChild(const wxDataViewItem &parent_item) +{ + PrusaObjectDataViewModelNode *root = (PrusaObjectDataViewModelNode*)parent_item.GetID(); + if (!root) return wxDataViewItem(0); + + const auto node = new PrusaObjectDataViewModelNode(root); + root->Insert(node, 0); + // notify control + const wxDataViewItem child((void*)node); + ItemAdded(parent_item, child); + return child; +} + wxDataViewItem PrusaObjectDataViewModel::Delete(const wxDataViewItem &item) { auto ret_item = wxDataViewItem(0); @@ -683,10 +700,14 @@ wxDataViewItem PrusaObjectDataViewModel::ReorganizeChildren(int current_volume_i return wxDataViewItem(node_parent->GetNthChild(new_volume_id)); } -// bool MyObjectTreeModel::IsEnabled(const wxDataViewItem &item, unsigned int col) const -// { -// -// } +bool PrusaObjectDataViewModel::IsEnabled(const wxDataViewItem &item, unsigned int col) const +{ + wxASSERT(item.IsOk()); + PrusaObjectDataViewModelNode *node = (PrusaObjectDataViewModelNode*)item.GetID(); + + // disable extruder selection for the "Settings" item + return !(col == 2 && node->m_extruder.IsEmpty()); +} wxDataViewItem PrusaObjectDataViewModel::GetParent(const wxDataViewItem &item) const { @@ -738,6 +759,21 @@ unsigned int PrusaObjectDataViewModel::GetChildren(const wxDataViewItem &parent, return count; } +bool PrusaObjectDataViewModel::HasSettings(const wxDataViewItem &item) const +{ + if (!item.IsOk()) + return false; + + PrusaObjectDataViewModelNode *node = (PrusaObjectDataViewModelNode*)item.GetID(); + if (node->GetChildCount() == 0) + return false; + + auto& children = node->GetChildren(); + if (children[0]->m_type == "settings") + return true; + + return false; +} // ---------------------------------------------------------------------------- // PrusaDoubleSlider @@ -1029,7 +1065,7 @@ wxString PrusaDoubleSlider::get_label(const SelectedSlider& selection) const void PrusaDoubleSlider::draw_thumb_text(wxDC& dc, const wxPoint& pos, const SelectedSlider& selection) const { - if (m_is_one_layer && selection != m_selection || !selection) + if ((m_is_one_layer || m_higher_value==m_lower_value) && selection != m_selection || !selection) return; wxCoord text_width, text_height; const wxString label = get_label(selection); diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index d1747e434..13fc764ce 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -183,9 +183,22 @@ public: m_icon = icon; m_type = "volume"; m_volume_id = volume_id; - m_extruder = extruder; + m_extruder = extruder; +#ifdef __WXGTK__ + // it's necessary on GTK because of control have to know if this item will be container + // in another case you couldn't to add subitem for this item + // it will be produce "segmentation fault" + m_container = true; +#endif //__WXGTK__ set_part_action_icon(); - } + } + + PrusaObjectDataViewModelNode( PrusaObjectDataViewModelNode* parent) : + m_parent(parent), + m_name("SETTINGS LIST"), + m_copy(wxEmptyString), + m_type("settings"), + m_extruder(wxEmptyString) {} ~PrusaObjectDataViewModelNode() { @@ -202,7 +215,7 @@ public: wxIcon& m_icon = m_empty_icon; wxString m_copy; std::string m_type; - int m_volume_id; + int m_volume_id = -2; bool m_container = false; wxString m_extruder = "default"; wxBitmap m_action_icon; @@ -326,6 +339,7 @@ public: // Set action icons for node void set_object_action_icon(); void set_part_action_icon(); + void set_settings_list_icon(const wxIcon& icon); }; // ---------------------------------------------------------------------------- @@ -350,6 +364,7 @@ public: const wxIcon& icon, const int = 0, const bool create_frst_child = true); + wxDataViewItem AddSettingsChild(const wxDataViewItem &parent_item); wxDataViewItem Delete(const wxDataViewItem &item); void DeleteAll(); void DeleteChildren(wxDataViewItem& parent); @@ -383,8 +398,7 @@ public: int new_volume_id, const wxDataViewItem &parent); -// virtual bool IsEnabled(const wxDataViewItem &item, -// unsigned int col) const override; + virtual bool IsEnabled(const wxDataViewItem &item, unsigned int col) const override; virtual wxDataViewItem GetParent(const wxDataViewItem &item) const override; virtual bool IsContainer(const wxDataViewItem &item) const override; @@ -394,6 +408,8 @@ public: // Is the container just a header or an item with all columns // In our case it is an item with all columns virtual bool HasContainerColumns(const wxDataViewItem& WXUNUSED(item)) const override { return true; } + + bool HasSettings(const wxDataViewItem &item) const; };