From 77e09e683d219200b434aeeff08b6553f0cb1b8e Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 12 Sep 2018 13:22:13 +0200 Subject: [PATCH] Fixed bug with PrusaDataViewBitmapText ctor on Linux + Cleaned code from unusable comments --- xs/src/slic3r/GUI/GUI_ObjectParts.cpp | 18 ++++++++---------- xs/src/slic3r/GUI/wxExtensions.cpp | 10 +++------- xs/src/slic3r/GUI/wxExtensions.hpp | 7 +------ 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index 73249edd5..ed56aae40 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -29,9 +29,9 @@ wxCollapsiblePane *m_collpane_settings = nullptr; PrusaDoubleSlider *m_slider = nullptr; wxGLCanvas *m_preview_canvas = nullptr; -wxBitmap/*Icon*/ m_icon_modifiermesh; -wxBitmap/*Icon*/ m_icon_solidmesh; -wxBitmap/*Icon*/ m_icon_manifold_warning; +wxBitmap m_icon_modifiermesh; +wxBitmap m_icon_solidmesh; +wxBitmap m_icon_manifold_warning; wxBitmap m_bmp_cog; wxBitmap m_bmp_split; @@ -141,11 +141,11 @@ void set_objects_from_model(Model &model) { } void init_mesh_icons(){ - m_icon_modifiermesh = wxBitmap/*wxIcon*/(Slic3r::GUI::from_u8(Slic3r::var("lambda.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("plugin.png")), wxBITMAP_TYPE_PNG); - m_icon_solidmesh = wxBitmap/*wxIcon*/(Slic3r::GUI::from_u8(Slic3r::var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG); + m_icon_modifiermesh = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("lambda.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("plugin.png")), wxBITMAP_TYPE_PNG); + m_icon_solidmesh = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG); // init icon for manifold warning - m_icon_manifold_warning = wxBitmap/*wxIcon*/(Slic3r::GUI::from_u8(Slic3r::var("exclamation_mark_.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("error.png")), wxBITMAP_TYPE_PNG); + m_icon_manifold_warning = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("exclamation_mark_.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("error.png")), wxBITMAP_TYPE_PNG); // init bitmap for "Split to sub-objects" context menu m_bmp_split = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("split.png")), wxBITMAP_TYPE_PNG); @@ -248,11 +248,10 @@ void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz) m_objects_ctrl->EnableDropTarget(wxDF_UNICODETEXT); #endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE - // column 0(Icon+Text) of the view control: + // column 0(Icon+Text) of the view control: + // And Icon can be consisting of several bitmaps m_objects_ctrl->AppendColumn(new wxDataViewColumn(_(L("Name")), new PrusaBitmapTextRenderer(), 0, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE)); -// m_objects_ctrl->AppendIconTextColumn(_(L("Name")), 0, wxDATAVIEW_CELL_INERT, 200, -// wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE); // column 1 of the view control: m_objects_ctrl->AppendTextColumn(_(L("Copy")), 1, wxDATAVIEW_CELL_INERT, 45, @@ -668,7 +667,6 @@ void add_object_to_list(const std::string &name, ModelObject* model_object) int errors = stats.degenerate_facets + stats.edges_fixed + stats.facets_removed + stats.facets_added + stats.facets_reversed + stats.backwards_edges; if (errors > 0) { -// const wxDataViewIconText data(item_name, m_icon_manifold_warning); const PrusaDataViewBitmapText data(item_name, m_icon_manifold_warning); wxVariant variant; variant << data; diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 6d03bb065..5facf95c9 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -383,7 +383,6 @@ bool PrusaObjectDataViewModelNode::update_settings_digest(const std::vectorm_name, node->m_icon); const PrusaDataViewBitmapText data(node->m_name, node->m_bmp); variant << data; break;} @@ -872,10 +869,9 @@ bool PrusaBitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state) { int xoffset = 0; - const /*wxIcon*/wxBitmap& icon = m_value.GetBitmap();// GetIcon(); + const wxBitmap& icon = m_value.GetBitmap(); if (icon.IsOk()) { -// dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2); dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2); xoffset = icon.GetWidth() + 4; } @@ -891,8 +887,8 @@ wxSize PrusaBitmapTextRenderer::GetSize() const { wxSize size = GetTextExtent(m_value.GetText()); - if (m_value.GetBitmap()/*GetIcon()*/.IsOk()) - size.x += m_value.GetBitmap()/*GetIcon()*/.GetWidth() + 4; + if (m_value.GetBitmap().IsOk()) + size.x += m_value.GetBitmap().GetWidth() + 4; return size; } return wxSize(80, 20); diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index 174253ad4..b6f9777a0 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -220,13 +220,11 @@ public: PrusaObjectDataViewModelNode( PrusaObjectDataViewModelNode* parent, const wxString& sub_obj_name, const wxBitmap& bmp, -// const wxIcon& icon, const wxString& extruder, const int volume_id=-1) { m_parent = parent; m_name = sub_obj_name; m_copy = wxEmptyString; -// m_icon = icon; m_bmp = bmp; m_type = "volume"; m_volume_id = volume_id; @@ -321,10 +319,8 @@ public: switch (col) { case 0:{ -// wxDataViewIconText data; PrusaDataViewBitmapText data; data << variant; -// m_icon = data.GetIcon(); m_bmp = data.GetBitmap(); m_name = data.GetText(); return true;} @@ -414,7 +410,6 @@ public: wxDataViewItem Add(const wxString &name, const int instances_count); wxDataViewItem AddChild(const wxDataViewItem &parent_item, const wxString &name, -// const wxIcon& icon, const wxBitmap& icon, const int extruder = 0, const bool create_frst_child = true); @@ -478,7 +473,7 @@ class PrusaBitmapTextRenderer : public wxDataViewCustomRenderer public: PrusaBitmapTextRenderer( wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align = wxDVR_DEFAULT_ALIGNMENT): - wxDataViewCustomRenderer(wxT("PrusaDataViewIconBitmapText"/*"wxDataViewIconText"*/), mode, align) {} + wxDataViewCustomRenderer(wxT("wxObject"), mode, align) {} bool SetValue(const wxVariant &value); bool GetValue(wxVariant &value) const;