]> git.sesse.net Git - vlc/commitdiff
skins2: remove range constraint for slider
authorErwan Tulou <erwan10@videolan.org>
Fri, 5 Apr 2013 15:52:26 +0000 (17:52 +0200)
committerErwan Tulou <erwan10@videolan.org>
Fri, 5 Apr 2013 17:14:34 +0000 (19:14 +0200)
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)

modules/gui/skins2/controls/ctrl_slider.cpp
modules/gui/skins2/controls/ctrl_slider.hpp

index fe5b002362f3adb32719e07be41030373712c7f7..7ff8974734632b3235513badeae79eb4e809ad10 100644 (file)
@@ -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()
index 10eaa602f08e5bd74a2e013a6b395e6910d625de..cddc1683d64ef746f1ab237a9c915ee51baf3470 100644 (file)
@@ -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