Final updates for the new button color implementation. The options class
now only has one button entry, "ButtonBg", instead of 3. It's up to the client what to do with it. All the clients are updated except mwm. As the author noted in his README, mwm isn't Motif window manager at all but KStep ;-) I disabled it for now until there is new drawing code in there, it would confuse users anyways since were about to release another Krash and it is identical to KStep. Also, I removed the Groove and GrooveText color entries. We now use the normal TitleBar and Font entries. Hence system will probably look funny until you adjust the colors since it draws text on the frame and not the titlebar bg. All the rest look much better by default. To configure button colors set the active/inactive button background color in KControl. I'll remove the other entries ASAP. You'll also note that the active/inactive colors are now actually what you would expect. svn path=/trunk/kdebase/kwin/; revision=47753
This commit is contained in:
parent
11b6ddb604
commit
b58843030c
9 changed files with 156 additions and 115 deletions
|
@ -1 +1 @@
|
|||
SUBDIRS=kstep system b2 laptop riscos mwm modernsystem
|
||||
SUBDIRS=kstep system b2 laptop riscos modernsystem
|
||||
|
|
|
@ -48,9 +48,38 @@ static unsigned char question_bits[] = {
|
|||
static QPixmap *titlePix=0;
|
||||
static KPixmap *aUpperGradient=0;
|
||||
static KPixmap *iUpperGradient=0;
|
||||
// buttons active, inactive, up, down, and 2 sizes :P
|
||||
static KPixmap *btnPix1;
|
||||
static KPixmap *btnDownPix1;
|
||||
static KPixmap *iBtnPix1;
|
||||
static KPixmap *iBtnDownPix1;
|
||||
static KPixmap *btnPix2;
|
||||
static KPixmap *btnDownPix2;
|
||||
static KPixmap *iBtnPix2;
|
||||
static KPixmap *iBtnDownPix2;
|
||||
static QColor btnForeground;
|
||||
|
||||
static bool pixmaps_created = false;
|
||||
|
||||
static int titleHeight = -1;
|
||||
static int btnWidth1 = 18;
|
||||
static int btnWidth2 = 28;
|
||||
|
||||
|
||||
static void drawButtonFrame(KPixmap *pix, const QColorGroup &g, bool sunken)
|
||||
{
|
||||
QPainter p;
|
||||
int w = pix->width();
|
||||
int h = pix->height();
|
||||
p.begin(pix);
|
||||
p.setPen(sunken ? g.dark() : g.light());
|
||||
p.drawLine(0, 0, w-1, 0);
|
||||
p.drawLine(0, 0, 0, w-1);
|
||||
p.setPen(sunken ? g.light() : g.dark());
|
||||
p.drawLine(w-1, 0, w-1, h-1);
|
||||
p.drawLine(0, h-1, w-1, h-1);
|
||||
p.end();
|
||||
}
|
||||
|
||||
static void create_pixmaps()
|
||||
{
|
||||
|
@ -88,7 +117,6 @@ static void create_pixmaps()
|
|||
aUpperGradient->resize(32, titleHeight+2);
|
||||
iUpperGradient = new KPixmap;
|
||||
iUpperGradient->resize(32, titleHeight+2);
|
||||
//QColor bgColor = kapp->palette().normal().background();
|
||||
QColor bgColor = options->color(Options::TitleBar, true);
|
||||
KPixmapEffect::gradient(*aUpperGradient,
|
||||
bgColor.light(120),
|
||||
|
@ -99,19 +127,66 @@ static void create_pixmaps()
|
|||
bgColor.light(120),
|
||||
bgColor.dark(120),
|
||||
KPixmapEffect::VerticalGradient);
|
||||
// buttons (active, 2 sizes)
|
||||
QColorGroup g = options->colorGroup(Options::ButtonBg, true);
|
||||
QColor c = g.background();
|
||||
btnPix1 = new KPixmap;
|
||||
btnPix1->resize(btnWidth1, titleHeight-2);
|
||||
KPixmapEffect::gradient(*btnPix1, c.light(120), c.dark(120),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
drawButtonFrame(btnPix1, g, false);
|
||||
btnDownPix1 = new KPixmap;
|
||||
btnDownPix1->resize(btnWidth1, titleHeight-2);
|
||||
KPixmapEffect::gradient(*btnDownPix1, c.dark(120), c.light(120),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
drawButtonFrame(btnDownPix1, g, true);
|
||||
btnPix2 = new KPixmap;
|
||||
btnPix2->resize(btnWidth2, titleHeight-2);
|
||||
KPixmapEffect::gradient(*btnPix2, c.light(120), c.dark(120),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
drawButtonFrame(btnPix2, g, false);
|
||||
btnDownPix2 = new KPixmap;
|
||||
btnDownPix2->resize(btnWidth2, titleHeight-2);
|
||||
KPixmapEffect::gradient(*btnDownPix2, c.dark(120), c.light(120),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
drawButtonFrame(btnDownPix2, g, true);
|
||||
// inactive
|
||||
g = options->colorGroup(Options::ButtonBg, false);
|
||||
c = g.background();
|
||||
iBtnPix1 = new KPixmap;
|
||||
iBtnPix1->resize(btnWidth1, titleHeight-2);
|
||||
KPixmapEffect::gradient(*iBtnPix1, c.light(120), c.dark(120),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
drawButtonFrame(iBtnPix1, g, false);
|
||||
iBtnDownPix1 = new KPixmap;
|
||||
iBtnDownPix1->resize(btnWidth1, titleHeight-2);
|
||||
KPixmapEffect::gradient(*iBtnDownPix1, c.dark(120), c.light(120),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
drawButtonFrame(iBtnDownPix1, g, true);
|
||||
iBtnPix2 = new KPixmap;
|
||||
iBtnPix2->resize(btnWidth2, titleHeight-2);
|
||||
KPixmapEffect::gradient(*iBtnPix2, c.light(120), c.dark(120),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
drawButtonFrame(iBtnPix2, g, false);
|
||||
iBtnDownPix2 = new KPixmap;
|
||||
iBtnDownPix2->resize(btnWidth2, titleHeight-2);
|
||||
KPixmapEffect::gradient(*iBtnDownPix2, c.dark(120), c.light(120),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
drawButtonFrame(iBtnDownPix2, g, true);
|
||||
}
|
||||
if(qGray(options->color(Options::ButtonBg, true).rgb()) > 128)
|
||||
btnForeground = Qt::black;
|
||||
else
|
||||
btnForeground = Qt::white;
|
||||
}
|
||||
|
||||
|
||||
SystemButton::SystemButton(int w, int h, QWidget *parent, const char *name,
|
||||
SystemButton::SystemButton(int w, int h, Client *parent, const char *name,
|
||||
const unsigned char *bitmap)
|
||||
: QButton(parent, name)
|
||||
{
|
||||
client = parent;
|
||||
setFixedSize(w, h);
|
||||
aBackground.resize(w, h);
|
||||
iBackground.resize(w, h);
|
||||
reset();
|
||||
//resize(22, 12);
|
||||
|
||||
if(bitmap)
|
||||
setBitmap(bitmap);
|
||||
|
@ -125,37 +200,7 @@ QSize SystemButton::sizeHint() const
|
|||
|
||||
void SystemButton::reset()
|
||||
{
|
||||
QPainter p;
|
||||
int w = width();
|
||||
int h = height();
|
||||
QColor hColor(options->color(Options::ButtonBg, true));
|
||||
QColor lColor(options->color(Options::ButtonBlend, true));
|
||||
|
||||
KPixmapEffect::gradient(aBackground, hColor.light(150), lColor.dark(150),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
p.begin(&aBackground);
|
||||
p.setPen(options->colorGroup(Options::ButtonBg, false).dark());
|
||||
p.drawLine(0, 0, w-1, 0);
|
||||
p.drawLine(0, 0, 0, w-1);
|
||||
p.setPen(options->colorGroup(Options::ButtonBg, false).light());
|
||||
p.drawLine(w-1, 0, w-1, h-1);
|
||||
p.drawLine(0, h-1, w-1, h-1);
|
||||
p.end();
|
||||
|
||||
hColor = (options->color(Options::ButtonBg, false));
|
||||
lColor = (options->color(Options::ButtonBlend, false));
|
||||
KPixmapEffect::gradient(iBackground, hColor.light(150), lColor.dark(150),
|
||||
KPixmapEffect::DiagonalGradient);
|
||||
p.begin(&iBackground);
|
||||
p.setPen(options->colorGroup(Options::ButtonBg, false).light());
|
||||
p.drawLine(0, 0, w-1, 0);
|
||||
p.drawLine(0, 0, 0, h-1);
|
||||
p.setPen(options->colorGroup(Options::ButtonBg, false).dark());
|
||||
p.drawLine(w-1, 0, w-1, h-1);
|
||||
p.drawLine(0, h-1, w-1, h-1);
|
||||
p.end();
|
||||
|
||||
|
||||
repaint(false);
|
||||
}
|
||||
|
||||
void SystemButton::setBitmap(const unsigned char *bitmap)
|
||||
|
@ -167,12 +212,36 @@ void SystemButton::setBitmap(const unsigned char *bitmap)
|
|||
|
||||
void SystemButton::drawButton(QPainter *p)
|
||||
{
|
||||
bool smallBtn = width() == btnWidth1;
|
||||
if(btnPix1){
|
||||
if(client->isActive()){
|
||||
if(isDown())
|
||||
p->drawPixmap(0, 0, aBackground);
|
||||
p->drawPixmap(0, 0, smallBtn ? *btnDownPix1 : *btnDownPix2);
|
||||
else
|
||||
p->drawPixmap(0, 0, iBackground);
|
||||
p->drawPixmap(0, 0, smallBtn ? *btnPix1 : *btnPix2);
|
||||
}
|
||||
else{
|
||||
if(isDown())
|
||||
p->drawPixmap(0, 0, smallBtn ? *iBtnDownPix1 : *iBtnDownPix2);
|
||||
else
|
||||
p->drawPixmap(0, 0, smallBtn ? *iBtnPix1 : *iBtnPix2);
|
||||
}
|
||||
}
|
||||
else{
|
||||
QColorGroup g = options->colorGroup(Options::ButtonBg,
|
||||
client->isActive());
|
||||
int w = width();
|
||||
int h = height();
|
||||
p->fillRect(1, 1, w-2, h-2, isDown() ? g.mid() : g.button());
|
||||
p->setPen(isDown() ? g.dark() : g.light());
|
||||
p->drawLine(0, 0, w-1, 0);
|
||||
p->drawLine(0, 0, 0, w-1);
|
||||
p->setPen(isDown() ? g.light() : g.dark());
|
||||
p->drawLine(w-1, 0, w-1, h-1);
|
||||
p->drawLine(0, h-1, w-1, h-1);
|
||||
}
|
||||
|
||||
p->setPen(options->color(Options::ButtonFg, isDown()));
|
||||
p->setPen(btnForeground);
|
||||
int xOff = (width()-8)/2;
|
||||
int yOff = (height()-8)/2;
|
||||
p->drawPixmap(isDown() ? xOff+1: xOff, isDown() ? yOff+1 : yOff, deco);
|
||||
|
@ -184,6 +253,14 @@ void LaptopClient::slotReset()
|
|||
if(aUpperGradient){
|
||||
delete aUpperGradient;
|
||||
delete iUpperGradient;
|
||||
delete btnPix1;
|
||||
delete btnDownPix1;
|
||||
delete iBtnPix1;
|
||||
delete iBtnDownPix1;
|
||||
delete btnPix2;
|
||||
delete btnDownPix2;
|
||||
delete iBtnPix2;
|
||||
delete iBtnDownPix2;
|
||||
}
|
||||
pixmaps_created = false;
|
||||
create_pixmaps();
|
||||
|
@ -435,4 +512,15 @@ void LaptopClient::init()
|
|||
//
|
||||
}
|
||||
|
||||
void LaptopClient::activeChange(bool)
|
||||
{
|
||||
repaint(false);
|
||||
button[0]->reset();
|
||||
button[1]->reset();
|
||||
button[2]->reset();
|
||||
button[3]->reset();
|
||||
if(button[4])
|
||||
button[4]->reset();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class QSpacerItem;
|
|||
class SystemButton : public QButton
|
||||
{
|
||||
public:
|
||||
SystemButton(int w, int h, QWidget *parent=0, const char *name=0,
|
||||
SystemButton(int w, int h, Client *parent=0, const char *name=0,
|
||||
const unsigned char *bitmap=NULL);
|
||||
void setBitmap(const unsigned char *bitmap);
|
||||
void reset();
|
||||
|
@ -21,8 +21,8 @@ public:
|
|||
protected:
|
||||
virtual void drawButton(QPainter *p);
|
||||
void drawButtonLabel(QPainter *){;}
|
||||
KPixmap aBackground, iBackground;
|
||||
QBitmap deco;
|
||||
Client *client;
|
||||
};
|
||||
|
||||
class LaptopClient : public Client
|
||||
|
@ -42,6 +42,7 @@ protected:
|
|||
void stickyChange(bool on);
|
||||
void maximizeChange(bool m);
|
||||
void doShape();
|
||||
void activeChange(bool);
|
||||
protected slots:
|
||||
void slotReset();
|
||||
private:
|
||||
|
|
|
@ -354,7 +354,7 @@ void ModernSys::paintEvent( QPaintEvent* )
|
|||
p.drawTiledPixmap(1, 1, w-2, 18, *iUpperGradient);
|
||||
else
|
||||
p.fillRect(1, 1, w-2, 18, fillBrush);
|
||||
p.setPen(options->color(Options::GrooveText, isActive()));
|
||||
p.setPen(options->color(Options::Font, isActive()));
|
||||
p.setFont(options->font(isActive()));
|
||||
p.drawText(t, AlignCenter, caption() );
|
||||
}
|
||||
|
|
|
@ -374,8 +374,17 @@ Static::update()
|
|||
setPalette(aBut, options->color(Options::ButtonBg, true));
|
||||
setPalette(iBut, options->color(Options::ButtonBg, false));
|
||||
|
||||
setInversePalette(aSym, options->color(Options::ButtonFg, true));
|
||||
setInversePalette(iSym, options->color(Options::ButtonFg, false));
|
||||
QColor btnForeground;
|
||||
if(qGray(options->color(Options::ButtonBg, true).rgb()) > 128)
|
||||
btnForeground = Qt::black;
|
||||
else
|
||||
btnForeground = Qt::white;
|
||||
setInversePalette(aSym, btnForeground);
|
||||
if(qGray(options->color(Options::ButtonBg, false).rgb()) > 128)
|
||||
btnForeground = Qt::black;
|
||||
else
|
||||
btnForeground = Qt::white;
|
||||
setInversePalette(iSym, btnForeground);
|
||||
|
||||
setPalette(aTitlePal_, options->color(Options::TitleBar, true));
|
||||
setPalette(iTitlePal_, options->color(Options::TitleBar, false));
|
||||
|
|
|
@ -370,13 +370,13 @@ void SystemClient::recalcTitleBuffer()
|
|||
p.setClipRegion(r);
|
||||
int i, ly;
|
||||
for(i=0, ly=4; i < 4; ++i, ly+=3){
|
||||
p.setPen(options->color(Options::Groove, true).light(150));
|
||||
p.setPen(options->color(Options::TitleBar, true).light(150));
|
||||
p.drawLine(0, ly, width()-1, ly);
|
||||
p.setPen(options->color(Options::Groove, true).dark(120));
|
||||
p.setPen(options->color(Options::TitleBar, true).dark(120));
|
||||
p.drawLine(0, ly+1, width()-1, ly+1);
|
||||
}
|
||||
p.setClipRect(t);
|
||||
p.setPen(options->color(Options::GrooveText, true));
|
||||
p.setPen(options->color(Options::Font, true));
|
||||
p.setFont(options->font(true));
|
||||
|
||||
p.drawText(t.x()+((t.width()-fm.width(caption()))/2)-4,
|
||||
|
@ -422,7 +422,7 @@ void SystemClient::paintEvent( QPaintEvent* )
|
|||
p.drawTiledPixmap(0, 0, width(), 18, *iUpperGradient);
|
||||
else
|
||||
p.fillRect(0, 0, width(), 18, fillBrush);
|
||||
p.setPen(options->color(Options::GrooveText, isActive()));
|
||||
p.setPen(options->color(Options::Font, isActive()));
|
||||
p.setFont(options->font(isActive()));
|
||||
p.drawText(t, AlignCenter, caption() );
|
||||
}
|
||||
|
|
59
options.cpp
59
options.cpp
|
@ -62,20 +62,9 @@ void Options::reload()
|
|||
// normal colors
|
||||
colors[Frame] = pal.normal().background();
|
||||
colors[Frame] = config->readColorEntry("frame", &colors[Frame]);
|
||||
colors[Handle] = QColor( 140, 140, 140 );
|
||||
colors[Handle] = colors[Frame];
|
||||
colors[Handle] = config->readColorEntry("handle", &colors[Handle]);
|
||||
|
||||
colors[Groove] = colors[Frame];
|
||||
colors[Groove] = config->readColorEntry("activeGroove",
|
||||
&colors[Groove]);
|
||||
|
||||
if(qGray(colors[Frame].rgb()) > 150)
|
||||
colors[GrooveText] = Qt::black;
|
||||
else
|
||||
colors[GrooveText] = Qt::white;
|
||||
colors[GrooveText] = config->readColorEntry("activeGrooveText",
|
||||
&colors[GrooveText]);
|
||||
|
||||
// full button configuration (background, blend, and foreground
|
||||
if(QPixmap::defaultDepth() > 8)
|
||||
colors[ButtonBg] = colors[Frame].light(130);
|
||||
|
@ -83,25 +72,6 @@ void Options::reload()
|
|||
colors[ButtonBg] = colors[Frame];
|
||||
colors[ButtonBg] = config->readColorEntry("activeTitleBtnBg",
|
||||
&colors[Frame]);
|
||||
if(QPixmap::defaultDepth() > 8)
|
||||
colors[ButtonBlend] = colors[Frame].dark(130);
|
||||
else
|
||||
colors[ButtonBlend] = colors[Frame];
|
||||
colors[ButtonBlend] = config->readColorEntry("activeTitleBtnBlend",
|
||||
&colors[ButtonBlend]);
|
||||
if(qGray(colors[ButtonBg].rgb()) > 150 ||
|
||||
qGray(colors[ButtonBlend].rgb()) > 150)
|
||||
colors[ButtonFg] = Qt::black;
|
||||
else
|
||||
colors[ButtonFg] = Qt::white;
|
||||
colors[ButtonFg] = config->readColorEntry("activeTitleBtnFg",
|
||||
&colors[ButtonFg]);
|
||||
|
||||
// single color button configuration
|
||||
colors[ButtonSingleColor] = Qt::darkGray;
|
||||
colors[ButtonSingleColor] =
|
||||
config->readColorEntry("activeTitleBtnFg", &colors[ButtonSingleColor]);
|
||||
|
||||
colors[TitleBar] = pal.normal().highlight();
|
||||
colors[TitleBar] = config->readColorEntry("activeBackground",
|
||||
&colors[TitleBar]);
|
||||
|
@ -118,17 +88,6 @@ void Options::reload()
|
|||
// inactive
|
||||
colors[Frame+KWINCOLORS] = config->readColorEntry("inactiveFrame",
|
||||
&colors[Frame]);
|
||||
colors[Groove+KWINCOLORS] =
|
||||
config->readColorEntry("inactiveGroove", &colors[Frame+KWINCOLORS]);
|
||||
|
||||
if(qGray(colors[Frame+KWINCOLORS].rgb()) > 150)
|
||||
colors[GrooveText+KWINCOLORS] = Qt::darkGray;
|
||||
else
|
||||
colors[GrooveText+KWINCOLORS] = Qt::lightGray;
|
||||
colors[GrooveText+KWINCOLORS] =
|
||||
config->readColorEntry("inactiveGrooveText",
|
||||
&colors[GrooveText+KWINCOLORS]);
|
||||
|
||||
colors[TitleBar+KWINCOLORS] = colors[Frame];
|
||||
colors[TitleBar+KWINCOLORS] = config->
|
||||
readColorEntry("inactiveBackground", &colors[TitleBar+KWINCOLORS]);
|
||||
|
@ -149,22 +108,6 @@ void Options::reload()
|
|||
config->readColorEntry("inactiveTitleBtnBg",
|
||||
&colors[ButtonBg]);
|
||||
|
||||
if(QPixmap::defaultDepth() > 8)
|
||||
colors[ButtonBlend+KWINCOLORS] = colors[ Frame+KWINCOLORS ].dark(130);
|
||||
else
|
||||
colors[ButtonBlend+KWINCOLORS] = colors[ Frame+KWINCOLORS ];
|
||||
colors[ButtonBlend+KWINCOLORS] =
|
||||
config->readColorEntry("inactiveTitleBtnBlend",
|
||||
&colors[ButtonBlend+KWINCOLORS]);
|
||||
|
||||
colors[ButtonFg+KWINCOLORS] = config->
|
||||
readColorEntry("inactiveTitleBtnFg", &colors[ButtonFg]);
|
||||
|
||||
// single color
|
||||
colors[ButtonSingleColor+KWINCOLORS] = config->
|
||||
readColorEntry("inactiveTitleBtnFg", &colors[ButtonSingleColor]);
|
||||
|
||||
|
||||
colors[Handle+KWINCOLORS] = colors[Frame];
|
||||
config->readColorEntry("inactiveHandle", &colors[Handle]);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|||
#include <qpalette.h>
|
||||
|
||||
// increment this when you add a color type (mosfet)
|
||||
#define KWINCOLORS 11
|
||||
#define KWINCOLORS 6
|
||||
|
||||
class Options : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -56,8 +56,7 @@ public:
|
|||
* are implemented you should retrieve them here.
|
||||
*/
|
||||
// increment KWINCOLORS if you add something (mosfet)
|
||||
enum ColorType{TitleBar=0, TitleBlend, Font, ButtonFg, ButtonBg,
|
||||
ButtonBlend, Frame, Handle, ButtonSingleColor, Groove, GrooveText};
|
||||
enum ColorType{TitleBar=0, TitleBlend, Font, ButtonBg, Frame, Handle};
|
||||
|
||||
MoveResizeMode resizeMode;
|
||||
MoveResizeMode moveMode;
|
||||
|
|
|
@ -50,8 +50,8 @@ static void create_pixmaps()
|
|||
if ( pixmaps_created )
|
||||
return;
|
||||
pixmaps_created = true;
|
||||
QColorGroup aGrp = options->colorGroup(Options::ButtonSingleColor, true);
|
||||
QColorGroup iGrp = options->colorGroup(Options::ButtonSingleColor, false);
|
||||
QColorGroup aGrp = options->colorGroup(Options::ButtonBg, true);
|
||||
QColorGroup iGrp = options->colorGroup(Options::ButtonBg, false);
|
||||
|
||||
QPainter aPainter, iPainter;
|
||||
close_pix = new QPixmap(16, 16);
|
||||
|
@ -395,3 +395,4 @@ void StdClient::maxButtonClicked( int button )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue