From a56bbea1408d1087821975c98f66cce68e4e3d73 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 22 May 2020 15:23:05 +0200 Subject: [PATCH 1/5] Reworked sys_color_changed() functions Fixed OSX specific bugs: - toolbar flashing for some mainframe sizes (Retina specific) - size of mainframe when settings layout in slNew mode Added missed icons to the "white" folder --- resources/icons/cog_.svg | 17 ++++++++++++++ resources/icons/white/edit_uni.svg | 20 +++++++++++++++++ resources/icons/white/search.svg | 4 ++++ src/slic3r/GUI/Field.cpp | 6 +++++ src/slic3r/GUI/Field.hpp | 1 + src/slic3r/GUI/GLCanvas3D.cpp | 6 ++++- src/slic3r/GUI/GUI_App.cpp | 5 +++++ src/slic3r/GUI/GUI_App.hpp | 1 + src/slic3r/GUI/GUI_ObjectLayers.cpp | 27 +++++++++++++++++++++++ src/slic3r/GUI/GUI_ObjectLayers.hpp | 1 + src/slic3r/GUI/GUI_ObjectManipulation.cpp | 4 +++- src/slic3r/GUI/MainFrame.cpp | 17 ++++++++++++-- src/slic3r/GUI/OptionsGroup.cpp | 14 ++++++++++++ src/slic3r/GUI/OptionsGroup.hpp | 1 + src/slic3r/GUI/Plater.cpp | 6 +++-- src/slic3r/GUI/Tab.cpp | 15 ++++++++----- src/slic3r/GUI/Tab.hpp | 1 + 17 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 resources/icons/cog_.svg create mode 100644 resources/icons/white/edit_uni.svg create mode 100644 resources/icons/white/search.svg diff --git a/resources/icons/cog_.svg b/resources/icons/cog_.svg new file mode 100644 index 000000000..94cab0a8e --- /dev/null +++ b/resources/icons/cog_.svg @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/resources/icons/white/edit_uni.svg b/resources/icons/white/edit_uni.svg new file mode 100644 index 000000000..661924763 --- /dev/null +++ b/resources/icons/white/edit_uni.svg @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/resources/icons/white/search.svg b/resources/icons/white/search.svg new file mode 100644 index 000000000..679bb30f7 --- /dev/null +++ b/resources/icons/white/search.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 834613743..4c7419cea 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -306,6 +306,12 @@ void Field::msw_rescale(bool rescale_sidetext) } } +void Field::sys_color_changed() +{ + m_Undo_to_sys_btn->msw_rescale(); + m_Undo_btn->msw_rescale(); +} + template bool is_defined_input_value(wxWindow* win, const ConfigOptionType& type) { diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index f41e3c7b0..484b2059f 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -221,6 +221,7 @@ public: } virtual void msw_rescale(bool rescale_sidetext = false); + void sys_color_changed(); bool get_enter_pressed() const { return bEnterPressed; } void set_enter_pressed(bool pressed) { bEnterPressed = pressed; } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 33b8e9b21..03e95b8a9 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4864,7 +4864,7 @@ bool GLCanvas3D::_init_main_toolbar() return false; item.name = "settings"; - item.icon_filename = "cog.svg"; + item.icon_filename = "cog_.svg"; item.tooltip = _u8L("Switch to Settings") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (m_process->current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab")) + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab") ; @@ -5417,6 +5417,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() const m_main_toolbar.set_scale(sc); m_undoredo_toolbar.set_scale(sc); m_collapse_toolbar.set_scale(sc); + size *= m_retina_helper->get_scale_factor(); #else m_main_toolbar.set_icons_size(size); m_undoredo_toolbar.set_icons_size(size); @@ -5437,6 +5438,9 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale() const // set minimum scale as a auto scale for the toolbars float new_scale = std::min(new_h_scale, new_v_scale); +#if ENABLE_RETINA_GL + new_scale /= m_retina_helper->get_scale_factor(); +#endif if (fabs(new_scale - scale) > 0.01) // scale is changed by 1% and more wxGetApp().set_auto_toolbar_icon_scale(new_scale); } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 411b6aeec..88018c87f 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -580,6 +580,11 @@ void GUI_App::set_label_clr_sys(const wxColour& clr) { app_config->save(); } +wxSize GUI_App::get_min_size() const +{ + return wxSize(76*m_em_unit, 49 * m_em_unit); +} + float GUI_App::toolbar_icon_scale(const bool is_limited/* = false*/) const { #ifdef __APPLE__ diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 984a1241e..c9664e8d5 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -138,6 +138,7 @@ public: const wxFont& bold_font() { return m_bold_font; } const wxFont& normal_font() { return m_normal_font; } int em_unit() const { return m_em_unit; } + wxSize get_min_size() const; float toolbar_icon_scale(const bool is_limited = false) const; void set_auto_toolbar_icon_scale(float scale) const; diff --git a/src/slic3r/GUI/GUI_ObjectLayers.cpp b/src/slic3r/GUI/GUI_ObjectLayers.cpp index 157e45ab4..cd65f69fc 100644 --- a/src/slic3r/GUI/GUI_ObjectLayers.cpp +++ b/src/slic3r/GUI/GUI_ObjectLayers.cpp @@ -272,6 +272,33 @@ void ObjectLayers::msw_rescale() m_grid_sizer->Layout(); } +void ObjectLayers::sys_color_changed() +{ + m_bmp_delete.msw_rescale(); + m_bmp_add.msw_rescale(); + + m_grid_sizer->SetHGap(wxGetApp().em_unit()); + + // rescale edit-boxes + const int cells_cnt = m_grid_sizer->GetCols() * m_grid_sizer->GetEffectiveRowsCount(); + for (int i = 0; i < cells_cnt; i++) + { + const wxSizerItem* item = m_grid_sizer->GetItem(i); + if (item->IsSizer()) {// case when we have editor with buttons + const std::vector btns = {2, 3}; // del_btn, add_btn + for (auto btn : btns) { + wxSizerItem* b_item = item->GetSizer()->GetItem(btn); + if (b_item->IsWindow()) { + auto button = dynamic_cast(b_item->GetWindow()); + if (button != nullptr) + button->msw_rescale(); + } + } + } + } + m_grid_sizer->Layout(); +} + void ObjectLayers::reset_selection() { m_selectable_range = { 0.0, 0.0 }; diff --git a/src/slic3r/GUI/GUI_ObjectLayers.hpp b/src/slic3r/GUI/GUI_ObjectLayers.hpp index 08b594910..736b5844d 100644 --- a/src/slic3r/GUI/GUI_ObjectLayers.hpp +++ b/src/slic3r/GUI/GUI_ObjectLayers.hpp @@ -94,6 +94,7 @@ public: void UpdateAndShow(const bool show) override; void msw_rescale(); + void sys_color_changed(); void reset_selection(); void set_selectable_range(const t_layer_height_range& range) { m_selectable_range = range; } diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index 2179a9559..32de03c98 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -417,6 +417,8 @@ ObjectManipulation::ObjectManipulation(wxWindow* parent) : m_main_grid_sizer->Add(editors_grid_sizer, 1, wxEXPAND); m_check_inch = new wxCheckBox(parent, wxID_ANY, "Inches"); + m_check_inch->SetFont(wxGetApp().normal_font()); + m_check_inch->SetValue(m_imperial_units); m_check_inch->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent&) { wxGetApp().app_config->set("use_inches", m_check_inch->GetValue() ? "1" : "0"); @@ -995,7 +997,7 @@ void ObjectManipulation::sys_color_changed() for (int id = 0; id < 3; ++id) m_mirror_buttons[id].first->msw_rescale(); - get_og()->msw_rescale(); + get_og()->sys_color_changed(); } static const char axes[] = { 'x', 'y', 'z' }; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 65c212d11..0bcf1bd95 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -89,6 +89,19 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S m_loaded = true; +#ifdef __APPLE__ + // Using SetMinSize() on Mac messes up the window position in some cases + // cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0 + // So, if we haven't possibility to set MinSize() for the MainFrame, + // set the MinSize() as a half of regular for the m_plater and m_tabpanel, when settings layout is in slNew mode + // Otherwise, MainFrame will be maximized by height + if (slNew) { + wxSize size = wxGetApp().get_min_size(); + size.SetWidth(int(0.5*size.GetHeight())); + m_plater->SetMinSize(size); + m_tabpanel->SetMinSize(size); + } +#endif // initialize layout auto sizer = new wxBoxSizer(wxVERTICAL); if (m_plater && m_layout != slOld) @@ -101,7 +114,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S SetSizer(sizer); Fit(); - const wxSize min_size = wxSize(76*wxGetApp().em_unit(), 49*wxGetApp().em_unit()); + const wxSize min_size = wxGetApp().get_min_size(); //wxSize(76*wxGetApp().em_unit(), 49*wxGetApp().em_unit()); #ifdef __APPLE__ // Using SetMinSize() on Mac messes up the window position in some cases // cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0 @@ -1471,7 +1484,7 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe) // wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on Windows 10 // with multiple high resolution displays connected. - m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME); + m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxGetApp().get_min_size(), wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME); #ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList m_tabpanel->SetFont(Slic3r::GUI::wxGetApp().normal_font()); #endif diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 5b2b5703b..5c2d6d38e 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -568,6 +568,20 @@ void ConfigOptionsGroup::msw_rescale() } } +void ConfigOptionsGroup::sys_color_changed() +{ + // update bitmaps for near label widgets (like "Set uniform scale" button on settings panel) + if (rescale_near_label_widget) + for (auto near_label_widget : m_near_label_widget_ptrs) + rescale_near_label_widget(near_label_widget); + + // update undo buttons : rescale bitmaps + for (const auto& field : m_fields) + field.second->sys_color_changed(); + + m_grid_sizer->Layout(); +} + boost::any ConfigOptionsGroup::config_value(const std::string& opt_key, int opt_index, bool deserialize) { if (deserialize) { diff --git a/src/slic3r/GUI/OptionsGroup.hpp b/src/slic3r/GUI/OptionsGroup.hpp index 09df9ea65..9fbb28339 100644 --- a/src/slic3r/GUI/OptionsGroup.hpp +++ b/src/slic3r/GUI/OptionsGroup.hpp @@ -280,6 +280,7 @@ public: void Show(const bool show); bool update_visibility(ConfigOptionMode mode); void msw_rescale(); + void sys_color_changed(); boost::any config_value(const std::string& opt_key, int opt_index, bool deserialize); // return option value from config boost::any get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index = -1); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 23ef1acc0..cea671c4f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -771,7 +771,9 @@ Sidebar::Sidebar(Plater *parent) p->scrolled->SetScrollbars(0, 100, 1, 2); SetFont(wxGetApp().normal_font()); +#ifndef __APPLE__ SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); +#endif // Sizer in the scrolled area auto *scrolled_sizer = new wxBoxSizer(wxVERTICAL); @@ -1108,7 +1110,7 @@ void Sidebar::sys_color_changed() p->object_list->sys_color_changed(); p->object_manipulation->sys_color_changed(); // p->object_settings->msw_rescale(); -// p->object_layers->msw_rescale(); + p->object_layers->sys_color_changed(); // btn...->msw_rescale() updates icon on button, so use it p->btn_send_gcode->msw_rescale(); @@ -4343,7 +4345,7 @@ void Sidebar::set_btn_label(const ActionButtonType btn_type, const wxString& lab // Plater / Public Plater::Plater(wxWindow *parent, MainFrame *main_frame) - : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(76 * wxGetApp().em_unit(), 49 * wxGetApp().em_unit())) + : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxGetApp().get_min_size()) , p(new priv(this, main_frame)) { // Initialization performed in the private c-tor diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 49fa03618..b1ff64608 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -597,7 +597,7 @@ void TabPrinter::sys_color_changed() // update missed options_groups const std::vector& pages = m_printer_technology == ptFFF ? m_pages_sla : m_pages_fff; for (auto page : pages) - page->msw_rescale(); + page->sys_color_changed(); Layout(); } @@ -890,8 +890,8 @@ void Tab::sys_color_changed() btn->msw_rescale(); for (const auto bmp : m_scaled_bitmaps) bmp->msw_rescale(); - for (ScalableBitmap& bmp : m_mode_bitmap_cache) - bmp.msw_rescale(); +// for (ScalableBitmap& bmp : m_mode_bitmap_cache) +// bmp.msw_rescale(); // update icons for tree_ctrl for (ScalableBitmap& bmp : m_scaled_icons_list) @@ -903,7 +903,6 @@ void Tab::sys_color_changed() m_icons->Add(bmp.bmp()); m_treectrl->AssignImageList(m_icons); - // Colors for ui "decoration" m_sys_label_clr = wxGetApp().get_label_clr_sys(); m_modified_label_clr = wxGetApp().get_label_clr_modified(); @@ -911,7 +910,7 @@ void Tab::sys_color_changed() // update options_groups for (auto page : m_pages) - page->msw_rescale(); + page->sys_color_changed(); Layout(); } @@ -3606,6 +3605,12 @@ void Page::msw_rescale() group->msw_rescale(); } +void Page::sys_color_changed() +{ + for (auto group : m_optgroups) + group->sys_color_changed(); +} + Field* Page::get_field(const t_config_option_key& opt_key, int opt_index /*= -1*/) const { Field* field = nullptr; diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index affe8c2c8..36b4a61ea 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -81,6 +81,7 @@ public: void reload_config(); void update_visibility(ConfigOptionMode mode); void msw_rescale(); + void sys_color_changed(); Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const; bool set_value(const t_config_option_key& opt_key, const boost::any& value); ConfigOptionsGroupShp new_optgroup(const wxString& title, int noncommon_label_width = -1); From 180742ccaae28c53c7a27f289c0d6c1f067c0b94 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 22 May 2020 15:32:49 +0200 Subject: [PATCH 2/5] Pulling patched boost::polygon from github prusa3d/polygon. --- deps/CMakeLists.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 74bf6eb53..4078af3df 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -129,6 +129,19 @@ else() include("deps-linux.cmake") endif() +# Patch the boost::polygon library with a custom one. +ExternalProject_Add(dep_boost_polygon + EXCLUDE_FROM_ALL ON + GIT_REPOSITORY "https://github.com/prusa3d/polygon" + GIT_TAG prusaslicer_gmp + DEPENDS dep_boost + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CMAKE_CURRENT_BINARY_DIR}/dep_boost_polygon-prefix/src/dep_boost_polygon/include/boost/polygon" + "${DESTDIR}/usr/local/include/boost/polygon" +) + set(ZLIB_PKG "") if (NOT ZLIB_FOUND) include(ZLIB/ZLIB.cmake) @@ -152,7 +165,7 @@ include(MPFR/MPFR.cmake) include(CGAL/CGAL.cmake) include(wxWidgets/wxWidgets.cmake) -if (ZLIB_PKG) +if (NOT "${ZLIB_PKG}" STREQUAL "") add_dependencies(dep_blosc ${ZLIB_PKG}) add_dependencies(dep_openexr ${ZLIB_PKG}) endif () @@ -162,6 +175,7 @@ if (MSVC) add_custom_target(deps ALL DEPENDS dep_boost + dep_boost_polygon dep_tbb dep_libcurl dep_wxWidgets @@ -182,6 +196,7 @@ else() add_custom_target(deps ALL DEPENDS dep_boost + dep_boost_polygon dep_tbb dep_libcurl dep_wxWidgets From c7ef1feaf0720981a2418d80cc5844ca1ca3ef25 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 22 May 2020 16:59:28 +0200 Subject: [PATCH 3/5] Added missed icons for the dark mode. Fixed typos from the previous commit --- resources/icons/white/dot.svg | 8 ++++++++ resources/icons/white/drop_to_bed.svg | 15 +++++++++++++++ resources/icons/white/eye_closed.svg | 13 +++++++++++++ resources/icons/white/eye_open.svg | 11 +++++++++++ resources/icons/white/lock_closed_f.svg | 10 ++++++++++ src/slic3r/GUI/MainFrame.cpp | 2 +- src/slic3r/GUI/ObjectDataViewModel.cpp | 2 +- src/slic3r/GUI/OptionsGroup.cpp | 2 -- src/slic3r/GUI/Tab.cpp | 6 ++---- 9 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 resources/icons/white/dot.svg create mode 100644 resources/icons/white/drop_to_bed.svg create mode 100644 resources/icons/white/eye_closed.svg create mode 100644 resources/icons/white/eye_open.svg create mode 100644 resources/icons/white/lock_closed_f.svg diff --git a/resources/icons/white/dot.svg b/resources/icons/white/dot.svg new file mode 100644 index 000000000..90fbaf7fb --- /dev/null +++ b/resources/icons/white/dot.svg @@ -0,0 +1,8 @@ + + + + + + + diff --git a/resources/icons/white/drop_to_bed.svg b/resources/icons/white/drop_to_bed.svg new file mode 100644 index 000000000..76243f897 --- /dev/null +++ b/resources/icons/white/drop_to_bed.svg @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/resources/icons/white/eye_closed.svg b/resources/icons/white/eye_closed.svg new file mode 100644 index 000000000..0cdd16ae0 --- /dev/null +++ b/resources/icons/white/eye_closed.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/resources/icons/white/eye_open.svg b/resources/icons/white/eye_open.svg new file mode 100644 index 000000000..1b320da07 --- /dev/null +++ b/resources/icons/white/eye_open.svg @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/resources/icons/white/lock_closed_f.svg b/resources/icons/white/lock_closed_f.svg new file mode 100644 index 000000000..412c93c16 --- /dev/null +++ b/resources/icons/white/lock_closed_f.svg @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 0bcf1bd95..47cd3443d 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -97,7 +97,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S // Otherwise, MainFrame will be maximized by height if (slNew) { wxSize size = wxGetApp().get_min_size(); - size.SetWidth(int(0.5*size.GetHeight())); + size.SetHeight(int(0.5*size.GetHeight())); m_plater->SetMinSize(size); m_tabpanel->SetMinSize(size); } diff --git a/src/slic3r/GUI/ObjectDataViewModel.cpp b/src/slic3r/GUI/ObjectDataViewModel.cpp index d9b9af016..336475d2e 100644 --- a/src/slic3r/GUI/ObjectDataViewModel.cpp +++ b/src/slic3r/GUI/ObjectDataViewModel.cpp @@ -138,7 +138,7 @@ void ObjectDataViewModelNode::update_settings_digest_bitmaps() std::map& categories_icon = Slic3r::GUI::wxGetApp().obj_list()->CATEGORY_ICON; std::string scaled_bitmap_name = m_name.ToUTF8().data(); - scaled_bitmap_name += "-em" + std::to_string(Slic3r::GUI::wxGetApp().em_unit()); + scaled_bitmap_name += "-em" + std::to_string(wxGetApp().em_unit()) + (wxGetApp().dark_mode() ? "-dm" : ""); wxBitmap *bmp = m_bitmap_cache->find(scaled_bitmap_name); if (bmp == nullptr) { diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 5c2d6d38e..fa94e6321 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -578,8 +578,6 @@ void ConfigOptionsGroup::sys_color_changed() // update undo buttons : rescale bitmaps for (const auto& field : m_fields) field.second->sys_color_changed(); - - m_grid_sizer->Layout(); } boost::any ConfigOptionsGroup::config_value(const std::string& opt_key, int opt_index, bool deserialize) { diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index b1ff64608..da48224b3 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -190,15 +190,13 @@ void Tab::create_preset_tab() add_scaled_button(panel, &m_search_btn, "search"); m_search_btn->SetToolTip(format_wxstr(_L("Click to start a search or use %1% shortcut"), "Ctrl+F")); - // Determine the theme color of OS (dark or light) - auto luma = wxGetApp().get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); // Bitmaps to be shown on the "Revert to system" aka "Lock to system" button next to each input field. - add_scaled_bitmap(this, m_bmp_value_lock , luma >= 128 ? "lock_closed" : "lock_closed_white"); + add_scaled_bitmap(this, m_bmp_value_lock , "lock_closed"); add_scaled_bitmap(this, m_bmp_value_unlock, "lock_open"); m_bmp_non_system = &m_bmp_white_bullet; // Bitmaps to be shown on the "Undo user changes" button next to each input field. add_scaled_bitmap(this, m_bmp_value_revert, "undo"); - add_scaled_bitmap(this, m_bmp_white_bullet, luma >= 128 ? "dot" : "dot_white"); + add_scaled_bitmap(this, m_bmp_white_bullet, "dot"); fill_icon_descriptions(); set_tooltips_text(); From 1c826c063b4bf75a0ec1fff991e219deb6b1e8fa Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 25 May 2020 10:48:53 +0200 Subject: [PATCH 4/5] GCodeViewer refactoring and GLShaderProgram upgrade --- resources/shaders/options_120.fs | 5 +- src/slic3r/GUI/3DScene.cpp | 2 +- src/slic3r/GUI/GCodeViewer.cpp | 148 ++++++------------------------- src/slic3r/GUI/GLShader.cpp | 25 ++++++ src/slic3r/GUI/GLShader.hpp | 3 + 5 files changed, 59 insertions(+), 124 deletions(-) diff --git a/resources/shaders/options_120.fs b/resources/shaders/options_120.fs index 5f699f920..236174f3a 100644 --- a/resources/shaders/options_120.fs +++ b/resources/shaders/options_120.fs @@ -5,10 +5,11 @@ uniform vec3 uniform_color; void main() { vec2 pos = gl_PointCoord - vec2(0.5, 0.5); - float sq_radius = pos.x * pos.x + pos.y * pos.y; + float sq_radius = dot(pos, pos); if (sq_radius > 0.25) discard; - else if ((sq_radius < 0.005625) || (sq_radius > 0.180625)) + + if ((sq_radius < 0.005625) || (sq_radius > 0.180625)) gl_FragColor = vec4(0.5 * uniform_color, 1.0); else gl_FragColor = vec4(uniform_color, 1.0); diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index fb7d4c24c..49b1c255b 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -672,7 +672,7 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab shader->set_uniform("print_box.actived", volume.first->shader_outside_printer_detection_enabled); shader->set_uniform("print_box.volume_world_matrix", volume.first->world_matrix()); shader->set_uniform("slope.actived", m_slope.active && !volume.first->is_modifier && !volume.first->is_wipe_tower); - shader->set_uniform("slope.volume_world_normal_matrix", volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast()); + shader->set_uniform("slope.volume_world_normal_matrix", static_cast(volume.first->world_matrix().matrix().block(0, 0, 3, 3).inverse().transpose().cast())); volume.first->render(); #else diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 330a5a261..54c7d3bb5 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -740,9 +740,29 @@ void GCodeViewer::render_toolpaths() const bool is_glsl_120 = wxGetApp().is_glsl_version_greater_or_equal_to(1, 20); int detected_point_sizes[2]; ::glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, detected_point_sizes); - std::array point_sizes = { 2.0f, std::min(64.0f, static_cast(detected_point_sizes[1])) }; + std::array point_sizes = { std::min(8.0f, static_cast(detected_point_sizes[1])), std::min(48.0f, static_cast(detected_point_sizes[1])) }; double zoom = wxGetApp().plater()->get_camera().get_zoom(); + auto render_options = [this, is_glsl_120, zoom, point_sizes](const IBuffer& buffer, EOptionsColors colors_id, GLShaderProgram& shader) { + shader.set_uniform("uniform_color", Options_Colors[static_cast(colors_id)]); + shader.set_uniform("zoom", zoom); + shader.set_uniform("point_sizes", point_sizes); + if (is_glsl_120) { + glsafe(::glEnable(GL_POINT_SPRITE)); + glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)); + } + for (const RenderPath& path : buffer.render_paths) { + glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); +#if ENABLE_GCODE_VIEWER_STATISTICS + ++m_statistics.gl_multi_points_calls_count; +#endif // ENABLE_GCODE_VIEWER_STATISTICS + } + if (is_glsl_120) { + glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE)); + glsafe(::glDisable(GL_POINT_SPRITE)); + } + }; + glsafe(::glCullFace(GL_BACK)); glsafe(::glLineWidth(3.0f)); @@ -773,146 +793,32 @@ void GCodeViewer::render_toolpaths() const { case GCodeProcessor::EMoveType::Tool_change: { - shader->set_uniform("uniform_color", Options_Colors[static_cast(EOptionsColors::ToolChanges)]); - shader->set_uniform("zoom", zoom); - shader->set_uniform("point_sizes", point_sizes); - if (is_glsl_120) - { - glsafe(::glEnable(GL_POINT_SPRITE)); - glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)); - } - for (const RenderPath& path : buffer.render_paths) - { - glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); -#if ENABLE_GCODE_VIEWER_STATISTICS - ++m_statistics.gl_multi_points_calls_count; -#endif // ENABLE_GCODE_VIEWER_STATISTICS - } - if (is_glsl_120) - { - glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE)); - glsafe(::glDisable(GL_POINT_SPRITE)); - } + render_options(buffer, EOptionsColors::ToolChanges, *shader); break; } case GCodeProcessor::EMoveType::Color_change: { - shader->set_uniform("uniform_color", Options_Colors[static_cast(EOptionsColors::ColorChanges)]); - shader->set_uniform("zoom", zoom); - shader->set_uniform("point_sizes", point_sizes); - if (is_glsl_120) - { - glsafe(::glEnable(GL_POINT_SPRITE)); - glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)); - } - for (const RenderPath& path : buffer.render_paths) - { - glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); -#if ENABLE_GCODE_VIEWER_STATISTICS - ++m_statistics.gl_multi_points_calls_count; -#endif // ENABLE_GCODE_VIEWER_STATISTICS - } - if (is_glsl_120) - { - glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE)); - glsafe(::glDisable(GL_POINT_SPRITE)); - } + render_options(buffer, EOptionsColors::ColorChanges, *shader); break; } case GCodeProcessor::EMoveType::Pause_Print: { - shader->set_uniform("uniform_color", Options_Colors[static_cast(EOptionsColors::PausePrints)]); - shader->set_uniform("zoom", zoom); - shader->set_uniform("point_sizes", point_sizes); - if (is_glsl_120) - { - glsafe(::glEnable(GL_POINT_SPRITE)); - glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)); - } - for (const RenderPath& path : buffer.render_paths) - { - glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); -#if ENABLE_GCODE_VIEWER_STATISTICS - ++m_statistics.gl_multi_points_calls_count; -#endif // ENABLE_GCODE_VIEWER_STATISTICS - } - if (is_glsl_120) - { - glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE)); - glsafe(::glDisable(GL_POINT_SPRITE)); - } + render_options(buffer, EOptionsColors::PausePrints, *shader); break; } case GCodeProcessor::EMoveType::Custom_GCode: { - shader->set_uniform("uniform_color", Options_Colors[static_cast(EOptionsColors::CustomGCodes)]); - shader->set_uniform("zoom", zoom); - shader->set_uniform("point_sizes", point_sizes); - if (is_glsl_120) - { - glsafe(::glEnable(GL_POINT_SPRITE)); - glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)); - } - for (const RenderPath& path : buffer.render_paths) - { - glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); -#if ENABLE_GCODE_VIEWER_STATISTICS - ++m_statistics.gl_multi_points_calls_count; -#endif // ENABLE_GCODE_VIEWER_STATISTICS - } - if (is_glsl_120) - { - glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE)); - glsafe(::glDisable(GL_POINT_SPRITE)); - } + render_options(buffer, EOptionsColors::CustomGCodes, *shader); break; } case GCodeProcessor::EMoveType::Retract: { - shader->set_uniform("uniform_color", Options_Colors[static_cast(EOptionsColors::Retractions)]); - shader->set_uniform("zoom", zoom); - shader->set_uniform("point_sizes", point_sizes); - if (is_glsl_120) - { - glsafe(::glEnable(GL_POINT_SPRITE)); - glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)); - } - for (const RenderPath& path : buffer.render_paths) - { - glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); -#if ENABLE_GCODE_VIEWER_STATISTICS - ++m_statistics.gl_multi_points_calls_count; -#endif // ENABLE_GCODE_VIEWER_STATISTICS - if (is_glsl_120) - { - glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE)); - glsafe(::glDisable(GL_POINT_SPRITE)); - } - } + render_options(buffer, EOptionsColors::Retractions, *shader); break; } case GCodeProcessor::EMoveType::Unretract: { - shader->set_uniform("uniform_color", Options_Colors[static_cast(EOptionsColors::Unretractions)]); - shader->set_uniform("zoom", zoom); - shader->set_uniform("point_sizes", point_sizes); - if (is_glsl_120) - { - glsafe(::glEnable(GL_POINT_SPRITE)); - glsafe(::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE)); - } - for (const RenderPath& path : buffer.render_paths) - { - glsafe(::glMultiDrawElements(GL_POINTS, (const GLsizei*)path.sizes.data(), GL_UNSIGNED_INT, (const void* const*)path.offsets.data(), (GLsizei)path.sizes.size())); -#if ENABLE_GCODE_VIEWER_STATISTICS - ++m_statistics.gl_multi_points_calls_count; -#endif // ENABLE_GCODE_VIEWER_STATISTICS - } - if (is_glsl_120) - { - glsafe(::glDisable(GL_VERTEX_PROGRAM_POINT_SIZE)); - glsafe(::glDisable(GL_POINT_SPRITE)); - } + render_options(buffer, EOptionsColors::Unretractions, *shader); break; } case GCodeProcessor::EMoveType::Extrude: diff --git a/src/slic3r/GUI/GLShader.cpp b/src/slic3r/GUI/GLShader.cpp index 42e5b0a9f..a6d641f89 100644 --- a/src/slic3r/GUI/GLShader.cpp +++ b/src/slic3r/GUI/GLShader.cpp @@ -215,6 +215,16 @@ bool GLShaderProgram::set_uniform(const char* name, double value) const return set_uniform(name, static_cast(value)); } +bool GLShaderProgram::set_uniform(const char* name, const std::array& value) const +{ + int id = get_uniform_location(name); + if (id >= 0) { + glsafe(::glUniform4iv(id, 1, static_cast(value.data()))); + return true; + } + return false; +} + bool GLShaderProgram::set_uniform(const char* name, const std::array& value) const { int id = get_uniform_location(name); @@ -290,6 +300,21 @@ bool GLShaderProgram::set_uniform(const char* name, const Matrix3f& value) const return false; } +bool GLShaderProgram::set_uniform(const char* name, const Vec3f& value) const +{ + int id = get_uniform_location(name); + if (id >= 0) { + glsafe(::glUniform3fv(id, 1, static_cast(value.data()))); + return true; + } + return false; +} + +bool GLShaderProgram::set_uniform(const char* name, const Vec3d& value) const +{ + return set_uniform(name, static_cast(value.cast())); +} + int GLShaderProgram::get_attrib_location(const char* name) const { return (m_id > 0) ? ::glGetAttribLocation(m_id, name) : -1; diff --git a/src/slic3r/GUI/GLShader.hpp b/src/slic3r/GUI/GLShader.hpp index e58437fbd..521f6796f 100644 --- a/src/slic3r/GUI/GLShader.hpp +++ b/src/slic3r/GUI/GLShader.hpp @@ -43,6 +43,7 @@ public: bool set_uniform(const char* name, bool value) const; bool set_uniform(const char* name, float value) const; bool set_uniform(const char* name, double value) const; + bool set_uniform(const char* name, const std::array& value) const; bool set_uniform(const char* name, const std::array& value) const; bool set_uniform(const char* name, const std::array& value) const; bool set_uniform(const char* name, const std::array& value) const; @@ -50,6 +51,8 @@ public: bool set_uniform(const char* name, const Transform3f& value) const; bool set_uniform(const char* name, const Transform3d& value) const; bool set_uniform(const char* name, const Matrix3f& value) const; + bool set_uniform(const char* name, const Vec3f& value) const; + bool set_uniform(const char* name, const Vec3d& value) const; // returns -1 if not found int get_attrib_location(const char* name) const; From 1af798dbd7ed9b4763bd28c9cd9e65911cd7a2bd Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 25 May 2020 11:16:40 +0200 Subject: [PATCH 5/5] DoubleSlider::Control thumb text rendered closer to the slider --- resources/shaders/options_120.fs | 1 + src/slic3r/GUI/DoubleSlider.cpp | 10 +++++----- src/slic3r/GUI/GUI_Preview.cpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/resources/shaders/options_120.fs b/resources/shaders/options_120.fs index 236174f3a..1c53f6c72 100644 --- a/resources/shaders/options_120.fs +++ b/resources/shaders/options_120.fs @@ -1,3 +1,4 @@ +// version 120 is needed for gl_PointCoord #version 120 uniform vec3 uniform_color; diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 5c16e11ee..7415f333f 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -566,12 +566,12 @@ void Control::draw_tick_text(wxDC& dc, const wxPoint& pos, int tick, bool right_ dc.GetMultiLineTextExtent(label, &text_width, &text_height); wxPoint text_pos; if (right_side) - text_pos = is_horizontal() ? wxPoint(pos.x + 1, pos.y + m_thumb_size.x) : - wxPoint(pos.x + m_thumb_size.x+1, pos.y - 0.5*text_height - 1); + text_pos = is_horizontal() ? wxPoint(pos.x + 1, pos.y + m_thumb_size.x / 4) : + wxPoint(pos.x + m_thumb_size.x + 1, pos.y - 0.5 * text_height - 1); else - text_pos = is_horizontal() ? wxPoint(pos.x - text_width - 1, pos.y - m_thumb_size.x - text_height) : - wxPoint(pos.x - text_width - 1 - m_thumb_size.x, pos.y - 0.5*text_height + 1); - dc.DrawText(label, text_pos); + text_pos = is_horizontal() ? wxPoint(pos.x - text_width - 1, pos.y - m_thumb_size.x / 4 - text_height) : + wxPoint(pos.x - text_width - 1 - m_thumb_size.x, pos.y - 0.5 * text_height + 1); + dc.DrawText(label, text_pos); } void Control::draw_thumb_text(wxDC& dc, const wxPoint& pos, const SelectedSlider& selection) const diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 1784dbccc..fdbd396e2 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -343,7 +343,7 @@ bool Preview::init(wxWindow* parent, Model* model) #endif // ENABLE_GCODE_VIEWER #if ENABLE_GCODE_VIEWER - m_moves_slider = new DoubleSlider::Control(m_bottom_toolbar_panel, wxID_ANY, 0, 0, 0, 100, wxDefaultPosition, wxSize(-1, 4 * GetTextExtent("m").y), wxSL_HORIZONTAL); + m_moves_slider = new DoubleSlider::Control(m_bottom_toolbar_panel, wxID_ANY, 0, 0, 0, 100, wxDefaultPosition, wxSize(-1, 3 * GetTextExtent("m").y), wxSL_HORIZONTAL); m_moves_slider->SetDrawMode(DoubleSlider::dmSequentialGCodeView); wxBoxSizer* bottom_toolbar_sizer = new wxBoxSizer(wxHORIZONTAL);