Commit 6314367b authored by Olivier Teulière's avatar Olivier Teulière

* skins2: When a control changes, refresh only the needed part of the layout

   instead of refreshing everything
parent df0d5be1
...@@ -133,8 +133,9 @@ void CtrlButton::transUpOverDownOver( SkinObject *pCtrl ) ...@@ -133,8 +133,9 @@ void CtrlButton::transUpOverDownOver( SkinObject *pCtrl )
{ {
CtrlButton *pThis = (CtrlButton*)pCtrl; CtrlButton *pThis = (CtrlButton*)pCtrl;
pThis->captureMouse(); pThis->captureMouse();
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgDown; pThis->m_pImg = pThis->m_pImgDown;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
} }
...@@ -142,8 +143,9 @@ void CtrlButton::transDownOverUpOver( SkinObject *pCtrl ) ...@@ -142,8 +143,9 @@ void CtrlButton::transDownOverUpOver( SkinObject *pCtrl )
{ {
CtrlButton *pThis = (CtrlButton*)pCtrl; CtrlButton *pThis = (CtrlButton*)pCtrl;
pThis->releaseMouse(); pThis->releaseMouse();
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgUp; pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
// Execute the command associated to this button // Execute the command associated to this button
pThis->m_rCommand.execute(); pThis->m_rCommand.execute();
} }
...@@ -152,32 +154,36 @@ void CtrlButton::transDownOverUpOver( SkinObject *pCtrl ) ...@@ -152,32 +154,36 @@ void CtrlButton::transDownOverUpOver( SkinObject *pCtrl )
void CtrlButton::transDownOverDown( SkinObject *pCtrl ) void CtrlButton::transDownOverDown( SkinObject *pCtrl )
{ {
CtrlButton *pThis = (CtrlButton*)pCtrl; CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgUp; pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
} }
void CtrlButton::transDownDownOver( SkinObject *pCtrl ) void CtrlButton::transDownDownOver( SkinObject *pCtrl )
{ {
CtrlButton *pThis = (CtrlButton*)pCtrl; CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgDown; pThis->m_pImg = pThis->m_pImgDown;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
} }
void CtrlButton::transUpUpOver( SkinObject *pCtrl ) void CtrlButton::transUpUpOver( SkinObject *pCtrl )
{ {
CtrlButton *pThis = (CtrlButton*)pCtrl; CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgOver; pThis->m_pImg = pThis->m_pImgOver;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
} }
void CtrlButton::transUpOverUp( SkinObject *pCtrl ) void CtrlButton::transUpOverUp( SkinObject *pCtrl )
{ {
CtrlButton *pThis = (CtrlButton*)pCtrl; CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgUp; pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
} }
...@@ -191,15 +197,17 @@ void CtrlButton::transDownUp( SkinObject *pCtrl ) ...@@ -191,15 +197,17 @@ void CtrlButton::transDownUp( SkinObject *pCtrl )
void CtrlButton::transUpHidden( SkinObject *pCtrl ) void CtrlButton::transUpHidden( SkinObject *pCtrl )
{ {
CtrlButton *pThis = (CtrlButton*)pCtrl; CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = NULL; pThis->m_pImg = NULL;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
} }
void CtrlButton::transHiddenUp( SkinObject *pCtrl ) void CtrlButton::transHiddenUp( SkinObject *pCtrl )
{ {
CtrlButton *pThis = (CtrlButton*)pCtrl; CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgUp; pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ctrl_button.hpp * ctrl_button.hpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: ctrl_button.hpp,v 1.2 2004/02/29 16:49:55 asmax Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr> * Olivier Teulire <ipkiss@via.ecp.fr>
......
...@@ -177,8 +177,9 @@ void CtrlCheckbox::transUpOverDownOver( SkinObject *pCtrl ) ...@@ -177,8 +177,9 @@ void CtrlCheckbox::transUpOverDownOver( SkinObject *pCtrl )
{ {
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl; CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
pThis->captureMouse(); pThis->captureMouse();
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgDown; pThis->m_pImgCurrent = pThis->m_pImgDown;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
} }
...@@ -188,8 +189,9 @@ void CtrlCheckbox::transDownOverUpOver( SkinObject *pCtrl ) ...@@ -188,8 +189,9 @@ void CtrlCheckbox::transDownOverUpOver( SkinObject *pCtrl )
pThis->releaseMouse(); pThis->releaseMouse();
// Invert the state variable // Invert the state variable
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgUp; pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
// Execute the command // Execute the command
pThis->m_pCommand->execute(); pThis->m_pCommand->execute();
...@@ -199,32 +201,36 @@ void CtrlCheckbox::transDownOverUpOver( SkinObject *pCtrl ) ...@@ -199,32 +201,36 @@ void CtrlCheckbox::transDownOverUpOver( SkinObject *pCtrl )
void CtrlCheckbox::transDownOverDown( SkinObject *pCtrl ) void CtrlCheckbox::transDownOverDown( SkinObject *pCtrl )
{ {
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl; CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgUp; pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
} }
void CtrlCheckbox::transDownDownOver( SkinObject *pCtrl ) void CtrlCheckbox::transDownDownOver( SkinObject *pCtrl )
{ {
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl; CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgDown; pThis->m_pImgCurrent = pThis->m_pImgDown;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
} }
void CtrlCheckbox::transUpUpOver( SkinObject *pCtrl ) void CtrlCheckbox::transUpUpOver( SkinObject *pCtrl )
{ {
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl; CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgOver; pThis->m_pImgCurrent = pThis->m_pImgOver;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
} }
void CtrlCheckbox::transUpOverUp( SkinObject *pCtrl ) void CtrlCheckbox::transUpOverUp( SkinObject *pCtrl )
{ {
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl; CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgUp; pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
} }
...@@ -238,16 +244,18 @@ void CtrlCheckbox::transDownUp( SkinObject *pCtrl ) ...@@ -238,16 +244,18 @@ void CtrlCheckbox::transDownUp( SkinObject *pCtrl )
void CtrlCheckbox::transUpHidden( SkinObject *pCtrl ) void CtrlCheckbox::transUpHidden( SkinObject *pCtrl )
{ {
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl; CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = NULL; pThis->m_pImgCurrent = NULL;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
} }
void CtrlCheckbox::transHiddenUp( SkinObject *pCtrl ) void CtrlCheckbox::transHiddenUp( SkinObject *pCtrl )
{ {
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl; CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgUp; pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
} }
......
...@@ -69,12 +69,41 @@ void CtrlGeneric::setLayout( GenericLayout *pLayout, ...@@ -69,12 +69,41 @@ void CtrlGeneric::setLayout( GenericLayout *pLayout,
} }
void CtrlGeneric::notifyLayout() const void CtrlGeneric::notifyLayout( int width, int height ) const
{ {
// Notify the layout // Notify the layout
if( m_pLayout ) if( m_pLayout )
{ {
m_pLayout->onControlUpdate( *this ); m_pLayout->onControlUpdate( *this, width, height );
}
}
void CtrlGeneric::notifyLayoutMaxSize( const OSGraphics *pImg1,
const OSGraphics *pImg2 )
{
if( pImg1 == NULL )
{
if( pImg2 == NULL )
{
notifyLayout();
}
else
{
notifyLayout( pImg2->getWidth(), pImg2->getHeight() );
}
}
else
{
if( pImg2 == NULL )
{
notifyLayout( pImg1->getWidth(), pImg1->getHeight() );
}
else
{
notifyLayout( max( pImg1->getWidth(), pImg2->getWidth() ),
max( pImg1->getHeight(), pImg2->getHeight() ) );
}
} }
} }
...@@ -128,7 +157,7 @@ bool CtrlGeneric::isVisible() const ...@@ -128,7 +157,7 @@ bool CtrlGeneric::isVisible() const
void CtrlGeneric::onUpdate( Subject<VarBool> &rVariable ) void CtrlGeneric::onUpdate( Subject<VarBool> &rVariable )
{ {
// Is it the visibily variable ? // Is it the visibility variable ?
if( &rVariable == m_pVisible ) if( &rVariable == m_pVisible )
{ {
// Redraw the layout // Redraw the layout
......
...@@ -83,8 +83,15 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool> ...@@ -83,8 +83,15 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool>
CtrlGeneric( intf_thread_t *pIntf, const UString &rHelp, CtrlGeneric( intf_thread_t *pIntf, const UString &rHelp,
VarBool *pVisible = NULL ); VarBool *pVisible = NULL );
/// Tell the layout when the image has changed /// Tell the layout when the image has changed, with the size of the
virtual void notifyLayout() const; /// rectangle to repaint (use the default values for repainting the
/// whole window)
virtual void notifyLayout( int witdh = -1, int height = -1 ) const;
/// Same as notifyLayout(), but takes optional images as parameters.
/// The maximum size(s) of the images will be used for repainting.
void notifyLayoutMaxSize( const OSGraphics *pImg1 = NULL,
const OSGraphics *pImg2 = NULL );
/// Ask the layout to capture the mouse /// Ask the layout to capture the mouse
virtual void captureMouse() const; virtual void captureMouse() const;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ctrl_radialslider.cpp * ctrl_radialslider.cpp
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: ctrl_radialslider.cpp,v 1.3 2004/02/29 16:49:55 asmax Exp $ * $Id$
* *
* Authors: Cyril Deguet <asmax@via.ecp.fr> * Authors: Cyril Deguet <asmax@via.ecp.fr>
* Olivier Teulire <ipkiss@via.ecp.fr> * Olivier Teulire <ipkiss@via.ecp.fr>
...@@ -101,7 +101,7 @@ void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest ) ...@@ -101,7 +101,7 @@ void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest )
void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable ) void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable )
{ {
m_position = (int)( m_rVariable.get() * m_numImg ); m_position = (int)( m_rVariable.get() * m_numImg );
notifyLayout(); notifyLayout( m_width, m_height );
} }
......
...@@ -163,7 +163,7 @@ void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest ) ...@@ -163,7 +163,7 @@ void CtrlSliderCursor::draw( OSGraphics &rImage, int xDest, int yDest )
void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable ) void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable )
{ {
// The position has changed // The position has changed
notifyLayout(); notifyLayout( m_rCurve.getWidth(), m_rCurve.getHeight() );
} }
...@@ -189,7 +189,8 @@ void CtrlSliderCursor::transOverDown( SkinObject *pCtrl ) ...@@ -189,7 +189,8 @@ void CtrlSliderCursor::transOverDown( SkinObject *pCtrl )
pThis->captureMouse(); pThis->captureMouse();
pThis->m_pImg = pThis->m_pImgDown; pThis->m_pImg = pThis->m_pImgDown;
pThis->notifyLayout(); pThis->notifyLayout( pThis->m_rCurve.getWidth(),
pThis->m_rCurve.getHeight() );
} }
...@@ -202,7 +203,8 @@ void CtrlSliderCursor::transDownOver( SkinObject *pCtrl ) ...@@ -202,7 +203,8 @@ void CtrlSliderCursor::transDownOver( SkinObject *pCtrl )
pThis->releaseMouse(); pThis->releaseMouse();
pThis->m_pImg = pThis->m_pImgUp; pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayout( pThis->m_rCurve.getWidth(),
pThis->m_rCurve.getHeight() );
} }
...@@ -211,7 +213,8 @@ void CtrlSliderCursor::transUpOver( SkinObject *pCtrl ) ...@@ -211,7 +213,8 @@ void CtrlSliderCursor::transUpOver( SkinObject *pCtrl )
CtrlSliderCursor *pThis = (CtrlSliderCursor*)pCtrl; CtrlSliderCursor *pThis = (CtrlSliderCursor*)pCtrl;
pThis->m_pImg = pThis->m_pImgOver; pThis->m_pImg = pThis->m_pImgOver;
pThis->notifyLayout(); pThis->notifyLayout( pThis->m_rCurve.getWidth(),
pThis->m_rCurve.getHeight() );
} }
...@@ -220,7 +223,8 @@ void CtrlSliderCursor::transOverUp( SkinObject *pCtrl ) ...@@ -220,7 +223,8 @@ void CtrlSliderCursor::transOverUp( SkinObject *pCtrl )
CtrlSliderCursor *pThis = (CtrlSliderCursor*)pCtrl; CtrlSliderCursor *pThis = (CtrlSliderCursor*)pCtrl;
pThis->m_pImg = pThis->m_pImgUp; pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout(); pThis->notifyLayout( pThis->m_rCurve.getWidth(),
pThis->m_rCurve.getHeight() );
} }
......
...@@ -227,7 +227,7 @@ void CtrlText::displayText( const UString &rText ) ...@@ -227,7 +227,7 @@ void CtrlText::displayText( const UString &rText )
m_pTimer->stop(); m_pTimer->stop();
} }
} }
notifyLayout(); notifyLayout( getPosition()->getWidth(), getPosition()->getHeight() );
} }
} }
...@@ -311,7 +311,8 @@ void CtrlText::transMove( SkinObject *pCtrl ) ...@@ -311,7 +311,8 @@ void CtrlText::transMove( SkinObject *pCtrl )
pThis->m_xPos = (pEvtMouse->getXPos() - pThis->m_xOffset); pThis->m_xPos = (pEvtMouse->getXPos() - pThis->m_xOffset);
pThis->adjust( pThis->m_xPos ); pThis->adjust( pThis->m_xPos );
pThis->notifyLayout(); pThis->notifyLayout( pThis->getPosition()->getWidth(),
pThis->getPosition()->getHeight() );
} }
} }
...@@ -323,7 +324,8 @@ void CtrlText::updateText( SkinObject *pCtrl ) ...@@ -323,7 +324,8 @@ void CtrlText::updateText( SkinObject *pCtrl )
pThis->m_xPos -= MOVING_TEXT_STEP; pThis->m_xPos -= MOVING_TEXT_STEP;
pThis->adjust( pThis->m_xPos ); pThis->adjust( pThis->m_xPos );
pThis->notifyLayout(); pThis->notifyLayout( pThis->getPosition()->getWidth(),
pThis->getPosition()->getHeight() );
} }
......
...@@ -121,10 +121,21 @@ const list<LayeredControl> &GenericLayout::getControlList() const ...@@ -121,10 +121,21 @@ const list<LayeredControl> &GenericLayout::getControlList() const
} }
void GenericLayout::onControlUpdate( const CtrlGeneric &rCtrl ) void GenericLayout::onControlUpdate( const CtrlGeneric &rCtrl,
int width, int height )
{ {
// TODO: refresh only the needed area if possible // The size was not specified (or invalid)
refreshAll(); if( width <= 0 || height <= 0 )
{
refreshAll();
return;
}
const Position *pPos = rCtrl.getPosition();
if( pPos )
{
refreshRect( pPos->getLeft(), pPos->getTop(), width, height );
}
} }
...@@ -177,6 +188,12 @@ void GenericLayout::resize( int width, int height ) ...@@ -177,6 +188,12 @@ void GenericLayout::resize( int width, int height )
void GenericLayout::refreshAll() void GenericLayout::refreshAll()
{
refreshRect( 0, 0, m_width, m_height );
}
void GenericLayout::refreshRect( int x, int y, int width, int height )
{ {
// Draw all the controls of the layout // Draw all the controls of the layout
list<LayeredControl>::const_iterator iter; list<LayeredControl>::const_iterator iter;
...@@ -194,7 +211,17 @@ void GenericLayout::refreshAll() ...@@ -194,7 +211,17 @@ void GenericLayout::refreshAll()
TopWindow *pWindow = getWindow(); TopWindow *pWindow = getWindow();
if( pWindow ) if( pWindow )
{ {
pWindow->refresh( 0, 0, m_width, m_height ); // Check boundaries
if( x < 0 )
x = 0;
if( y < 0)
y = 0;
if( x + width > m_width )
width = m_width - x;
if( y + height > m_height )
height = m_height - y;
pWindow->refresh( x, y, width, height );
} }
} }
......
...@@ -105,7 +105,8 @@ class GenericLayout: public SkinObject, public Box ...@@ -105,7 +105,8 @@ class GenericLayout: public SkinObject, public Box
virtual const list<LayeredControl> &getControlList() const; virtual const list<LayeredControl> &getControlList() const;
/// Called by a control when its image has changed /// Called by a control when its image has changed
virtual void onControlUpdate( const CtrlGeneric &rCtrl ); virtual void onControlUpdate( const CtrlGeneric &rCtrl,
int width, int height );
/// Get the list of the anchors of this layout /// Get the list of the anchors of this layout
virtual const list<Anchor*>& getAnchorList() const; virtual const list<Anchor*>& getAnchorList() const;
...@@ -114,6 +115,9 @@ class GenericLayout: public SkinObject, public Box ...@@ -114,6 +115,9 @@ class GenericLayout: public SkinObject, public Box
virtual void addAnchor( Anchor *pAnchor ); virtual void addAnchor( Anchor *pAnchor );
private: private:
/// Refresh a rectangular portion of the window
void GenericLayout::refreshRect( int x, int y, int width, int height );
/// Parent window of the layout /// Parent window of the layout
TopWindow *m_pWindow; TopWindow *m_pWindow;
/// Layout size /// Layout size
......
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