]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/controls/ctrl_radialslider.cpp
skins2: fix RadialSlider (overflow)
[vlc] / modules / gui / skins2 / controls / ctrl_radialslider.cpp
index 6c8b6be6f3253921f0149baa4061fad102d623e7..a1bbec3c00e02dc8d6632327e31c4b064548c718 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -41,12 +41,11 @@ CtrlRadialSlider::CtrlRadialSlider( intf_thread_t *pIntf,
     CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_numImg( numImg ),
     m_rVariable( rVariable ), m_minAngle( minAngle ), m_maxAngle( maxAngle ),
     m_cmdUpDown( this ), m_cmdDownUp( this ),
-    m_cmdMove( this )
+    m_cmdMove( this ), m_position( 0 )
 {
     // Build the images of the sequence
-    OSFactory *pOsFactory = OSFactory::instance( getIntf() );
-    m_pImgSeq = pOsFactory->createOSGraphics( rBmpSeq.getWidth(),
-                                              rBmpSeq.getHeight() );
+    m_pImgSeq = OSFactory::instance( getIntf() )->createOSGraphics(
+                                     rBmpSeq.getWidth(), rBmpSeq.getHeight() );
     m_pImgSeq->drawBitmap( rBmpSeq, 0, 0 );
 
     m_width = rBmpSeq.getWidth();
@@ -72,7 +71,7 @@ CtrlRadialSlider::CtrlRadialSlider( intf_thread_t *pIntf,
 CtrlRadialSlider::~CtrlRadialSlider()
 {
     m_rVariable.delObserver( this );
-    SKINS_DELETE( m_pImgSeq );
+    delete m_pImgSeq;
 }
 
 
@@ -98,10 +97,10 @@ void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest )
 }
 
 
-void CtrlRadialSlider::onUpdate( Subject<VarPercent,void*> &rVariable,
+void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable,
                                  void *arg  )
 {
-    m_position = (int)( m_rVariable.get() * m_numImg );
+    m_position = (int)( m_rVariable.get() * ( m_numImg - 1 ) );
     notifyLayout( m_width, m_height );
 }
 
@@ -125,7 +124,7 @@ void CtrlRadialSlider::CmdDownUp::execute()
 
 void CtrlRadialSlider::CmdMove::execute()
 {
-    EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
+    EvtMouse *pEvtMouse = static_cast<EvtMouse*>(m_pParent->m_pEvt);
 
     // Change the position of the cursor, in blocking mode
     m_pParent->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), true );
@@ -143,7 +142,7 @@ void CtrlRadialSlider::setCursor( int posX, int posY, bool blocking )
 
     // Compute the position relative to the center
     int x = posX - pPos->getLeft() - m_width / 2;
-    int y = posY - pPos->getTop() - m_width / 2;
+    int y = posY - pPos->getTop() - m_height / 2;
 
     // Compute the polar coordinates. angle is -(-j,OM)
     float r = sqrt((float)(x*x + y*y));