]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/controls/ctrl_button.cpp
skins2: improve refresh of layouts
[vlc] / modules / gui / skins2 / controls / ctrl_button.cpp
index a1eb12559a6f0f576e57cebc775b68c91e100f43..1c19bc3bdadf16da9df30a1b920fe7d7c1a9545a 100644 (file)
@@ -114,16 +114,22 @@ bool CtrlButton::mouseOver( int x, int y ) const
 }
 
 
-void CtrlButton::draw( OSGraphics &rImage, int xDest, int yDest )
-{
-    if( m_pImg )
+void CtrlButton::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h )
+{
+    const Position *pPos = getPosition();
+    rect region( pPos->getLeft(), pPos->getTop(),
+                 pPos->getWidth(), pPos->getHeight() );
+    rect clip( xDest, yDest, w, h );
+    rect inter;
+    if( rect::intersect( region, clip, &inter ) && m_pImg )
     {
         // Draw the current image
-        m_pImg->draw( rImage, xDest, yDest );
+        m_pImg->draw( rImage, inter.x, inter.y, inter.width, inter.height,
+                      inter.x - pPos->getLeft(),
+                      inter.y - pPos->getTop() );
     }
 }
 
-
 void CtrlButton::setImage( AnimBitmap *pImg )
 {
     AnimBitmap *pOldImg = m_pImg;
@@ -147,7 +153,7 @@ void CtrlButton::setImage( AnimBitmap *pImg )
 
 void CtrlButton::onUpdate( Subject<AnimBitmap> &rBitmap, void *arg )
 {
-    notifyLayout();
+    notifyLayout( m_pImg->getWidth(), m_pImg->getHeight() );
 }