diff --git a/kdecoration/breezebutton.cpp b/kdecoration/breezebutton.cpp index a1966026..1e9de64b 100644 --- a/kdecoration/breezebutton.cpp +++ b/kdecoration/breezebutton.cpp @@ -53,7 +53,7 @@ namespace Breeze //__________________________________________________________________ Button::Button(QObject *parent, const QVariantList &args) : DecorationButton(args.at(0).value(), args.at(1).value(), parent) - , m_standalone(true) + , m_flag(FlagStandalone) , m_animation( new QPropertyAnimation( this ) ) {} @@ -83,7 +83,10 @@ namespace Breeze if (!decoration()) return; painter->save(); - painter->translate( 0, m_verticalOffset ); + + // translate from offset + if( m_flag == FlagFirstInList ) painter->translate( m_offset ); + else painter->translate( 0, m_offset.y() ); if (type() == KDecoration2::DecorationButtonType::Menu) { @@ -112,7 +115,9 @@ namespace Breeze all further rendering is preformed inside QRect( 0, 0, 18, 18 ) */ painter->translate( geometry().topLeft() ); - painter->scale( geometry().width()/20, geometry().width()/20 ); + + const int width( geometry().width() - m_offset.x() ); + painter->scale( width/20, width/20 ); painter->translate( 1, 1 ); // render background diff --git a/kdecoration/breezebutton.h b/kdecoration/breezebutton.h index 95d0c84b..c43959a0 100644 --- a/kdecoration/breezebutton.h +++ b/kdecoration/breezebutton.h @@ -52,12 +52,33 @@ namespace Breeze //* create static Button *create(KDecoration2::DecorationButtonType type, KDecoration2::Decoration *decoration, QObject *parent); + //* flag + enum Flag + { + FlagNone, + FlagStandalone, + FlagFirstInList, + FlagLastInList + }; + + //* flag + void setFlag( Flag value ) + { m_flag = value; } + //* standalone buttons - bool isStandAlone() const { return m_standalone; } + bool isStandAlone() const { return m_flag == FlagStandalone; } + + //* offset + void setOffset( const QPointF& value ) + { m_offset = value; } + + //* horizontal offset, for rendering + void setHorizontalOffset( qreal value ) + { m_offset.setX( value ); } //* vertical offset, for rendering - void setVerticalOffset( int value ) - { m_verticalOffset = value; } + void setVerticalOffset( qreal value ) + { m_offset.setY( value ); } //*@name active state change animation //@{ @@ -92,13 +113,13 @@ namespace Breeze QColor backgroundColor( void ) const; //@} - bool m_standalone = false; + Flag m_flag = FlagNone; //* active state change animation QPropertyAnimation *m_animation; //* vertical offset (for rendering) - int m_verticalOffset = 0; + QPointF m_offset; //* active state change opacity qreal m_opacity = 0; diff --git a/kdecoration/breezedecoration.cpp b/kdecoration/breezedecoration.cpp index 549e1115..5f7bff12 100644 --- a/kdecoration/breezedecoration.cpp +++ b/kdecoration/breezedecoration.cpp @@ -330,7 +330,29 @@ namespace Breeze foreach( const QPointer& button, m_leftButtons->buttons() + m_rightButtons->buttons() ) { button.data()->setGeometry( QRectF( QPoint( 0, 0 ), QSizeF( bWidth, bHeight ) ) ); - static_cast( button.data() )->setVerticalOffset( verticalOffset ); + static_cast( button.data() )->setOffset( QPointF( 0, verticalOffset ) ); + } + + if( isMaximized() ) + { + // add offsets on the side buttons, to preserve padding, but satisfy Fitts law + const int hOffset = s->smallSpacing()*Metrics::TitleBar_SideMargin; + if( !m_leftButtons->buttons().isEmpty() ) + { + auto button = static_cast( m_leftButtons->buttons().front().data() ); + button->setGeometry( QRectF( QPoint( 0, 0 ), QSizeF( bWidth + hOffset, bHeight ) ) ); + button->setFlag( Button::FlagFirstInList ); + button->setHorizontalOffset( hOffset ); + } + + if( !m_rightButtons->buttons().isEmpty() ) + { + auto button = static_cast( m_rightButtons->buttons().back().data() ); + button->setGeometry( QRectF( QPoint( 0, 0 ), QSizeF( bWidth + hOffset, bHeight ) ) ); + button->setFlag( Button::FlagLastInList ); + button->setHorizontalOffset( hOffset ); + } + } // adjust buttons position