diff options
author | YuSanka <yusanka@gmail.com> | 2022-03-02 15:04:32 +0300 |
---|---|---|
committer | YuSanka <yusanka@gmail.com> | 2022-03-02 15:04:32 +0300 |
commit | 027ba51741731f2b2157482e753ae030ef3fbf8d (patch) | |
tree | 2a04423ee8cc6da85042498d77c867b0a2154dbb | |
parent | 8e55372ab0e80caab516469c271c96066854c5ad (diff) |
Suppress to update ruler for horizontal sliderys_gdi
-rw-r--r-- | src/slic3r/GUI/DoubleSlider.cpp | 12 | ||||
-rw-r--r-- | src/slic3r/GUI/DoubleSlider.hpp | 4 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 1bd5a848a..539ce5612 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -147,7 +147,8 @@ Control::Control( wxWindow *parent, m_font = GetFont(); this->SetMinSize(get_min_size()); - m_ruler.set_parent(this->GetParent()); + if (style == wxSL_VERTICAL) + m_ruler.set_parent(this->GetParent()); } void Control::msw_rescale() @@ -1052,6 +1053,8 @@ void Control::draw_colored_band(wxDC& dc) void Control::Ruler::init(const std::vector<double>& values, double scroll_step) { + if (!m_parent) + return; max_values.clear(); max_values.reserve(std::count(values.begin(), values.end(), values.front())); @@ -1073,12 +1076,13 @@ void Control::Ruler::set_parent(wxWindow* parent) void Control::Ruler::update_dpi() { - m_DPI = GUI::get_dpi_for_window(m_parent); + if (m_parent) + m_DPI = GUI::get_dpi_for_window(m_parent); } void Control::Ruler::update(const std::vector<double>& values, double scroll_step) { - if (values.empty() || + if (!m_parent || values.empty() || // check if need to update ruler in respect to input values values.front() == m_min_val && values.back() == m_max_val && m_scroll_step == scroll_step && max_values.size() == m_max_values_cnt) return; @@ -1131,7 +1135,7 @@ void Control::Ruler::update(const std::vector<double>& values, double scroll_ste void Control::draw_ruler(wxDC& dc) { - if (m_values.empty()) + if (m_values.empty() || !m_ruler.can_draw()) return; // When "No sparce layer" is enabled, use m_layers_values for ruler update. // Because of m_values has duplicate values in this case. diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp index 333bc4c35..91380381f 100644 --- a/src/slic3r/GUI/DoubleSlider.hpp +++ b/src/slic3r/GUI/DoubleSlider.hpp @@ -447,7 +447,8 @@ private: std::vector<wxPen*> m_segm_pens; class Ruler { - wxWindow* m_parent; + wxWindow* m_parent{nullptr}; // m_parent is nullptr for Unused ruler + // in this case we will not init/update/render it // values to check if ruler has to be updated double m_min_val; double m_max_val; @@ -468,6 +469,7 @@ private: void update(const std::vector<double>& values, double scroll_step); bool is_ok() { return long_step > 0 && short_step > 0; } size_t count() { return max_values.size(); } + bool can_draw() { return m_parent != nullptr; } } m_ruler; }; |