slightly modified the look of the titlebar gradient

svn path=/trunk/kdebase/kwin/; revision=398179
icc-effect-5.14.5
Sandro Giessl 2005-03-16 20:00:13 +00:00
parent 07540ec656
commit b4d6b5fd91
6 changed files with 52 additions and 49 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -32,9 +32,9 @@ namespace KWinPlastik {
enum ColorType {
WindowContour=0,
TitleGradientFrom,
TitleGradientTo,
TitleGradientToTop,
TitleGradient1, // top
TitleGradient2,
TitleGradient3, // bottom
TitleHighlightTop,
SideHighlightLeft,
SideHighlightRight,

View File

@ -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<int>(255-((60/static_cast<double>(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());

View File

@ -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,