diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 956a0008a..c7eecea75 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -1232,11 +1232,11 @@ void enable_action_buttons(bool enable) return; // Update background colour for buttons -// const wxColour bgrd_color = enable ? wxColour(255, 96, 0) : wxColour(204, 204, 204); + const wxColour bgrd_color = enable ? wxColour(224, 224, 224/*255, 96, 0*/) : wxColour(204, 204, 204); for (auto btn : g_buttons) { btn->Enable(enable); -// btn->SetBackgroundColour(bgrd_color); + btn->SetBackgroundColour(bgrd_color); } } diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index 7820eec43..5af20564b 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -249,8 +249,12 @@ void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz) #endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE // column 0(Icon+Text) of the view control: - m_objects_ctrl->AppendIconTextColumn(_(L("Name")), 0, wxDATAVIEW_CELL_INERT, 200, - wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE); + wxDataViewColumn *ret = new wxDataViewColumn(_(L("Name")), + new PrusaIconTextRenderer(wxT("PrusaDataViewIconText")), + 0, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE); + m_objects_ctrl->AppendColumn(ret); +// 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, @@ -1014,7 +1018,6 @@ void get_settings_choice(wxMenu *menu, int id, bool is_part) const auto item = m_objects_ctrl->GetSelection(); if (item) { const auto settings_item = m_objects_model->HasSettings(item); - settings_item ? printf("settings_item exist\n") : printf("settings_item will be created\n"); m_objects_ctrl->Select(settings_item ? settings_item : m_objects_model->AddSettingsChild(item)); #ifndef __WXOSX__ @@ -1553,7 +1556,6 @@ void part_selection_changed() wxString object_name = wxEmptyString; if (item) { - printf("item exists\n"); const bool is_settings_item = m_objects_model->IsSettingsItem(item); bool is_part = false; wxString og_name = wxEmptyString; diff --git a/xs/src/slic3r/GUI/OptionsGroup.hpp b/xs/src/slic3r/GUI/OptionsGroup.hpp index 5a18803a6..4941e5453 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.hpp +++ b/xs/src/slic3r/GUI/OptionsGroup.hpp @@ -161,8 +161,10 @@ public: ogDrawFlag flag = ogDEFAULT, column_t extra_clmn = nullptr) : m_parent(_parent), title(title), m_show_modified_btns(is_tab_opt), staticbox(title!=""), m_flag(flag), extra_column(extra_clmn){ - stb = new wxStaticBox(_parent, wxID_ANY, title); - stb->SetFont(bold_font()); + if (staticbox) { + stb = new wxStaticBox(_parent, wxID_ANY, title); + stb->SetFont(bold_font()); + } sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL)); auto num_columns = 1U; if (label_width != 0) num_columns++; diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 737833abd..f8fe5a582 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -473,9 +473,6 @@ wxDataViewItem PrusaObjectDataViewModel::AddSettingsChild(const wxDataViewItem & // notify control const wxDataViewItem child((void*)node); ItemAdded(parent_item, child); - - if (child) - printf("SettingsChild is created\n"); return child; } @@ -849,6 +846,52 @@ void PrusaObjectDataViewModel::UpdateSettingsDigest(const wxDataViewItem &item, ItemChanged(item); } + +// --------------------------------------------------------- +// PrusaIconTextRenderer +// --------------------------------------------------------- + +bool PrusaIconTextRenderer::SetValue(const wxVariant &value) +{ + m_value << value; + return true; +} + +bool PrusaIconTextRenderer::GetValue(wxVariant& WXUNUSED(value)) const +{ + return false; +} + +bool PrusaIconTextRenderer::Render(wxRect rect, wxDC *dc, int state) +{ + int xoffset = 0; + + const wxIcon& icon = m_value.GetIcon(); + if (icon.IsOk()) + { + dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2); + xoffset = icon.GetWidth() + 4; + } + + RenderText(m_value.GetText(), xoffset, rect, dc, state); + + return true; +} + +wxSize PrusaIconTextRenderer::GetSize() const +{ + if (!m_value.GetText().empty()) + { + wxSize size = GetTextExtent(m_value.GetText()); + + if (m_value.GetIcon().IsOk()) + size.x += m_value.GetIcon().GetWidth() + 4; + return size; + } + return wxSize(80, 20); +} + + // ---------------------------------------------------------------------------- // PrusaDoubleSlider // ---------------------------------------------------------------------------- diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index 08c899a19..5e5afe6dc 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -415,6 +415,29 @@ public: }; +// ---------------------------------------------------------------------------- +// PrusaIconTextRenderer +// ---------------------------------------------------------------------------- + +class PrusaIconTextRenderer : public wxDataViewCustomRenderer +{ +public: + PrusaIconTextRenderer( const wxString &varianttype = wxT("PrusaDataViewIconText"), + wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, + int align = wxDVR_DEFAULT_ALIGNMENT) {} + + bool SetValue(const wxVariant &value); + bool GetValue(wxVariant &value) const; + + virtual bool Render(wxRect cell, wxDC *dc, int state); + virtual wxSize GetSize() const; + + virtual bool HasEditorCtrl() const { return false; } + +private: + wxDataViewIconText m_value; +}; + // ---------------------------------------------------------------------------- // MyCustomRenderer