From 6a8e5c41d8acfd233a3d7d536155e6137268b9ad Mon Sep 17 00:00:00 2001 From: Sandro Giessl Date: Sun, 20 Mar 2005 22:24:04 +0000 Subject: [PATCH] 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 --- clients/plastik/config/config.cpp | 7 +- clients/plastik/config/configdialog.ui | 30 ++++-- clients/plastik/plastik.cpp | 143 ++++++++++++++++++------- clients/plastik/plastik.h | 1 + clients/plastik/plastikclient.cpp | 4 +- 5 files changed, 136 insertions(+), 49 deletions(-) diff --git a/clients/plastik/config/config.cpp b/clients/plastik/config/config.cpp index 092fe749ed..494dccec88 100644 --- a/clients/plastik/config/config.cpp +++ b/clients/plastik/config/config.cpp @@ -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); } ////////////////////////////////////////////////////////////////////////////// diff --git a/clients/plastik/config/configdialog.ui b/clients/plastik/config/configdialog.ui index 2dcff9a7c5..ca6325ee6e 100644 --- a/clients/plastik/config/configdialog.ui +++ b/clients/plastik/config/configdialog.ui @@ -1,4 +1,4 @@ - + ConfigDialog @@ -9,20 +9,20 @@ 0 0 541 - 167 + 170 Config Dialog - + unnamed 0 - + titleAlign @@ -59,7 +59,21 @@ - + + + coloredBorder + + + Colored Window Border + + + + + + Check this option if you the window border should be painted in the titlebar color. Otherwise it will be painted in the background color. + + + titleShadow @@ -70,7 +84,7 @@ Check this option if you want the titlebar text to have a 3D look with a shadow behind it. - + animateButtons @@ -81,7 +95,7 @@ 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. - + menuClose @@ -92,7 +106,7 @@ Check this option if you want windows to be closed when you double click the menu button, similar to Microsoft Windows. - + AlignLeft diff --git a/clients/plastik/plastik.cpp b/clients/plastik/plastik.cpp index 43ea8ec247..4ef8a27ad4 100644 --- a/clients/plastik/plastik.cpp +++ b/clients/plastik/plastik.cpp @@ -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(); diff --git a/clients/plastik/plastik.h b/clients/plastik/plastik.h index aa2d1685cb..177d63387d 100644 --- a/clients/plastik/plastik.h +++ b/clients/plastik/plastik.h @@ -101,6 +101,7 @@ public: private: void readConfig(); + bool m_coloredBorder; bool m_titleShadow; bool m_animateButtons; bool m_menuClose; diff --git a/clients/plastik/plastikclient.cpp b/clients/plastik/plastikclient.cpp index 4612804d4f..f323db2dbf 100644 --- a/clients/plastik/plastikclient.cpp +++ b/clients/plastik/plastikclient.cpp @@ -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) ); }