]> git.sesse.net Git - vlc/commitdiff
* skins/utils/bezier.cpp: Fixed a bug in the computation of the size of a
authorOlivier Teulière <ipkiss@videolan.org>
Fri, 17 Dec 2004 20:07:54 +0000 (20:07 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Fri, 17 Dec 2004 20:07:54 +0000 (20:07 +0000)
   Bezier curve
 * skins2/*: Fixed "lazy redrawing" for the slider control

modules/gui/skins2/controls/ctrl_generic.cpp
modules/gui/skins2/controls/ctrl_generic.hpp
modules/gui/skins2/controls/ctrl_slider.cpp
modules/gui/skins2/src/generic_layout.cpp
modules/gui/skins2/src/generic_layout.hpp
modules/gui/skins2/utils/bezier.cpp

index 524ba6a1bd9c8a19dd3765ba909244eed3eddca6..2b27c2a754c1f51121a85e21e50862a2c2bd0ce3 100755 (executable)
@@ -69,18 +69,19 @@ void CtrlGeneric::setLayout( GenericLayout *pLayout,
 }
 
 
-void CtrlGeneric::notifyLayout( int width, int height ) const
+void CtrlGeneric::notifyLayout( int width, int height,
+                                int xOffSet, int yOffSet ) const
 {
     // Notify the layout
     if( m_pLayout )
     {
-        m_pLayout->onControlUpdate( *this, width, height );
+        m_pLayout->onControlUpdate( *this, width, height, xOffSet, yOffSet );
     }
 }
 
 
 void CtrlGeneric::notifyLayoutMaxSize( const OSGraphics *pImg1,
-                                      const OSGraphics *pImg2 )
+                                       const OSGraphics *pImg2 )
 {
     if( pImg1 == NULL )
     {
index 78c940c5d533e660e8a55e1dd256373e0eae1347..a68a796581eecb4a2f77a23756820912a6d2001a 100644 (file)
@@ -84,9 +84,10 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool>
                      VarBool *pVisible = NULL );
 
         /// Tell the layout when the image has changed, with the size of the
-        /// rectangle to repaint (use the default values for repainting the
-        /// whole window)
-        virtual void notifyLayout( int witdh = -1, int height = -1 ) const;
+        /// rectangle to repaint and its offset.
+        /// Use the default values to repaint the whole window
+        virtual void notifyLayout( int witdh = -1, int height = -1,
+                                   int xOffSet = 0, int yOffSet = 0 ) const;
 
         /// Same as notifyLayout(), but takes optional images as parameters.
         /// The maximum size(s) of the images will be used for repainting.
index ba206a8fba52cb709a128dda5b67b21ce291b02d..28cb0bece5b8bde06d5eec9682a9b3a5928efb77 100644 (file)
@@ -163,7 +163,15 @@ void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest )
 void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable )
 {
     // The position has changed
-    notifyLayout( m_rCurve.getWidth(), m_rCurve.getHeight() );
+    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();
 }
 
 
@@ -189,8 +197,16 @@ void CtrlSliderCursor::transOverDown( SkinObject *pCtrl )
 
     pThis->captureMouse();
     pThis->m_pImg = pThis->m_pImgDown;
-    pThis->notifyLayout( pThis->m_rCurve.getWidth(),
-                         pThis->m_rCurve.getHeight() );
+    if( pThis->m_pImg )
+    {
+        pThis->notifyLayout(
+            pThis->m_rCurve.getWidth() + pThis->m_pImg->getWidth(),
+            pThis->m_rCurve.getHeight() + pThis->m_pImg->getHeight(),
+            - pThis->m_pImg->getWidth() / 2,
+            - pThis->m_pImg->getHeight() / 2 );
+    }
+    else
+        pThis->notifyLayout();
 }
 
 
@@ -203,8 +219,16 @@ void CtrlSliderCursor::transDownOver( SkinObject *pCtrl )
 
     pThis->releaseMouse();
     pThis->m_pImg = pThis->m_pImgUp;
-    pThis->notifyLayout( pThis->m_rCurve.getWidth(),
-                         pThis->m_rCurve.getHeight() );
+    if( pThis->m_pImg )
+    {
+        pThis->notifyLayout(
+            pThis->m_rCurve.getWidth() + pThis->m_pImg->getWidth(),
+            pThis->m_rCurve.getHeight() + pThis->m_pImg->getHeight(),
+            - pThis->m_pImg->getWidth() / 2,
+            - pThis->m_pImg->getHeight() / 2 );
+    }
+    else
+        pThis->notifyLayout();
 }
 
 
@@ -213,8 +237,16 @@ void CtrlSliderCursor::transUpOver( SkinObject *pCtrl )
     CtrlSliderCursor *pThis = (CtrlSliderCursor*)pCtrl;
 
     pThis->m_pImg = pThis->m_pImgOver;
-    pThis->notifyLayout( pThis->m_rCurve.getWidth(),
-                         pThis->m_rCurve.getHeight() );
+    if( pThis->m_pImg )
+    {
+        pThis->notifyLayout(
+            pThis->m_rCurve.getWidth() + pThis->m_pImg->getWidth(),
+            pThis->m_rCurve.getHeight() + pThis->m_pImg->getHeight(),
+            - pThis->m_pImg->getWidth() / 2,
+            - pThis->m_pImg->getHeight() / 2 );
+    }
+    else
+        pThis->notifyLayout();
 }
 
 
@@ -223,8 +255,16 @@ void CtrlSliderCursor::transOverUp( SkinObject *pCtrl )
     CtrlSliderCursor *pThis = (CtrlSliderCursor*)pCtrl;
 
     pThis->m_pImg = pThis->m_pImgUp;
-    pThis->notifyLayout( pThis->m_rCurve.getWidth(),
-                         pThis->m_rCurve.getHeight() );
+    if( pThis->m_pImg )
+    {
+        pThis->notifyLayout(
+            pThis->m_rCurve.getWidth() + pThis->m_pImg->getWidth(),
+            pThis->m_rCurve.getHeight() + pThis->m_pImg->getHeight(),
+            - pThis->m_pImg->getWidth() / 2,
+            - pThis->m_pImg->getHeight() / 2 );
+    }
+    else
+        pThis->notifyLayout();
 }
 
 
index 65436cd1e12c9c90ef6bdb20bff786aa3de1cf73..03768bea6c3b8fc0dae59721be8d7c3aa1bb333b 100644 (file)
@@ -122,9 +122,10 @@ const list<LayeredControl> &GenericLayout::getControlList() const
 
 
 void GenericLayout::onControlUpdate( const CtrlGeneric &rCtrl,
-                                     int width, int height )
+                                     int width, int height,
+                                     int xOffSet, int yOffSet )
 {
-    // The size was not specified (or invalid)
+    // The size is not valid, refresh the whole layout
     if( width <= 0 || height <= 0 )
     {
         refreshAll();
@@ -134,7 +135,9 @@ void GenericLayout::onControlUpdate( const CtrlGeneric &rCtrl,
     const Position *pPos = rCtrl.getPosition();
     if( pPos )
     {
-        refreshRect( pPos->getLeft(), pPos->getTop(), width, height );
+        refreshRect( pPos->getLeft() + xOffSet,
+                     pPos->getTop() + yOffSet,
+                     width, height );
     }
 }
 
index 8404fe11dda9b3acb047f94cc9049f75ed0d1c58..07be198388283aa4fb5a00724eb3751303047f21 100644 (file)
@@ -105,8 +105,12 @@ class GenericLayout: public SkinObject, public Box
         virtual const list<LayeredControl> &getControlList() const;
 
         /// Called by a control when its image has changed
+        /// The arguments indicate the size of the rectangle to refresh,
+        /// and the offset (from the control position) of this rectangle.
+        /// Use a negative width or height to refresh the layout completely
         virtual void onControlUpdate( const CtrlGeneric &rCtrl,
-                                      int width, int height );
+                                      int width, int height,
+                                      int xOffSet, int yOffSet );
 
         /// Get the list of the anchors of this layout
         virtual const list<Anchor*>& getAnchorList() const;
index 7189c5f24583218bfce36c7332f00f09db7e60ca..5110b0e9d009bf2b2c4dd209e2af64f488433cb7 100644 (file)
@@ -133,9 +133,9 @@ int Bezier::getWidth() const
     int width = 0;
     for( int i = 0; i < m_nbPoints; i++ )
     {
-        if( m_leftVect[i] > width )
+        if( m_leftVect[i] >= width )
         {
-            width = m_leftVect[i];
+            width = m_leftVect[i] + 1;
         }
     }
     return width;
@@ -147,9 +147,9 @@ int Bezier::getHeight() const
     int height = 0;
     for( int i = 0; i < m_nbPoints; i++ )
     {
-        if( m_topVect[i] > height )
+        if( m_topVect[i] >= height )
         {
-            height = m_topVect[i];
+            height = m_topVect[i] + 1;
         }
     }
     return height;