Commit 744c1b58 authored by Olivier Teulière's avatar Olivier Teulière

* skins/utils/bezier.cpp: Fixed a bug in the computation of the size of a

   Bezier curve
 * skins2/*: Fixed "lazy redrawing" for the slider control
parent dab1d31a
......@@ -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 )
{
......
......@@ -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.
......
......@@ -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();
}
......
......@@ -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 );
}
}
......
......@@ -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;
......
......@@ -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;
......
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