]> git.sesse.net Git - vlc/commitdiff
* ctrl_slider.cpp: take the resize factor into account to refresh
authorCyril Deguet <asmax@videolan.org>
Wed, 16 Nov 2005 20:50:47 +0000 (20:50 +0000)
committerCyril Deguet <asmax@videolan.org>
Wed, 16 Nov 2005 20:50:47 +0000 (20:50 +0000)
 the window (fixed the bug of the disappearing slider)

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

index 641738fb02ab492987c52684079b1f6a7fb237d5..1973d5f2abccca131ac57102e166e3cde2b29609 100644 (file)
@@ -162,15 +162,7 @@ void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest )
 void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable )
 {
     // The position has changed
-    if( m_pImg )
-    {
-        notifyLayout( m_rCurve.getWidth() + m_pImg->getWidth(),
-                      m_rCurve.getHeight() + m_pImg->getHeight(),
-                      - m_pImg->getWidth() / 2,
-                      - m_pImg->getHeight() / 2 );
-    }
-    else
-        notifyLayout();
+    refreshLayout();
 }
 
 
@@ -195,16 +187,7 @@ void CtrlSliderCursor::CmdOverDown::execute()
 
     m_pParent->captureMouse();
     m_pParent->m_pImg = m_pParent->m_pImgDown;
-    if( m_pParent->m_pImg )
-    {
-        m_pParent->notifyLayout(
-            m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
-            m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
-            - m_pParent->m_pImg->getWidth() / 2,
-            - m_pParent->m_pImg->getHeight() / 2 );
-    }
-    else
-        m_pParent->notifyLayout();
+    m_pParent->refreshLayout();
 }
 
 
@@ -215,48 +198,21 @@ void CtrlSliderCursor::CmdDownOver::execute()
 
     m_pParent->releaseMouse();
     m_pParent->m_pImg = m_pParent->m_pImgUp;
-    if( m_pParent->m_pImg )
-    {
-        m_pParent->notifyLayout(
-            m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
-            m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
-            - m_pParent->m_pImg->getWidth() / 2,
-            - m_pParent->m_pImg->getHeight() / 2 );
-    }
-    else
-        m_pParent->notifyLayout();
+    m_pParent->refreshLayout();
 }
 
 
 void CtrlSliderCursor::CmdUpOver::execute()
 {
     m_pParent->m_pImg = m_pParent->m_pImgOver;
-    if( m_pParent->m_pImg )
-    {
-        m_pParent->notifyLayout(
-            m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
-            m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
-            - m_pParent->m_pImg->getWidth() / 2,
-            - m_pParent->m_pImg->getHeight() / 2 );
-    }
-    else
-        m_pParent->notifyLayout();
+    m_pParent->refreshLayout();
 }
 
 
 void CtrlSliderCursor::CmdOverUp::execute()
 {
     m_pParent->m_pImg = m_pParent->m_pImgUp;
-    if( m_pParent->m_pImg )
-    {
-        m_pParent->notifyLayout(
-            m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
-            m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
-            - m_pParent->m_pImg->getWidth() / 2,
-            - m_pParent->m_pImg->getHeight() / 2 );
-    }
-    else
-        m_pParent->notifyLayout();
+    m_pParent->refreshLayout();
 }
 
 
@@ -332,6 +288,24 @@ void CtrlSliderCursor::getResizeFactors( float &rFactorX,
 }
 
 
+void CtrlSliderCursor::refreshLayout()
+{
+    if( m_pImg )
+    {
+        // Compute the resize factors
+        float factorX, factorY;
+        getResizeFactors( factorX, factorY );
+
+        notifyLayout( (int)(m_rCurve.getWidth() * factorX) + m_pImg->getWidth(),
+                      (int)(m_rCurve.getHeight() * factorY) + m_pImg->getHeight(),
+                      - m_pImg->getWidth() / 2,
+                      - m_pImg->getHeight() / 2 );
+    }
+    else
+        notifyLayout();
+}
+
+
 CtrlSliderBg::CtrlSliderBg( intf_thread_t *pIntf,
                             const Bezier &rCurve, VarPercent &rVariable,
                             int thickness, GenericBitmap *pBackground,
index d0d5e6a9d6eb0a34dd25d92108ec6aa8345f4f9b..ea1903651f7f40115899b3eac2240ae490c2d49e 100644 (file)
@@ -100,8 +100,11 @@ class CtrlSliderCursor: public CtrlGeneric, public Observer<VarPercent>
         /// Method called when the position variable is modified
         virtual void onUpdate( Subject<VarPercent> &rVariable );
 
-        /// Methode to compute the resize factors
+        /// Method to compute the resize factors
         void getResizeFactors( float &rFactorX, float &rFactorY ) const;
+
+        /// Call notifyLayout
+        void refreshLayout();
 };
 
 
@@ -156,7 +159,7 @@ class CtrlSliderBg: public CtrlGeneric, public Observer<VarPercent>
         /// Method called when the observed variable is modified
         virtual void onUpdate( Subject<VarPercent> &rVariable );
 
-        /// Methode to compute the resize factors
+        /// Method to compute the resize factors
         void getResizeFactors( float &rFactorX, float &rFactorY ) const;
 };