From 4132711f4c47077608c0a8d41600ee03e8b69e8b Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Mon, 5 Dec 2022 09:13:27 +0800 Subject: [PATCH] ENH: [STUDIO-1528] support list value icons for param field Change-Id: I44f14fde20fe4d9859c019ead09d1d565af23ba4 --- resources/images/param_3dhoneycomb.svg | 11 +++++++ resources/images/param_adaptivecubic.svg | 30 +++++++++++++++++++ resources/images/param_alignedrectilinear.svg | 15 ++++++++++ resources/images/param_archimedeanchords.svg | 11 +++++++ resources/images/param_concentric.svg | 12 ++++++++ resources/images/param_cubic.svg | 30 +++++++++++++++++++ resources/images/param_grid.svg | 16 ++++++++++ resources/images/param_gyroid.svg | 16 ++++++++++ resources/images/param_hilbertcurve.svg | 13 ++++++++ resources/images/param_honeycomb.svg | 11 +++++++ resources/images/param_lightning.svg | 13 ++++++++ resources/images/param_line.svg | 22 ++++++++++++++ resources/images/param_monotonic.svg | 15 ++++++++++ resources/images/param_monotonicline.svg | 21 +++++++++++++ resources/images/param_octagramspiral.svg | 12 ++++++++ resources/images/param_rectilinear-grid.svg | 20 +++++++++++++ resources/images/param_rectilinear.svg | 15 ++++++++++ resources/images/param_supportcubic.svg | 30 +++++++++++++++++++ resources/images/param_tri-hexagon.svg | 19 ++++++++++++ resources/images/param_triangles.svg | 19 ++++++++++++ resources/images/param_zig-zag.svg | 20 +++++++++++++ src/slic3r/GUI/Field.cpp | 30 +++++++++++++++++-- 22 files changed, 399 insertions(+), 2 deletions(-) create mode 100644 resources/images/param_3dhoneycomb.svg create mode 100644 resources/images/param_adaptivecubic.svg create mode 100644 resources/images/param_alignedrectilinear.svg create mode 100644 resources/images/param_archimedeanchords.svg create mode 100644 resources/images/param_concentric.svg create mode 100644 resources/images/param_cubic.svg create mode 100644 resources/images/param_grid.svg create mode 100644 resources/images/param_gyroid.svg create mode 100644 resources/images/param_hilbertcurve.svg create mode 100644 resources/images/param_honeycomb.svg create mode 100644 resources/images/param_lightning.svg create mode 100644 resources/images/param_line.svg create mode 100644 resources/images/param_monotonic.svg create mode 100644 resources/images/param_monotonicline.svg create mode 100644 resources/images/param_octagramspiral.svg create mode 100644 resources/images/param_rectilinear-grid.svg create mode 100644 resources/images/param_rectilinear.svg create mode 100644 resources/images/param_supportcubic.svg create mode 100644 resources/images/param_tri-hexagon.svg create mode 100644 resources/images/param_triangles.svg create mode 100644 resources/images/param_zig-zag.svg diff --git a/resources/images/param_3dhoneycomb.svg b/resources/images/param_3dhoneycomb.svg new file mode 100644 index 000000000..9d2b94182 --- /dev/null +++ b/resources/images/param_3dhoneycomb.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/resources/images/param_adaptivecubic.svg b/resources/images/param_adaptivecubic.svg new file mode 100644 index 000000000..7490ca81b --- /dev/null +++ b/resources/images/param_adaptivecubic.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/param_alignedrectilinear.svg b/resources/images/param_alignedrectilinear.svg new file mode 100644 index 000000000..3e29d271a --- /dev/null +++ b/resources/images/param_alignedrectilinear.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/resources/images/param_archimedeanchords.svg b/resources/images/param_archimedeanchords.svg new file mode 100644 index 000000000..80d653916 --- /dev/null +++ b/resources/images/param_archimedeanchords.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/resources/images/param_concentric.svg b/resources/images/param_concentric.svg new file mode 100644 index 000000000..47062df63 --- /dev/null +++ b/resources/images/param_concentric.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/resources/images/param_cubic.svg b/resources/images/param_cubic.svg new file mode 100644 index 000000000..344aeb1c8 --- /dev/null +++ b/resources/images/param_cubic.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/param_grid.svg b/resources/images/param_grid.svg new file mode 100644 index 000000000..5ef847573 --- /dev/null +++ b/resources/images/param_grid.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/resources/images/param_gyroid.svg b/resources/images/param_gyroid.svg new file mode 100644 index 000000000..fa42716ef --- /dev/null +++ b/resources/images/param_gyroid.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/resources/images/param_hilbertcurve.svg b/resources/images/param_hilbertcurve.svg new file mode 100644 index 000000000..f76ff649e --- /dev/null +++ b/resources/images/param_hilbertcurve.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/resources/images/param_honeycomb.svg b/resources/images/param_honeycomb.svg new file mode 100644 index 000000000..9d2b94182 --- /dev/null +++ b/resources/images/param_honeycomb.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/resources/images/param_lightning.svg b/resources/images/param_lightning.svg new file mode 100644 index 000000000..0385be412 --- /dev/null +++ b/resources/images/param_lightning.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/resources/images/param_line.svg b/resources/images/param_line.svg new file mode 100644 index 000000000..aed3393a8 --- /dev/null +++ b/resources/images/param_line.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/param_monotonic.svg b/resources/images/param_monotonic.svg new file mode 100644 index 000000000..0c9245e28 --- /dev/null +++ b/resources/images/param_monotonic.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/resources/images/param_monotonicline.svg b/resources/images/param_monotonicline.svg new file mode 100644 index 000000000..b95924270 --- /dev/null +++ b/resources/images/param_monotonicline.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/param_octagramspiral.svg b/resources/images/param_octagramspiral.svg new file mode 100644 index 000000000..d4848698b --- /dev/null +++ b/resources/images/param_octagramspiral.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/resources/images/param_rectilinear-grid.svg b/resources/images/param_rectilinear-grid.svg new file mode 100644 index 000000000..c47cb2c82 --- /dev/null +++ b/resources/images/param_rectilinear-grid.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/param_rectilinear.svg b/resources/images/param_rectilinear.svg new file mode 100644 index 000000000..3e29d271a --- /dev/null +++ b/resources/images/param_rectilinear.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/resources/images/param_supportcubic.svg b/resources/images/param_supportcubic.svg new file mode 100644 index 000000000..344aeb1c8 --- /dev/null +++ b/resources/images/param_supportcubic.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/param_tri-hexagon.svg b/resources/images/param_tri-hexagon.svg new file mode 100644 index 000000000..636925673 --- /dev/null +++ b/resources/images/param_tri-hexagon.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/param_triangles.svg b/resources/images/param_triangles.svg new file mode 100644 index 000000000..8b7fd23a0 --- /dev/null +++ b/resources/images/param_triangles.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/param_zig-zag.svg b/resources/images/param_zig-zag.svg new file mode 100644 index 000000000..58ddf0ea9 --- /dev/null +++ b/resources/images/param_zig-zag.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 2023ed957..6fe5d297c 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1009,6 +1009,7 @@ void Choice::BUILD() { temp = new choice_ctrl(m_parent, wxID_ANY, wxString(""), wxDefaultPosition, size, 0, nullptr, wxCB_READONLY); #endif //__WXOSX__ } + temp->GetDropDown().SetUseContentWidth(true); if (parent_is_custom_ctrl && m_opt.height < 0) opt_height = (double) temp->GetTextCtrl()->GetSize().GetHeight() / m_em_unit; @@ -1035,8 +1036,19 @@ void Choice::BUILD() { temp->Append(el); } else { // Append localized enum_labels - for (auto el : m_opt.enum_labels) - temp->Append(_(el)); + int i = 0; + boost::filesystem::path image_path(Slic3r::resources_dir()); + image_path /= "images"; + for (auto el : m_opt.enum_labels) { + auto icon_name = "param_" + m_opt.enum_values[i]; + if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) { + ScalableBitmap bm(temp, icon_name, 24); + temp->Append(_(el), bm.bmp()); + } else { + temp->Append(_(el)); + } + ++i; + } } set_selection(); } @@ -1393,6 +1405,20 @@ void Choice::msw_rescale() field->SetValue(selection) : field->SetSelection(idx); #else + if (!m_opt.enum_labels.empty()) { + boost::filesystem::path image_path(Slic3r::resources_dir()); + image_path /= "images"; + int i = 0; + auto temp = dynamic_cast(window); + for (auto el : m_opt.enum_values) { + auto icon_name = "param_" + m_opt.enum_values[i]; + if (boost::filesystem::exists(image_path / (icon_name + ".svg"))) { + ScalableBitmap bm(window, icon_name, 24); + temp->SetItemBitmap(i, bm.bmp()); + } + ++i; + } + } auto size = wxSize(def_width_wider() * m_em_unit, wxDefaultCoord); if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);