From 7e6619d02359e3ace1632f6494d60a01655f5bdd Mon Sep 17 00:00:00 2001 From: Salva Ardid Date: Thu, 28 Nov 2019 10:22:17 -0500 Subject: [PATCH] V0.7.0 --- CMakeLists.txt | 2 +- ChangeLog | 13 + breezebutton.cpp | 3910 +++++++++++++++++++--------- breezebutton.h | 17 +- breezesettingsdata.kcfg | 25 +- config/ui/breezeconfigurationui.ui | 37 +- 6 files changed, 2700 insertions(+), 1304 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a80c7eb..6e4c5ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ project(sierrabreezeenhanced) -set(PROJECT_VERSION "0.6.3") +set(PROJECT_VERSION "0.7.0") set(PROJECT_VERSION_MAJOR 0) cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) diff --git a/ChangeLog b/ChangeLog index 49908b9..07e6602 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ + +V0.7.0 +--------- + +* Rearranged button styles +* Added macOS styles (Sierra and Dark Aurorae symbols) +* macOS Dark Aurorae is new default +* Adapted traffic colors (more similar to macOS Catalina) +* Thinner ring borders (more similar to macOS Catalina) +* Added Dark Aurorae symbol styles (color and monochrome) +* Checked buttons now occupy all available space (including that of animation) +* Many minor fixes and improved consistency + V0.6.3 --------- diff --git a/breezebutton.cpp b/breezebutton.cpp index 6578a6e..fbdd069 100644 --- a/breezebutton.cpp +++ b/breezebutton.cpp @@ -146,20 +146,26 @@ namespace Breeze auto d = qobject_cast( decoration() ); - if ( d && d->internalSettings()->buttonStyle() == 3 ) - drawIconPlasmaStyle( painter ); - else if ( d && d->internalSettings()->buttonStyle() == 4 ) - drawIconGnomeStyle( painter ); - else if ( d && d->internalSettings()->buttonStyle() == 5 ) - drawIconMacStyle( painter ); - else if ( d && ( d->internalSettings()->buttonStyle() == 6 || d->internalSettings()->buttonStyle() == 7 || d->internalSettings()->buttonStyle() == 8 ) ) - drawIconDarkAuroraeStyle( painter ); - else if ( d && d->internalSettings()->buttonStyle() == 9 ) - drawIconSymbolStyle( painter ); + if ( d && d->internalSettings()->buttonStyle() == 0 ) + drawIconPlasma( painter ); + else if ( d && d->internalSettings()->buttonStyle() == 1 ) + drawIconGnome( painter ); + else if ( d && d->internalSettings()->buttonStyle() == 2 ) + drawIconMacSierra( painter ); + else if ( d && d->internalSettings()->buttonStyle() == 3 ) + drawIconMacDarkAurorae( painter ); + else if ( d && ( d->internalSettings()->buttonStyle() == 4 || d->internalSettings()->buttonStyle() == 5 || d->internalSettings()->buttonStyle() == 6 ) ) + drawIconSBEsierra( painter ); + else if ( d && ( d->internalSettings()->buttonStyle() == 7 || d->internalSettings()->buttonStyle() == 8 || d->internalSettings()->buttonStyle() == 9 ) ) + drawIconSBEdarkAurorae( painter ); else if ( d && d->internalSettings()->buttonStyle() == 10 ) - drawIconSymbolStyleMono( painter ); - else - drawIconSBEstyle( painter ); + drawIconSierraColorSymbols( painter ); + else if ( d && d->internalSettings()->buttonStyle() == 11 ) + drawIconDarkAuroraeColorSymbols( painter ); + else if ( d && d->internalSettings()->buttonStyle() == 12 ) + drawIconSierraMonochromeSymbols( painter ); + else if ( d && d->internalSettings()->buttonStyle() == 13 ) + drawIconDarkAuroraeMonochromeSymbols( painter ); } @@ -168,7 +174,7 @@ namespace Breeze } //__________________________________________________________________ - void Button::drawIconSBEstyle( QPainter *painter ) const + void Button::drawIconPlasma( QPainter *painter ) const { painter->setRenderHints( QPainter::Antialiasing ); @@ -184,432 +190,362 @@ namespace Breeze painter->scale( width/20, width/20 ); painter->translate( 1, 1 ); - auto d = qobject_cast( decoration() ); - bool inactiveWindow( d && !d->client().data()->isActive() ); - bool useActiveButtonStyle( d && d->internalSettings()->buttonStyle() == 1 ); - bool useInactiveButtonStyle( d && d->internalSettings()->buttonStyle() == 2 ); - bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); + // render background + const QColor backgroundColor( this->backgroundColor() ); + if( backgroundColor.isValid() ) + { + painter->setPen( Qt::NoPen ); + painter->setBrush( backgroundColor ); + painter->drawEllipse( QRectF( 0, 0, 18, 18 ) ); + } - const QColor darkSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(81, 102, 107) : QColor(34, 45, 50) ); - const QColor lightSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(192, 193, 194) : QColor(250, 251, 252) ); + // render mark + const QColor foregroundColor( this->foregroundColor() ); + if( foregroundColor.isValid() ) + { - const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); - const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); + // setup painter + QPen pen( foregroundColor ); + pen.setCapStyle( Qt::RoundCap ); + pen.setJoinStyle( Qt::MiterJoin ); + pen.setWidthF( 1.1*qMax((qreal)1.0, 20/width ) ); - // symbols color + painter->setPen( pen ); + painter->setBrush( Qt::NoBrush ); - QColor symbolColor( this->autoColor( inactiveWindow, useActiveButtonStyle, useInactiveButtonStyle, isMatchTitleBarColor, darkSymbolColor, lightSymbolColor ) ); + switch( type() ) + { - // symbols pen + case DecorationButtonType::Close: + { + painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); + painter->drawLine( 13, 5, 5, 13 ); + break; + } - QPen symbol_pen( symbolColor ); - symbol_pen.setJoinStyle( Qt::MiterJoin ); - symbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); + case DecorationButtonType::Maximize: + { + if( isChecked() ) + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); - switch( type() ) - { + painter->drawPolygon( QVector{ + QPointF( 4, 9 ), + QPointF( 9, 4 ), + QPointF( 14, 9 ), + QPointF( 9, 14 )} ); - case DecorationButtonType::Close: - { - const QColor button_color = QColor(252, 87, 83); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + } else { + painter->drawPolyline( QVector{ + QPointF( 4, 11 ), + QPointF( 9, 6 ), + QPointF( 14, 11 )}); + } + break; + } - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) + case DecorationButtonType::Minimize: { - // ring - painter->setBrush( Qt::NoBrush ); - painter->setPen( button_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 7 ), + QPointF( 9, 12 ), + QPointF( 14, 7 ) }); + break; } - else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + + case DecorationButtonType::OnAllDesktops: { - // nothing - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); + painter->setPen( Qt::NoPen ); + painter->setBrush( foregroundColor ); + + if( isChecked()) + { + + // outer ring + painter->drawEllipse( QRectF( 3, 3, 12, 12 ) ); + + // center dot + QColor backgroundColor( this->backgroundColor() ); + auto d = qobject_cast( decoration() ); + if( !backgroundColor.isValid() && d ) backgroundColor = d->titleBarColor(); + + if( backgroundColor.isValid() ) + { + painter->setBrush( backgroundColor ); + painter->drawEllipse( QRectF( 8, 8, 2, 2 ) ); + } + + } else { + + painter->drawPolygon( QVector { + QPointF( 6.5, 8.5 ), + QPointF( 12, 3 ), + QPointF( 15, 6 ), + QPointF( 9.5, 11.5 )} ); + + painter->setPen( pen ); + painter->drawLine( QPointF( 5.5, 7.5 ), QPointF( 10.5, 12.5 ) ); + painter->drawLine( QPointF( 12, 6 ), QPointF( 4.5, 13.5 ) ); + } + break; } - else + + case DecorationButtonType::Shade: { - // filled - painter->setBrush( button_color ); - painter->setPen( button_pen ); + + if (isChecked()) + { + + painter->drawLine( QPointF( 4, 5.5 ), QPointF( 14, 5.5 ) ); // painter->drawLine( 4, 5, 14, 5 ); + painter->drawPolyline( QVector { + QPointF( 4, 8 ), + QPointF( 9, 13 ), + QPointF( 14, 8 )} ); + + } else { + + painter->drawLine( QPointF( 4, 5.5 ), QPointF( 14, 5.5 ) ); // painter->drawLine( 4, 5, 14, 5 ); + painter->drawPolyline( QVector { + QPointF( 4, 13 ), + QPointF( 9, 8 ), + QPointF( 14, 13 ) }); + } + + break; + } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + + case DecorationButtonType::KeepBelow: { - painter->setPen( symbol_pen ); - // it's a cross - painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 12 ) ); - painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 6 ) ); - } - break; - } - case DecorationButtonType::Maximize: - { - const QColor button_color = QColor(51, 199, 72); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->drawPolyline( QVector { + QPointF( 4, 5 ), + QPointF( 9, 10 ), + QPointF( 14, 5 ) }); + + painter->drawPolyline( QVector { + QPointF( 4, 9 ), + QPointF( 9, 14 ), + QPointF( 14, 9 ) }); + break; - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) - { - // ring - painter->setBrush( Qt::NoBrush ); - painter->setPen( button_pen ); } - else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + + case DecorationButtonType::KeepAbove: { - // nothing - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); + painter->drawPolyline( QVector { + QPointF( 4, 9 ), + QPointF( 9, 4 ), + QPointF( 14, 9 ) }); + + painter->drawPolyline( QVector { + QPointF( 4, 13 ), + QPointF( 9, 8 ), + QPointF( 14, 13 ) }); + break; } - else + + + case DecorationButtonType::ApplicationMenu: { - // filled - painter->setBrush( button_color ); - painter->setPen( button_pen ); + painter->drawRect( QRectF( 3.5, 4.5, 11, 1 ) ); // painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); + painter->drawRect( QRectF( 3.5, 8.5, 11, 1 ) ); // painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); + painter->drawRect( QRectF( 3.5, 12.5, 11, 1 ) ); // painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); + break; } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - painter->setPen( Qt::NoPen ); - - // two triangles - QPainterPath path1, path2; - if( isChecked() ) - { - path1.moveTo(8.5, 9.5); - path1.lineTo(2.5, 9.5); - path1.lineTo(8.5, 15.5); - path2.moveTo(9.5, 8.5); - path2.lineTo(15.5, 8.5); - path2.lineTo(9.5, 2.5); - } - else - { - path1.moveTo(5, 13); - path1.lineTo(11, 13); - path1.lineTo(5, 7); + case DecorationButtonType::ContextHelp: + { + QPainterPath path; + path.moveTo( 5, 6 ); + path.arcTo( QRectF( 5, 3.5, 8, 5 ), 180, -180 ); + path.cubicTo( QPointF(12.5, 9.5), QPointF( 9, 7.5 ), QPointF( 9, 11.5 ) ); + painter->drawPath( path ); - path2.moveTo(13, 5); - path2.lineTo(7, 5); - path2.lineTo(13, 11); - } + painter->drawRect( QRectF( 9, 15, 0.5, 0.5 ) ); // painter->drawPoint( 9, 15 ); - painter->fillPath(path1, QBrush(symbolColor)); - painter->fillPath(path2, QBrush(symbolColor)); + break; } - break; + + default: break; } - case DecorationButtonType::Minimize: - { - const QColor button_color = QColor(253, 188, 64); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + } - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) - { - // ring - painter->setBrush( Qt::NoBrush ); - painter->setPen( button_pen ); - } - else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - // nothing - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); - } - else - { - // filled - painter->setBrush( button_color ); - painter->setPen( button_pen ); - } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); - } - break; - } + } - case DecorationButtonType::OnAllDesktops: + //__________________________________________________________________ + void Button::drawIconGnome( QPainter *painter ) const + { + + painter->setRenderHints( QPainter::Antialiasing ); + + /* + scale painter so that its window matches QRect( -1, -1, 20, 20 ) + this makes all further rendering and scaling simpler + all further rendering is preformed inside QRect( 0, 0, 18, 18 ) + */ + painter->translate( geometry().topLeft() ); + + const qreal width( m_iconSize.width() ); + painter->scale( width/20, width/20 ); + painter->translate( 1, 1 ); + + // render background + const QColor backgroundColor( this->backgroundColor() ); + if( backgroundColor.isValid() ) + { + painter->setPen( Qt::NoPen ); + painter->setBrush( backgroundColor ); + painter->drawEllipse( QRectF( 0, 0, 18, 18 ) ); + } + + // render mark + const QColor foregroundColor( this->foregroundColor() ); + if( foregroundColor.isValid() ) + { + + // setup painter + QPen pen( foregroundColor ); + pen.setJoinStyle( Qt::MiterJoin ); + pen.setWidthF( 1.2*qMax((qreal)1.0, 20/width ) ); + + painter->setPen( pen ); + painter->setBrush( Qt::NoBrush ); + + switch( type() ) { - const QColor button_color = QColor(125, 209, 200); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) - { - // ring - painter->setBrush( Qt::NoBrush ); - painter->setPen( button_pen ); - } - else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - // nothing - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); - } - else + case DecorationButtonType::Close: { - // filled - painter->setBrush( button_color ); - painter->setPen( button_pen ); + painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); + painter->drawLine( 13, 5, 5, 13 ); + break; } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + + case DecorationButtonType::Maximize: { - painter->setPen( Qt::NoPen ); - painter->setBrush(QBrush(symbolColor)); - painter->drawEllipse( QRectF( 6, 6, 6, 6 ) ); + if( isChecked() ) + painter->drawRect( 7, 7, 4, 4 ); + else + painter->drawRect( 5, 5, 8, 8 ); + break; } - break; - } - - case DecorationButtonType::Shade: - { - const QColor button_color = QColor(204, 176, 213); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + case DecorationButtonType::Minimize: { - // ring - painter->setBrush( Qt::NoBrush ); - painter->setPen( button_pen ); + painter->drawLine( QPointF( 5, 12 ), QPointF( 12, 12 ) ); + break; } - else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + + case DecorationButtonType::OnAllDesktops: { - // nothing - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); + painter->setPen( Qt::NoPen ); + painter->setBrush( foregroundColor ); + + QPointF c(static_cast(9), static_cast(9)); + if( isChecked()) { + painter->drawEllipse( c, 9.0, 9.0 ); + painter->setBrush( backgroundColor ); + painter->drawEllipse( c, 2.0, 2.0 ); + } + else + painter->drawEllipse( c, 4.0, 4.0 ); + break; } - else + + case DecorationButtonType::Shade: { - // filled - painter->setBrush( button_color ); - painter->setPen( button_pen ); + + if (isChecked()) + { + + painter->drawLine( 5, 6, 13, 6 ); + QPainterPath path; + path.moveTo(9, 13); + path.lineTo(4, 9); + path.lineTo(14, 9); + painter->fillPath(path, QBrush(foregroundColor)); + + + } else { + + painter->drawLine( 5, 6, 13, 6 ); + QPainterPath path; + path.moveTo(9, 9); + path.lineTo(4, 13); + path.lineTo(14, 13); + painter->fillPath(path, QBrush(foregroundColor)); + + } + + break; + } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if (isChecked()) + + case DecorationButtonType::KeepBelow: { - painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 12 ) ); + painter->setPen( Qt::NoPen ); + painter->setBrush( foregroundColor ); + QPainterPath path; - path.moveTo(9, 11); - path.lineTo(5, 6); - path.lineTo(13, 6); - painter->fillPath(path, QBrush(symbolColor)); + path.moveTo(9, 14); + path.lineTo(4, 6); + path.lineTo(14, 6); + painter->fillPath(path, QBrush(foregroundColor)); + + break; } - else if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) { - painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 6 ) ); + + case DecorationButtonType::KeepAbove: + { + painter->setPen( Qt::NoPen ); + painter->setBrush( foregroundColor ); + QPainterPath path; - path.moveTo(9, 7); - path.lineTo(5, 12); - path.lineTo(13, 12); - painter->fillPath(path, QBrush(symbolColor)); - } - break; + path.moveTo(9, 5); + path.lineTo(4, 13); + path.lineTo(14, 13); + painter->fillPath(path, QBrush(foregroundColor)); - } + break; + } - case DecorationButtonType::KeepBelow: - { - const QColor button_color = QColor(255, 137, 241); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) - { - // ring - painter->setBrush( Qt::NoBrush ); - painter->setPen( button_pen ); - } - else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + case DecorationButtonType::ApplicationMenu: { - // nothing - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); + painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); + painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); + painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); + break; } - else + + case DecorationButtonType::ContextHelp: { - // filled - painter->setBrush( button_color ); - painter->setPen( button_pen ); + QPainterPath path; + path.moveTo( 5, 6 ); + path.arcTo( QRectF( 5, 3.5, 8, 5 ), 180, -180 ); + path.cubicTo( QPointF(12.5, 9.5), QPointF( 9, 7.5 ), QPointF( 9, 11.5 ) ); + painter->drawPath( path ); + + painter->drawPoint( 9, 15 ); + + break; } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - painter->setPen( Qt::NoPen ); - - QPainterPath path; - path.moveTo(9, 12); - path.lineTo(5, 6); - path.lineTo(13, 6); - painter->fillPath(path, QBrush(symbolColor)); - } - break; - - } - - case DecorationButtonType::KeepAbove: - { - const QColor button_color = QColor(135, 206, 249); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) - { - // ring - painter->setBrush( Qt::NoBrush ); - painter->setPen( button_pen ); - } - else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - // nothing - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); - } - else - { - // filled - painter->setBrush( button_color ); - painter->setPen( button_pen ); - } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - painter->setPen( Qt::NoPen ); - - QPainterPath path; - path.moveTo(9, 6); - path.lineTo(5, 12); - path.lineTo(13, 12); - painter->fillPath(path, QBrush(symbolColor)); - } - break; - } - - case DecorationButtonType::ApplicationMenu: - { - QColor menuSymbolColor; - uint r = qRed(titleBarColor.rgb()); - uint g = qGreen(titleBarColor.rgb()); - uint b = qBlue(titleBarColor.rgb()); - // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color - // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; - // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) - qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); - if ( colorConditional > 186 || g > 186 ) - menuSymbolColor = darkSymbolColor; - else - menuSymbolColor = lightSymbolColor; - - QPen menuSymbol_pen( menuSymbolColor ); - menuSymbol_pen.setJoinStyle( Qt::MiterJoin ); - menuSymbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); - - painter->setPen( menuSymbol_pen ); - - painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); - painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); - painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); - - break; - } - - case DecorationButtonType::ContextHelp: - { - const QColor button_color = QColor(102, 156, 246); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) - { - // ring - painter->setBrush( Qt::NoBrush ); - painter->setPen( button_pen ); - } - else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - // nothing - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); - } - else - { - // filled - painter->setBrush( button_color ); - painter->setPen( button_pen ); - } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) - { - painter->setPen( symbol_pen ); - QPainterPath path; - path.moveTo( 6, 6 ); - path.arcTo( QRectF( 5.5, 4, 7.5, 4.5 ), 180, -180 ); - path.cubicTo( QPointF(11, 9), QPointF( 9, 6 ), QPointF( 9, 10 ) ); - painter->drawPath( path ); - painter->drawPoint( 9, 13 ); - } - break; + default: break; } - default: break; } + } //__________________________________________________________________ - void Button::drawIconMacStyle( QPainter *painter ) const + void Button::drawIconMacSierra( QPainter *painter ) const { painter->setRenderHints( QPainter::Antialiasing ); @@ -651,8 +587,10 @@ namespace Breeze case DecorationButtonType::Close: { QColor button_color; - if ( !inactiveWindow ) - button_color = QColor(252, 87, 83); + if ( !inactiveWindow && qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(238, 102, 90); + else if( !inactiveWindow ) + button_color = QColor(255, 94, 88); else if ( qGray(titleBarColor.rgb()) < 128 ) button_color = QColor(100, 100, 100); else @@ -681,8 +619,10 @@ namespace Breeze case DecorationButtonType::Maximize: { QColor button_color; - if ( !inactiveWindow ) - button_color = QColor(51, 199, 72); + if ( !inactiveWindow && qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 196, 86); + else if( !inactiveWindow ) + button_color = QColor(40, 200, 64); else if ( qGray(titleBarColor.rgb()) < 128 ) button_color = QColor(100, 100, 100); else @@ -734,8 +674,10 @@ namespace Breeze case DecorationButtonType::Minimize: { QColor button_color; - if ( !inactiveWindow ) - button_color = QColor(253, 188, 64); + if ( !inactiveWindow && qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(223, 192, 76); + else if( !inactiveWindow ) + button_color = QColor(255, 188, 48); else if ( qGray(titleBarColor.rgb()) < 128 ) button_color = QColor(100, 100, 100); else @@ -774,11 +716,18 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); + if ( isHovered() || isChecked() ) { painter->setPen( Qt::NoPen ); @@ -803,12 +752,19 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); - if (isChecked()) + + if ( isChecked() ) { painter->setPen( symbol_pen ); painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 12 ) ); @@ -849,11 +805,18 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); + if ( isHovered() || isChecked() ) { painter->setPen( Qt::NoPen ); @@ -883,11 +846,18 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); + if ( isHovered() || isChecked() ) { painter->setPen( Qt::NoPen ); @@ -945,11 +915,18 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); + if ( isHovered() || isChecked() ) { painter->setPen( symbol_pen ); @@ -967,9 +944,8 @@ namespace Breeze } } - //__________________________________________________________________ - void Button::drawIconPlasmaStyle( QPainter *painter ) const + void Button::drawIconMacDarkAurorae( QPainter *painter ) const { painter->setRenderHints( QPainter::Antialiasing ); @@ -985,404 +961,425 @@ namespace Breeze painter->scale( width/20, width/20 ); painter->translate( 1, 1 ); - // render background - const QColor backgroundColor( this->backgroundColor() ); - if( backgroundColor.isValid() ) - { - painter->setPen( Qt::NoPen ); - painter->setBrush( backgroundColor ); - painter->drawEllipse( QRectF( 0, 0, 18, 18 ) ); - } + auto d = qobject_cast( decoration() ); + bool inactiveWindow( d && !d->client().data()->isActive() ); + bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); - // render mark - const QColor foregroundColor( this->foregroundColor() ); - if( foregroundColor.isValid() ) - { + const QColor darkSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(81, 102, 107) : QColor(34, 45, 50) ); + const QColor lightSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(192, 193, 194) : QColor(250, 251, 252) ); - // setup painter - QPen pen( foregroundColor ); - pen.setCapStyle( Qt::RoundCap ); - pen.setJoinStyle( Qt::MiterJoin ); - pen.setWidthF( 1.1*qMax((qreal)1.0, 20/width ) ); + const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); + const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); - painter->setPen( pen ); - painter->setBrush( Qt::NoBrush ); + // symbols color - switch( type() ) - { + QColor symbolColor( this->autoColor( inactiveWindow, true, false, isMatchTitleBarColor, darkSymbolColor, lightSymbolColor ) ); - case DecorationButtonType::Close: - { - painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); - painter->drawLine( 13, 5, 5, 13 ); - break; - } + // symbols pen - case DecorationButtonType::Maximize: - { - if( isChecked() ) - { - pen.setJoinStyle( Qt::RoundJoin ); - painter->setPen( pen ); + QPen symbol_pen( symbolColor ); + symbol_pen.setJoinStyle( Qt::MiterJoin ); + symbol_pen.setWidthF( 1.2*qMax((qreal)1.0, 20/width ) ); - painter->drawPolygon( QVector{ - QPointF( 4, 9 ), - QPointF( 9, 4 ), - QPointF( 14, 9 ), - QPointF( 9, 14 )} ); + switch( type() ) + { - } else { - painter->drawPolyline( QVector{ - QPointF( 4, 11 ), - QPointF( 9, 6 ), - QPointF( 14, 11 )}); - } - break; - } + case DecorationButtonType::Close: + { + QColor button_color; + if ( !inactiveWindow && qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(238, 102, 90); + else if( !inactiveWindow ) + button_color = QColor(255, 94, 88); + else if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 100, 100); + else + button_color = QColor(200, 200, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->setBrush( button_color ); + painter->setPen( button_pen ); - case DecorationButtonType::Minimize: - { - painter->drawPolyline( QVector{ - QPointF( 4, 7 ), - QPointF( 9, 12 ), - QPointF( 14, 7 ) }); - break; + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + if ( isHovered() ) + { + painter->setPen( symbol_pen ); + // it's a cross + painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); + painter->drawLine( QPointF( 5, 13 ), QPointF( 13, 5 ) ); } + break; + } - case DecorationButtonType::OnAllDesktops: + case DecorationButtonType::Maximize: + { + QColor button_color; + if ( !inactiveWindow && qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 196, 86); + else if( !inactiveWindow ) + button_color = QColor(40, 200, 64); + else if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 100, 100); + else + button_color = QColor(200, 200, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->setBrush( button_color ); + painter->setPen( button_pen ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + if ( isHovered() ) { - painter->setPen( Qt::NoPen ); - painter->setBrush( foregroundColor ); - if( isChecked()) - { + painter->setPen( symbol_pen ); - // outer ring - painter->drawEllipse( QRectF( 3, 3, 12, 12 ) ); + // solid vs. open rectangle + if( isChecked() ) + { + painter->drawLine( QPointF( 4.5, 6 ), QPointF( 13.5, 6 ) ); + painter->drawLine( QPointF( 13.5, 6 ), QPointF( 13.5, 12 ) ); + painter->drawLine( QPointF( 4.5, 6 ), QPointF( 4.5, 12 ) ); + painter->drawLine( QPointF( 4.5, 12 ), QPointF( 13.5, 12 ) ); + } + else + { + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) ); + painter->drawLine( QPointF( 13.5, 4.5 ), QPointF( 13.5, 9 ) ); + painter->drawLine( QPointF( 4.5, 9 ), QPointF( 4.5, 13.5 ) ); + painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) ); + } - // center dot - QColor backgroundColor( this->backgroundColor() ); - auto d = qobject_cast( decoration() ); - if( !backgroundColor.isValid() && d ) backgroundColor = d->titleBarColor(); + } + break; + } - if( backgroundColor.isValid() ) - { - painter->setBrush( backgroundColor ); - painter->drawEllipse( QRectF( 8, 8, 2, 2 ) ); - } + case DecorationButtonType::Minimize: + { + QColor button_color; + if ( !inactiveWindow && qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(223, 192, 76); + else if( !inactiveWindow ) + button_color = QColor(255, 188, 48); + else if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 100, 100); + else + button_color = QColor(200, 200, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->setBrush( button_color ); + painter->setPen( button_pen ); - } else { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); - painter->drawPolygon( QVector { - QPointF( 6.5, 8.5 ), - QPointF( 12, 3 ), - QPointF( 15, 6 ), - QPointF( 9.5, 11.5 )} ); + if ( isHovered() ) + { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); + } + break; + } - painter->setPen( pen ); - painter->drawLine( QPointF( 5.5, 7.5 ), QPointF( 10.5, 12.5 ) ); - painter->drawLine( QPointF( 12, 6 ), QPointF( 4.5, 13.5 ) ); - } - break; + case DecorationButtonType::OnAllDesktops: + { + QColor button_color; + if ( !inactiveWindow ) + button_color = QColor(125, 209, 200); + else if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 100, 100); + else + button_color = QColor(200, 200, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->setBrush( button_color ); + painter->setPen( button_pen ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); } + painter->setBrush( Qt::NoBrush ); - case DecorationButtonType::Shade: + if ( isHovered() && !isChecked() ) { + painter->setPen( symbol_pen ); - if (isChecked()) - { + painter->drawLine( QPointF( 7, 5 ), QPointF( 15, 5 ) ); + painter->drawLine( QPointF( 15, 5 ), QPointF( 15, 13 ) ); + painter->drawLine( QPointF( 7, 5 ), QPointF( 7, 13 ) ); + painter->drawLine( QPointF( 7, 13 ), QPointF( 15, 13 ) ); - painter->drawLine( QPointF( 4, 5.5 ), QPointF( 14, 5.5 ) ); // painter->drawLine( 4, 5, 14, 5 ); - painter->drawPolyline( QVector { - QPointF( 4, 8 ), - QPointF( 9, 13 ), - QPointF( 14, 8 )} ); + painter->drawLine( QPointF( 3, 5 ), QPointF( 3, 13 ) ); + painter->drawLine( QPointF( 3, 5 ), QPointF( 4.5, 5 ) ); + painter->drawLine( QPointF( 3, 13 ), QPointF( 4.5, 13 ) ); + } + else if ( isChecked() ) + { + painter->setPen( symbol_pen ); - } else { + painter->drawLine( QPointF( 5, 5 ), QPointF( 11, 5 ) ); + painter->drawLine( QPointF( 11, 5 ), QPointF( 11, 11 ) ); + painter->drawLine( QPointF( 5, 5 ), QPointF( 5, 11 ) ); + painter->drawLine( QPointF( 5, 11 ), QPointF( 11, 11 ) ); - painter->drawLine( QPointF( 4, 5.5 ), QPointF( 14, 5.5 ) ); // painter->drawLine( 4, 5, 14, 5 ); - painter->drawPolyline( QVector { - QPointF( 4, 13 ), - QPointF( 9, 8 ), - QPointF( 14, 13 ) }); - } + painter->drawLine( QPointF( 7, 7 ), QPointF( 13, 7 ) ); + painter->drawLine( QPointF( 13, 7 ), QPointF( 13, 13 ) ); + painter->drawLine( QPointF( 7, 7 ), QPointF( 7, 13 ) ); + painter->drawLine( QPointF( 7, 13 ), QPointF( 13, 13 ) ); + } + break; + } - break; + case DecorationButtonType::Shade: + { + QColor button_color; + if ( !inactiveWindow ) + button_color = QColor(204, 176, 213); + else if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 100, 100); + else + button_color = QColor(200, 200, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->setBrush( button_color ); + painter->setPen( button_pen ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); } + painter->setBrush( Qt::NoBrush ); - case DecorationButtonType::KeepBelow: + if ( isChecked() ) { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 4, 12 ), QPointF( 14, 12 ) ); - painter->drawPolyline( QVector { - QPointF( 4, 5 ), - QPointF( 9, 10 ), - QPointF( 14, 5 ) }); - - painter->drawPolyline( QVector { - QPointF( 4, 9 ), - QPointF( 9, 14 ), - QPointF( 14, 9 ) }); - break; - + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 6, 2, 2 ) ); } - - case DecorationButtonType::KeepAbove: + else if ( isHovered() ) { - painter->drawPolyline( QVector { - QPointF( 4, 9 ), - QPointF( 9, 4 ), - QPointF( 14, 9 ) }); + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 4, 6 ), QPointF( 14, 6 ) ); - painter->drawPolyline( QVector { - QPointF( 4, 13 ), - QPointF( 9, 8 ), - QPointF( 14, 13 ) }); - break; + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 10, 2, 2 ) ); } + break; + } - case DecorationButtonType::ApplicationMenu: - { - painter->drawRect( QRectF( 3.5, 4.5, 11, 1 ) ); // painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); - painter->drawRect( QRectF( 3.5, 8.5, 11, 1 ) ); // painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); - painter->drawRect( QRectF( 3.5, 12.5, 11, 1 ) ); // painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); - break; + case DecorationButtonType::KeepBelow: + { + QColor button_color; + if ( !inactiveWindow ) + button_color = QColor(255, 137, 241); + else if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 100, 100); + else + button_color = QColor(200, 200, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->setBrush( button_color ); + painter->setPen( button_pen ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); } + painter->setBrush( Qt::NoBrush ); - case DecorationButtonType::ContextHelp: + if ( isHovered() || isChecked() ) { - QPainterPath path; - path.moveTo( 5, 6 ); - path.arcTo( QRectF( 5, 3.5, 8, 5 ), 180, -180 ); - path.cubicTo( QPointF(12.5, 9.5), QPointF( 9, 7.5 ), QPointF( 9, 11.5 ) ); - painter->drawPath( path ); - - painter->drawRect( QRectF( 9, 15, 0.5, 0.5 ) ); // painter->drawPoint( 9, 15 ); - - break; + painter->setPen( symbol_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 7 ), + QPointF( 9, 12 ), + QPointF( 14, 7 ) }); } + break; - default: break; } - } - - } - - //__________________________________________________________________ - void Button::drawIconGnomeStyle( QPainter *painter ) const - { - - painter->setRenderHints( QPainter::Antialiasing ); - - /* - scale painter so that its window matches QRect( -1, -1, 20, 20 ) - this makes all further rendering and scaling simpler - all further rendering is preformed inside QRect( 0, 0, 18, 18 ) - */ - painter->translate( geometry().topLeft() ); - - const qreal width( m_iconSize.width() ); - painter->scale( width/20, width/20 ); - painter->translate( 1, 1 ); - - // render background - const QColor backgroundColor( this->backgroundColor() ); - if( backgroundColor.isValid() ) - { - painter->setPen( Qt::NoPen ); - painter->setBrush( backgroundColor ); - painter->drawEllipse( QRectF( 0, 0, 18, 18 ) ); - } - - // render mark - const QColor foregroundColor( this->foregroundColor() ); - if( foregroundColor.isValid() ) - { - - // setup painter - QPen pen( foregroundColor ); - pen.setJoinStyle( Qt::MiterJoin ); - pen.setWidthF( 1.2*qMax((qreal)1.0, 20/width ) ); - - painter->setPen( pen ); - painter->setBrush( Qt::NoBrush ); - - switch( type() ) + case DecorationButtonType::KeepAbove: { + QColor button_color; + if ( !inactiveWindow ) + button_color = QColor(135, 206, 249); + else if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 100, 100); + else + button_color = QColor(200, 200, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->setBrush( button_color ); + painter->setPen( button_pen ); - case DecorationButtonType::Close: - { - painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); - painter->drawLine( 13, 5, 5, 13 ); - break; - } - - case DecorationButtonType::Maximize: - { - if( isChecked() ) - painter->drawRect( 7, 7, 4, 4 ); - else - painter->drawRect( 5, 5, 8, 8 ); - break; - } - - case DecorationButtonType::Minimize: - { - painter->drawLine( QPointF( 5, 12 ), QPointF( 12, 12 ) ); - break; + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); } - - case DecorationButtonType::OnAllDesktops: - { - painter->setPen( Qt::NoPen ); - painter->setBrush( foregroundColor ); - - QPointF c(static_cast(9), static_cast(9)); - if( isChecked()) { - painter->drawEllipse( c, 9.0, 9.0 ); - painter->setBrush( backgroundColor ); - painter->drawEllipse( c, 2.0, 2.0 ); - } - else - painter->drawEllipse( c, 4.0, 4.0 ); - break; + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); } + painter->setBrush( Qt::NoBrush ); - case DecorationButtonType::Shade: + if ( isHovered() || isChecked() ) { - - if (isChecked()) - { - - painter->drawLine( 5, 6, 13, 6 ); - QPainterPath path; - path.moveTo(9, 13); - path.lineTo(4, 9); - path.lineTo(14, 9); - painter->fillPath(path, QBrush(foregroundColor)); - - - } else { - - painter->drawLine( 5, 6, 13, 6 ); - QPainterPath path; - path.moveTo(9, 9); - path.lineTo(4, 13); - path.lineTo(14, 13); - painter->fillPath(path, QBrush(foregroundColor)); - - } - - break; - + painter->setPen( symbol_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 11 ), + QPointF( 9, 6 ), + QPointF( 14, 11 )}); } + break; + } - case DecorationButtonType::KeepBelow: - { - - painter->setPen( Qt::NoPen ); - painter->setBrush( foregroundColor ); + case DecorationButtonType::ApplicationMenu: + { + QColor menuSymbolColor; - QPainterPath path; - path.moveTo(9, 14); - path.lineTo(4, 6); - path.lineTo(14, 6); - painter->fillPath(path, QBrush(foregroundColor)); + uint r = qRed(titleBarColor.rgb()); + uint g = qGreen(titleBarColor.rgb()); + uint b = qBlue(titleBarColor.rgb()); + // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color + // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; + // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) + qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); + if ( colorConditional > 186 || g > 186 ) + menuSymbolColor = darkSymbolColor; + else + menuSymbolColor = lightSymbolColor; - break; + QPen menuSymbol_pen( menuSymbolColor ); + menuSymbol_pen.setJoinStyle( Qt::MiterJoin ); + menuSymbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); - } + painter->setPen( menuSymbol_pen ); - case DecorationButtonType::KeepAbove: - { + painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); + painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); + painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); - painter->setPen( Qt::NoPen ); - painter->setBrush( foregroundColor ); + break; + } - QPainterPath path; - path.moveTo(9, 5); - path.lineTo(4, 13); - path.lineTo(14, 13); - painter->fillPath(path, QBrush(foregroundColor)); + case DecorationButtonType::ContextHelp: + { + QColor button_color; + if ( !inactiveWindow ) + button_color = QColor(102, 156, 246); + else if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 100, 100); + else + button_color = QColor(200, 200, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + painter->setBrush( button_color ); + painter->setPen( button_pen ); - break; + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); } - - - case DecorationButtonType::ApplicationMenu: - { - painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); - painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); - painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); - break; + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); } + painter->setBrush( Qt::NoBrush ); - case DecorationButtonType::ContextHelp: + if ( isHovered() || isChecked() ) { - QPainterPath path; - path.moveTo( 5, 6 ); - path.arcTo( QRectF( 5, 3.5, 8, 5 ), 180, -180 ); - path.cubicTo( QPointF(12.5, 9.5), QPointF( 9, 7.5 ), QPointF( 9, 11.5 ) ); - painter->drawPath( path ); - - painter->drawPoint( 9, 15 ); + painter->setPen( symbol_pen ); + int startAngle = 260 * 16; + int spanAngle = 280 * 16; + painter->drawArc( QRectF( 5, 3, 8, 8), startAngle, spanAngle ); - break; + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 14, 2, 2 ) ); } - - default: break; + break; } + default: break; } - } //__________________________________________________________________ - void Button::drawIconSymbolStyleMono( QPainter *painter ) const + void Button::drawIconSBEsierra( QPainter *painter ) const { + painter->setRenderHints( QPainter::Antialiasing ); /* - * scale painter so that its window matches QRect( -1, -1, 20, 20 ) - * this makes all further rendering and scaling simpler - * all further rendering is preformed inside QRect( 0, 0, 18, 18 ) - */ + scale painter so that its window matches QRect( -1, -1, 20, 20 ) + this makes all further rendering and scaling simpler + all further rendering is preformed inside QRect( 0, 0, 18, 18 ) + */ painter->translate( geometry().topLeft() ); const qreal width( m_iconSize.width() ); painter->scale( width/20, width/20 ); painter->translate( 1, 1 ); - const QColor darkSymbolColor = QColor(34, 45, 50); - const QColor lightSymbolColor = QColor(250, 251, 252); - auto d = qobject_cast( decoration() ); - + bool inactiveWindow( d && !d->client().data()->isActive() ); + bool useActiveButtonStyle( d && d->internalSettings()->buttonStyle() == 5 ); + bool useInactiveButtonStyle( d && d->internalSettings()->buttonStyle() == 6 ); bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); + const QColor darkSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(81, 102, 107) : QColor(34, 45, 50) ); + const QColor lightSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(192, 193, 194) : QColor(250, 251, 252) ); + const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); - uint r = qRed(titleBarColor.rgb()); - uint g = qGreen(titleBarColor.rgb()); - uint b = qBlue(titleBarColor.rgb()); - QColor symbolColor; - QColor symbolBgdColor; + // symbols color - // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color - // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; - // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) - qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); - if ( colorConditional > 186 || g > 186 ) { - symbolColor = darkSymbolColor; - symbolBgdColor = lightSymbolColor; - } - else { - symbolColor = lightSymbolColor; - symbolBgdColor = darkSymbolColor; - } + QColor symbolColor( this->autoColor( inactiveWindow, useActiveButtonStyle, useInactiveButtonStyle, isMatchTitleBarColor, darkSymbolColor, lightSymbolColor ) ); // symbols pen @@ -1393,331 +1390,215 @@ namespace Breeze switch( type() ) { - case DecorationButtonType::Close: - { - QColor button_color = symbolColor; - button_color.setAlpha( button_color.alpha()*m_opacity ); - painter->setPen( Qt::NoPen ); - painter->setBrush( button_color ); - - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); + case DecorationButtonType::Close: + { + QColor button_color; + if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(238, 102, 90); + else + button_color = QColor(255, 94, 88); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - button_color.setAlpha( 255 ); - symbolBgdColor.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); - symbol_pen.setColor(mycolor); - painter->setPen( symbol_pen ); - // it's a cross - painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 12 ) ); - painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 6 ) ); + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) + { + // ring + painter->setBrush( Qt::NoBrush ); + painter->setPen( button_pen ); + } + else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + // nothing + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + } + else + { + // filled + painter->setBrush( button_color ); + painter->setPen( button_pen ); + } + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + painter->setPen( symbol_pen ); + // it's a cross + painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 12 ) ); + painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 6 ) ); + } + break; + } - break; - } + case DecorationButtonType::Maximize: + { + QColor button_color; + if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 196, 86); + else + button_color = QColor(40, 200, 64); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - case DecorationButtonType::Maximize: - { - QColor button_color = symbolColor; - button_color.setAlpha( button_color.alpha()*m_opacity ); - painter->setPen( Qt::NoPen ); - painter->setBrush( button_color ); + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) + { + // ring + painter->setBrush( Qt::NoBrush ); + painter->setPen( button_pen ); + } + else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + // nothing + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + } + else + { + // filled + painter->setBrush( button_color ); + painter->setPen( button_pen ); + } + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); + if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + painter->setPen( Qt::NoPen ); - button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + // two triangles + QPainterPath path1, path2; + if( isChecked() ) + { + path1.moveTo(8.5, 9.5); + path1.lineTo(2.5, 9.5); + path1.lineTo(8.5, 15.5); - // two triangles - QPainterPath path1, path2; - if( isChecked() ) - { - path1.moveTo(8.5, 9.5); - path1.lineTo(2.5, 9.5); - path1.lineTo(8.5, 15.5); + path2.moveTo(9.5, 8.5); + path2.lineTo(15.5, 8.5); + path2.lineTo(9.5, 2.5); + } + else + { + path1.moveTo(5, 13); + path1.lineTo(11, 13); + path1.lineTo(5, 7); - path2.moveTo(9.5, 8.5); - path2.lineTo(15.5, 8.5); - path2.lineTo(9.5, 2.5); - } - else - { - path1.moveTo(5, 13); - path1.lineTo(11, 13); - path1.lineTo(5, 7); + path2.moveTo(13, 5); + path2.lineTo(7, 5); + path2.lineTo(13, 11); + } - path2.moveTo(13, 5); - path2.lineTo(7, 5); - path2.lineTo(13, 11); + painter->fillPath(path1, QBrush(symbolColor)); + painter->fillPath(path2, QBrush(symbolColor)); + } + break; } - painter->fillPath(path1, QBrush(mycolor)); - painter->fillPath(path2, QBrush(mycolor)); + case DecorationButtonType::Minimize: + { + QColor button_color; + if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(223, 192, 76); + else + button_color = QColor(255, 188, 48); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - break; - } + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) + { + // ring + painter->setBrush( Qt::NoBrush ); + painter->setPen( button_pen ); + } + else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + // nothing + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + } + else + { + // filled + painter->setBrush( button_color ); + painter->setPen( button_pen ); + } + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); + } + break; + } - case DecorationButtonType::Minimize: - { - QColor button_color = symbolColor; - button_color.setAlpha( button_color.alpha()*m_opacity ); - painter->setPen( Qt::NoPen ); - painter->setBrush( button_color ); + case DecorationButtonType::OnAllDesktops: + { + const QColor button_color = QColor(125, 209, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + { + // ring + painter->setBrush( Qt::NoBrush ); + painter->setPen( button_pen ); + } + else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + // nothing + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + } + else + { + // filled + painter->setBrush( button_color ); + painter->setPen( button_pen ); + } - button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); - symbol_pen.setColor(mycolor); - painter->setPen( symbol_pen ); - // it's a horizontal line - painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); - break; - } + if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + painter->setPen( Qt::NoPen ); + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 6, 6, 6, 6 ) ); + } + break; + } - case DecorationButtonType::OnAllDesktops: - { - QColor button_color = symbolColor; - if ( !isChecked() ) - button_color.setAlpha( button_color.alpha()*m_opacity ); - painter->setPen( Qt::NoPen ); - painter->setBrush( button_color ); + case DecorationButtonType::Shade: + { + const QColor button_color = QColor(204, 176, 213); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - - button_color.setAlpha( 255 ); - QColor mycolor = symbolColor; - if ( isChecked() && !isHovered() ) - mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); - else - mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); - symbol_pen.setColor(mycolor); - painter->setPen( Qt::NoPen ); - painter->setBrush(QBrush(mycolor)); - painter->drawEllipse( QRectF( 6, 6, 6, 6 ) ); - - break; - } - - case DecorationButtonType::Shade: - { - QColor button_color = symbolColor; - button_color.setAlpha( button_color.alpha()*m_opacity ); - painter->setPen( Qt::NoPen ); - painter->setBrush( button_color ); - - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - - button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); - symbol_pen.setColor(mycolor); - painter->setPen( symbol_pen ); - // it's a triangle with a dash - if (isChecked()) - { - painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 12 ) ); - painter->setPen( Qt::NoPen ); - QPainterPath path; - path.moveTo(9, 11); - path.lineTo(5, 6); - path.lineTo(13, 6); - painter->fillPath(path, QBrush(mycolor)); - - } - else { - painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 6 ) ); - painter->setPen( Qt::NoPen ); - QPainterPath path; - path.moveTo(9, 7); - path.lineTo(5, 12); - path.lineTo(13, 12); - painter->fillPath(path, QBrush(mycolor)); - } - - break; - - } - - case DecorationButtonType::KeepBelow: - { - QColor button_color = symbolColor; - if ( !isChecked() ) - button_color.setAlpha( button_color.alpha()*m_opacity ); - painter->setPen( Qt::NoPen ); - painter->setBrush( button_color ); - - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - - button_color.setAlpha( 255 ); - QColor mycolor = symbolColor; - if ( isChecked() && !isHovered() ) - mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); - else - mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); - painter->setPen( Qt::NoPen ); - - // it's a downward pointing triangle - QPainterPath path; - path.moveTo(9, 12); - path.lineTo(5, 6); - path.lineTo(13, 6); - painter->fillPath(path, QBrush(mycolor)); - - break; - - } - - case DecorationButtonType::KeepAbove: - { - QColor button_color = symbolColor; - if ( !isChecked() ) - button_color.setAlpha( button_color.alpha()*m_opacity ); - painter->setPen( Qt::NoPen ); - painter->setBrush( button_color ); - - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - - button_color.setAlpha( 255 ); - QColor mycolor = symbolColor; - if ( isChecked() && !isHovered() ) - mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); - else - mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); - painter->setPen( Qt::NoPen ); - - // it's a upward pointing triangle - QPainterPath path; - path.moveTo(9, 6); - path.lineTo(5, 12); - path.lineTo(13, 12); - painter->fillPath(path, QBrush(mycolor)); - - break; - } - - case DecorationButtonType::ApplicationMenu: - { - painter->setPen( symbol_pen ); - - painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); - painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); - painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); - - break; - } - - case DecorationButtonType::ContextHelp: - { - QColor button_color = symbolColor; - button_color.setAlpha( button_color.alpha()*m_opacity ); - painter->setPen( Qt::NoPen ); - painter->setBrush( button_color ); - - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - - button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); - symbol_pen.setColor(mycolor); - painter->setPen( symbol_pen ); - // it's a question mark - QPainterPath path; - path.moveTo( 6, 6 ); - path.arcTo( QRectF( 5.5, 4, 7.5, 4.5 ), 180, -180 ); - path.cubicTo( QPointF(11, 9), QPointF( 9, 6 ), QPointF( 9, 10 ) ); - painter->drawPath( path ); - painter->drawPoint( 9, 13 ); - - break; - } - - default: break; - } - } - - //__________________________________________________________________ - void Button::drawIconDarkAuroraeStyle( QPainter *painter ) const - { - - painter->setRenderHints( QPainter::Antialiasing ); - - /* - scale painter so that its window matches QRect( -1, -1, 20, 20 ) - this makes all further rendering and scaling simpler - all further rendering is preformed inside QRect( 0, 0, 18, 18 ) - */ - painter->translate( geometry().topLeft() ); - - const qreal width( m_iconSize.width() ); - painter->scale( width/20, width/20 ); - painter->translate( 1, 1 ); - - auto d = qobject_cast( decoration() ); - bool inactiveWindow( d && !d->client().data()->isActive() ); - bool useActiveButtonStyle( d && d->internalSettings()->buttonStyle() == 6 ); - bool useInactiveButtonStyle( d && d->internalSettings()->buttonStyle() == 7 ); - bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); - - const QColor darkSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(81, 102, 107) : QColor(34, 45, 50) ); - const QColor lightSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(192, 193, 194) : QColor(250, 251, 252) ); - - const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); - const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); - - // symbols color - - QColor symbolColor( this->autoColor( inactiveWindow, useActiveButtonStyle, useInactiveButtonStyle, isMatchTitleBarColor, darkSymbolColor, lightSymbolColor ) ); - - // symbols pen - - QPen symbol_pen( symbolColor ); - symbol_pen.setJoinStyle( Qt::MiterJoin ); - symbol_pen.setWidthF( 1.2*qMax((qreal)1.0, 20/width ) ); - - switch( type() ) - { - - case DecorationButtonType::Close: - { - const QColor button_color = QColor(252, 87, 83); - QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); - button_pen.setJoinStyle( Qt::MiterJoin ); - button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) { // ring painter->setBrush( Qt::NoBrush ); @@ -1735,29 +1616,53 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); - if ( isHovered() ) + + if (isChecked()) { - painter->setPen( symbol_pen ); - // it's a cross - painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); - painter->drawLine( QPointF( 5, 13 ), QPointF( 13, 5 ) ); + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 12 ) ); + painter->setPen( Qt::NoPen ); + QPainterPath path; + path.moveTo(9, 11); + path.lineTo(5, 6); + path.lineTo(13, 6); + painter->fillPath(path, QBrush(symbolColor)); + + } + else if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 6 ) ); + painter->setPen( Qt::NoPen ); + QPainterPath path; + path.moveTo(9, 7); + path.lineTo(5, 12); + path.lineTo(13, 12); + painter->fillPath(path, QBrush(symbolColor)); } break; + } - case DecorationButtonType::Maximize: + case DecorationButtonType::KeepBelow: { - const QColor button_color = QColor(51, 199, 72); + const QColor button_color = QColor(255, 137, 241); QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); button_pen.setJoinStyle( Qt::MiterJoin ); button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) { // ring painter->setBrush( Qt::NoBrush ); @@ -1775,44 +1680,41 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( isHovered() ) - { - painter->setPen( symbol_pen ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); - // solid vs. open rectangle - if( isChecked() ) - { - painter->drawLine( QPointF( 4.5, 6 ), QPointF( 13.5, 6 ) ); - painter->drawLine( QPointF( 13.5, 6 ), QPointF( 13.5, 12 ) ); - painter->drawLine( QPointF( 4.5, 6 ), QPointF( 4.5, 12 ) ); - painter->drawLine( QPointF( 4.5, 12 ), QPointF( 13.5, 12 ) ); - } - else - { - painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) ); - painter->drawLine( QPointF( 13.5, 4.5 ), QPointF( 13.5, 9 ) ); - painter->drawLine( QPointF( 4.5, 9 ), QPointF( 4.5, 13.5 ) ); - painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) ); - } + if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + painter->setPen( Qt::NoPen ); + QPainterPath path; + path.moveTo(9, 12); + path.lineTo(5, 6); + path.lineTo(13, 6); + painter->fillPath(path, QBrush(symbolColor)); } break; + } - case DecorationButtonType::Minimize: + case DecorationButtonType::KeepAbove: { - const QColor button_color = QColor(253, 188, 64); + const QColor button_color = QColor(135, 206, 249); QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); button_pen.setJoinStyle( Qt::MiterJoin ); button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) { // ring painter->setBrush( Qt::NoBrush ); @@ -1830,22 +1732,64 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); - if ( isHovered() ) + + if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) { - painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); + painter->setPen( Qt::NoPen ); + + QPainterPath path; + path.moveTo(9, 6); + path.lineTo(5, 12); + path.lineTo(13, 12); + painter->fillPath(path, QBrush(symbolColor)); } break; } - case DecorationButtonType::OnAllDesktops: + case DecorationButtonType::ApplicationMenu: { - const QColor button_color = QColor(125, 209, 200); + QColor menuSymbolColor; + + uint r = qRed(titleBarColor.rgb()); + uint g = qGreen(titleBarColor.rgb()); + uint b = qBlue(titleBarColor.rgb()); + // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color + // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; + // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) + qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); + if ( colorConditional > 186 || g > 186 ) + menuSymbolColor = darkSymbolColor; + else + menuSymbolColor = lightSymbolColor; + + QPen menuSymbol_pen( menuSymbolColor ); + menuSymbol_pen.setJoinStyle( Qt::MiterJoin ); + menuSymbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); + + painter->setPen( menuSymbol_pen ); + + painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); + painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); + painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); + + break; + } + + case DecorationButtonType::ContextHelp: + { + const QColor button_color = QColor(102, 156, 246); QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); button_pen.setJoinStyle( Qt::MiterJoin ); button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); @@ -1868,49 +1812,90 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); - painter->setBrush( Qt::NoBrush ); - if ( !isChecked() && ( isHovered() ) ) - { - painter->setPen( symbol_pen ); - - painter->drawLine( QPointF( 7, 5 ), QPointF( 15, 5 ) ); - painter->drawLine( QPointF( 15, 5 ), QPointF( 15, 13 ) ); - painter->drawLine( QPointF( 7, 5 ), QPointF( 7, 13 ) ); - painter->drawLine( QPointF( 7, 13 ), QPointF( 15, 13 ) ); - painter->drawLine( QPointF( 3, 5 ), QPointF( 3, 13 ) ); - painter->drawLine( QPointF( 3, 5 ), QPointF( 4.5, 5 ) ); - painter->drawLine( QPointF( 3, 13 ), QPointF( 4.5, 13 ) ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); } - else if ( isChecked() && ( isHovered() ) ) + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) { painter->setPen( symbol_pen ); - - painter->drawLine( QPointF( 5, 5 ), QPointF( 11, 5 ) ); - painter->drawLine( QPointF( 11, 5 ), QPointF( 11, 11 ) ); - painter->drawLine( QPointF( 5, 5 ), QPointF( 5, 11 ) ); - painter->drawLine( QPointF( 5, 11 ), QPointF( 11, 11 ) ); - - painter->drawLine( QPointF( 7, 7 ), QPointF( 13, 7 ) ); - painter->drawLine( QPointF( 13, 7 ), QPointF( 13, 13 ) ); - painter->drawLine( QPointF( 7, 7 ), QPointF( 7, 13 ) ); - painter->drawLine( QPointF( 7, 13 ), QPointF( 13, 13 ) ); + QPainterPath path; + path.moveTo( 6, 6 ); + path.arcTo( QRectF( 5.5, 4, 7.5, 4.5 ), 180, -180 ); + path.cubicTo( QPointF(11, 9), QPointF( 9, 6 ), QPointF( 9, 10 ) ); + painter->drawPath( path ); + painter->drawPoint( 9, 13 ); } break; } - case DecorationButtonType::Shade: + default: break; + } + } + + //__________________________________________________________________ + void Button::drawIconSBEdarkAurorae( QPainter *painter ) const + { + + painter->setRenderHints( QPainter::Antialiasing ); + + /* + scale painter so that its window matches QRect( -1, -1, 20, 20 ) + this makes all further rendering and scaling simpler + all further rendering is preformed inside QRect( 0, 0, 18, 18 ) + */ + painter->translate( geometry().topLeft() ); + + const qreal width( m_iconSize.width() ); + painter->scale( width/20, width/20 ); + painter->translate( 1, 1 ); + + auto d = qobject_cast( decoration() ); + bool inactiveWindow( d && !d->client().data()->isActive() ); + bool useActiveButtonStyle( d && d->internalSettings()->buttonStyle() == 8 ); + bool useInactiveButtonStyle( d && d->internalSettings()->buttonStyle() == 9 ); + bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); + + const QColor darkSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(81, 102, 107) : QColor(34, 45, 50) ); + const QColor lightSymbolColor( ( inactiveWindow && isMatchTitleBarColor ) ? QColor(192, 193, 194) : QColor(250, 251, 252) ); + + const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); + const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); + + // symbols color + + QColor symbolColor( this->autoColor( inactiveWindow, useActiveButtonStyle, useInactiveButtonStyle, isMatchTitleBarColor, darkSymbolColor, lightSymbolColor ) ); + + // symbols pen + + QPen symbol_pen( symbolColor ); + symbol_pen.setJoinStyle( Qt::MiterJoin ); + symbol_pen.setWidthF( 1.2*qMax((qreal)1.0, 20/width ) ); + + switch( type() ) + { + + case DecorationButtonType::Close: { - const QColor button_color = QColor(204, 176, 213); + QColor button_color; + if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(238, 102, 90); + else + button_color = QColor(255, 94, 88); QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); button_pen.setJoinStyle( Qt::MiterJoin ); button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) { // ring painter->setBrush( Qt::NoBrush ); @@ -1933,26 +1918,28 @@ namespace Breeze QPointF c(static_cast(9), static_cast(9)); painter->drawEllipse( c, r, r ); painter->setBrush( Qt::NoBrush ); - if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) { painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 4, 6 ), QPointF( 14, 6 ) ); - - painter->setBrush(QBrush(symbolColor)); - painter->drawEllipse( QRectF( 8, 10, 2, 2 ) ); + // it's a cross + painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); + painter->drawLine( QPointF( 5, 13 ), QPointF( 13, 5 ) ); } break; - } - case DecorationButtonType::KeepBelow: + case DecorationButtonType::Maximize: { - const QColor button_color = QColor(255, 137, 241); + QColor button_color; + if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(100, 196, 86); + else + button_color = QColor(40, 200, 64); QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); button_pen.setJoinStyle( Qt::MiterJoin ); button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) { // ring painter->setBrush( Qt::NoBrush ); @@ -1975,26 +1962,43 @@ namespace Breeze QPointF c(static_cast(9), static_cast(9)); painter->drawEllipse( c, r, r ); painter->setBrush( Qt::NoBrush ); - if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) { + painter->setPen( symbol_pen ); - painter->drawPolyline( QVector{ - QPointF( 4, 7 ), - QPointF( 9, 12 ), - QPointF( 14, 7 ) }); + + // solid vs. open rectangle + if( isChecked() ) + { + painter->drawLine( QPointF( 4.5, 6 ), QPointF( 13.5, 6 ) ); + painter->drawLine( QPointF( 13.5, 6 ), QPointF( 13.5, 12 ) ); + painter->drawLine( QPointF( 4.5, 6 ), QPointF( 4.5, 12 ) ); + painter->drawLine( QPointF( 4.5, 12 ), QPointF( 13.5, 12 ) ); + } + else + { + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) ); + painter->drawLine( QPointF( 13.5, 4.5 ), QPointF( 13.5, 9 ) ); + painter->drawLine( QPointF( 4.5, 9 ), QPointF( 4.5, 13.5 ) ); + painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) ); + } + } break; - } - case DecorationButtonType::KeepAbove: + case DecorationButtonType::Minimize: { - const QColor button_color = QColor(135, 206, 249); + QColor button_color; + if ( qGray(titleBarColor.rgb()) < 128 ) + button_color = QColor(223, 192, 76); + else + button_color = QColor(255, 188, 48); QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); button_pen.setJoinStyle( Qt::MiterJoin ); button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); - if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && isHovered() ) { // ring painter->setBrush( Qt::NoBrush ); @@ -2012,37 +2016,261 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); } + qreal r = static_cast(7) + static_cast(2) * m_animation->currentValue().toReal(); QPointF c(static_cast(9), static_cast(9)); painter->drawEllipse( c, r, r ); painter->setBrush( Qt::NoBrush ); - if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + + if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) { painter->setPen( symbol_pen ); - painter->drawPolyline( QVector{ - QPointF( 4, 11 ), - QPointF( 9, 6 ), - QPointF( 14, 11 )}); + painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); } break; } - case DecorationButtonType::ApplicationMenu: + case DecorationButtonType::OnAllDesktops: { - QColor menuSymbolColor; - - uint r = qRed(titleBarColor.rgb()); - uint g = qGreen(titleBarColor.rgb()); - uint b = qBlue(titleBarColor.rgb()); - // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color - // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; - // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) - qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); - if ( colorConditional > 186 || g > 186 ) - menuSymbolColor = darkSymbolColor; - else - menuSymbolColor = lightSymbolColor; + const QColor button_color = QColor(125, 209, 200); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + { + // ring + painter->setBrush( Qt::NoBrush ); + painter->setPen( button_pen ); + } + else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + // nothing + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + } + else + { + // filled + painter->setBrush( button_color ); + painter->setPen( button_pen ); + } + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + if ( !isChecked() && ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) ) + { + painter->setPen( symbol_pen ); + + painter->drawLine( QPointF( 7, 5 ), QPointF( 15, 5 ) ); + painter->drawLine( QPointF( 15, 5 ), QPointF( 15, 13 ) ); + painter->drawLine( QPointF( 7, 5 ), QPointF( 7, 13 ) ); + painter->drawLine( QPointF( 7, 13 ), QPointF( 15, 13 ) ); + + painter->drawLine( QPointF( 3, 5 ), QPointF( 3, 13 ) ); + painter->drawLine( QPointF( 3, 5 ), QPointF( 4.5, 5 ) ); + painter->drawLine( QPointF( 3, 13 ), QPointF( 4.5, 13 ) ); + } + else if ( isChecked() && ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) ) + { + painter->setPen( symbol_pen ); + + painter->drawLine( QPointF( 5, 5 ), QPointF( 11, 5 ) ); + painter->drawLine( QPointF( 11, 5 ), QPointF( 11, 11 ) ); + painter->drawLine( QPointF( 5, 5 ), QPointF( 5, 11 ) ); + painter->drawLine( QPointF( 5, 11 ), QPointF( 11, 11 ) ); + + painter->drawLine( QPointF( 7, 7 ), QPointF( 13, 7 ) ); + painter->drawLine( QPointF( 13, 7 ), QPointF( 13, 13 ) ); + painter->drawLine( QPointF( 7, 7 ), QPointF( 7, 13 ) ); + painter->drawLine( QPointF( 7, 13 ), QPointF( 13, 13 ) ); + } + break; + } + + case DecorationButtonType::Shade: + { + const QColor button_color = QColor(204, 176, 213); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + { + // ring + painter->setBrush( Qt::NoBrush ); + painter->setPen( button_pen ); + } + else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + // nothing + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + } + else + { + // filled + painter->setBrush( button_color ); + painter->setPen( button_pen ); + } + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + if (isChecked()) + { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 4, 12 ), QPointF( 14, 12 ) ); + + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 6, 2, 2 ) ); + } + else if ( isHovered() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 4, 6 ), QPointF( 14, 6 ) ); + + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 10, 2, 2 ) ); + } + break; + + } + + case DecorationButtonType::KeepBelow: + { + const QColor button_color = QColor(255, 137, 241); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + { + // ring + painter->setBrush( Qt::NoBrush ); + painter->setPen( button_pen ); + } + else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + // nothing + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + } + else + { + // filled + painter->setBrush( button_color ); + painter->setPen( button_pen ); + } + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + painter->setPen( symbol_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 7 ), + QPointF( 9, 12 ), + QPointF( 14, 7 ) }); + } + break; + + } + + case DecorationButtonType::KeepAbove: + { + const QColor button_color = QColor(135, 206, 249); + QPen button_pen( qGray(titleBarColor.rgb()) < 100 ? button_color.lighter(115) : button_color.darker(150) ); + button_pen.setJoinStyle( Qt::MiterJoin ); + button_pen.setWidthF( 1.0*qMax((qreal)1.0, 20/width ) ); + + if ( ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) && ( isHovered() || isChecked() ) ) + { + // ring + painter->setBrush( Qt::NoBrush ); + painter->setPen( button_pen ); + } + else if ( ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + // nothing + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + } + else + { + // filled + painter->setBrush( button_color ); + painter->setPen( button_pen ); + } + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) + { + painter->setPen( symbol_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 11 ), + QPointF( 9, 6 ), + QPointF( 14, 11 )}); + } + break; + } + + case DecorationButtonType::ApplicationMenu: + { + QColor menuSymbolColor; + + uint r = qRed(titleBarColor.rgb()); + uint g = qGreen(titleBarColor.rgb()); + uint b = qBlue(titleBarColor.rgb()); + // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color + // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; + // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) + qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); + if ( colorConditional > 186 || g > 186 ) + menuSymbolColor = darkSymbolColor; + else + menuSymbolColor = lightSymbolColor; QPen menuSymbol_pen( menuSymbolColor ); menuSymbol_pen.setJoinStyle( Qt::MiterJoin ); @@ -2082,11 +2310,19 @@ namespace Breeze painter->setBrush( button_color ); painter->setPen( button_pen ); } - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); + if ( isHovered() || isChecked() || ( inactiveWindow && !useActiveButtonStyle ) || useInactiveButtonStyle ) { painter->setPen( symbol_pen ); @@ -2094,18 +2330,1095 @@ namespace Breeze int spanAngle = 280 * 16; painter->drawArc( QRectF( 5, 3, 8, 8), startAngle, spanAngle ); - painter->setBrush(QBrush(symbolColor)); - painter->drawEllipse( QRectF( 8, 14, 2, 2 ) ); - } - break; - } + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 14, 2, 2 ) ); + } + break; + } + + default: break; + } + } + + //__________________________________________________________________ + void Button::drawIconSierraColorSymbols( QPainter *painter ) const + { + painter->setRenderHints( QPainter::Antialiasing ); + + /* + scale painter so that its window matches QRect( -1, -1, 20, 20 ) + this makes all further rendering and scaling simpler + all further rendering is preformed inside QRect( 0, 0, 18, 18 ) + */ + painter->translate( geometry().topLeft() ); + + const qreal width( m_iconSize.width() ); + painter->scale( width/20, width/20 ); + painter->translate( 1, 1 ); + + auto d = qobject_cast( decoration() ); + bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); + + const QColor darkSymbolColor = QColor(34, 45, 50); + const QColor lightSymbolColor = QColor(250, 251, 252); + QColor symbolColor = darkSymbolColor; + + const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); + const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); + + // symbols pen + + QPen symbol_pen( symbolColor ); + symbol_pen.setJoinStyle( Qt::MiterJoin ); + symbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); + + switch( type() ) + { + + case DecorationButtonType::Close: + { + QColor button_color = QColor(238, 102, 90); + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a cross + painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 12 ) ); + painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 6 ) ); + + break; + } + + case DecorationButtonType::Maximize: + { + QColor button_color = QColor(100, 196, 86); + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + + button_color.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + + // two triangles + QPainterPath path1, path2; + if( isChecked() ) + { + path1.moveTo(8.5, 9.5); + path1.lineTo(2.5, 9.5); + path1.lineTo(8.5, 15.5); + + path2.moveTo(9.5, 8.5); + path2.lineTo(15.5, 8.5); + path2.lineTo(9.5, 2.5); + } + else + { + path1.moveTo(5, 13); + path1.lineTo(11, 13); + path1.lineTo(5, 7); + + path2.moveTo(13, 5); + path2.lineTo(7, 5); + path2.lineTo(13, 11); + } + + painter->fillPath(path1, QBrush(mycolor)); + painter->fillPath(path2, QBrush(mycolor)); + + break; + } + + case DecorationButtonType::Minimize: + { + QColor button_color = QColor(223, 192, 76); + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a horizontal line + painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); + + break; + } + + case DecorationButtonType::OnAllDesktops: + { + QColor button_color = QColor(125, 209, 200); + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( !isChecked() ) + mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + // painter->setPen( symbol_pen ); + painter->setPen( Qt::NoPen ); + painter->setBrush(QBrush(mycolor)); + painter->drawEllipse( QRectF( 6, 6, 6, 6 ) ); + + break; + } + + case DecorationButtonType::Shade: + { + QColor button_color = QColor(204, 176, 213); + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( !isChecked() ) + mycolor = this->mixColors(button_color.darker (100), symbolColor, m_opacity); + painter->setPen( mycolor ); + + // it's a triangle with a dash + if (isChecked()) + { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 12 ) ); + painter->setPen( Qt::NoPen ); + QPainterPath path; + path.moveTo(9, 11); + path.lineTo(5, 6); + path.lineTo(13, 6); + painter->fillPath(path, QBrush(mycolor)); + + } + else { + painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 6 ) ); + painter->setPen( Qt::NoPen ); + QPainterPath path; + path.moveTo(9, 7); + path.lineTo(5, 12); + path.lineTo(13, 12); + painter->fillPath(path, QBrush(mycolor)); + } + + break; + + } + + case DecorationButtonType::KeepBelow: + { + QColor button_color = QColor(255, 137, 241); + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( !isChecked() ) + mycolor = this->mixColors(button_color.darker (100), symbolColor, m_opacity); + painter->setPen( Qt::NoPen ); + + // it's a downward pointing triangle + QPainterPath path; + path.moveTo(9, 12); + path.lineTo(5, 6); + path.lineTo(13, 6); + painter->fillPath(path, QBrush(mycolor)); + + break; + + } + + case DecorationButtonType::KeepAbove: + { + QColor button_color = QColor(135, 206, 249); + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( !isChecked() ) + mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + painter->setPen( Qt::NoPen ); + + // it's a upward pointing triangle + QPainterPath path; + path.moveTo(9, 6); + path.lineTo(5, 12); + path.lineTo(13, 12); + painter->fillPath(path, QBrush(mycolor)); + + break; + } + + case DecorationButtonType::ApplicationMenu: + { + QColor menuSymbolColor; + + uint r = qRed(titleBarColor.rgb()); + uint g = qGreen(titleBarColor.rgb()); + uint b = qBlue(titleBarColor.rgb()); + // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color + // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; + // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) + qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); + if ( colorConditional > 186 || g > 186 ) + menuSymbolColor = darkSymbolColor; + else + menuSymbolColor = lightSymbolColor; + + QPen menuSymbol_pen( menuSymbolColor ); + menuSymbol_pen.setJoinStyle( Qt::MiterJoin ); + menuSymbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); + + painter->setPen( menuSymbol_pen ); + + painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); + painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); + painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); + + break; + } + + case DecorationButtonType::ContextHelp: + { + QColor button_color = QColor(102, 156, 246); + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a question mark + QPainterPath path; + path.moveTo( 6, 6 ); + path.arcTo( QRectF( 5.5, 4, 7.5, 4.5 ), 180, -180 ); + path.cubicTo( QPointF(11, 9), QPointF( 9, 6 ), QPointF( 9, 10 ) ); + painter->drawPath( path ); + painter->drawPoint( 9, 13 ); + + break; + } + + default: break; + } + } + + //__________________________________________________________________ + void Button::drawIconDarkAuroraeColorSymbols( QPainter *painter ) const + { + painter->setRenderHints( QPainter::Antialiasing ); + + /* + scale painter so that its window matches QRect( -1, -1, 20, 20 ) + this makes all further rendering and scaling simpler + all further rendering is preformed inside QRect( 0, 0, 18, 18 ) + */ + painter->translate( geometry().topLeft() ); + + const qreal width( m_iconSize.width() ); + painter->scale( width/20, width/20 ); + painter->translate( 1, 1 ); + + auto d = qobject_cast( decoration() ); + bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); + + const QColor darkSymbolColor = QColor(34, 45, 50); + const QColor lightSymbolColor = QColor(250, 251, 252); + QColor symbolColor = darkSymbolColor; + + const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); + const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); + + // symbols pen + + QPen symbol_pen( symbolColor ); + symbol_pen.setJoinStyle( Qt::MiterJoin ); + symbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); + + switch( type() ) + { + + case DecorationButtonType::Close: + { + QColor button_color = QColor(238, 102, 90); + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a cross + painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); + painter->drawLine( QPointF( 5, 13 ), QPointF( 13, 5 ) ); + + break; + } + + case DecorationButtonType::Maximize: + { + QColor button_color = QColor(100, 196, 86); + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + + // solid vs. open rectangle + if( isChecked() ) + { + painter->drawLine( QPointF( 4.5, 6 ), QPointF( 13.5, 6 ) ); + painter->drawLine( QPointF( 13.5, 6 ), QPointF( 13.5, 12 ) ); + painter->drawLine( QPointF( 4.5, 6 ), QPointF( 4.5, 12 ) ); + painter->drawLine( QPointF( 4.5, 12 ), QPointF( 13.5, 12 ) ); + } + else + { + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) ); + painter->drawLine( QPointF( 13.5, 4.5 ), QPointF( 13.5, 9 ) ); + painter->drawLine( QPointF( 4.5, 9 ), QPointF( 4.5, 13.5 ) ); + painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) ); + } + + break; + } + + case DecorationButtonType::Minimize: + { + QColor button_color = QColor(223, 192, 76); + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a horizontal line + painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); + + break; + } + + case DecorationButtonType::OnAllDesktops: + { + QColor button_color = QColor(125, 209, 200); + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( !isChecked() ) + mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + + // it's a triangle with a dash + if (isChecked()) + { + painter->drawLine( QPointF( 5, 5 ), QPointF( 11, 5 ) ); + painter->drawLine( QPointF( 11, 5 ), QPointF( 11, 11 ) ); + painter->drawLine( QPointF( 5, 5 ), QPointF( 5, 11 ) ); + painter->drawLine( QPointF( 5, 11 ), QPointF( 11, 11 ) ); + + painter->drawLine( QPointF( 7, 7 ), QPointF( 13, 7 ) ); + painter->drawLine( QPointF( 13, 7 ), QPointF( 13, 13 ) ); + painter->drawLine( QPointF( 7, 7 ), QPointF( 7, 13 ) ); + painter->drawLine( QPointF( 7, 13 ), QPointF( 13, 13 ) ); + } + else { + painter->drawLine( QPointF( 7, 5 ), QPointF( 15, 5 ) ); + painter->drawLine( QPointF( 15, 5 ), QPointF( 15, 13 ) ); + painter->drawLine( QPointF( 7, 5 ), QPointF( 7, 13 ) ); + painter->drawLine( QPointF( 7, 13 ), QPointF( 15, 13 ) ); + + painter->drawLine( QPointF( 3, 5 ), QPointF( 3, 13 ) ); + painter->drawLine( QPointF( 3, 5 ), QPointF( 4.5, 5 ) ); + painter->drawLine( QPointF( 3, 13 ), QPointF( 4.5, 13 ) ); + } + break; + } + + case DecorationButtonType::Shade: + { + QColor button_color = QColor(204, 176, 213); + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( !isChecked() ) + mycolor = this->mixColors(button_color.darker (100), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + if (isChecked()) + { + painter->drawLine( QPointF( 4, 12 ), QPointF( 14, 12 ) ); + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 6, 2, 2 ) ); + } + else { + painter->drawLine( QPointF( 4, 6 ), QPointF( 14, 6 ) ); + painter->setBrush(QBrush(mycolor)); + painter->drawEllipse( QRectF( 8, 10, 2, 2 ) ); + } + + break; + + } + + case DecorationButtonType::KeepBelow: + { + QColor button_color = QColor(255, 137, 241); + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( !isChecked() ) + mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 7 ), + QPointF( 9, 12 ), + QPointF( 14, 7 ) }); + + break; + + } + + case DecorationButtonType::KeepAbove: + { + QColor button_color = QColor(135, 206, 249); + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( !isChecked() ) + mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 11 ), + QPointF( 9, 6 ), + QPointF( 14, 11 )}); + + break; + } + + case DecorationButtonType::ApplicationMenu: + { + QColor menuSymbolColor; + + uint r = qRed(titleBarColor.rgb()); + uint g = qGreen(titleBarColor.rgb()); + uint b = qBlue(titleBarColor.rgb()); + // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color + // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; + // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) + qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); + if ( colorConditional > 186 || g > 186 ) + menuSymbolColor = darkSymbolColor; + else + menuSymbolColor = lightSymbolColor; + + QPen menuSymbol_pen( menuSymbolColor ); + menuSymbol_pen.setJoinStyle( Qt::MiterJoin ); + menuSymbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); + + painter->setPen( menuSymbol_pen ); + + painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); + painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); + painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); + + break; + } + + case DecorationButtonType::ContextHelp: + { + QColor button_color = QColor(102, 156, 246); + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a question mark + + painter->setPen( symbol_pen ); + int startAngle = 260 * 16; + int spanAngle = 280 * 16; + painter->drawArc( QRectF( 5, 3, 8, 8), startAngle, spanAngle ); + + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 14, 2, 2 ) ); + + break; + } + + default: break; + } + } + + //__________________________________________________________________ + void Button::drawIconSierraMonochromeSymbols( QPainter *painter ) const + { + painter->setRenderHints( QPainter::Antialiasing ); + + /* + * scale painter so that its window matches QRect( -1, -1, 20, 20 ) + * this makes all further rendering and scaling simpler + * all further rendering is preformed inside QRect( 0, 0, 18, 18 ) + */ + painter->translate( geometry().topLeft() ); + + const qreal width( m_iconSize.width() ); + painter->scale( width/20, width/20 ); + painter->translate( 1, 1 ); + + const QColor darkSymbolColor = QColor(34, 45, 50); + const QColor lightSymbolColor = QColor(250, 251, 252); + + auto d = qobject_cast( decoration() ); + bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); + + const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); + const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); + uint r = qRed(titleBarColor.rgb()); + uint g = qGreen(titleBarColor.rgb()); + uint b = qBlue(titleBarColor.rgb()); + + QColor symbolColor; + QColor symbolBgdColor; + + // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color + // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; + // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) + qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); + if ( colorConditional > 186 || g > 186 ) { + symbolColor = darkSymbolColor; + symbolBgdColor = lightSymbolColor; + } + else { + symbolColor = lightSymbolColor; + symbolBgdColor = darkSymbolColor; + } + + // symbols pen + + QPen symbol_pen( symbolColor ); + symbol_pen.setJoinStyle( Qt::MiterJoin ); + symbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); + + switch( type() ) + { + + case DecorationButtonType::Close: + { + QColor button_color = symbolColor; + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a cross + painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 12 ) ); + painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 6 ) ); + + break; + } + + case DecorationButtonType::Maximize: + { + QColor button_color = symbolColor; + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + painter->setPen( Qt::NoPen ); + + button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + + // two triangles + QPainterPath path1, path2; + if( isChecked() ) + { + path1.moveTo(8.5, 9.5); + path1.lineTo(2.5, 9.5); + path1.lineTo(8.5, 15.5); + + path2.moveTo(9.5, 8.5); + path2.lineTo(15.5, 8.5); + path2.lineTo(9.5, 2.5); + } + else + { + path1.moveTo(5, 13); + path1.lineTo(11, 13); + path1.lineTo(5, 7); + + path2.moveTo(13, 5); + path2.lineTo(7, 5); + path2.lineTo(13, 11); + } + + painter->fillPath(path1, QBrush(mycolor)); + painter->fillPath(path2, QBrush(mycolor)); + + break; + } + + case DecorationButtonType::Minimize: + { + QColor button_color = symbolColor; + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a horizontal line + painter->drawLine( QPointF( 5, 9 ), QPointF( 13, 9 ) ); + + break; + } + + case DecorationButtonType::OnAllDesktops: + { + QColor button_color = symbolColor; + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( isChecked() && !isHovered() ) + mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); + else + mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( Qt::NoPen ); + painter->setBrush(QBrush(mycolor)); + painter->drawEllipse( QRectF( 6, 6, 6, 6 ) ); + + break; + } + + case DecorationButtonType::Shade: + { + QColor button_color = symbolColor; + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( isChecked() && !isHovered() ) + mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); + else + mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + // it's a triangle with a dash + if (isChecked()) + { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 12 ) ); + painter->setPen( Qt::NoPen ); + QPainterPath path; + path.moveTo(9, 11); + path.lineTo(5, 6); + path.lineTo(13, 6); + painter->fillPath(path, QBrush(mycolor)); + } + else { + painter->setPen( symbol_pen ); + painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 6 ) ); + painter->setPen( Qt::NoPen ); + QPainterPath path; + path.moveTo(9, 7); + path.lineTo(5, 12); + path.lineTo(13, 12); + painter->fillPath(path, QBrush(mycolor)); + } + + break; + + } + + case DecorationButtonType::KeepBelow: + { + QColor button_color = symbolColor; + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( isChecked() && !isHovered() ) + mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); + else + mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + painter->setPen( Qt::NoPen ); + + // it's a downward pointing triangle + QPainterPath path; + path.moveTo(9, 12); + path.lineTo(5, 6); + path.lineTo(13, 6); + painter->fillPath(path, QBrush(mycolor)); + + break; + + } + + case DecorationButtonType::KeepAbove: + { + QColor button_color = symbolColor; + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( isChecked() && !isHovered() ) + mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); + else + mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + painter->setPen( Qt::NoPen ); + + // it's a upward pointing triangle + QPainterPath path; + path.moveTo(9, 6); + path.lineTo(5, 12); + path.lineTo(13, 12); + painter->fillPath(path, QBrush(mycolor)); + + break; + } + + case DecorationButtonType::ApplicationMenu: + { + painter->setPen( symbol_pen ); + + painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); + painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); + painter->drawLine( QPointF( 3.5, 13 ), QPointF( 14.5, 13 ) ); + + break; + } - default: break; + case DecorationButtonType::ContextHelp: + { + QColor button_color = symbolColor; + button_color.setAlpha( button_color.alpha()*m_opacity ); + painter->setPen( Qt::NoPen ); + painter->setBrush( button_color ); + + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } + painter->setBrush( Qt::NoBrush ); + + button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + + // it's a question mark + + QPainterPath path; + path.moveTo( 6, 6 ); + path.arcTo( QRectF( 5.5, 4, 7.5, 4.5 ), 180, -180 ); + path.cubicTo( QPointF(11, 9), QPointF( 9, 6 ), QPointF( 9, 10 ) ); + painter->drawPath( path ); + painter->drawPoint( 9, 13 ); + + break; } + + default: break; + } } //__________________________________________________________________ - void Button::drawIconSymbolStyle( QPainter *painter ) const + void Button::drawIconDarkAuroraeMonochromeSymbols( QPainter *painter ) const { painter->setRenderHints( QPainter::Antialiasing ); @@ -2120,15 +3433,33 @@ namespace Breeze painter->scale( width/20, width/20 ); painter->translate( 1, 1 ); - auto d = qobject_cast( decoration() ); - bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); - const QColor darkSymbolColor = QColor(34, 45, 50); const QColor lightSymbolColor = QColor(250, 251, 252); - QColor symbolColor = darkSymbolColor; + + auto d = qobject_cast( decoration() ); + bool isMatchTitleBarColor( d && d->internalSettings()->matchColorForTitleBar() ); const QColor matchedTitleBarColor(d->client().data()->palette().color(QPalette::Window)); const QColor titleBarColor ( isMatchTitleBarColor ? matchedTitleBarColor : d->titleBarColor() ); + uint r = qRed(titleBarColor.rgb()); + uint g = qGreen(titleBarColor.rgb()); + uint b = qBlue(titleBarColor.rgb()); + + QColor symbolColor; + QColor symbolBgdColor; + + // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color + // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; + // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) + qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); + if ( colorConditional > 186 || g > 186 ) { + symbolColor = darkSymbolColor; + symbolBgdColor = lightSymbolColor; + } + else { + symbolColor = lightSymbolColor; + symbolBgdColor = darkSymbolColor; + } // symbols pen @@ -2141,7 +3472,7 @@ namespace Breeze case DecorationButtonType::Close: { - QColor button_color = QColor(252, 87, 83); + QColor button_color = symbolColor; button_color.setAlpha( button_color.alpha()*m_opacity ); painter->setPen( Qt::NoPen ); painter->setBrush( button_color ); @@ -2153,19 +3484,20 @@ namespace Breeze painter->setBrush( Qt::NoBrush ); button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); symbol_pen.setColor(mycolor); painter->setPen( symbol_pen ); // it's a cross - painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 12 ) ); - painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 6 ) ); + painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); + painter->drawLine( QPointF( 5, 13 ), QPointF( 13, 5 ) ); break; } case DecorationButtonType::Maximize: { - QColor button_color = QColor(51, 199, 72); + QColor button_color = symbolColor; button_color.setAlpha( button_color.alpha()*m_opacity ); painter->setPen( Qt::NoPen ); painter->setBrush( button_color ); @@ -2175,43 +3507,35 @@ namespace Breeze QPointF c(static_cast(9), static_cast(9)); painter->drawEllipse( c, r, r ); painter->setBrush( Qt::NoBrush ); - painter->setPen( Qt::NoPen ); button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); - // two triangles - QPainterPath path1, path2; + // solid vs. open rectangle if( isChecked() ) { - path1.moveTo(8.5, 9.5); - path1.lineTo(2.5, 9.5); - path1.lineTo(8.5, 15.5); - - path2.moveTo(9.5, 8.5); - path2.lineTo(15.5, 8.5); - path2.lineTo(9.5, 2.5); + painter->drawLine( QPointF( 4.5, 6 ), QPointF( 13.5, 6 ) ); + painter->drawLine( QPointF( 13.5, 6 ), QPointF( 13.5, 12 ) ); + painter->drawLine( QPointF( 4.5, 6 ), QPointF( 4.5, 12 ) ); + painter->drawLine( QPointF( 4.5, 12 ), QPointF( 13.5, 12 ) ); } else { - path1.moveTo(5, 13); - path1.lineTo(11, 13); - path1.lineTo(5, 7); - - path2.moveTo(13, 5); - path2.lineTo(7, 5); - path2.lineTo(13, 11); + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) ); + painter->drawLine( QPointF( 13.5, 4.5 ), QPointF( 13.5, 9 ) ); + painter->drawLine( QPointF( 4.5, 9 ), QPointF( 4.5, 13.5 ) ); + painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) ); } - painter->fillPath(path1, QBrush(mycolor)); - painter->fillPath(path2, QBrush(mycolor)); - break; } case DecorationButtonType::Minimize: { - QColor button_color = QColor(253, 188, 64); + QColor button_color = symbolColor; button_color.setAlpha( button_color.alpha()*m_opacity ); painter->setPen( Qt::NoPen ); painter->setBrush( button_color ); @@ -2223,7 +3547,8 @@ namespace Breeze painter->setBrush( Qt::NoBrush ); button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); symbol_pen.setColor(mycolor); painter->setPen( symbol_pen ); // it's a horizontal line @@ -2234,70 +3559,99 @@ namespace Breeze case DecorationButtonType::OnAllDesktops: { - QColor button_color = QColor(125, 209, 200); + QColor button_color = symbolColor; if ( !isChecked() ) button_color.setAlpha( button_color.alpha()*m_opacity ); painter->setPen( Qt::NoPen ); painter->setBrush( button_color ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); QColor mycolor = symbolColor; - if ( !isChecked() ) - mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + if ( isChecked() && !isHovered() ) + mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); + else + mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); symbol_pen.setColor(mycolor); - // painter->setPen( symbol_pen ); - painter->setPen( Qt::NoPen ); - painter->setBrush(QBrush(mycolor)); - painter->drawEllipse( QRectF( 6, 6, 6, 6 ) ); + painter->setPen( symbol_pen ); + + // it's a triangle with a dash + if (isChecked()) + { + painter->drawLine( QPointF( 5, 5 ), QPointF( 11, 5 ) ); + painter->drawLine( QPointF( 11, 5 ), QPointF( 11, 11 ) ); + painter->drawLine( QPointF( 5, 5 ), QPointF( 5, 11 ) ); + painter->drawLine( QPointF( 5, 11 ), QPointF( 11, 11 ) ); + + painter->drawLine( QPointF( 7, 7 ), QPointF( 13, 7 ) ); + painter->drawLine( QPointF( 13, 7 ), QPointF( 13, 13 ) ); + painter->drawLine( QPointF( 7, 7 ), QPointF( 7, 13 ) ); + painter->drawLine( QPointF( 7, 13 ), QPointF( 13, 13 ) ); + } + else { + painter->drawLine( QPointF( 7, 5 ), QPointF( 15, 5 ) ); + painter->drawLine( QPointF( 15, 5 ), QPointF( 15, 13 ) ); + painter->drawLine( QPointF( 7, 5 ), QPointF( 7, 13 ) ); + painter->drawLine( QPointF( 7, 13 ), QPointF( 15, 13 ) ); + painter->drawLine( QPointF( 3, 5 ), QPointF( 3, 13 ) ); + painter->drawLine( QPointF( 3, 5 ), QPointF( 4.5, 5 ) ); + painter->drawLine( QPointF( 3, 13 ), QPointF( 4.5, 13 ) ); + } break; } case DecorationButtonType::Shade: { - QColor button_color = QColor(204, 176, 213); - button_color.setAlpha( button_color.alpha()*m_opacity ); + QColor button_color = symbolColor; + if ( !isChecked() ) + button_color.setAlpha( button_color.alpha()*m_opacity ); painter->setPen( Qt::NoPen ); painter->setBrush( button_color ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = symbolColor; + if ( isChecked() && !isHovered() ) + mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); + else + mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); symbol_pen.setColor(mycolor); painter->setPen( symbol_pen ); - // it's a triangle with a dash if (isChecked()) { - painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 6, 12 ), QPointF( 12, 12 ) ); - painter->setPen( Qt::NoPen ); - QPainterPath path; - path.moveTo(9, 11); - path.lineTo(5, 6); - path.lineTo(13, 6); - painter->fillPath(path, QBrush(mycolor)); - + painter->drawLine( QPointF( 4, 12 ), QPointF( 14, 12 ) ); + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 6, 2, 2 ) ); } else { - painter->setPen( symbol_pen ); - painter->drawLine( QPointF( 6, 6 ), QPointF( 12, 6 ) ); - painter->setPen( Qt::NoPen ); - QPainterPath path; - path.moveTo(9, 7); - path.lineTo(5, 12); - path.lineTo(13, 12); - painter->fillPath(path, QBrush(mycolor)); + painter->drawLine( QPointF( 4, 6 ), QPointF( 14, 6 ) ); + painter->setBrush(QBrush(mycolor)); + painter->drawEllipse( QRectF( 8, 10, 2, 2 ) ); } break; @@ -2306,30 +3660,37 @@ namespace Breeze case DecorationButtonType::KeepBelow: { - QColor button_color = QColor(255, 137, 241); + QColor button_color = symbolColor; if ( !isChecked() ) button_color.setAlpha( button_color.alpha()*m_opacity ); painter->setPen( Qt::NoPen ); painter->setBrush( button_color ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); QColor mycolor = symbolColor; - if ( !isChecked() ) - mycolor = this->mixColors(button_color.darker (100), symbolColor, m_opacity); - painter->setPen( Qt::NoPen ); - - // it's a downward pointing triangle - QPainterPath path; - path.moveTo(9, 12); - path.lineTo(5, 6); - path.lineTo(13, 6); - painter->fillPath(path, QBrush(mycolor)); + if ( isChecked() && !isHovered() ) + mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); + else + mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 7 ), + QPointF( 9, 12 ), + QPointF( 14, 7 ) }); break; @@ -2337,55 +3698,44 @@ namespace Breeze case DecorationButtonType::KeepAbove: { - QColor button_color = QColor(135, 206, 249); + QColor button_color = symbolColor; if ( !isChecked() ) button_color.setAlpha( button_color.alpha()*m_opacity ); painter->setPen( Qt::NoPen ); painter->setBrush( button_color ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); button_color.setAlpha( 255 ); + symbolBgdColor.setAlpha( 255 ); QColor mycolor = symbolColor; - if ( !isChecked() ) - mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); - painter->setPen( Qt::NoPen ); - - // it's a upward pointing triangle - QPainterPath path; - path.moveTo(9, 6); - path.lineTo(5, 12); - path.lineTo(13, 12); - painter->fillPath(path, QBrush(mycolor)); + if ( isChecked() && !isHovered() ) + mycolor = this->mixColors(symbolBgdColor, button_color, m_opacity); + else + mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); + symbol_pen.setColor(mycolor); + painter->setPen( symbol_pen ); + painter->drawPolyline( QVector{ + QPointF( 4, 11 ), + QPointF( 9, 6 ), + QPointF( 14, 11 )}); break; } case DecorationButtonType::ApplicationMenu: { - QColor menuSymbolColor; - - uint r = qRed(titleBarColor.rgb()); - uint g = qGreen(titleBarColor.rgb()); - uint b = qBlue(titleBarColor.rgb()); - // modified from https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color - // qreal titleBarLuminance = (0.2126 * static_cast(r) + 0.7152 * static_cast(g) + 0.0722 * static_cast(b)) / 255.; - // if ( titleBarLuminance > sqrt(1.05 * 0.05) - 0.05 ) - qreal colorConditional = 0.299 * static_cast(r) + 0.587 * static_cast(g) + 0.114 * static_cast(b); - if ( colorConditional > 186 || g > 186 ) - menuSymbolColor = darkSymbolColor; - else - menuSymbolColor = lightSymbolColor; - - QPen menuSymbol_pen( menuSymbolColor ); - menuSymbol_pen.setJoinStyle( Qt::MiterJoin ); - menuSymbol_pen.setWidthF( 1.7*qMax((qreal)1.0, 20/width ) ); - - painter->setPen( menuSymbol_pen ); + painter->setPen( symbol_pen ); painter->drawLine( QPointF( 3.5, 5 ), QPointF( 14.5, 5 ) ); painter->drawLine( QPointF( 3.5, 9 ), QPointF( 14.5, 9 ) ); @@ -2396,28 +3746,38 @@ namespace Breeze case DecorationButtonType::ContextHelp: { - QColor button_color =QColor(102, 156, 246); + QColor button_color = symbolColor; button_color.setAlpha( button_color.alpha()*m_opacity ); painter->setPen( Qt::NoPen ); painter->setBrush( button_color ); - qreal r = static_cast(7) - + static_cast(2) * m_animation->currentValue().toReal(); - QPointF c(static_cast(9), static_cast(9)); - painter->drawEllipse( c, r, r ); + if ( !isChecked() ) { + qreal r = static_cast(7) + + static_cast(2) * m_animation->currentValue().toReal(); + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, r, r ); + } + else { + QPointF c(static_cast(9), static_cast(9)); + painter->drawEllipse( c, 9, 9 ); + } painter->setBrush( Qt::NoBrush ); button_color.setAlpha( 255 ); - QColor mycolor = this->mixColors(button_color.darker( 100 ), symbolColor, m_opacity); + symbolBgdColor.setAlpha( 255 ); + QColor mycolor = this->mixColors(button_color, symbolBgdColor, m_opacity); symbol_pen.setColor(mycolor); painter->setPen( symbol_pen ); + // it's a question mark - QPainterPath path; - path.moveTo( 6, 6 ); - path.arcTo( QRectF( 5.5, 4, 7.5, 4.5 ), 180, -180 ); - path.cubicTo( QPointF(11, 9), QPointF( 9, 6 ), QPointF( 9, 10 ) ); - painter->drawPath( path ); - painter->drawPoint( 9, 13 ); + + painter->setPen( symbol_pen ); + int startAngle = 260 * 16; + int spanAngle = 280 * 16; + painter->drawArc( QRectF( 5, 3, 8, 8), startAngle, spanAngle ); + + painter->setBrush(QBrush(symbolColor)); + painter->drawEllipse( QRectF( 8, 14, 2, 2 ) ); break; } diff --git a/breezebutton.h b/breezebutton.h index 843e5eb..25d7684 100644 --- a/breezebutton.h +++ b/breezebutton.h @@ -112,13 +112,16 @@ namespace Breeze explicit Button(KDecoration2::DecorationButtonType type, Decoration *decoration, QObject *parent = nullptr); //* draw button icon - void drawIconSBEstyle( QPainter *) const; - void drawIconPlasmaStyle( QPainter *) const; - void drawIconGnomeStyle( QPainter *) const; - void drawIconMacStyle( QPainter *) const; - void drawIconDarkAuroraeStyle( QPainter *) const; - void drawIconSymbolStyle( QPainter *) const; - void drawIconSymbolStyleMono( QPainter *) const; + void drawIconPlasma( QPainter *) const; + void drawIconGnome( QPainter *) const; + void drawIconMacSierra( QPainter *) const; + void drawIconMacDarkAurorae( QPainter *) const; + void drawIconSBEsierra( QPainter *) const; + void drawIconSBEdarkAurorae( QPainter *) const; + void drawIconSierraColorSymbols( QPainter *) const; + void drawIconDarkAuroraeColorSymbols( QPainter *) const; + void drawIconSierraMonochromeSymbols( QPainter *) const; + void drawIconDarkAuroraeMonochromeSymbols( QPainter *) const; //*@name colors //@{ diff --git a/breezesettingsdata.kcfg b/breezesettingsdata.kcfg index 7d5aebd..2567574 100644 --- a/breezesettingsdata.kcfg +++ b/breezesettingsdata.kcfg @@ -130,17 +130,22 @@ - - - - - - - - - + + + + + + + + + + + + + + - SBEstyle + macDarkAurorae diff --git a/config/ui/breezeconfigurationui.ui b/config/ui/breezeconfigurationui.ui index dd986d2..3886ce9 100644 --- a/config/ui/breezeconfigurationui.ui +++ b/config/ui/breezeconfigurationui.ui @@ -37,57 +37,72 @@ - SBE Style + Plasma - Active SBE + Gnome - Inactive SBE + mac Sierra - Plasma Style + mac Dark Aurorae - Gnome Style + SBE Sierra - macOS Style + SBE Sierra Active - Dark Aurorae Style + SBE Sierra Inactive - Active Dark Aurorae + SBE Dark Aurorae - Inactive Dark Aurorae + SBE Dark Aurorae Active + + + SBE Dark Aurorae Inactive + + - Symbol Style (Color) + Sierra Color Symbols - Symbol Style (Monochrome) + Dark Aurorae Color Symbols + + + + + Sierra Monochrome Symbols + + + + + Dark Aurorae Monochrome Symbols