diff --git a/clients/plastik/CMakeLists.txt b/clients/plastik/CMakeLists.txt index e3c4fcd070..fce0829029 100644 --- a/clients/plastik/CMakeLists.txt +++ b/clients/plastik/CMakeLists.txt @@ -3,11 +3,11 @@ add_subdirectory( config ) ########### next target ############### -set(kwin3_plastik_PART_SRCS - plastik.cpp - plastikclient.cpp - plastikbutton.cpp - misc.cpp ) +set(kwin3_plastik_PART_SRCS + plastik.cpp + plastikclient.cpp + plastikbutton.cpp + ) kde4_add_plugin(kwin3_plastik ${kwin3_plastik_PART_SRCS}) diff --git a/clients/plastik/misc.cpp b/clients/plastik/misc.cpp deleted file mode 100644 index a8b13ab335..0000000000 --- a/clients/plastik/misc.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* Plastik KWin window decoration - Copyright (C) 2003 Sandro Giessl - - based on the window decoration "Web": - Copyright (C) 2001 Rik Hemsley (rikkus) - - 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) any later version. - - 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; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include "misc.h" - -QColor hsvRelative(const QColor& baseColor, int relativeH, int relativeS, int relativeV) -{ - int h, s, v; - baseColor.getHsv(&h, &s, &v); - - h += relativeH; - s += relativeS; - v += relativeV; - - if(h < 0) { h = 0; } - else if(h > 359) { h = 359; } - if(s < 0) { s = 0; } - else if(s > 255) { s = 255; } - if(v < 0) { v = 0; } - else if(v > 255) { v = 255; } - - QColor c; - c.setHsv( h, s, v ); - return c; -} - -QColor alphaBlendColors(const QColor &bgColor, const QColor &fgColor, const int a) -{ - - // normal button... - QRgb rgb = bgColor.rgb(); - QRgb rgb_b = fgColor.rgb(); - int alpha = a; - if(alpha>255) alpha = 255; - if(alpha<0) alpha = 0; - int inv_alpha = 255 - alpha; - - QColor result = QColor( qRgb(qRed(rgb_b)*inv_alpha/255 + qRed(rgb)*alpha/255, - qGreen(rgb_b)*inv_alpha/255 + qGreen(rgb)*alpha/255, - qBlue(rgb_b)*inv_alpha/255 + qBlue(rgb)*alpha/255) ); - - return result; -} - -QImage recolorImage(QImage *img, QColor color) { - QImage destImg(img->width(),img->height(), QImage::Format_ARGB32); - for (int x = 0; x < img->width(); x++) { - for (int y = 0; y < img->height(); y++) { - if(img->pixel(x,y) == qRgb(0,0,255) ) { - destImg.setPixel(x,y,color.rgb() ); // set to the new color - } else { - destImg.setPixel(x,y,qRgba(0,0,0,0) ); // set transparent... - } - } - } - - return destImg; -} diff --git a/clients/plastik/misc.h b/clients/plastik/misc.h deleted file mode 100644 index 6c06b282bc..0000000000 --- a/clients/plastik/misc.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Plastik KWin window decoration - Copyright (C) 2003 Sandro Giessl - - based on the window decoration "Web": - Copyright (C) 2001 Rik Hemsley (rikkus) - - 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) any later version. - - 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; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - */ - -#ifndef MISC_H -#define MISC_H - -QColor hsvRelative(const QColor& baseColor, int relativeH, int relativeS = 0, int relativeV = 0); -QColor alphaBlendColors(const QColor &backgroundColor, const QColor &foregroundColor, const int alpha); -QImage recolorImage(QImage *img, QColor color); - -#endif // MISC_H diff --git a/clients/plastik/plastik.cpp b/clients/plastik/plastik.cpp index 39f7fe4f8c..3d183c225d 100644 --- a/clients/plastik/plastik.cpp +++ b/clients/plastik/plastik.cpp @@ -25,7 +25,6 @@ #include #include -#include "misc.h" #include "plastik.h" #include "plastik.moc" #include "plastikclient.h" diff --git a/clients/plastik/plastikbutton.cpp b/clients/plastik/plastikbutton.cpp index 624d55f65e..53eeee36f5 100644 --- a/clients/plastik/plastikbutton.cpp +++ b/clients/plastik/plastikbutton.cpp @@ -33,9 +33,10 @@ #include "plastikbutton.moc" #include "plastikclient.h" -#include "misc.h" +#include #include +#include namespace KWinPlastik { @@ -176,34 +177,34 @@ void PlastikButton::drawButton(QPainter *painter) bool active = m_client->isActive(); QPixmap tempPixmap; - QColor highlightColor; - if(type() == CloseButton) { - highlightColor = QColor(255,64,0); - } else { - highlightColor = Qt::white; + + double c = KGlobalSettings::contrastF(); + QColor titleBar = KDecoration::options()->color(KDecoration::ColorTitleBar, active); + QColor contourTop = KColorScheme::shade(titleBar, KColorScheme::DarkShade, c - 0.4); + QColor contourBottom = KColorScheme::shade(titleBar, KColorScheme::MidShade, c); + QColor surfaceTop = KColorScheme::shade(titleBar, KColorScheme::MidlightShade, c - 0.4); + QColor surfaceBottom = KColorScheme::shade(titleBar, KColorScheme::LightShade, c - 0.4); + + QColor highlightColor = titleBar; + double alpha; + if (type() == CloseButton) { + KColorScheme kcs(active ? QPalette::Active : QPalette::Inactive, KColorScheme::Button); + highlightColor = kcs.foreground(KColorScheme::NegativeText).color(); + } + if (isDown()) { + highlightColor = KColorScheme::shade(highlightColor, KColorScheme::ShadowShade); + alpha = 0.3; + } + else if (animProgress > 0) { + alpha = 0.6 * (double)animProgress / (double)ANIMATIONSTEPS; + highlightColor = KColorScheme::shade(highlightColor, KColorScheme::LightShade, qMin(1.0, c + 0.4)); } - QColor contourTop = alphaBlendColors(Handler()->getColor(TitleGradient2, active), - Qt::black, 215); - QColor contourBottom = alphaBlendColors(Handler()->getColor(TitleGradient3, active), - Qt::black, 215); - QColor sourfaceTop = alphaBlendColors(Handler()->getColor(TitleGradient2, active), - Qt::white, 210); - QColor sourfaceBottom = alphaBlendColors(Handler()->getColor(TitleGradient3, active), - Qt::white, 210); - - int highlightAlpha = static_cast(255-((60/static_cast(ANIMATIONSTEPS))* - static_cast(animProgress) ) ); - contourTop = alphaBlendColors(contourTop, highlightColor, highlightAlpha ); - contourBottom = alphaBlendColors(contourBottom, highlightColor, highlightAlpha); - sourfaceTop = alphaBlendColors(sourfaceTop, highlightColor, highlightAlpha); - sourfaceBottom = alphaBlendColors(sourfaceBottom, highlightColor, highlightAlpha); - - if (isDown() ) { - contourTop = alphaBlendColors(contourTop, Qt::black, 200); - contourBottom = alphaBlendColors(contourBottom, Qt::black, 200); - sourfaceTop = alphaBlendColors(sourfaceTop, Qt::black, 200); - sourfaceBottom = alphaBlendColors(sourfaceBottom, Qt::black, 200); + if (alpha > 0.0) { + contourTop = KColorUtils::mix(contourTop, highlightColor, alpha); + contourBottom = KColorUtils::mix(contourBottom, highlightColor, alpha); + surfaceTop = KColorUtils::mix(surfaceTop, highlightColor, alpha); + surfaceBottom = KColorUtils::mix(surfaceBottom, highlightColor, alpha); } QPixmap buffer(width(), height()); @@ -225,8 +226,8 @@ void PlastikButton::drawButton(QPainter *painter) bP.drawRoundRect(r, rx, ry); // surface QLinearGradient surfaceGradient(0, 0, 0, r.height()); - surfaceGradient.setColorAt(0.0, sourfaceTop); - surfaceGradient.setColorAt(1.0, sourfaceBottom); + surfaceGradient.setColorAt(0.0, surfaceTop); + surfaceGradient.setColorAt(1.0, surfaceBottom); bP.setBrush(surfaceGradient); bP.drawRoundRect(r.adjusted(1,1,-1,-1), rx, ry); } diff --git a/clients/plastik/plastikclient.cpp b/clients/plastik/plastikclient.cpp index 61754d4426..8fb894784c 100644 --- a/clients/plastik/plastikclient.cpp +++ b/clients/plastik/plastikclient.cpp @@ -34,7 +34,6 @@ #include "plastikclient.h" #include "plastikbutton.h" -#include "misc.h" #include