From e6e3e98fd58234b8077143e04c3f233f64b06e11 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 26 Oct 2020 13:52:51 +0100 Subject: [PATCH] Fixed editable lower thumb of sequential slider when changing settings in preference dialog while the preview is hidden --- src/slic3r/GUI/DoubleSlider.cpp | 28 ++++++++++++++++------------ src/slic3r/GUI/DoubleSlider.hpp | 2 -- src/slic3r/GUI/GUI_Preview.cpp | 4 ---- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 911ee9c42..f37131570 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -12,6 +12,9 @@ #include "I18N.hpp" #include "ExtruderSequenceDialog.hpp" #include "libslic3r/Print.hpp" +#if ENABLE_GCODE_VIEWER +#include "libslic3r/AppConfig.hpp" +#endif // ENABLE_GCODE_VIEWER #include #include @@ -45,17 +48,18 @@ static std::string gcode(Type type) { const PrintConfig& config = GUI::wxGetApp().plater()->fff_print().config(); switch (type) { - case ColorChange: - return config.color_change_gcode; - case PausePrint: - return config.pause_print_gcode; - case Template: - return config.template_custom_gcode; - default: - return ""; + case ColorChange: return config.color_change_gcode; + case PausePrint: return config.pause_print_gcode; + case Template: return config.template_custom_gcode; + default: return ""; } } +static bool is_lower_thumb_editable() +{ + return Slic3r::GUI::get_app_config()->get("seq_top_layer_only") == "0"; +} + Control::Control( wxWindow *parent, wxWindowID id, int lowerValue, @@ -959,7 +963,7 @@ int Control::get_value_from_position(const wxCoord x, const wxCoord y) bool Control::detect_selected_slider(const wxPoint& pt) { if (is_point_in_rect(pt, m_rect_lower_thumb)) - m_selection = m_lower_editable ? ssLower : ssUndef; + m_selection = is_lower_thumb_editable() ? ssLower : ssUndef; else if(is_point_in_rect(pt, m_rect_higher_thumb)) m_selection = ssHigher; else @@ -1415,7 +1419,7 @@ void Control::OnWheel(wxMouseEvent& event) ssLower : ssHigher; } - if (m_selection == ssLower && !m_lower_editable) + if (m_selection == ssLower && !is_lower_thumb_editable()) m_selection = ssUndef; #if ENABLE_GCODE_VIEWER @@ -1468,7 +1472,7 @@ void Control::OnKeyDown(wxKeyEvent &event) else if (key == WXK_UP || key == WXK_DOWN) { if (key == WXK_UP) m_selection = ssHigher; - else if (key == WXK_DOWN && m_lower_editable) + else if (key == WXK_DOWN && is_lower_thumb_editable()) m_selection = ssLower; Refresh(); } @@ -1483,7 +1487,7 @@ void Control::OnKeyDown(wxKeyEvent &event) if (key == WXK_LEFT || key == WXK_RIGHT) { if (key == WXK_LEFT) m_selection = ssHigher; - else if (key == WXK_RIGHT && m_lower_editable) + else if (key == WXK_RIGHT && is_lower_thumb_editable()) m_selection = ssLower; Refresh(); } diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp index 4711f0832..d13e6259f 100644 --- a/src/slic3r/GUI/DoubleSlider.hpp +++ b/src/slic3r/GUI/DoubleSlider.hpp @@ -228,7 +228,6 @@ public: void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder); void SetExtruderColors(const std::vector& extruder_colors); - void set_lower_editable(bool editable) { m_lower_editable = editable; } void set_render_as_disabled(bool value) { m_render_as_disabled = value; } bool is_rendering_as_disabled() const { return m_render_as_disabled; } @@ -340,7 +339,6 @@ private: int m_lower_value; int m_higher_value; - bool m_lower_editable{ true }; bool m_render_as_disabled{ false }; ScalableBitmap m_bmp_thumb_higher; diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 134da4848..ff7d21e0c 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -346,7 +346,6 @@ bool Preview::init(wxWindow* parent, Model* model) right_sizer->Add(m_layers_slider_sizer, 1, wxEXPAND, 0); 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->set_lower_editable(get_app_config()->get("seq_top_layer_only") == "0"); m_moves_slider->SetDrawMode(DoubleSlider::dmSequentialGCodeView); wxBoxSizer* bottom_toolbar_sizer = new wxBoxSizer(wxHORIZONTAL); @@ -539,9 +538,6 @@ void Preview::refresh_print() return; load_print(true); -#if ENABLE_GCODE_VIEWER - m_moves_slider->set_lower_editable(get_app_config()->get("seq_top_layer_only") == "0"); -#endif // ENABLE_GCODE_VIEWER } void Preview::msw_rescale()