improve getInnetPoint() and getOuterPoint() so that

- they use a nice switch
- the real anchor widget position is taken into account (no more magic constant, and the position is correct even in RtL configurations)

svn path=/trunk/KDE/kdegraphics/okular/; revision=748015
This commit is contained in:
Pino Toscano 2007-12-13 11:32:09 +00:00
parent f7b8b3f6f4
commit 5a06b9d911

View file

@ -356,7 +356,6 @@ ToolBarButton::ToolBarButton( QWidget * parent, const AnnotationToolItem &item )
/* PageViewToolBar */
static const int toolBarGridSize = 40;
static const int toolBarRBMargin = 2;
class ToolBarPrivate
{
@ -727,25 +726,45 @@ void ToolBarPrivate::reposition()
QPoint ToolBarPrivate::getInnerPoint() const
{
// returns the final position of the widget
if ( anchorSide == PageViewToolBar::Left )
return QPoint( 0, ( anchorWidget->height() - q->height() ) / 2 );
if ( anchorSide == PageViewToolBar::Top )
return QPoint( ( anchorWidget->width() - q->width() ) / 2, 0 );
if ( anchorSide == PageViewToolBar::Right )
return QPoint( anchorWidget->width() - q->width() + toolBarRBMargin, ( anchorWidget->height() - q->height() ) / 2 );
return QPoint( ( anchorWidget->width() - q->width()) / 2, anchorWidget->height() - q->height() + toolBarRBMargin );
QPoint newPos;
switch ( anchorSide )
{
case PageViewToolBar::Left:
newPos = QPoint( 0, ( anchorWidget->height() - q->height() ) / 2 );
break;
case PageViewToolBar::Top:
newPos = QPoint( ( anchorWidget->width() - q->width() ) / 2, 0 );
break;
case PageViewToolBar::Right:
newPos = QPoint( anchorWidget->width() - q->width(), ( anchorWidget->height() - q->height() ) / 2 );
break;
case PageViewToolBar::Bottom:
newPos = QPoint( ( anchorWidget->width() - q->width()) / 2, anchorWidget->height() - q->height() );
break;
}
return newPos + anchorWidget->pos();
}
QPoint ToolBarPrivate::getOuterPoint() const
{
// returns the point from which the transition starts
if ( anchorSide == PageViewToolBar::Left )
return QPoint( -q->width(), ( anchorWidget->height() - q->height() ) / 2 );
if ( anchorSide == PageViewToolBar::Top )
return QPoint( ( anchorWidget->width() - q->width() ) / 2, -q->height() );
if ( anchorSide == PageViewToolBar::Right )
return QPoint( anchorWidget->width() + toolBarRBMargin, ( anchorWidget->height() - q->height() ) / 2 );
return QPoint( ( anchorWidget->width() - q->width() ) / 2, anchorWidget->height() + toolBarRBMargin );
QPoint newPos;
switch ( anchorSide )
{
case PageViewToolBar::Left:
newPos = QPoint( -q->width(), ( anchorWidget->height() - q->height() ) / 2 );
break;
case PageViewToolBar::Top:
newPos = QPoint( ( anchorWidget->width() - q->width() ) / 2, -q->height() );
break;
case PageViewToolBar::Right:
newPos = QPoint( anchorWidget->width(), ( anchorWidget->height() - q->height() ) / 2 );
break;
case PageViewToolBar::Bottom:
newPos = QPoint( ( anchorWidget->width() - q->width() ) / 2, anchorWidget->height() );
break;
}
return newPos + anchorWidget->pos();
}
void PageViewToolBar::slotAnimate()