[vlc-commits] skins2: remove range constraint for slider

Erwan Tulou git at videolan.org
Fri Apr 5 19:16:02 CEST 2013


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Fri Apr  5 17:52:26 2013 +0200| [39c57090b1468d3b85c96b62b7c20e3937aa817c] | committer: Erwan Tulou

skins2: remove range constraint for slider

Till now, moving a skins2 slider was only possible if the pointer didn't get
too far away from the control (hardcoded parameter of 40 pixels in skins2).
Though this feature can also be seen elsewhere (firefox slider does it too),
the result may not look so natural especially for things like equalizers.
Moreover, qt4 doesn't implement this constraint, and therefore true skins2
sliders and qt4 sliders obtained from the popup menus were behaving differently.

So better remove this limitation and make things consistent throughout vlc
(skins2 + qt4)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=39c57090b1468d3b85c96b62b7c20e3937aa817c
---

 modules/gui/skins2/controls/ctrl_slider.cpp |   25 ++++---------------------
 modules/gui/skins2/controls/ctrl_slider.hpp |    2 --
 2 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/modules/gui/skins2/controls/ctrl_slider.cpp b/modules/gui/skins2/controls/ctrl_slider.cpp
index fe5b002..7ff8974 100644
--- a/modules/gui/skins2/controls/ctrl_slider.cpp
+++ b/modules/gui/skins2/controls/ctrl_slider.cpp
@@ -34,8 +34,6 @@
 #include "../utils/var_percent.hpp"
 
 
-#define RANGE 40
-
 static inline float scroll( bool up, float pct, float step )
 {
     return pct + ( up ? step : -step );
@@ -57,8 +55,7 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
     m_cmdOverDown( this ), m_cmdDownOver( this ),
     m_cmdOverUp( this ), m_cmdUpOver( this ),
     m_cmdMove( this ), m_cmdScroll( this ),
-    m_lastPercentage( 0 ), m_lastCursorRect(),
-    m_xOffset( 0 ), m_yOffset( 0 ),
+    m_lastCursorRect(), m_xOffset( 0 ), m_yOffset( 0 ),
     m_pEvt( NULL ), m_rCurve( rCurve )
 {
     // Build the images of the cursor
@@ -94,9 +91,6 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
 
     // Observe the position variable
     m_rVariable.addObserver( this );
-
-    // Initial position of the cursor
-    m_lastPercentage = m_rVariable.get();
 }
 
 
@@ -204,9 +198,6 @@ void CtrlSliderCursor::CmdOverDown::execute()
 
 void CtrlSliderCursor::CmdDownOver::execute()
 {
-    // Save the position
-    m_pParent->m_lastPercentage = m_pParent->m_rVariable.get();
-
     m_pParent->releaseMouse();
     m_pParent->m_pImg = m_pParent->m_pImgUp;
     m_pParent->refreshLayout();
@@ -245,17 +236,9 @@ void CtrlSliderCursor::CmdMove::execute()
     int relXPond = (int)(relX / factorX);
     int relYPond = (int)(relY / factorY);
 
-    // Update the position
-    if( m_pParent->m_rCurve.getMinDist( relXPond, relYPond ) < RANGE )
-    {
-        float percentage = m_pParent->m_rCurve.getNearestPercent( relXPond,
-                                                              relYPond );
-        m_pParent->m_rVariable.set( percentage );
-    }
-    else
-    {
-        m_pParent->m_rVariable.set( m_pParent->m_lastPercentage );
-    }
+    float percentage =
+        m_pParent->m_rCurve.getNearestPercent( relXPond, relYPond );
+    m_pParent->m_rVariable.set( percentage );
 }
 
 void CtrlSliderCursor::CmdScroll::execute()
diff --git a/modules/gui/skins2/controls/ctrl_slider.hpp b/modules/gui/skins2/controls/ctrl_slider.hpp
index 10eaa60..cddc168 100644
--- a/modules/gui/skins2/controls/ctrl_slider.hpp
+++ b/modules/gui/skins2/controls/ctrl_slider.hpp
@@ -95,8 +95,6 @@ private:
     DEFINE_CALLBACK( CtrlSliderCursor, UpOver )
     DEFINE_CALLBACK( CtrlSliderCursor, Move )
     DEFINE_CALLBACK( CtrlSliderCursor, Scroll )
-    /// Last saved position of the cursor (stored as a percentage)
-    float m_lastPercentage;
     /// Last saved cursor placement
     rect m_lastCursorRect;
     /// Offset between the mouse pointer and the center of the cursor



More information about the vlc-commits mailing list