}
-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 )
{
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.
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();
}
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();
}
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();
}
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();
}
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();
}
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();
const Position *pPos = rCtrl.getPosition();
if( pPos )
{
- refreshRect( pPos->getLeft(), pPos->getTop(), width, height );
+ refreshRect( pPos->getLeft() + xOffSet,
+ pPos->getTop() + yOffSet,
+ width, height );
}
}
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;
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;
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;