From b4d6b5fd91e32270be193501b827ee3631ad5cb0 Mon Sep 17 00:00:00 2001 From: Sandro Giessl Date: Wed, 16 Mar 2005 20:00:13 +0000 Subject: [PATCH] slightly modified the look of the titlebar gradient svn path=/trunk/kdebase/kwin/; revision=398179 --- clients/plastik/misc.cpp | 2 +- clients/plastik/misc.h | 2 +- clients/plastik/plastik.cpp | 77 ++++++++++++++++--------------- clients/plastik/plastik.h | 6 +-- clients/plastik/plastikbutton.cpp | 12 ++--- clients/plastik/plastikclient.cpp | 2 +- 6 files changed, 52 insertions(+), 49 deletions(-) diff --git a/clients/plastik/misc.cpp b/clients/plastik/misc.cpp index bfb29464d7..62a005cd73 100644 --- a/clients/plastik/misc.cpp +++ b/clients/plastik/misc.cpp @@ -29,7 +29,7 @@ #include "misc.h" -QColor hsvRelative(QColor& baseColor, int relativeH, int relativeS, int relativeV) +QColor hsvRelative(const QColor& baseColor, int relativeH, int relativeS, int relativeV) { int h, s, v; baseColor.hsv(&h, &s, &v); diff --git a/clients/plastik/misc.h b/clients/plastik/misc.h index 2e73fb7516..a2b20013db 100644 --- a/clients/plastik/misc.h +++ b/clients/plastik/misc.h @@ -23,7 +23,7 @@ #ifndef MISC_H #define MISC_H -QColor hsvRelative(QColor& baseColor, int relativeH, int relativeS = 0, int relativeV = 0); +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); diff --git a/clients/plastik/plastik.cpp b/clients/plastik/plastik.cpp index 5046cf5564..24cbc757a7 100644 --- a/clients/plastik/plastik.cpp +++ b/clients/plastik/plastik.cpp @@ -190,17 +190,15 @@ QColor PlastikHandler::getColor(KWinPlastik::ColorType type, const bool active) switch (type) { case WindowContour: return KDecoration::options()->color(ColorTitleBar, active).dark(190); - case TitleGradientFrom: + case TitleGradient1: + return hsvRelative(KDecoration::options()->color(ColorTitleBar, active), 0,-10,+10); + break; + case TitleGradient2: + return hsvRelative(KDecoration::options()->color(ColorTitleBar, active), 0,0,-25); + break; + case TitleGradient3: return KDecoration::options()->color(ColorTitleBar, active); break; - case TitleGradientTo: - return alphaBlendColors(KDecoration::options()->color(ColorTitleBar, active), - Qt::white, active?210:220); - break; - case TitleGradientToTop: - return alphaBlendColors(KDecoration::options()->color(ColorTitleBar, active), - Qt::white, active?180:190); - break; case TitleHighlightTop: case SideHighlightLeft: return alphaBlendColors(KDecoration::options()->color(ColorTitleBar, active), @@ -227,41 +225,46 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow switch (type) { case TitleBarTileTop: - { - int h = 4-2; // TODO: don't hardcode the height... - - KPixmap tempPixmap; - tempPixmap.resize(1, h); - KPixmapEffect::gradient(tempPixmap, - getColor(TitleGradientToTop, active), - getColor(TitleGradientFrom, active), - KPixmapEffect::VerticalGradient); - QPixmap *pixmap = new QPixmap(1, h); - QPainter painter(pixmap); - painter.drawPixmap(0, 0, tempPixmap); - painter.end(); - - m_pixmaps[toolWindow][active][type] = pixmap; - return *pixmap; - - break; - } - case TitleBarTile: { - int h = toolWindow ? m_titleHeightTool : m_titleHeight; + const int topHeight = 2; + const int topGradientHeight = 4; + + int h = (toolWindow ? m_titleHeightTool : m_titleHeight) + topHeight; + + QPixmap gradient(1, h); // TODO: test width of 5 or so for performance + + QPainter painter(&gradient); KPixmap tempPixmap; - tempPixmap.resize(5, h); + tempPixmap.resize(1, topGradientHeight); KPixmapEffect::gradient(tempPixmap, - PlastikHandler::getColor(TitleGradientFrom, active), - PlastikHandler::getColor(TitleGradientTo, active), + getColor(TitleGradient1, active), + getColor(TitleGradient2, active), KPixmapEffect::VerticalGradient); - QPixmap *pixmap = new QPixmap(5, h); - QPainter painter(pixmap); - painter.drawPixmap(0, 0, tempPixmap); + painter.drawPixmap(0,0, tempPixmap); + + tempPixmap.resize(1, h-topGradientHeight); + KPixmapEffect::gradient(tempPixmap, + getColor(TitleGradient2, active), + getColor(TitleGradient3, active), + KPixmapEffect::VerticalGradient); + painter.drawPixmap(0,topGradientHeight, tempPixmap); painter.end(); + QPixmap *pixmap; + if (type == TitleBarTileTop) { + pixmap = new QPixmap(1, topHeight); + painter.begin(pixmap); + painter.drawPixmap(0, 0, gradient); + painter.end(); + } else { + pixmap = new QPixmap(1, h-topHeight); + painter.begin(pixmap); + painter.drawPixmap(0, 0, gradient, 0,topHeight); + painter.end(); + } + m_pixmaps[toolWindow][active][type] = pixmap; return *pixmap; @@ -298,7 +301,7 @@ const QPixmap &PlastikHandler::buttonPixmap(ButtonPixmaps type, const QSize &siz delete m_pixmaps[toolWindow][active][typeIndex]; m_pixmaps[toolWindow][active][typeIndex] = 0; - QColor iconColor = alphaBlendColors(getColor(TitleGradientTo, active), pressed ? Qt::white : Qt::black, 50); + QColor iconColor = alphaBlendColors(getColor(TitleGradient3, active), pressed ? Qt::white : Qt::black, 50); QImage img; diff --git a/clients/plastik/plastik.h b/clients/plastik/plastik.h index 5a0720a5cc..0d575417f5 100644 --- a/clients/plastik/plastik.h +++ b/clients/plastik/plastik.h @@ -32,9 +32,9 @@ namespace KWinPlastik { enum ColorType { WindowContour=0, - TitleGradientFrom, - TitleGradientTo, - TitleGradientToTop, + TitleGradient1, // top + TitleGradient2, + TitleGradient3, // bottom TitleHighlightTop, SideHighlightLeft, SideHighlightRight, diff --git a/clients/plastik/plastikbutton.cpp b/clients/plastik/plastikbutton.cpp index 88658fd198..3a382c6bd4 100644 --- a/clients/plastik/plastikbutton.cpp +++ b/clients/plastik/plastikbutton.cpp @@ -178,13 +178,13 @@ void PlastikButton::drawButton(QPainter *painter) highlightColor = Qt::white; } - QColor contourTop = alphaBlendColors(Handler()->getColor(TitleGradientFrom, active), + QColor contourTop = alphaBlendColors(Handler()->getColor(TitleGradient2, active), Qt::black, 220); - QColor contourBottom = alphaBlendColors(Handler()->getColor(TitleGradientTo, active), + QColor contourBottom = alphaBlendColors(Handler()->getColor(TitleGradient3, active), Qt::black, 220); - QColor sourfaceTop = alphaBlendColors(Handler()->getColor(TitleGradientFrom, active), + QColor sourfaceTop = alphaBlendColors(Handler()->getColor(TitleGradient2, active), Qt::white, 220); - QColor sourfaceBottom = alphaBlendColors(Handler()->getColor(TitleGradientTo, active), + QColor sourfaceBottom = alphaBlendColors(Handler()->getColor(TitleGradient3, active), Qt::white, 220); int highlightAlpha = static_cast(255-((60/static_cast(ANIMATIONSTEPS))* @@ -227,13 +227,13 @@ void PlastikButton::drawButton(QPainter *painter) bP.drawPixmap(r.x(), r.y()+2, tempKPixmap); bP.drawPixmap(r.right(), r.y()+2, tempKPixmap); // sort of anti-alias for the contour - bP.setPen(alphaBlendColors(Handler()->getColor(TitleGradientFrom, active), + bP.setPen(alphaBlendColors(Handler()->getColor(TitleGradient2, active), contourTop, 150) ); bP.drawPoint(r.x()+1, r.y()); bP.drawPoint(r.right()-1, r.y()); bP.drawPoint(r.x(), r.y()+1); bP.drawPoint(r.right(), r.y()+1); - bP.setPen(alphaBlendColors(Handler()->getColor(TitleGradientTo, active), + bP.setPen(alphaBlendColors(Handler()->getColor(TitleGradient3, active), contourBottom, 150) ); bP.drawPoint(r.x()+1, r.bottom()); bP.drawPoint(r.right()-1, r.bottom()); diff --git a/clients/plastik/plastikclient.cpp b/clients/plastik/plastikclient.cpp index 9e5046c085..bcb9666cdd 100644 --- a/clients/plastik/plastikclient.cpp +++ b/clients/plastik/plastikclient.cpp @@ -252,7 +252,7 @@ void PlastikClient::paintEvent(QPaintEvent *e) // colors... const QColor windowContour = Handler()->getColor(WindowContour, active); - const QColor deco = Handler()->getColor(TitleGradientTo, active); + const QColor deco = Handler()->getColor(TitleGradient3, active); const QColor border = Handler()->getColor(Border, active); const QColor highlightTop = Handler()->getColor(TitleHighlightTop, active); const QColor highlightTitleLeft = alphaBlendColors(deco,