Commit 6314367b authored by ipkiss's avatar ipkiss

* 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 )
{
CtrlButton *pThis = (CtrlButton*)pCtrl;
pThis->captureMouse();
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgDown;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
}
......@@ -142,8 +143,9 @@ void CtrlButton::transDownOverUpOver( SkinObject *pCtrl )
{
CtrlButton *pThis = (CtrlButton*)pCtrl;
pThis->releaseMouse();
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
// Execute the command associated to this button
pThis->m_rCommand.execute();
}
......@@ -152,32 +154,36 @@ void CtrlButton::transDownOverUpOver( SkinObject *pCtrl )
void CtrlButton::transDownOverDown( SkinObject *pCtrl )
{
CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
}
void CtrlButton::transDownDownOver( SkinObject *pCtrl )
{
CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgDown;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
}
void CtrlButton::transUpUpOver( SkinObject *pCtrl )
{
CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgOver;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
}
void CtrlButton::transUpOverUp( SkinObject *pCtrl )
{
CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
}
......@@ -191,15 +197,17 @@ void CtrlButton::transDownUp( SkinObject *pCtrl )
void CtrlButton::transUpHidden( SkinObject *pCtrl )
{
CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = NULL;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
}
void CtrlButton::transHiddenUp( SkinObject *pCtrl )
{
CtrlButton *pThis = (CtrlButton*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImg;
pThis->m_pImg = pThis->m_pImgUp;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImg );
}
......@@ -2,7 +2,7 @@
* ctrl_button.hpp
*****************************************************************************
* 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>
* Olivier Teulire <ipkiss@via.ecp.fr>
......
......@@ -177,8 +177,9 @@ void CtrlCheckbox::transUpOverDownOver( SkinObject *pCtrl )
{
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
pThis->captureMouse();
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgDown;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
}
......@@ -188,8 +189,9 @@ void CtrlCheckbox::transDownOverUpOver( SkinObject *pCtrl )
pThis->releaseMouse();
// Invert the state variable
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
// Execute the command
pThis->m_pCommand->execute();
......@@ -199,32 +201,36 @@ void CtrlCheckbox::transDownOverUpOver( SkinObject *pCtrl )
void CtrlCheckbox::transDownOverDown( SkinObject *pCtrl )
{
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
}
void CtrlCheckbox::transDownDownOver( SkinObject *pCtrl )
{
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgDown;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
}
void CtrlCheckbox::transUpUpOver( SkinObject *pCtrl )
{
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgOver;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
}
void CtrlCheckbox::transUpOverUp( SkinObject *pCtrl )
{
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
}
......@@ -238,16 +244,18 @@ void CtrlCheckbox::transDownUp( SkinObject *pCtrl )
void CtrlCheckbox::transUpHidden( SkinObject *pCtrl )
{
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = NULL;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
}
void CtrlCheckbox::transHiddenUp( SkinObject *pCtrl )
{
CtrlCheckbox *pThis = (CtrlCheckbox*)pCtrl;
const OSGraphics *pOldImg = pThis->m_pImgCurrent;
pThis->m_pImgCurrent = pThis->m_pImgUp;
pThis->notifyLayout();
pThis->notifyLayoutMaxSize( pOldImg, pThis->m_pImgCurrent );
}
......
......@@ -69,12 +69,41 @@ void CtrlGeneric::setLayout( GenericLayout *pLayout,
}
void CtrlGeneric::notifyLayout() const
void CtrlGeneric::notifyLayout( int width, int height ) const
{
// Notify the layout
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
void CtrlGeneric::onUpdate( Subject<VarBool> &rVariable )
{
// Is it the visibily variable ?
// Is it the visibility variable ?
if( &rVariable == m_pVisible )
{
// Redraw the layout
......
......@@ -83,8 +83,15 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool>
CtrlGeneric( intf_thread_t *pIntf, const UString &rHelp,
VarBool *pVisible = NULL );
/// Tell the layout when the image has changed
virtual void notifyLayout() const;
/// 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;
/// 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
virtual void captureMouse() const;
......
......@@ -2,7 +2,7 @@
* ctrl_radialslider.cpp
*****************************************************************************
* 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>
* Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -101,7 +101,7 @@ void CtrlRadialSlider::draw( OSGraphics &rImage, int xDest, int yDest )
void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable )
{
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 )
void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable )
{
// The position has changed
notifyLayout();
notifyLayout( m_rCurve.getWidth(), m_rCurve.getHeight() );
}
......@@ -189,7 +189,8 @@ void CtrlSliderCursor::transOverDown( SkinObject *pCtrl )
pThis->captureMouse();
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 )
pThis->releaseMouse();
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 )
CtrlSliderCursor *pThis = (CtrlSliderCursor*)pCtrl;
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 )
CtrlSliderCursor *pThis = (CtrlSliderCursor*)pCtrl;
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 )
m_pTimer->stop();
}
}
notifyLayout();
notifyLayout( getPosition()->getWidth(), getPosition()->getHeight() );
}
}
......@@ -311,7 +311,8 @@ void CtrlText::transMove( SkinObject *pCtrl )
pThis->m_xPos = (pEvtMouse->getXPos() - pThis->m_xOffset);
pThis->adjust( pThis->m_xPos );
pThis->notifyLayout();
pThis->notifyLayout( pThis->getPosition()->getWidth(),
pThis->getPosition()->getHeight() );
}
}
......@@ -323,7 +324,8 @@ void CtrlText::updateText( SkinObject *pCtrl )
pThis->m_xPos -= MOVING_TEXT_STEP;
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
}
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)
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 )
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
list<LayeredControl>::const_iterator iter;
......@@ -194,7 +211,17 @@ void GenericLayout::refreshAll()
TopWindow *pWindow = getWindow();
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
virtual const list<LayeredControl> &getControlList() const;
/// 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
virtual const list<Anchor*>& getAnchorList() const;
......@@ -114,6 +115,9 @@ class GenericLayout: public SkinObject, public Box
virtual void addAnchor( Anchor *pAnchor );
private:
/// Refresh a rectangular portion of the window
void GenericLayout::refreshRect( int x, int y, int width, int height );
/// Parent window of the layout
TopWindow *m_pWindow;
/// 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