Add an option for a titlebar-colored window border. I think it looks better than

before, enabled by default.

FEATURE: 98922

svn path=/trunk/kdebase/kwin/; revision=399363
icc-effect-5.14.5
Sandro Giessl 2005-03-20 22:24:04 +00:00
parent cd66337cff
commit 6a8e5c41d8
5 changed files with 136 additions and 49 deletions

View File

@ -57,7 +57,8 @@ PlastikConfig::PlastikConfig(KConfig* config, QWidget* parent)
this, SIGNAL(changed()));
connect(m_dialog->titleShadow, SIGNAL(toggled(bool)),
this, SIGNAL(changed()));
connect(m_dialog->coloredBorder, SIGNAL(toggled(bool)),
this, SIGNAL(changed()));
}
PlastikConfig::~PlastikConfig()
@ -80,6 +81,8 @@ void PlastikConfig::load(KConfig*)
m_dialog->menuClose->setChecked(menuClose);
bool titleShadow = m_config->readBoolEntry("TitleShadow", true);
m_dialog->titleShadow->setChecked(titleShadow);
bool coloredBorder = m_config->readBoolEntry("ColoredBorder", true);
m_dialog->coloredBorder->setChecked(coloredBorder);
}
void PlastikConfig::save(KConfig*)
@ -91,6 +94,7 @@ void PlastikConfig::save(KConfig*)
m_config->writeEntry("AnimateButtons", m_dialog->animateButtons->isChecked() );
m_config->writeEntry("CloseOnMenuDoubleClick", m_dialog->menuClose->isChecked() );
m_config->writeEntry("TitleShadow", m_dialog->titleShadow->isChecked() );
m_config->writeEntry("ColoredBorder", m_dialog->coloredBorder->isChecked() );
m_config->sync();
}
@ -102,6 +106,7 @@ void PlastikConfig::defaults()
m_dialog->animateButtons->setChecked(true);
m_dialog->menuClose->setChecked(false);
m_dialog->titleShadow->setChecked(true);
m_dialog->coloredBorder->setChecked(true);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,4 +1,4 @@
<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>ConfigDialog</class>
<widget class="QWidget">
<property name="name">
@ -9,20 +9,20 @@
<x>0</x>
<y>0</y>
<width>541</width>
<height>167</height>
<height>170</height>
</rect>
</property>
<property name="caption">
<string>Config Dialog</string>
</property>
<grid>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<widget class="QButtonGroup" row="0" column="0" rowspan="1" colspan="4">
<widget class="QButtonGroup">
<property name="name">
<cstring>titleAlign</cstring>
</property>
@ -59,7 +59,21 @@
</widget>
</hbox>
</widget>
<widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="4">
<widget class="QCheckBox">
<property name="name">
<cstring>coloredBorder</cstring>
</property>
<property name="text">
<string>Colored Window Border</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="whatsThis" stdset="0">
<string>Check this option if you the window border should be painted in the titlebar color. Otherwise it will be painted in the background color.</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>titleShadow</cstring>
</property>
@ -70,7 +84,7 @@
<string>Check this option if you want the titlebar text to have a 3D look with a shadow behind it.</string>
</property>
</widget>
<widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="3">
<widget class="QCheckBox">
<property name="name">
<cstring>animateButtons</cstring>
</property>
@ -81,7 +95,7 @@
<string>Check this option if you want the buttons to fade in when the mouse pointer hovers over them and fade out again when it moves away.</string>
</property>
</widget>
<widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="4">
<widget class="QCheckBox">
<property name="name">
<cstring>menuClose</cstring>
</property>
@ -92,7 +106,7 @@
<string>Check this option if you want windows to be closed when you double click the menu button, similar to Microsoft Windows.</string>
</property>
</widget>
</grid>
</vbox>
</widget>
<tabstops>
<tabstop>AlignLeft</tabstop>

View File

@ -65,7 +65,7 @@ bool PlastikHandler::reset(unsigned long changed)
switch(KDecoration::options()->preferredBorderSize( this )) {
case BorderTiny:
m_borderSize = 2;
m_borderSize = 3;
break;
case BorderLarge:
m_borderSize = 8;
@ -186,6 +186,7 @@ void PlastikHandler::readConfig()
else if (value == "AlignHCenter") m_titleAlign = Qt::AlignHCenter;
else if (value == "AlignRight") m_titleAlign = Qt::AlignRight;
m_coloredBorder = config.readBoolEntry("ColoredBorder", true);
m_animateButtons = config.readBoolEntry("AnimateButtons", true);
m_menuClose = config.readBoolEntry("CloseOnMenuDoubleClick", true);
}
@ -206,11 +207,11 @@ QColor PlastikHandler::getColor(KWinPlastik::ColorType type, const bool active)
break;
case ShadeTitleLight:
return alphaBlendColors(KDecoration::options()->color(ColorTitleBar, active),
Qt::white, active?150:160);
Qt::white, active?205:215);
break;
case ShadeTitleDark:
return alphaBlendColors(KDecoration::options()->color(ColorTitleBar, active),
Qt::black, active?150:160);
Qt::black, active?205:215);
break;
case Border:
return KDecoration::options()->color(ColorFrame, active);
@ -269,7 +270,11 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
pm = new QPixmap(1, titleBarTileHeight);
painter.begin(pm);
painter.drawPixmap(0, 0, gradient, 0,2);
painter.setPen(getColor(TitleGradient3, active) );
if (m_coloredBorder) {
painter.setPen(getColor(TitleGradient3, active).dark(110) );
} else {
painter.setPen(getColor(TitleGradient3, active) );
}
painter.drawPoint(0,titleBarTileHeight-1);
painter.end();
}
@ -292,11 +297,15 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
painter.drawLine(0,0, 0,h);
painter.drawPoint(1,1);
const QColor highlightTitleLeft = alphaBlendColors(getColor(TitleGradient3, active),
getColor(ShadeTitleLight, active), 150);
const QColor highlightTitleLeft = getColor(ShadeTitleLight, active);
painter.setPen(highlightTitleLeft);
painter.drawLine(1,2, 1,h);
if (m_coloredBorder) {
painter.setPen(getColor(TitleGradient3, active) );
painter.drawLine(2,h-1, w-1,h-1);
}
// outside the region normally masked by doShape
painter.setPen(QColor(0,0,0) );
painter.drawLine(0, 0, 1, 0 );
@ -320,11 +329,15 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
painter.drawLine(w-1,0, w-1,h);
painter.drawPoint(w-2,1);
const QColor highlightTitleRight = alphaBlendColors(getColor(TitleGradient3, active),
getColor(ShadeTitleDark, active), 150);
const QColor highlightTitleRight = getColor(ShadeTitleDark, active);
painter.setPen(highlightTitleRight);
painter.drawLine(w-2,2, w-2,h);
if (m_coloredBorder) {
painter.setPen(getColor(TitleGradient3, active) );
painter.drawLine(0,h-1, w-3,h-1);
}
// outside the region normally masked by doShape
painter.setPen(QColor(0,0,0) );
painter.drawLine(w-2, 0, w-1, 0 );
@ -339,14 +352,27 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
pm = new QPixmap(w, 1);
QPainter painter(pm);
painter.setPen(getColor(WindowContour, active) );
painter.drawPoint(0, 0);
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleLight, active), 150) );
painter.drawPoint(1, 0);
painter.setPen(getColor(Border, active) );
painter.drawLine(2,0, w-1,0);
if (m_coloredBorder) {
painter.setPen(getColor(WindowContour, active) );
painter.drawPoint(0, 0);
painter.setPen(getColor(ShadeTitleLight, active) );
painter.drawPoint(1, 0);
if (w > 3) {
painter.setPen(getColor(TitleGradient3, active) );
painter.drawLine(2,0, w-2,0);
}
painter.setPen(getColor(TitleGradient3, active).dark(110) );
painter.drawPoint(w-1,0);
} else {
painter.setPen(getColor(WindowContour, active) );
painter.drawPoint(0, 0);
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleLight, active), 130) );
painter.drawPoint(1, 0);
painter.setPen(getColor(Border, active) );
painter.drawLine(2,0, w-1,0);
}
painter.end();
@ -359,14 +385,27 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
pm = new QPixmap(w, 1);
QPainter painter(pm);
painter.setPen(getColor(Border, active) );
painter.drawLine(0,0, w-3,0);
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleDark, active), 150) );
painter.drawPoint(w-2, 0);
painter.setPen(getColor(WindowContour, active) );
painter.drawPoint(w-1, 0);
if (m_coloredBorder) {
painter.setPen(getColor(TitleGradient3, active).dark(110) );
painter.drawPoint(0,0);
if (w > 3) {
painter.setPen(getColor(TitleGradient3, active) );
painter.drawLine(1,0, w-3,0);
}
painter.setPen(getColor(ShadeTitleDark, active) );
painter.drawPoint(w-2, 0);
painter.setPen(getColor(WindowContour, active) );
painter.drawPoint(w-1, 0);
} else {
painter.setPen(getColor(Border, active) );
painter.drawLine(0,0, w-3,0);
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleDark, active), 130) );
painter.drawPoint(w-2, 0);
painter.setPen(getColor(WindowContour, active) );
painter.drawPoint(w-1, 0);
}
painter.end();
break;
@ -382,10 +421,20 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
painter.drawTiledPixmap(0,0,w,h, pixmap(BorderBottomTile, active, toolWindow) );
painter.setPen(getColor(WindowContour, active) );
painter.drawLine(0,0, 0,h);
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleLight, active), 150) );
painter.drawLine(1,0, 1,h-2);
if (m_coloredBorder) {
if (h > 3) {
painter.setPen(getColor(ShadeTitleLight, active) );
painter.drawLine(1,0, 1,h-2);
}
painter.setPen(getColor(TitleGradient3, active) );
painter.drawLine(2,0, w-1,0);
} else {
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleLight, active), 130) );
painter.drawLine(1,0, 1,h-2);
}
painter.end();
@ -402,10 +451,18 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
painter.drawTiledPixmap(0,0,w,h, pixmap(BorderBottomTile, active, toolWindow) );
painter.setPen(getColor(WindowContour, active) );
painter.drawLine(w-1,0, w-1,h);
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleDark, active), 150) );
painter.drawLine(w-2,0, w-2,h-2);
if (m_coloredBorder) {
painter.setPen(getColor(ShadeTitleDark, active) );
painter.drawLine(w-2,0, w-2,h-2);
painter.setPen(getColor(TitleGradient3, active) );
painter.drawLine(0,0, w-3,0);
} else {
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleDark, active), 130) );
painter.drawLine(w-2,0, w-2,h-2);
}
painter.end();
@ -419,12 +476,22 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow
pm = new QPixmap(1, m_borderSize);
QPainter painter(pm);
painter.setPen(getColor(Border, active) );
painter.drawLine(0,0, 0,h-3);
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleDark, active), 150) );
painter.drawPoint(0, h-2);
if (m_coloredBorder) {
painter.setPen(getColor(TitleGradient3, active).dark(110) );
painter.drawPoint(0,0);
painter.setPen(getColor(TitleGradient3, active) );
painter.drawLine(0,1, 0,h-3);
painter.setPen(getColor(ShadeTitleDark, active) );
painter.drawPoint(0, h-2);
} else {
painter.setPen(getColor(Border, active) );
painter.drawLine(0,0, 0,h-3);
painter.setPen(
alphaBlendColors(getColor(Border, active),
getColor(ShadeTitleDark, active), 130) );
painter.drawPoint(0, h-2);
}
painter.setPen(getColor(WindowContour, active) );
painter.drawPoint(0, h-1);
painter.end();

View File

@ -101,6 +101,7 @@ public:
private:
void readConfig();
bool m_coloredBorder;
bool m_titleShadow;
bool m_animateButtons;
bool m_menuClose;

View File

@ -336,7 +336,7 @@ void PlastikClient::paintEvent(QPaintEvent *e)
// leftSpacer
if(borderLeft > 0 && sideHeight > 0)
{
tempRect.setCoords(r_x, titleEdgeBottomBottom+1, borderLeftRight, borderBottomTop);
tempRect.setCoords(r_x, titleEdgeBottomBottom+1, borderLeftRight, borderBottomTop-1);
if (tempRect.isValid() && region.contains(tempRect) ) {
painter.drawTiledPixmap(tempRect, handler->pixmap(BorderLeftTile, active, toolWindow) );
}
@ -345,7 +345,7 @@ void PlastikClient::paintEvent(QPaintEvent *e)
// rightSpacer
if(borderRight > 0 && sideHeight > 0)
{
tempRect.setCoords(borderRightLeft, titleEdgeBottomBottom+1, r_x2, borderBottomTop);
tempRect.setCoords(borderRightLeft, titleEdgeBottomBottom+1, r_x2, borderBottomTop-1);
if (tempRect.isValid() && region.contains(tempRect) ) {
painter.drawTiledPixmap(tempRect, handler->pixmap(BorderRightTile, active, toolWindow) );
}