From 7b5f84b7dfdb9de22bfb87d3d69ab29e021a5a23 Mon Sep 17 00:00:00 2001
From: enricoturri1966 <enricoturri@seznam.cz>
Date: Tue, 18 Aug 2020 12:39:46 +0200
Subject: [PATCH] Extended hover capability in DoubleSlider::Control

---
 src/slic3r/GUI/DoubleSlider.cpp | 26 ++++++++++++++++++--------
 src/slic3r/GUI/DoubleSlider.hpp |  6 ++++++
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp
index a7cb7d54d..8a9ac34ea 100644
--- a/src/slic3r/GUI/DoubleSlider.cpp
+++ b/src/slic3r/GUI/DoubleSlider.cpp
@@ -600,10 +600,8 @@ void Control::draw_tick_text(wxDC& dc, const wxPoint& pos, int tick, bool right_
     const wxString label = get_label(tick);
     dc.GetMultiLineTextExtent(label, &text_width, &text_height);
     wxPoint text_pos;
-    if (right_side)
-    {
-        if (is_horizontal())
-        {
+    if (right_side) {
+        if (is_horizontal()) {
             int width;
             int height;
             get_size(&width, &height);
@@ -614,17 +612,21 @@ void Control::draw_tick_text(wxDC& dc, const wxPoint& pos, int tick, bool right_
         }
         else
             text_pos = wxPoint(pos.x + m_thumb_size.x + 1, pos.y - 0.5 * text_height - 1);
+
+        // update text rectangle
+        m_rect_lower_thumb_text = wxRect(text_pos, wxSize(text_width, text_height));
     }
-    else
-    {
-        if (is_horizontal())
-        {
+    else {
+        if (is_horizontal()) {
             int x = pos.x - text_width - 1;
             int xx = (x > 0) ? x : pos.x + 1;
             text_pos = wxPoint(xx, pos.y - m_thumb_size.x / 2 - text_height - 1);
         }
         else
             text_pos = wxPoint(pos.x - text_width - 1 - m_thumb_size.x, pos.y - 0.5 * text_height + 1);
+
+        // update text rectangle
+        m_rect_higher_thumb_text = wxRect(text_pos, wxSize(text_width, text_height));
     }
 
     dc.DrawText(label, text_pos);
@@ -1206,6 +1208,14 @@ void Control::OnMotion(wxMouseEvent& event)
         else if (m_mode == SingleExtruder && is_point_in_rect(pos, get_colored_band_rect()) &&
                  get_edited_tick_for_position(pos) >= 0 )
             m_focus = fiColorBand;
+        else if (is_point_in_rect(pos, m_rect_lower_thumb))
+            m_focus = fiLowerThumb;
+        else if (is_point_in_rect(pos, m_rect_higher_thumb))
+            m_focus = fiHigherThumb;
+        else if (is_point_in_rect(pos, m_rect_lower_thumb_text))
+            m_focus = fiLowerThumbText;
+        else if (is_point_in_rect(pos, m_rect_higher_thumb_text))
+            m_focus = fiHigherThumbText;
         else {
             m_focus = fiTick;
             tick = get_tick_near_point(pos);
diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp
index fc8ebced8..fb87ac4a9 100644
--- a/src/slic3r/GUI/DoubleSlider.hpp
+++ b/src/slic3r/GUI/DoubleSlider.hpp
@@ -44,6 +44,10 @@ enum FocusedItem {
     fiCogIcon,
     fiColorBand,
     fiActionIcon,
+    fiLowerThumb,
+    fiHigherThumb,
+    fiLowerThumbText,
+    fiHigherThumbText,
     fiTick
 };
 
@@ -360,6 +364,8 @@ private:
 
     wxRect      m_rect_lower_thumb;
     wxRect      m_rect_higher_thumb;
+    mutable wxRect m_rect_lower_thumb_text;
+    mutable wxRect m_rect_higher_thumb_text;
     wxRect      m_rect_tick_action;
     wxRect      m_rect_one_layer_icon;
     wxRect      m_rect_revert_icon;