diff --git a/src/slic3r/GUI/ExtraRenderers.cpp b/src/slic3r/GUI/ExtraRenderers.cpp index b49a3eb60e..046b8fa165 100644 --- a/src/slic3r/GUI/ExtraRenderers.cpp +++ b/src/slic3r/GUI/ExtraRenderers.cpp @@ -49,9 +49,9 @@ BitmapTextRenderer::~BitmapTextRenderer() #endif // SUPPORTS_MARKUP } -#ifdef SUPPORTS_MARKUP void BitmapTextRenderer::EnableMarkup(bool enable) { +#ifdef SUPPORTS_MARKUP #ifdef wxHAS_GENERIC_DATAVIEWCTRL if (enable) { if (!m_markupText) @@ -63,20 +63,30 @@ void BitmapTextRenderer::EnableMarkup(bool enable) m_markupText = nullptr; } } -#elseif - is_markupText = enable +#else + is_markupText = enable; #endif //wxHAS_GENERIC_DATAVIEWCTRL -} #endif // SUPPORTS_MARKUP +} bool BitmapTextRenderer::SetValue(const wxVariant &value) { m_value << value; -#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL) +#ifdef SUPPORTS_MARKUP +#ifdef wxHAS_GENERIC_DATAVIEWCTRL if (m_markupText) m_markupText->SetMarkup(m_value.GetText()); -#endif // SUPPORTS_MARKUP && wxHAS_GENERIC_DATAVIEWCTRL +#else +#if defined(__WXGTK__) + GValue gvalue = G_VALUE_INIT; + g_value_init(&gvalue, G_TYPE_STRING); + g_value_set_string(&gvalue, wxGTK_CONV_FONT(str.GetText(), GetOwner()->GetOwner()->GetFont())); + g_object_set_property(G_OBJECT(m_renderer/*.GetText()*/), is_markupText ? "markup" : "text", &gvalue); + g_value_unset(&gvalue); +#endif // __WXGTK__ +#endif // wxHAS_GENERIC_DATAVIEWCTRL +#endif // SUPPORTS_MARKUP return true; } @@ -117,10 +127,8 @@ bool BitmapTextRenderer::Render(wxRect rect, wxDC *dc, int state) #if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL) if (m_markupText) { - int flags = 0; - rect.x += xoffset; - m_markupText->Render(GetView(), *dc, rect, flags, GetEllipsizeMode()); + m_markupText->Render(GetView(), *dc, rect, 0, GetEllipsizeMode()); } else #endif // SUPPORTS_MARKUP && wxHAS_GENERIC_DATAVIEWCTRL @@ -161,7 +169,7 @@ wxSize BitmapTextRenderer::GetSize() const wxWindow* BitmapTextRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value) { - if (!can_create_editor_ctrl()) + if (can_create_editor_ctrl && !can_create_editor_ctrl()) return nullptr; DataViewBitmapText data; @@ -261,7 +269,7 @@ wxSize BitmapChoiceRenderer::GetSize() const wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value) { - if (!can_create_editor_ctrl()) + if (can_create_editor_ctrl && !can_create_editor_ctrl()) return nullptr; std::vector icons = get_extruder_color_icons(); diff --git a/src/slic3r/GUI/ExtraRenderers.hpp b/src/slic3r/GUI/ExtraRenderers.hpp index 41f0d7d32e..4c1fb09dec 100644 --- a/src/slic3r/GUI/ExtraRenderers.hpp +++ b/src/slic3r/GUI/ExtraRenderers.hpp @@ -61,7 +61,7 @@ class BitmapTextRenderer : public wxDataViewCustomRenderer #endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING { public: - BitmapTextRenderer(wxWindow* parent, + BitmapTextRenderer(bool use_markup = false, wxDataViewCellMode mode = #ifdef __WXOSX__ wxDATAVIEW_CELL_INERT @@ -73,24 +73,19 @@ public: #if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING ); #else - ) : - wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align), - m_parent(parent) + ) : + wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align) { -#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL) - m_markupText = nullptr; -#endif // SUPPORTS_MARKUP && wxHAS_GENERIC_DATAVIEWCTRL + EnableMarkup(use_markup); } #endif //ENABLE_NONCUSTOM_DATA_VIEW_RENDERING ~BitmapTextRenderer(); -#ifdef SUPPORTS_MARKUP void EnableMarkup(bool enable = true); -#endif // SUPPORTS_MARKUP - bool SetValue(const wxVariant& value); - bool GetValue(wxVariant& value) const; + bool SetValue(const wxVariant& value) override; + bool GetValue(wxVariant& value) const override; #if ENABLE_NONCUSTOM_DATA_VIEW_RENDERING && wxUSE_ACCESSIBILITY virtual wxString GetAccessibleDescription() const override; #endif // wxUSE_ACCESSIBILITY && ENABLE_NONCUSTOM_DATA_VIEW_RENDERING @@ -115,15 +110,14 @@ public: private: DataViewBitmapText m_value; bool m_was_unusable_symbol{ false }; - wxWindow* m_parent{ nullptr }; std::function can_create_editor_ctrl { nullptr }; #ifdef SUPPORTS_MARKUP #ifdef wxHAS_GENERIC_DATAVIEWCTRL - class wxItemMarkupText* m_markupText; - #elseif - bool is_markupText; + class wxItemMarkupText* m_markupText { nullptr };; + #else + bool is_markupText {false}; #endif #endif // SUPPORTS_MARKUP }; diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index bbc0f5760b..7648f7d233 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -277,7 +277,7 @@ void ObjectList::create_objects_ctrl() // column ItemName(Icon+Text) of the view control: // And Icon can be consisting of several bitmaps - BitmapTextRenderer* bmp_text_renderer = new BitmapTextRenderer(this); + BitmapTextRenderer* bmp_text_renderer = new BitmapTextRenderer(); bmp_text_renderer->set_can_create_editor_ctrl_function([this]() { return m_objects_model->GetItemType(GetSelection()) & (itVolume | itObject); }); diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index d13ef469f1..da9c8fe25d 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -323,7 +323,7 @@ const Option& OptionsSearcher::get_option(size_t pos_in_filter) const const Option& OptionsSearcher::get_option(const std::string& opt_key) const { - auto it = std::upper_bound(options.begin(), options.end(), Option({ boost::nowide::widen(opt_key) })); + auto it = std::lower_bound(options.begin(), options.end(), Option({ boost::nowide::widen(opt_key) })); assert(it != options.end()); return options[it - options.begin()]; diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 4db41ffaa3..1bdc2959b7 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -35,7 +35,7 @@ static const std::map type_icon_names = { {Preset::TYPE_SLA_PRINT, "cog" }, {Preset::TYPE_FILAMENT, "spool" }, {Preset::TYPE_SLA_MATERIAL, "resin" }, - {Preset::TYPE_PRINTER, "sla_printer" }, + {Preset::TYPE_PRINTER, "printer" }, }; static std::string black = "#000000"; @@ -427,7 +427,7 @@ wxString UnsavedChangesModel::GetColumnType(unsigned int col) const //------------------------------------------ UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type) - : DPIDialog(NULL, wxID_ANY, _L("Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) + : DPIDialog(nullptr, wxID_ANY, _L("Unsaved Changes"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { wxColour bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); SetBackgroundColour(bgr_clr); @@ -440,15 +440,12 @@ UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type) m_tree->AssociateModel(m_tree_model); m_tree_model->SetAssociatedControl(m_tree); - m_tree->AppendToggleColumn(/*L"\u2714"*/"", UnsavedChangesModel::colToggle, wxDATAVIEW_CELL_ACTIVATABLE, 6 * em, wxALIGN_NOT);//2610,11,12 //2714 + m_tree->AppendColumn(new wxDataViewColumn("", new BitmapTextRenderer(true), UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE)); - BitmapTextRenderer* renderer = new BitmapTextRenderer(m_tree); -#ifdef SUPPORTS_MARKUP - renderer->EnableMarkup(); -#endif - m_tree->AppendColumn(new wxDataViewColumn("", renderer, UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE)); - m_tree->AppendColumn(new wxDataViewColumn("Old value", renderer, UnsavedChangesModel::colOldValue, 20 * em, wxALIGN_TOP)); - m_tree->AppendColumn(new wxDataViewColumn("New value", renderer, UnsavedChangesModel::colNewValue, 20 * em, wxALIGN_TOP)); + m_tree->AppendToggleColumn(L"\u2714", UnsavedChangesModel::colToggle, wxDATAVIEW_CELL_ACTIVATABLE, 6 * em);//2610,11,12 //2714 + + m_tree->AppendColumn(new wxDataViewColumn("Old value", new BitmapTextRenderer(true), UnsavedChangesModel::colOldValue, 20 * em, wxALIGN_TOP)); + m_tree->AppendColumn(new wxDataViewColumn("New value", new BitmapTextRenderer(true), UnsavedChangesModel::colNewValue, 20 * em, wxALIGN_TOP)); m_tree->Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &UnsavedChangesDialog::item_value_changed, this); diff --git a/src/slic3r/GUI/UnsavedChangesDialog.hpp b/src/slic3r/GUI/UnsavedChangesDialog.hpp index c4a02d7bcc..3d5867ea44 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.hpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.hpp @@ -134,8 +134,8 @@ class UnsavedChangesModel : public wxDataViewModel public: enum { - colToggle, colIconText, + colToggle, colOldValue, colNewValue, colMax