Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2020-08-10 10:45:32 +0300
committerYuSanka <yusanka@gmail.com>2020-08-10 10:45:32 +0300
commit8b74ae4568db08dd1039204291b9b83e2842b7b4 (patch)
treef359e114094e54922b75fc09a05c5e93338f37cc /src/slic3r
parentc4569c93f2afc988de3c8b11fd1c9ce51af41b55 (diff)
Use the wxDataViewIconTextRenderer instead of the DataViewBitmapTextRenderer under GTK
Diffstat (limited to 'src/slic3r')
-rw-r--r--src/slic3r/GUI/UnsavedChangesDialog.cpp37
-rw-r--r--src/slic3r/GUI/UnsavedChangesDialog.hpp10
2 files changed, 43 insertions, 4 deletions
diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp
index 3f85ac742..33f6f19de 100644
--- a/src/slic3r/GUI/UnsavedChangesDialog.cpp
+++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp
@@ -42,14 +42,14 @@ static std::string orange = "#ed6b21";
static void color_string(wxString& str, const std::string& color)
{
-#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL)
+#if defined(SUPPORTS_MARKUP) && /*!defined(__APPLE__)*/defined(wxHAS_GENERIC_DATAVIEWCTRL)
str = from_u8((boost::format("<span color=\"%1%\">%2%</span>") % color % into_u8(str)).str());
#endif
}
static void make_string_bold(wxString& str)
{
-#if defined(SUPPORTS_MARKUP) && defined(wxHAS_GENERIC_DATAVIEWCTRL)
+#if defined(SUPPORTS_MARKUP) && !defined(__APPLE__)//defined(wxHAS_GENERIC_DATAVIEWCTRL)
str = from_u8((boost::format("<b>%1%</b>") % into_u8(str)).str());
#endif
}
@@ -60,7 +60,11 @@ ModelNode::ModelNode(Preset::Type preset_type, const wxString& text) :
m_preset_type(preset_type),
m_text(text)
{
+#ifdef __linux__
+ m_icon.CopyFromBitmap(create_scaled_bitmap(type_icon_names.at(preset_type)));
+#else
m_icon = create_scaled_bitmap(type_icon_names.at(preset_type));
+#endif //__linux__
}
// group node
@@ -68,7 +72,11 @@ ModelNode::ModelNode(ModelNode* parent, const wxString& text, const std::string&
m_parent(parent),
m_text(text)
{
+#ifdef __linux__
+ m_icon.CopyFromBitmap(create_scaled_bitmap(icon_name));
+#else
m_icon = create_scaled_bitmap(icon_name);
+#endif //__linux__
}
// category node
@@ -300,7 +308,11 @@ void UnsavedChangesModel::GetValue(wxVariant& variant, const wxDataViewItem& ite
variant = node->m_toggle;
break;
case colIconText:
+#ifdef __linux__
+ variant << wxDataViewIconText(node->m_text, node->m_icon);
+#else
variant << DataViewBitmapText(node->m_text, node->m_icon);
+#endif //__linux__
break;
case colOldValue:
variant << DataViewBitmapText(node->m_old_value, node->m_old_color_bmp);
@@ -322,10 +334,18 @@ bool UnsavedChangesModel::SetValue(const wxVariant& variant, const wxDataViewIte
switch (col)
{
case colIconText: {
+#ifdef __linux__
+ wxDataViewIconText data;
+#else
DataViewBitmapText data;
+#endif //__linux__
data << variant;
- node->m_icon = data.GetBitmap();
node->m_text = data.GetText();
+#ifdef __linux__
+ node->m_icon = data.GetIcon();
+#else
+ node->m_icon = data.GetBitmap();
+#endif //__linux__
return true; }
case colToggle:
node->m_toggle = variant.GetBool();
@@ -439,7 +459,16 @@ UnsavedChangesDialog::UnsavedChangesDialog(Preset::Type type)
m_tree_model->SetAssociatedControl(m_tree);
m_tree->AppendToggleColumn(L"\u2714", UnsavedChangesModel::colToggle, wxDATAVIEW_CELL_ACTIVATABLE/*, 6 * em*/);//2610,11,12 //2714
- wxDataViewColumn* icon_text_clmn = new wxDataViewColumn("", new BitmapTextRenderer(true), UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE);
+
+#ifdef __linux__
+ wxDataViewIconTextRenderer* rd = new wxDataViewIconTextRenderer();
+#ifdef SUPPORTS_MARKUP
+ rd->EnableMarkup(true);
+#endif
+ wxDataViewColumn* icon_text_clmn = new wxDataViewColumn("", rd, UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_CELL_INERT);
+#else
+ wxDataViewColumn* icon_text_clmn = new wxDataViewColumn("", new BitmapTextRenderer(true), UnsavedChangesModel::colIconText, 30 * em, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE);
+#endif //__linux__
m_tree->AppendColumn(icon_text_clmn);
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));
diff --git a/src/slic3r/GUI/UnsavedChangesDialog.hpp b/src/slic3r/GUI/UnsavedChangesDialog.hpp
index 8afd97896..29926cb24 100644
--- a/src/slic3r/GUI/UnsavedChangesDialog.hpp
+++ b/src/slic3r/GUI/UnsavedChangesDialog.hpp
@@ -18,6 +18,12 @@ namespace GUI{
class ModelNode;
WX_DEFINE_ARRAY_PTR(ModelNode*, ModelNodePtrArray);
+// On all of 3 different platforms Bitmap+Text icon column looks different
+// because of Markup text is missed or not implemented.
+// As a temporary workaround, we will use:
+// MSW - DataViewBitmapText (our custom renderer wxBitmap + wxString, supported Markup text)
+// OSX - -//-, but Markup text is not implemented right now
+// GTK - wxDataViewIconText (wxWidgets for GTK renderer wxIcon + wxString, supported Markup text)
class ModelNode
{
wxWindow* m_parent_win{ nullptr };
@@ -47,7 +53,11 @@ class ModelNode
public:
bool m_toggle {true};
+#ifdef __linux__
+ wxIcon m_icon;
+#else
wxBitmap m_icon;
+#endif //__linux__
wxBitmap m_old_color_bmp;
wxBitmap m_new_color_bmp;
wxString m_text;