From 56095681ed88f10b290a2027368af18d1eca1c1a Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Sun, 2 May 2010 18:50:01 +0000 Subject: [PATCH] changed helper.h/.cpp into oxygendecohelper.h/.cpp for consistency with classname. svn path=/trunk/KDE/kdebase/workspace/; revision=1121943 --- clients/oxygen/CMakeLists.txt | 4 +- clients/oxygen/helper.cpp | 143 ----------------- clients/oxygen/oxygenbutton.h | 2 +- clients/oxygen/oxygenclient.h | 8 +- clients/oxygen/oxygendecohelper.cpp | 147 ++++++++++++++++++ .../oxygen/{helper.h => oxygendecohelper.h} | 26 ++-- clients/oxygen/oxygenfactory.h | 7 +- clients/oxygen/oxygenshadowcache.cpp | 2 +- clients/oxygen/oxygenshadowcache.h | 13 +- 9 files changed, 179 insertions(+), 173 deletions(-) delete mode 100644 clients/oxygen/helper.cpp create mode 100644 clients/oxygen/oxygendecohelper.cpp rename clients/oxygen/{helper.h => oxygendecohelper.h} (71%) diff --git a/clients/oxygen/CMakeLists.txt b/clients/oxygen/CMakeLists.txt index 7fd5bede73..c8942d10c0 100644 --- a/clients/oxygen/CMakeLists.txt +++ b/clients/oxygen/CMakeLists.txt @@ -5,14 +5,14 @@ include_directories(${KDEBASE_WORKSPACE_SOURCE_DIR}/libs/oxygen) ########### next target ############### set(kwin_oxygen_SRCS - helper.cpp - oxygenfactory.cpp oxygenbutton.cpp oxygenclient.cpp oxygenclientgroupitemdata.cpp oxygenconfiguration.cpp + oxygendecohelper.cpp oxygenexception.cpp oxygenexceptionlist.cpp + oxygenfactory.cpp oxygenshadowconfiguration.cpp oxygenshadowcache.cpp oxygensizegrip.cpp diff --git a/clients/oxygen/helper.cpp b/clients/oxygen/helper.cpp deleted file mode 100644 index b3463982f5..0000000000 --- a/clients/oxygen/helper.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2008 Long Huynh Huu - * Copyright 2007 Matthew Woehlke - * Copyright 2007 Casper Boemann - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "helper.h" - -#include -//______________________________________________________________________________ -OxygenDecoHelper::OxygenDecoHelper(const QByteArray &componentName): -OxygenHelper(componentName) -{} - -//______________________________________________________________________________ -QPixmap OxygenDecoHelper::windecoButton(const QColor &color, bool pressed, int size) -{ - quint64 key = (quint64(color.rgba()) << 32) | (size << 1) | (int)pressed; - QPixmap *pixmap = m_windecoButtonCache.object(key); - - if (!pixmap) - { - pixmap = new QPixmap(size, size); - pixmap->fill(Qt::transparent); - - QColor light = calcLightColor(color); - QColor dark = calcDarkColor(color); - - QPainter p(pixmap); - p.setRenderHints(QPainter::Antialiasing); - p.setPen(Qt::NoPen); - qreal u = size/18.0; - p.translate( 0.5*u, (0.5-0.668)*u ); - - { - //plain background - QLinearGradient lg( 0, u*1.665, 0, u*(12.33+1.665) ); - if( pressed ) - { - lg.setColorAt( 1, light ); - lg.setColorAt( 0, dark ); - } else { - lg.setColorAt( 0, light ); - lg.setColorAt( 1, dark ); - } - - QRectF r( u*0.5*(17-12.33), u*1.665, u*12.33, u*12.33 ); - p.setBrush( lg ); - p.drawEllipse( r ); - } - - { - // outline circle - qreal penWidth = 0.7; - QLinearGradient lg( 0, u*1.665, 0, u*(2.0*12.33+1.665) ); - lg.setColorAt( 0, light ); - lg.setColorAt( 1, dark ); - QRectF r( u*0.5*(17-12.33+penWidth), u*(1.665+penWidth), u*(12.33-penWidth), u*(12.33-penWidth) ); - p.setPen( QPen( lg, penWidth*u ) ); - p.drawEllipse( r ); - p.end(); - } - - m_windecoButtonCache.insert(key, pixmap); - } - - return *pixmap; -} - -//_______________________________________________________________________ -QPixmap OxygenDecoHelper::windecoButtonGlow(const QColor &color, int size) -{ - quint64 key = (quint64(color.rgba()) << 32) | size; - QPixmap *pixmap = m_windecoButtonGlowCache.object(key); - - if (!pixmap) - { - pixmap = new QPixmap(size, size); - pixmap->fill(Qt::transparent); - - // right now the same color is used for the two shadows - QColor light = color; - QColor dark = color; - - QPainter p(pixmap); - p.setRenderHints(QPainter::Antialiasing); - p.setPen(Qt::NoPen); - qreal u = size/18.0; - p.translate( 0.5*u, (0.5-0.668)*u ); - - { - - // outer shadow - QRadialGradient rg( u*8.5, u*8.5, u*8.5 ); - - int nPoints = 5; - qreal x[5] = { 0.61, 0.72, 0.81, 0.9, 1}; - qreal values[5] = { 255-172, 255-178, 255-210, 255-250, 0 }; - QColor c = dark; - for( int i = 0; irect() ); - p.setBrush( rg ); - p.drawRect( r ); - } - - { - // inner shadow - QRadialGradient rg( u*8.5, u*8.5, u*8.5 ); - - static int nPoints = 6; - qreal x[6] = { 0.61, 0.67, 0.7, 0.74, 0.78, 1 }; - qreal values[6] = { 255-92, 255-100, 255-135, 255-205, 255-250, 0 }; - QColor c = light; - for( int i = 0; irect() ); - p.setBrush( rg ); - p.drawRect( r ); - } - - m_windecoButtonGlowCache.insert(key, pixmap); - - } - - return *pixmap; -} diff --git a/clients/oxygen/oxygenbutton.h b/clients/oxygen/oxygenbutton.h index fa9392a823..8b447c248f 100644 --- a/clients/oxygen/oxygenbutton.h +++ b/clients/oxygen/oxygenbutton.h @@ -135,7 +135,7 @@ namespace Oxygen const Client &client_; //! helper - OxygenDecoHelper &helper_; + DecoHelper &helper_; //! button type ButtonType type_; diff --git a/clients/oxygen/oxygenclient.h b/clients/oxygen/oxygenclient.h index 32831b5327..d35dfbc87b 100644 --- a/clients/oxygen/oxygenclient.h +++ b/clients/oxygen/oxygenclient.h @@ -28,12 +28,12 @@ // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// -#include "oxygenfactory.h" +#include "oxygenanimation.h" #include "oxygenclientgroupitemdata.h" #include "oxygenconfiguration.h" +#include "oxygendecohelper.h" +#include "oxygenfactory.h" #include "oxygentitleanimationdata.h" -#include "oxygenanimation.h" -#include "helper.h" #include #include @@ -140,7 +140,7 @@ namespace Oxygen //@} //! helper class - OxygenDecoHelper& helper( void ) const + DecoHelper& helper( void ) const { return factory_->helper(); } //! helper class diff --git a/clients/oxygen/oxygendecohelper.cpp b/clients/oxygen/oxygendecohelper.cpp new file mode 100644 index 0000000000..c7fc1074e1 --- /dev/null +++ b/clients/oxygen/oxygendecohelper.cpp @@ -0,0 +1,147 @@ +/* + * Copyright 2008 Long Huynh Huu + * Copyright 2007 Matthew Woehlke + * Copyright 2007 Casper Boemann + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "oxygendecohelper.h" + +#include + +namespace Oxygen +{ + //______________________________________________________________________________ + DecoHelper::DecoHelper(const QByteArray &componentName): + OxygenHelper(componentName) + {} + + //______________________________________________________________________________ + QPixmap DecoHelper::windecoButton(const QColor &color, bool pressed, int size) + { + quint64 key = (quint64(color.rgba()) << 32) | (size << 1) | (int)pressed; + QPixmap *pixmap = m_windecoButtonCache.object(key); + + if (!pixmap) + { + pixmap = new QPixmap(size, size); + pixmap->fill(Qt::transparent); + + QColor light = calcLightColor(color); + QColor dark = calcDarkColor(color); + + QPainter p(pixmap); + p.setRenderHints(QPainter::Antialiasing); + p.setPen(Qt::NoPen); + qreal u = size/18.0; + p.translate( 0.5*u, (0.5-0.668)*u ); + + { + //plain background + QLinearGradient lg( 0, u*1.665, 0, u*(12.33+1.665) ); + if( pressed ) + { + lg.setColorAt( 1, light ); + lg.setColorAt( 0, dark ); + } else { + lg.setColorAt( 0, light ); + lg.setColorAt( 1, dark ); + } + + QRectF r( u*0.5*(17-12.33), u*1.665, u*12.33, u*12.33 ); + p.setBrush( lg ); + p.drawEllipse( r ); + } + + { + // outline circle + qreal penWidth = 0.7; + QLinearGradient lg( 0, u*1.665, 0, u*(2.0*12.33+1.665) ); + lg.setColorAt( 0, light ); + lg.setColorAt( 1, dark ); + QRectF r( u*0.5*(17-12.33+penWidth), u*(1.665+penWidth), u*(12.33-penWidth), u*(12.33-penWidth) ); + p.setPen( QPen( lg, penWidth*u ) ); + p.drawEllipse( r ); + p.end(); + } + + m_windecoButtonCache.insert(key, pixmap); + } + + return *pixmap; + } + + //_______________________________________________________________________ + QPixmap DecoHelper::windecoButtonGlow(const QColor &color, int size) + { + quint64 key = (quint64(color.rgba()) << 32) | size; + QPixmap *pixmap = m_windecoButtonGlowCache.object(key); + + if (!pixmap) + { + pixmap = new QPixmap(size, size); + pixmap->fill(Qt::transparent); + + // right now the same color is used for the two shadows + QColor light = color; + QColor dark = color; + + QPainter p(pixmap); + p.setRenderHints(QPainter::Antialiasing); + p.setPen(Qt::NoPen); + qreal u = size/18.0; + p.translate( 0.5*u, (0.5-0.668)*u ); + + { + + // outer shadow + QRadialGradient rg( u*8.5, u*8.5, u*8.5 ); + + int nPoints = 5; + qreal x[5] = { 0.61, 0.72, 0.81, 0.9, 1}; + qreal values[5] = { 255-172, 255-178, 255-210, 255-250, 0 }; + QColor c = dark; + for( int i = 0; irect() ); + p.setBrush( rg ); + p.drawRect( r ); + } + + { + // inner shadow + QRadialGradient rg( u*8.5, u*8.5, u*8.5 ); + + static int nPoints = 6; + qreal x[6] = { 0.61, 0.67, 0.7, 0.74, 0.78, 1 }; + qreal values[6] = { 255-92, 255-100, 255-135, 255-205, 255-250, 0 }; + QColor c = light; + for( int i = 0; irect() ); + p.setBrush( rg ); + p.drawRect( r ); + } + + m_windecoButtonGlowCache.insert(key, pixmap); + + } + + return *pixmap; + } +} diff --git a/clients/oxygen/helper.h b/clients/oxygen/oxygendecohelper.h similarity index 71% rename from clients/oxygen/helper.h rename to clients/oxygen/oxygendecohelper.h index 48815d2261..51a90a0cb9 100644 --- a/clients/oxygen/helper.h +++ b/clients/oxygen/oxygendecohelper.h @@ -25,21 +25,25 @@ //! helper class /*! contains utility functions used at multiple places in oxygen style */ -class OxygenDecoHelper : public OxygenHelper +namespace Oxygen { + class DecoHelper : public OxygenHelper + { - public: + public: - explicit OxygenDecoHelper(const QByteArray &componentName); - virtual ~OxygenDecoHelper() {} + explicit DecoHelper(const QByteArray &componentName); + virtual ~DecoHelper() {} - //!@name decoration specific helper functions - //! - //@{ - virtual QPixmap windecoButton(const QColor &color, bool pressed, int size = 21); - virtual QPixmap windecoButtonGlow(const QColor &color, int size = 21); - //@} + //!@name decoration specific helper functions + //! + //@{ + virtual QPixmap windecoButton(const QColor &color, bool pressed, int size = 21); + virtual QPixmap windecoButtonGlow(const QColor &color, int size = 21); + //@} -}; + }; + +} #endif // __OXYGEN_STYLE_HELPER_H diff --git a/clients/oxygen/oxygenfactory.h b/clients/oxygen/oxygenfactory.h index 2ed8b9030d..e29671e80a 100644 --- a/clients/oxygen/oxygenfactory.h +++ b/clients/oxygen/oxygenfactory.h @@ -32,10 +32,9 @@ #include #include "oxygenconfiguration.h" +#include "oxygendecohelper.h" #include "oxygenexceptionlist.h" - #include "oxygenshadowcache.h" -#include "helper.h" namespace Oxygen { @@ -105,7 +104,7 @@ namespace Oxygen { return initialized_; } //! helper - virtual OxygenDecoHelper& helper( void ) + virtual DecoHelper& helper( void ) { return helper_; } //! shadow cache @@ -144,7 +143,7 @@ namespace Oxygen bool initialized_; //! helper - OxygenDecoHelper helper_; + DecoHelper helper_; //! shadow cache ShadowCache shadowCache_; diff --git a/clients/oxygen/oxygenshadowcache.cpp b/clients/oxygen/oxygenshadowcache.cpp index 5cc6374ce6..94102c5bd7 100644 --- a/clients/oxygen/oxygenshadowcache.cpp +++ b/clients/oxygen/oxygenshadowcache.cpp @@ -37,7 +37,7 @@ namespace Oxygen { //_______________________________________________________ - ShadowCache::ShadowCache( OxygenDecoHelper& helper ): + ShadowCache::ShadowCache( DecoHelper& helper ): helper_( helper ), activeShadowConfiguration_( ShadowConfiguration( QPalette::Active ) ), inactiveShadowConfiguration_( ShadowConfiguration( QPalette::Inactive ) ) diff --git a/clients/oxygen/oxygenshadowcache.h b/clients/oxygen/oxygenshadowcache.h index 88953adf84..afe8702f18 100644 --- a/clients/oxygen/oxygenshadowcache.h +++ b/clients/oxygen/oxygenshadowcache.h @@ -27,13 +27,12 @@ // IN THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////// +#include "oxygendecohelper.h" +#include "oxygenshadowconfiguration.h" + #include #include -#include "oxygenshadowconfiguration.h" -#include "helper.h" - -class OxygenHelper; namespace Oxygen { @@ -44,7 +43,7 @@ namespace Oxygen public: //! constructor - ShadowCache( OxygenDecoHelper& helper ); + ShadowCache( DecoHelper& helper ); //! destructor virtual ~ShadowCache( void ) @@ -192,7 +191,7 @@ namespace Oxygen protected: - OxygenHelper& helper( void ) const + DecoHelper& helper( void ) const { return helper_; } private: @@ -202,7 +201,7 @@ namespace Oxygen void renderGradient( QPainter&, const QRectF&, const QRadialGradient&, bool hasBorder = true ) const; //! helper - OxygenDecoHelper& helper_; + DecoHelper& helper_; //! caching enable state bool enabled_;