Commit 39c57090 authored by Erwan Tulou's avatar 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)
parent 29db598a
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include "../utils/var_percent.hpp" #include "../utils/var_percent.hpp"
#define RANGE 40
static inline float scroll( bool up, float pct, float step ) static inline float scroll( bool up, float pct, float step )
{ {
return pct + ( up ? step : -step ); return pct + ( up ? step : -step );
...@@ -57,8 +55,7 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf, ...@@ -57,8 +55,7 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
m_cmdOverDown( this ), m_cmdDownOver( this ), m_cmdOverDown( this ), m_cmdDownOver( this ),
m_cmdOverUp( this ), m_cmdUpOver( this ), m_cmdOverUp( this ), m_cmdUpOver( this ),
m_cmdMove( this ), m_cmdScroll( this ), m_cmdMove( this ), m_cmdScroll( this ),
m_lastPercentage( 0 ), m_lastCursorRect(), m_lastCursorRect(), m_xOffset( 0 ), m_yOffset( 0 ),
m_xOffset( 0 ), m_yOffset( 0 ),
m_pEvt( NULL ), m_rCurve( rCurve ) m_pEvt( NULL ), m_rCurve( rCurve )
{ {
// Build the images of the cursor // Build the images of the cursor
...@@ -94,9 +91,6 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf, ...@@ -94,9 +91,6 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
// Observe the position variable // Observe the position variable
m_rVariable.addObserver( this ); m_rVariable.addObserver( this );
// Initial position of the cursor
m_lastPercentage = m_rVariable.get();
} }
...@@ -204,9 +198,6 @@ void CtrlSliderCursor::CmdOverDown::execute() ...@@ -204,9 +198,6 @@ void CtrlSliderCursor::CmdOverDown::execute()
void CtrlSliderCursor::CmdDownOver::execute() void CtrlSliderCursor::CmdDownOver::execute()
{ {
// Save the position
m_pParent->m_lastPercentage = m_pParent->m_rVariable.get();
m_pParent->releaseMouse(); m_pParent->releaseMouse();
m_pParent->m_pImg = m_pParent->m_pImgUp; m_pParent->m_pImg = m_pParent->m_pImgUp;
m_pParent->refreshLayout(); m_pParent->refreshLayout();
...@@ -245,17 +236,9 @@ void CtrlSliderCursor::CmdMove::execute() ...@@ -245,17 +236,9 @@ void CtrlSliderCursor::CmdMove::execute()
int relXPond = (int)(relX / factorX); int relXPond = (int)(relX / factorX);
int relYPond = (int)(relY / factorY); int relYPond = (int)(relY / factorY);
// Update the position float percentage =
if( m_pParent->m_rCurve.getMinDist( relXPond, relYPond ) < RANGE ) m_pParent->m_rCurve.getNearestPercent( relXPond, relYPond );
{ m_pParent->m_rVariable.set( percentage );
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 );
}
} }
void CtrlSliderCursor::CmdScroll::execute() void CtrlSliderCursor::CmdScroll::execute()
......
...@@ -95,8 +95,6 @@ private: ...@@ -95,8 +95,6 @@ private:
DEFINE_CALLBACK( CtrlSliderCursor, UpOver ) DEFINE_CALLBACK( CtrlSliderCursor, UpOver )
DEFINE_CALLBACK( CtrlSliderCursor, Move ) DEFINE_CALLBACK( CtrlSliderCursor, Move )
DEFINE_CALLBACK( CtrlSliderCursor, Scroll ) DEFINE_CALLBACK( CtrlSliderCursor, Scroll )
/// Last saved position of the cursor (stored as a percentage)
float m_lastPercentage;
/// Last saved cursor placement /// Last saved cursor placement
rect m_lastCursorRect; rect m_lastCursorRect;
/// Offset between the mouse pointer and the center of the cursor /// Offset between the mouse pointer and the center of the cursor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment