diff --git a/kdecoration/breezebutton.cpp b/kdecoration/breezebutton.cpp --- a/kdecoration/breezebutton.cpp +++ b/kdecoration/breezebutton.cpp @@ -1,6 +1,7 @@ /* * Copyright 2014 Martin Gräßlin * Copyright 2014 Hugo Pereira Da Costa + * Copyright 2020 Paul McAuley * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -19,6 +20,7 @@ * along with this program. If not, see . */ #include "breezebutton.h" +#include "breezerenderdecorationbuttonicon.h" #include #include @@ -188,112 +190,48 @@ // setup painter QPen pen( foregroundColor ); - pen.setCapStyle( Qt::RoundCap ); - pen.setJoinStyle( Qt::MiterJoin ); pen.setWidthF( PenWidth::Symbol*qMax((qreal)1.0, 20/width ) ); - painter->setPen( pen ); - painter->setBrush( Qt::NoBrush ); + auto d = qobject_cast( decoration() ); + + std::unique_ptr iconRenderer; + if (d) iconRenderer = RenderDecorationButtonIcon18By18::factory( painter, pen, d->internalSettings()->buttonIconStyle(), false ); + else iconRenderer = RenderDecorationButtonIcon18By18::factory( painter, pen ); switch( type() ) { case DecorationButtonType::Close: { - painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); - painter->drawLine( 13, 5, 5, 13 ); + iconRenderer->renderCloseIcon(); break; } case DecorationButtonType::Maximize: { - if( isChecked() ) - { - pen.setJoinStyle( Qt::RoundJoin ); - painter->setPen( pen ); - - painter->drawPolygon( QVector{ - QPointF( 4, 9 ), - QPointF( 9, 4 ), - QPointF( 14, 9 ), - QPointF( 9, 14 )} ); - - } else { - painter->drawPolyline( QVector{ - QPointF( 4, 11 ), - QPointF( 9, 6 ), - QPointF( 14, 11 )}); - } + if( isChecked() ) iconRenderer->renderRestoreIcon(); + else iconRenderer->renderMaximizeIcon(); break; } case DecorationButtonType::Minimize: { - painter->drawPolyline( QVector{ - QPointF( 4, 7 ), - QPointF( 9, 12 ), - QPointF( 14, 7 ) }); + iconRenderer->renderMinimizeIcon(); break; } case DecorationButtonType::OnAllDesktops: { - 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 ) ); - } + if( isChecked()) iconRenderer->renderPinnedOnAllDesktopsIcon(); + else iconRenderer->renderPinOnAllDesktopsIcon(); break; } case DecorationButtonType::Shade: { - if (isChecked()) - { - - painter->drawLine( QPointF( 4, 5.5 ), QPointF( 14, 5.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->drawPolyline( QVector { - QPointF( 4, 13 ), - QPointF( 9, 8 ), - QPointF( 14, 13 ) }); - } - + if (isChecked()) iconRenderer->renderUnShadeIcon(); + else iconRenderer->renderShadeIcon(); break; } @@ -301,52 +239,27 @@ case DecorationButtonType::KeepBelow: { - painter->drawPolyline( QVector { - QPointF( 4, 5 ), - QPointF( 9, 10 ), - QPointF( 14, 5 ) }); - - painter->drawPolyline( QVector { - QPointF( 4, 9 ), - QPointF( 9, 14 ), - QPointF( 14, 9 ) }); + iconRenderer->renderKeepBehindIcon(); break; } case DecorationButtonType::KeepAbove: { - painter->drawPolyline( QVector { - QPointF( 4, 9 ), - QPointF( 9, 4 ), - QPointF( 14, 9 ) }); - - painter->drawPolyline( QVector { - QPointF( 4, 13 ), - QPointF( 9, 8 ), - QPointF( 14, 13 ) }); + iconRenderer->renderKeepInFrontIcon(); break; } case DecorationButtonType::ApplicationMenu: { - painter->drawRect( QRectF( 3.5, 4.5, 11, 1 ) ); - painter->drawRect( QRectF( 3.5, 8.5, 11, 1 ) ); - painter->drawRect( QRectF( 3.5, 12.5, 11, 1 ) ); + iconRenderer->renderApplicationMenuIcon(); break; } 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 ); - - painter->drawRect( QRectF( 9, 15, 0.5, 0.5 ) ); - + iconRenderer->renderContextHelpIcon(); break; } diff --git a/kdecoration/breezesettingsdata.kcfg b/kdecoration/breezesettingsdata.kcfg --- a/kdecoration/breezesettingsdata.kcfg +++ b/kdecoration/breezesettingsdata.kcfg @@ -34,6 +34,16 @@ true + + + + + + + + + StyleOxygen + diff --git a/kdecoration/config/breezeconfigwidget.cpp b/kdecoration/config/breezeconfigwidget.cpp --- a/kdecoration/config/breezeconfigwidget.cpp +++ b/kdecoration/config/breezeconfigwidget.cpp @@ -47,6 +47,7 @@ // track ui changes connect( m_ui.titleAlignment, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); + connect( m_ui.buttonIconStyle, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); connect( m_ui.buttonSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) ); connect( m_ui.outlineCloseButton, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged ); connect( m_ui.drawBorderOnMaximizedWindows, &QAbstractButton::clicked, this, &ConfigWidget::updateChanged ); @@ -78,6 +79,7 @@ // assign to ui m_ui.titleAlignment->setCurrentIndex( m_internalSettings->titleAlignment() ); + m_ui.buttonIconStyle->setCurrentIndex( m_internalSettings->buttonIconStyle() ); m_ui.buttonSize->setCurrentIndex( m_internalSettings->buttonSize() ); m_ui.drawBorderOnMaximizedWindows->setChecked( m_internalSettings->drawBorderOnMaximizedWindows() ); m_ui.outlineCloseButton->setChecked( m_internalSettings->outlineCloseButton() ); @@ -112,6 +114,7 @@ // apply modifications from ui m_internalSettings->setTitleAlignment( m_ui.titleAlignment->currentIndex() ); + m_internalSettings->setButtonIconStyle( m_ui.buttonIconStyle->currentIndex() ); m_internalSettings->setButtonSize( m_ui.buttonSize->currentIndex() ); m_internalSettings->setOutlineCloseButton( m_ui.outlineCloseButton->isChecked() ); m_internalSettings->setDrawBorderOnMaximizedWindows( m_ui.drawBorderOnMaximizedWindows->isChecked() ); @@ -160,7 +163,9 @@ // assign to ui m_ui.titleAlignment->setCurrentIndex( m_internalSettings->titleAlignment() ); + m_ui.buttonIconStyle->setCurrentIndex( m_internalSettings->buttonIconStyle() ); m_ui.buttonSize->setCurrentIndex( m_internalSettings->buttonSize() ); + m_ui.outlineCloseButton->setChecked( m_internalSettings->outlineCloseButton() ); m_ui.drawBorderOnMaximizedWindows->setChecked( m_internalSettings->drawBorderOnMaximizedWindows() ); m_ui.drawSizeGrip->setChecked( m_internalSettings->drawSizeGrip() ); m_ui.drawBackgroundGradient->setChecked( m_internalSettings->drawBackgroundGradient() ); @@ -186,6 +191,7 @@ if (m_ui.drawTitleBarSeparator->isChecked() != m_internalSettings->drawTitleBarSeparator()) modified = true; if( m_ui.titleAlignment->currentIndex() != m_internalSettings->titleAlignment() ) modified = true; + else if( m_ui.buttonIconStyle->currentIndex() != m_internalSettings->buttonIconStyle() ) modified = true; else if( m_ui.buttonSize->currentIndex() != m_internalSettings->buttonSize() ) modified = true; else if( m_ui.outlineCloseButton->isChecked() != m_internalSettings->outlineCloseButton() ) modified = true; else if( m_ui.drawBorderOnMaximizedWindows->isChecked() != m_internalSettings->drawBorderOnMaximizedWindows() ) modified = true; diff --git a/kdecoration/config/ui/breezeconfigurationui.ui b/kdecoration/config/ui/breezeconfigurationui.ui --- a/kdecoration/config/ui/breezeconfigurationui.ui +++ b/kdecoration/config/ui/breezeconfigurationui.ui @@ -37,7 +37,7 @@ - + B&utton size: @@ -50,7 +50,7 @@ - + @@ -116,7 +116,39 @@ - + + + + Button icon st&yle: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + buttonIconStyle + + + + + + + + Classic + + + + + Oxygen + + + + + Redmond + + + + + Qt::Vertical @@ -129,35 +161,35 @@ - + Add handle to resize windows with no border - + Draw separator between titlebar and window - + Allow resizing maximized windows from window edges - + Draw a circle around close button - + Draw titlebar background gradient diff --git a/kstyle/breeze.kcfg b/kstyle/breeze.kcfg --- a/kstyle/breeze.kcfg +++ b/kstyle/breeze.kcfg @@ -35,6 +35,16 @@ true + + + + + + + + + StyleOxygen + diff --git a/kstyle/breezehelper.cpp b/kstyle/breezehelper.cpp --- a/kstyle/breezehelper.cpp +++ b/kstyle/breezehelper.cpp @@ -21,6 +21,7 @@ #include "breeze.h" #include "breezestyleconfigdata.h" +#include "breezerenderdecorationbuttonicon.h" #include #include @@ -1359,48 +1360,34 @@ } - pen.setCapStyle( Qt::RoundCap ); - pen.setJoinStyle( Qt::MiterJoin ); pen.setWidthF( PenWidth::Symbol*qMax(1.0, 18.0/rect.width() ) ); - painter->setPen( pen ); - + + std::unique_ptr iconRenderer; + iconRenderer = RenderDecorationButtonIcon18By18::factory( painter, pen, StyleConfigData::buttonIconStyle(), true ); + switch( buttonType ) { case ButtonClose: { - painter->drawLine( QPointF( 5, 5 ), QPointF( 13, 13 ) ); - painter->drawLine( 13, 5, 5, 13 ); + iconRenderer->renderCloseIcon(); break; } case ButtonMaximize: { - painter->drawPolyline( QVector{ - QPointF( 4, 11 ), - QPointF( 9, 6 ), - QPointF( 14, 11 )}); + iconRenderer->renderMaximizeIcon(); break; } case ButtonMinimize: { - - painter->drawPolyline(QVector{ - QPointF( 4, 7 ), - QPointF( 9, 12 ), - QPointF( 14, 7 )} ); + iconRenderer->renderMinimizeIcon(); break; } case ButtonRestore: { - pen.setJoinStyle( Qt::RoundJoin ); - painter->setPen( pen ); - painter->drawPolygon( QVector{ - QPointF( 4.5, 9 ), - QPointF( 9, 4.5 ), - QPointF( 13.5, 9 ), - QPointF( 9, 13.5 )}); + iconRenderer->renderRestoreIcon(); break; } diff --git a/libbreezecommon/CMakeLists.txt b/libbreezecommon/CMakeLists.txt --- a/libbreezecommon/CMakeLists.txt +++ b/libbreezecommon/CMakeLists.txt @@ -5,6 +5,10 @@ ################# breezestyle target ################# set(breezecommon_LIB_SRCS breezeboxshadowrenderer.cpp + breezerenderdecorationbuttonicon.cpp + breezestyleclassic.cpp + breezestyleoxygen.cpp + breezestyleredmond.cpp ) add_library(breezecommon5 ${breezecommon_LIB_SRCS}) diff --git a/libbreezecommon/breezerenderdecorationbuttonicon.h b/libbreezecommon/breezerenderdecorationbuttonicon.h new file mode 100755 --- /dev/null +++ b/libbreezecommon/breezerenderdecorationbuttonicon.h @@ -0,0 +1,101 @@ +#ifndef BREEZE_RENDERDECORATIONBUTTONICON_H +#define BREEZE_RENDERDECORATIONBUTTONICON_H + +/* + * Copyright 2020 Paul McAuley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "breezecommon_export.h" + +#include +#include + +namespace Breeze +{ + + /** + * @brief Base Class to render decoration button icons in style set by EnumButtonIconStyle. + * Rendering is to be performed on a QPainter object with an 18x18 reference window. + * Co-ordinates relative to top-left. + * To be used as common code base across both kdecoration and kstyle. + */ + class BREEZECOMMON_EXPORT RenderDecorationButtonIcon18By18 + { + + public: + + /** + * @brief Button Icon styles as defined in the .kcfg files. + */ + enum EnumButtonIconStyle { StyleClassic, StyleOxygen, StyleRedmond }; + + + /** + * @brief Factory to return a pointer to a new inherited object to render in the specified style. + * + * @param painter A QPainter object already initialised with an 18x18 reference window. + * @param pen QPen with width and color already initialized. + * @param buttonIconStyle The desired icon style as equivalent to type EnumButtonIconStyle. + * @param notInTitlebar Indicates that button is not to be drawn in the title bar, but somewhere else in the UI -- ususally means will be smaller + * @return std::unique_ptr< Breeze::RenderDecorationButtonIcon18By18, std::default_delete< Breeze::RenderDecorationButtonIcon18By18 > > Pointer to a new sub-style object. + */ + static std::unique_ptr factory( QPainter* painter, const QPen& pen, int buttonIconStyle = int(StyleOxygen), const bool notInTitlebar = false); + + virtual ~RenderDecorationButtonIcon18By18(){}; + + virtual void renderCloseIcon(); + virtual void renderMaximizeIcon(); + virtual void renderRestoreIcon(); + virtual void renderMinimizeIcon(); + virtual void renderPinnedOnAllDesktopsIcon(); + virtual void renderPinOnAllDesktopsIcon(); + virtual void renderShadeIcon(); + virtual void renderUnShadeIcon(); + virtual void renderKeepBehindIcon(); + virtual void renderKeepInFrontIcon(); + virtual void renderApplicationMenuIcon(); + virtual void renderContextHelpIcon(); + + protected: + + /** + * @brief Constructor + * + * @param painter A QPainter object already initialised with an 18x18 reference window. + * @param pen QPen with width and color already initialised. + * @param notInTitlebar Indicates that button is not to be drawn in the title bar, but somewhere else in the UI -- ususally means will be smaller + */ + RenderDecorationButtonIcon18By18( QPainter* painter, const QPen& pen, const bool notInTitlebar); + + + /** + * @brief Initialises pen to standardise cap and join styles. + * No brush is normal for Breeze's simple outline style. + */ + virtual void initPainter(); + + QPainter* painter; + QPen pen; + bool notInTitlebar; + + }; + +} + +#endif diff --git a/libbreezecommon/breezerenderdecorationbuttonicon.cpp b/libbreezecommon/breezerenderdecorationbuttonicon.cpp new file mode 100755 --- /dev/null +++ b/libbreezecommon/breezerenderdecorationbuttonicon.cpp @@ -0,0 +1,202 @@ +/* + * Copyright 2020 Paul McAuley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "breezerenderdecorationbuttonicon.h" +#include "breezestyleclassic.h" +#include "breezestyleoxygen.h" +#include "breezestyleredmond.h" + +namespace Breeze +{ + + std::unique_ptr RenderDecorationButtonIcon18By18::factory( QPainter* painter, const QPen& pen, int buttonIconStyle, const bool notInTitlebar) + { + switch( EnumButtonIconStyle(buttonIconStyle) ) + { + case StyleClassic: + return std::unique_ptr( new RenderStyleClassic18By18(painter, pen, notInTitlebar) ); + case StyleOxygen: + default: + return std::unique_ptr( new RenderStyleOxygen18By18(painter, pen, notInTitlebar) ); + case StyleRedmond: + return std::unique_ptr( new RenderStyleRedmond18By18(painter, pen, notInTitlebar) ); + } + } + + + + RenderDecorationButtonIcon18By18::RenderDecorationButtonIcon18By18( QPainter* painter, const QPen& pen, const bool notInTitlebar ) + { + this->painter = painter; + this->pen = pen; + this->notInTitlebar = notInTitlebar; + + initPainter(); + } + + + + void RenderDecorationButtonIcon18By18::initPainter() + { + pen.setCapStyle( Qt::RoundCap ); + pen.setJoinStyle( Qt::MiterJoin ); + painter->setPen( pen ); + painter->setBrush( Qt::NoBrush ); + } + + + /* base methods are based on Oxygen style -- override with other styles */ + void RenderDecorationButtonIcon18By18::renderCloseIcon() + { + painter->drawLine( 5, 5, 13, 13 ); + painter->drawLine( 13, 5, 5, 13 ); + } + + void RenderDecorationButtonIcon18By18::renderMaximizeIcon() + { + //up arrow + painter->drawPolyline( QVector{ + QPointF( 4, 11 ), + QPointF( 9, 6 ), + QPointF( 14, 11 )} ); + } + + void RenderDecorationButtonIcon18By18::renderRestoreIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + if (this->notInTitlebar) { // slightly smaller diamond + + //diamond / floating kite + painter->drawConvexPolygon( QVector{ + QPointF( 4.5, 9 ), + QPointF( 9, 4.5 ), + QPointF( 13.5, 9 ), + QPointF( 9, 13.5 )}); + + } else { + + //diamond / floating kite + painter->drawConvexPolygon( QVector{ + QPointF( 4, 9 ), + QPointF( 9, 4 ), + QPointF( 14, 9 ), + QPointF( 9, 14 )} ); + } + } + + void RenderDecorationButtonIcon18By18::renderMinimizeIcon() + { + //down arrow + painter->drawPolyline( QVector{ + QPointF( 4, 7 ), + QPointF( 9, 12 ), + QPointF( 14, 7 )} ); + } + + void RenderDecorationButtonIcon18By18::renderPinnedOnAllDesktopsIcon() + { + // thick hollow ring + pen.setWidthF(5); + painter->setPen( pen ); + painter->drawEllipse( QPointF( 9, 9 ), qreal(3.5), qreal(3.5) ); + } + + void RenderDecorationButtonIcon18By18::renderPinOnAllDesktopsIcon() + { + painter->setBrush( pen.color() ); + painter->setPen( Qt::NoPen ); + painter->drawConvexPolygon( 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 ) ); + } + + void RenderDecorationButtonIcon18By18::renderShadeIcon() + { + painter->drawLine( QPointF( 4, 4.5 ), QPointF( 14, 4.5 ) ); + painter->drawPolyline( QVector{ + QPointF( 4, 13 ), + QPointF( 9, 8 ), + QPointF( 14, 13 )} ); + } + + void RenderDecorationButtonIcon18By18::renderUnShadeIcon() + { + painter->drawLine( QPointF( 4, 4.5 ), QPointF( 14, 4.5 ) ); + painter->drawPolyline( QVector{ + QPointF( 4, 8 ), + QPointF( 9, 13 ), + QPointF( 14, 8 )} ); + } + + void RenderDecorationButtonIcon18By18::renderKeepBehindIcon() + { + //two down arrows + painter->drawPolyline( QVector{ + QPointF( 4, 5 ), + QPointF( 9, 10 ), + QPointF( 14, 5 )} ); + + painter->drawPolyline( QVector{ + QPointF( 4, 9 ), + QPointF( 9, 14 ), + QPointF( 14, 9 )} ); + } + + void RenderDecorationButtonIcon18By18::renderKeepInFrontIcon() + { + //two up arrows + painter->drawPolyline( QVector{ + QPointF( 4, 9 ), + QPointF( 9, 4 ), + QPointF( 14, 9 )} ); + + painter->drawPolyline( QVector{ + QPointF( 4, 13 ), + QPointF( 9, 8 ), + QPointF( 14, 13 )} ); + } + + void RenderDecorationButtonIcon18By18::renderApplicationMenuIcon() + { + painter->drawRect( QRectF( 3.5, 4.5, 11, 1 ) ); + painter->drawRect( QRectF( 3.5, 8.5, 11, 1 ) ); + painter->drawRect( QRectF( 3.5, 12.5, 11, 1 ) ); + } + + void RenderDecorationButtonIcon18By18::renderContextHelpIcon() + { + 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 ) ); + } + +} diff --git a/libbreezecommon/breezestyleclassic.h b/libbreezecommon/breezestyleclassic.h new file mode 100755 --- /dev/null +++ b/libbreezecommon/breezestyleclassic.h @@ -0,0 +1,53 @@ +#ifndef BREEZE_STYLECLASSIC_H +#define BREEZE_STYLECLASSIC_H + +/* + * Copyright 2020 Paul McAuley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "breezerenderdecorationbuttonicon.h" + +#include + +namespace Breeze +{ + + class RenderStyleClassic18By18 : public RenderDecorationButtonIcon18By18 + { + public: + /** + * @brief Constructor - calls constructor of base class + * + * @param painter A QPainter object already initialised with an 18x18 reference window. + * @param pen QPen with width and color already initialised. + * @param notInTitlebar Indicates that button is not to be drawn in the title bar, but somewhere else in the UI -- ususally means will be smaller + */ + RenderStyleClassic18By18(QPainter* painter, const QPen& pen, const bool notInTitlebar) : RenderDecorationButtonIcon18By18(painter, pen, notInTitlebar){}; + + void renderCloseIcon() override; + void renderMaximizeIcon() override; + void renderRestoreIcon() override; + void renderMinimizeIcon() override; + void renderKeepBehindIcon() override; + void renderKeepInFrontIcon() override; + }; + +} + +#endif diff --git a/libbreezecommon/breezestyleclassic.cpp b/libbreezecommon/breezestyleclassic.cpp new file mode 100755 --- /dev/null +++ b/libbreezecommon/breezestyleclassic.cpp @@ -0,0 +1,229 @@ +/* + * Copyright 2020 Paul McAuley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "breezestyleclassic.h" + +namespace Breeze +{ + void RenderStyleClassic18By18::renderCloseIcon() + { + // slightly larger X to tie-in with design of square maximize button + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 13.5 ) ); + painter->drawLine( QPointF(13.5, 4.5), QPointF(4.5, 13.5) ); + } + + void RenderStyleClassic18By18::renderMaximizeIcon() + { + //large square + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + painter->drawRect( QRectF( QPointF( 4.5, 4.5 ), QPointF( 13.5, 13.5 ) ) ); + } + + void RenderStyleClassic18By18::renderRestoreIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + if(this->notInTitlebar){ + //disable antialiasing to remove blur at small sizes + painter->setRenderHints( QPainter::Antialiasing, false ); + + //overlapping windows icon + painter->drawRect( QRectF( QPointF( 4, 6 ), QPointF( 11, 13 ) ) ); + painter->drawPolyline( QVector{ + QPointF( 6, 6 ), + QPointF( 6, 4 ), + QPointF( 13, 4 ), + QPointF( 13, 11 ), + QPointF( 11, 11 )} ); + + } else { + + //overlapping windows icon + painter->drawRect( QRectF( QPointF( 4.5, 6.5 ), QPointF( 11.5, 13.5 ) ) ); + painter->drawPolyline( QVector{ + QPointF( 6.5, 6.5 ), + QPointF( 6.5, 4.5 ), + QPointF( 13.5, 4.5 ), + QPointF( 13.5, 11.5 ), + QPointF( 11.5, 11.5 )} ); + } + } + + void RenderStyleClassic18By18::renderMinimizeIcon() + { + //tiny filled square + pen.setJoinStyle( Qt::RoundJoin ); + painter->setBrush( pen.color() ); + painter->setPen( pen ); + + painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 10.5, 10.5 ) ) ); + } + + +/*//Experimental 3 squares + void RenderStyleClassic18By18::renderKeepBehindIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + //foreground squares + painter->drawRect( QRectF( QPointF( 3.5, 3.5 ), QPointF( 8.5, 8.5 ) ) ); + painter->drawRect( QRectF( QPointF( 9.5, 9.5 ), QPointF( 14.5, 14.5 ) ) ); + + //filled background square + painter->setBrush( pen.color() ); + painter->drawPolygon( QPolygonF() + << QPointF( 8.5, 5.5 ) + << QPointF( 12.5, 5.5 ) + << QPointF( 12.5, 9.5 ) + << QPointF( 9.5, 9.5 ) + << QPointF( 9.5, 12.5 ) + << QPointF( 5.5, 12.5 ) + << QPointF( 5.5, 8.5 ) + << QPointF( 8.5, 8.5 ) + ); + } + + void RenderStyleClassic18By18::renderKeepInFrontIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + //background squares + painter->drawRect( QRectF( QPointF( 3.5, 3.5 ), QPointF( 8.5, 8.5 ) ) ); + painter->drawRect( QRectF( QPointF( 9.5, 9.5 ), QPointF( 14.5, 14.5 ) ) ); + + //filled foreground square + painter->setBrush( pen.color() ); + painter->drawRect( QRectF( QPointF( 5.5, 5.5 ), QPointF( 12.5, 12.5 ) ) ); + } +*/ + +/*//Experimental 2 squares + void RenderStyleClassic18By18::renderKeepBehindIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + //foreground square + painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 13.5, 13.5 ) ) ); + + //filled background square + painter->setBrush( pen.color() ); + painter->drawPolygon( QPolygonF() + << QPointF( 4.5, 4.5 ) + << QPointF( 10.5, 4.5 ) + << QPointF( 10.5, 7.5 ) + << QPointF( 7.5, 7.5 ) + << QPointF( 7.5, 10.5 ) + << QPointF( 4.5, 10.5 ) + ); + + } + + void RenderStyleClassic18By18::renderKeepInFrontIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + //background square + painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 13.5, 13.5 ) ) ); + + //filled foreground square + painter->setBrush( pen.color() ); + painter->drawRect( QRectF( QPointF( 4.5, 4.5 ), QPointF( 10.5, 10.5 ) ) ); + } +*/ + +/* //Experimental filled arrows + void RenderStyleClassic18By18::renderKeepBehindIcon() + { + //horizontal lines + painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) ); + painter->drawLine( QPointF( 9.5, 9.5 ), QPointF( 13.5, 9.5 ) ); + painter->drawLine( QPointF( 9.5, 5.5 ), QPointF( 13.5, 5.5 ) ); + + //arrow + painter->drawLine( QPointF( 4.5, 3.5 ), QPointF( 4.5, 11.5 ) ); + + painter->setBrush( pen.color() ); + painter->drawConvexPolygon( QPolygonF() + << QPointF( 2.5, 8.5 ) + << QPointF( 4.5, 11.5 ) + << QPointF( 6.5, 8.5 ) ); + } + + void RenderStyleClassic18By18::renderKeepInFrontIcon() + { + //horizontal lines + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) ); + painter->drawLine( QPointF( 4.5, 8.5 ), QPointF( 8.5, 8.5 ) ); + painter->drawLine( QPointF( 4.5, 12.5 ), QPointF( 8.5, 12.5 ) ); + + //arrow + painter->drawLine( QPointF( 13.5, 6.5 ), QPointF( 13.5, 14.5 ) ); + + painter->setBrush( pen.color() ); + painter->drawConvexPolygon( QPolygonF() + << QPointF( 11.5, 9.5 ) + << QPointF( 13.5, 6.5 ) + << QPointF( 15.5, 9.5 ) ); + } +*/ + +// For consistency with breeze icon set + void RenderStyleClassic18By18::renderKeepBehindIcon() + { + //horizontal lines + painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) ); + painter->drawLine( QPointF( 9.5, 9.5 ), QPointF( 13.5, 9.5 ) ); + painter->drawLine( QPointF( 9.5, 5.5 ), QPointF( 13.5, 5.5 ) ); + + //arrow + painter->drawLine( QPointF( 4.5, 3.5 ), QPointF( 4.5, 11.5 ) ); + + painter->drawPolyline( QVector{ + QPointF( 2.5, 9.5 ), + QPointF( 4.5, 11.5 ), + QPointF( 6.5, 9.5 )} ); + } + + void RenderStyleClassic18By18::renderKeepInFrontIcon() + { + //horizontal lines + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) ); + painter->drawLine( QPointF( 4.5, 8.5 ), QPointF( 8.5, 8.5 ) ); + painter->drawLine( QPointF( 4.5, 12.5 ), QPointF( 8.5, 12.5 ) ); + + //arrow + painter->drawLine( QPointF( 13.5, 6.5 ), QPointF( 13.5, 14.5 ) ); + + painter->drawPolyline( QVector{ + QPointF( 11.5, 8.5 ), + QPointF( 13.5, 6.5 ), + QPointF( 15.5, 8.5 )} ); + } + + + +} diff --git a/libbreezecommon/breezestyleoxygen.h b/libbreezecommon/breezestyleoxygen.h new file mode 100755 --- /dev/null +++ b/libbreezecommon/breezestyleoxygen.h @@ -0,0 +1,46 @@ +#ifndef BREEZE_STYLEOXYGEN_H +#define BREEZE_STYLEOXYGEN_H + +/* + * Copyright 2017 Paul McAuley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "breezerenderdecorationbuttonicon.h" + +#include + +namespace Breeze +{ + + class RenderStyleOxygen18By18 : public RenderDecorationButtonIcon18By18 + { + public: + /** + * @brief Constructor - calls constructor of base class + * + * @param painter A QPainter object already initialised with an 18x18 reference window. + * @param pen QPen with width and color already initialised. + * @param notInTitlebar Indicates that button is not to be drawn in the title bar, but somewhere else in the UI -- ususally means will be smaller + */ + RenderStyleOxygen18By18(QPainter* painter, const QPen& pen, const bool notInTitlebar) : RenderDecorationButtonIcon18By18(painter, pen, notInTitlebar){}; + }; + +} + +#endif diff --git a/libbreezecommon/breezestyleoxygen.cpp b/libbreezecommon/breezestyleoxygen.cpp new file mode 100755 --- /dev/null +++ b/libbreezecommon/breezestyleoxygen.cpp @@ -0,0 +1,26 @@ +/* + * Copyright 2017 Paul McAuley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "breezestyleoxygen.h" + +namespace Breeze +{ + +} diff --git a/libbreezecommon/breezestyleredmond.h b/libbreezecommon/breezestyleredmond.h new file mode 100755 --- /dev/null +++ b/libbreezecommon/breezestyleredmond.h @@ -0,0 +1,53 @@ +#ifndef BREEZE_STYLEREDMOND_H +#define BREEZE_STYLEREDMOND_H + +/* + * Copyright 2017 Paul McAuley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "breezerenderdecorationbuttonicon.h" + +#include + +namespace Breeze +{ + + class RenderStyleRedmond18By18 : public RenderDecorationButtonIcon18By18 + { + public: + /** + * @brief Constructor - calls constructor of base class + * + * @param painter A QPainter object already initialised with an 18x18 reference window. + * @param pen QPen with width and color already initialised. + * @param notInTitlebar Indicates that button is not to be drawn in the title bar, but somewhere else in the UI -- ususally means will be smaller + */ + RenderStyleRedmond18By18(QPainter* painter, const QPen& pen, const bool notInTitlebar) : RenderDecorationButtonIcon18By18(painter, pen, notInTitlebar){}; + + void renderCloseIcon() override; + void renderMaximizeIcon() override; + void renderRestoreIcon() override; + void renderMinimizeIcon() override; + void renderKeepBehindIcon() override; + void renderKeepInFrontIcon() override; + }; + +} + +#endif diff --git a/libbreezecommon/breezestyleredmond.cpp b/libbreezecommon/breezestyleredmond.cpp new file mode 100755 --- /dev/null +++ b/libbreezecommon/breezestyleredmond.cpp @@ -0,0 +1,188 @@ +/* + * Copyright 2020 Paul McAuley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "breezestyleredmond.h" + +namespace Breeze +{ + void RenderStyleRedmond18By18::renderCloseIcon() + { + // slightly larger X to tie-in with design of square maximize button + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 13.5 ) ); + painter->drawLine( QPointF(13.5, 4.5), QPointF(4.5, 13.5) ); + } + + void RenderStyleRedmond18By18::renderMaximizeIcon() + { + //large square + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + painter->drawRect( QRectF( QPointF( 4.5, 4.5 ), QPointF( 13.5, 13.5 ) ) ); + } + + void RenderStyleRedmond18By18::renderRestoreIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + if(this->notInTitlebar){ + //disable antialiasing to remove blur at small sizes + painter->setRenderHints( QPainter::Antialiasing, false ); + + //overlapping windows icon + painter->drawRect( QRectF( QPointF( 4, 6 ), QPointF( 11, 13 ) ) ); + painter->drawPolyline( QVector{ + QPointF( 6, 6 ), + QPointF( 6, 4 ), + QPointF( 13, 4 ), + QPointF( 13, 11 ), + QPointF( 11, 11 )} ); + + } else { + + //overlapping windows icon + painter->drawRect( QRectF( QPointF( 4.5, 6.5 ), QPointF( 11.5, 13.5 ) ) ); + painter->drawPolyline( QVector{ + QPointF( 6.5, 6.5 ), + QPointF( 6.5, 4.5 ), + QPointF( 13.5, 4.5 ), + QPointF( 13.5, 11.5 ), + QPointF( 11.5, 11.5 )} ); + } + } + + void RenderStyleRedmond18By18::renderMinimizeIcon() + { + //horizontal line + painter->drawLine( QPointF( 4.5, 9.5 ), QPointF( 13.5, 9.5 ) ); + + } + + +/*//Experimental 3 squares + void RenderStyleRedmond18By18::renderKeepBehindIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + //foreground squares + painter->drawRect( QRectF( QPointF( 3.5, 3.5 ), QPointF( 8.5, 8.5 ) ) ); + painter->drawRect( QRectF( QPointF( 9.5, 9.5 ), QPointF( 14.5, 14.5 ) ) ); + + //filled background square + painter->setBrush( pen.color() ); + painter->drawPolygon( QPolygonF() + << QPointF( 8.5, 5.5 ) + << QPointF( 12.5, 5.5 ) + << QPointF( 12.5, 9.5 ) + << QPointF( 9.5, 9.5 ) + << QPointF( 9.5, 12.5 ) + << QPointF( 5.5, 12.5 ) + << QPointF( 5.5, 8.5 ) + << QPointF( 8.5, 8.5 ) + ); + } + + void RenderStyleRedmond18By18::renderKeepInFrontIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + //background squares + painter->drawRect( QRectF( QPointF( 3.5, 3.5 ), QPointF( 8.5, 8.5 ) ) ); + painter->drawRect( QRectF( QPointF( 9.5, 9.5 ), QPointF( 14.5, 14.5 ) ) ); + + //filled foreground square + painter->setBrush( pen.color() ); + painter->drawRect( QRectF( QPointF( 5.5, 5.5 ), QPointF( 12.5, 12.5 ) ) ); + } +*/ + +/*//Experimental 2 squares + void RenderStyleRedmond18By18::renderKeepBehindIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + //foreground square + painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 13.5, 13.5 ) ) ); + + //filled background square + painter->setBrush( pen.color() ); + painter->drawPolygon( QPolygonF() + << QPointF( 4.5, 4.5 ) + << QPointF( 10.5, 4.5 ) + << QPointF( 10.5, 7.5 ) + << QPointF( 7.5, 7.5 ) + << QPointF( 7.5, 10.5 ) + << QPointF( 4.5, 10.5 ) + ); + + } + + void RenderStyleRedmond18By18::renderKeepInFrontIcon() + { + pen.setJoinStyle( Qt::RoundJoin ); + painter->setPen( pen ); + + //background square + painter->drawRect( QRectF( QPointF( 7.5, 7.5 ), QPointF( 13.5, 13.5 ) ) ); + + //filled foreground square + painter->setBrush( pen.color() ); + painter->drawRect( QRectF( QPointF( 4.5, 4.5 ), QPointF( 10.5, 10.5 ) ) ); + } +*/ + +// For consistency with breeze icon set + void RenderStyleRedmond18By18::renderKeepBehindIcon() + { + //horizontal lines + painter->drawLine( QPointF( 4.5, 13.5 ), QPointF( 13.5, 13.5 ) ); + painter->drawLine( QPointF( 9.5, 9.5 ), QPointF( 13.5, 9.5 ) ); + painter->drawLine( QPointF( 9.5, 5.5 ), QPointF( 13.5, 5.5 ) ); + + //arrow + painter->drawLine( QPointF( 4.5, 3.5 ), QPointF( 4.5, 11.5 ) ); + + painter->drawPolyline( QVector{ + QPointF( 2.5, 9.5 ), + QPointF( 4.5, 11.5 ), + QPointF( 6.5, 9.5 )} ); + } + + void RenderStyleRedmond18By18::renderKeepInFrontIcon() + { + //horizontal lines + painter->drawLine( QPointF( 4.5, 4.5 ), QPointF( 13.5, 4.5 ) ); + painter->drawLine( QPointF( 4.5, 8.5 ), QPointF( 8.5, 8.5 ) ); + painter->drawLine( QPointF( 4.5, 12.5 ), QPointF( 8.5, 12.5 ) ); + + //arrow + painter->drawLine( QPointF( 13.5, 6.5 ), QPointF( 13.5, 14.5 ) ); + + painter->drawPolyline( QVector{ + QPointF( 11.5, 8.5 ), + QPointF( 13.5, 6.5 ), + QPointF( 15.5, 8.5 )} ); + } + +}