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())); this, SIGNAL(changed()));
connect(m_dialog->titleShadow, SIGNAL(toggled(bool)), connect(m_dialog->titleShadow, SIGNAL(toggled(bool)),
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(m_dialog->coloredBorder, SIGNAL(toggled(bool)),
this, SIGNAL(changed()));
} }
PlastikConfig::~PlastikConfig() PlastikConfig::~PlastikConfig()
@ -80,6 +81,8 @@ void PlastikConfig::load(KConfig*)
m_dialog->menuClose->setChecked(menuClose); m_dialog->menuClose->setChecked(menuClose);
bool titleShadow = m_config->readBoolEntry("TitleShadow", true); bool titleShadow = m_config->readBoolEntry("TitleShadow", true);
m_dialog->titleShadow->setChecked(titleShadow); m_dialog->titleShadow->setChecked(titleShadow);
bool coloredBorder = m_config->readBoolEntry("ColoredBorder", true);
m_dialog->coloredBorder->setChecked(coloredBorder);
} }
void PlastikConfig::save(KConfig*) void PlastikConfig::save(KConfig*)
@ -91,6 +94,7 @@ void PlastikConfig::save(KConfig*)
m_config->writeEntry("AnimateButtons", m_dialog->animateButtons->isChecked() ); m_config->writeEntry("AnimateButtons", m_dialog->animateButtons->isChecked() );
m_config->writeEntry("CloseOnMenuDoubleClick", m_dialog->menuClose->isChecked() ); m_config->writeEntry("CloseOnMenuDoubleClick", m_dialog->menuClose->isChecked() );
m_config->writeEntry("TitleShadow", m_dialog->titleShadow->isChecked() ); m_config->writeEntry("TitleShadow", m_dialog->titleShadow->isChecked() );
m_config->writeEntry("ColoredBorder", m_dialog->coloredBorder->isChecked() );
m_config->sync(); m_config->sync();
} }
@ -102,6 +106,7 @@ void PlastikConfig::defaults()
m_dialog->animateButtons->setChecked(true); m_dialog->animateButtons->setChecked(true);
m_dialog->menuClose->setChecked(false); m_dialog->menuClose->setChecked(false);
m_dialog->titleShadow->setChecked(true); 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> <class>ConfigDialog</class>
<widget class="QWidget"> <widget class="QWidget">
<property name="name"> <property name="name">
@ -9,20 +9,20 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>541</width> <width>541</width>
<height>167</height> <height>170</height>
</rect> </rect>
</property> </property>
<property name="caption"> <property name="caption">
<string>Config Dialog</string> <string>Config Dialog</string>
</property> </property>
<grid> <vbox>
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </property>
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
</property> </property>
<widget class="QButtonGroup" row="0" column="0" rowspan="1" colspan="4"> <widget class="QButtonGroup">
<property name="name"> <property name="name">
<cstring>titleAlign</cstring> <cstring>titleAlign</cstring>
</property> </property>
@ -59,7 +59,21 @@
</widget> </widget>
</hbox> </hbox>
</widget> </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"> <property name="name">
<cstring>titleShadow</cstring> <cstring>titleShadow</cstring>
</property> </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> <string>Check this option if you want the titlebar text to have a 3D look with a shadow behind it.</string>
</property> </property>
</widget> </widget>
<widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="3"> <widget class="QCheckBox">
<property name="name"> <property name="name">
<cstring>animateButtons</cstring> <cstring>animateButtons</cstring>
</property> </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> <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> </property>
</widget> </widget>
<widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="4"> <widget class="QCheckBox">
<property name="name"> <property name="name">
<cstring>menuClose</cstring> <cstring>menuClose</cstring>
</property> </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> <string>Check this option if you want windows to be closed when you double click the menu button, similar to Microsoft Windows.</string>
</property> </property>
</widget> </widget>
</grid> </vbox>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>AlignLeft</tabstop> <tabstop>AlignLeft</tabstop>

View File

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

View File

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

View File

@ -336,7 +336,7 @@ void PlastikClient::paintEvent(QPaintEvent *e)
// leftSpacer // leftSpacer
if(borderLeft > 0 && sideHeight > 0) 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) ) { if (tempRect.isValid() && region.contains(tempRect) ) {
painter.drawTiledPixmap(tempRect, handler->pixmap(BorderLeftTile, active, toolWindow) ); painter.drawTiledPixmap(tempRect, handler->pixmap(BorderLeftTile, active, toolWindow) );
} }
@ -345,7 +345,7 @@ void PlastikClient::paintEvent(QPaintEvent *e)
// rightSpacer // rightSpacer
if(borderRight > 0 && sideHeight > 0) 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) ) { if (tempRect.isValid() && region.contains(tempRect) ) {
painter.drawTiledPixmap(tempRect, handler->pixmap(BorderRightTile, active, toolWindow) ); painter.drawTiledPixmap(tempRect, handler->pixmap(BorderRightTile, active, toolWindow) );
} }