From 9fa1b862852deb37fdf8de07ca9986e07e426b73 Mon Sep 17 00:00:00 2001 From: Rivo Laks Date: Wed, 12 Mar 2008 22:12:55 +0000 Subject: [PATCH] Make shadow's color configurable and use color scheme for finding the default value. Patch by Louai Al-Khanji svn path=/trunk/KDE/kdebase/workspace/; revision=784969 --- effects/data/shadow-texture.png | Bin 640 -> 689 bytes effects/shadow.cpp | 4 +++- effects/shadow.h | 1 + effects/shadow_config.cpp | 26 +++++++++++++++++++++++++- effects/shadow_config.h | 2 ++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/effects/data/shadow-texture.png b/effects/data/shadow-texture.png index 17f92b94dd3617edc2bd7bb8cd6a39e3be9e1395..e6a9145d78d3f9c8b19d3bce620eb897105ace74 100644 GIT binary patch delta 645 zcmV;00($*`1+fK?Bntv!OGiWi0IH26GLaz{e*#rWL_t(Y$9}CLn4buieKX=3m;2dHkAd?xCCMs z%oBt>887@RBar-vnv13ofvA`K%pynz20`>K+2e3ShRDp6DM&W0Fd2kw91sGLP(s+k ze;5RVp`yZ2VK5mW;PC`J0TiN$Ks5NlxWZx;CINUH9*5vSAt0717zMCcYH9@;00It2 zkD&*gCLlnx1?!^TS9)t|3=nYibVWRInS;T9&5AV}wrp5a1D=)#jRJ(MMx3gU2&`GL zVaJ|5udER|?%b#}8Bb6}BmpG(Mg}(Qe>w2Zffo!7-<%Nw9*4!_FiIn~DBJ|GV#}U) ze(}K@!kse)M@vhW<&}YjB;yof%_|2!IC4bzq~gJqE44~nROv|KSc?@kYhHNc$Zx=K zVaJA5QK5zU%ct}*@i=ev6hZ3ssAbdf;Laxo;SWDFbhuK!=WdL-<{ce(zBy5Ge?j=+ z#1}Un^jX9>?S)ibL%Z}e+&E)s*&#H1apFotkHb&nu(>FQhIJbL4Z(3`3v~Q&;X*@; zn?u;#+d*5lSDgbbH)_D~prN6mqsJ9V#G#o|5<>*3L>w)5Dnwan=@h^#0AmE?I!}TP zN?7eiukGB^>tKn`BP|J-plq(XZf}!|NB=L>(Ddqm0{@J$t(o3w1a0i7JolVS<{=t^e{Xb&MWfGh4*$9p zcMi)^nedKp*Yfi3B2DYIaH5sfoufU9h&pgPrtjxz#>FFfikRgz9##*w1WPrYYv zJkWR45e-R9!+0qq3o^cO(Dyo_);dPAR9|?OB~DO+!cTRkPqYsxmNEZ9K<=HOOPq?? zBRB^8sL#64Ig%5te**s#HN@5E1RkFi2>b}-4E&3}>M{fipgncaOG!%M2Q?EcWBJx# z7vSG?g`xx5>rp#B3q?o}L~{Zv1uGJ)NpKE&h2)g)x4PGFJ)j_kr_u;=8*2?naS1NK zjc%wdSI>-3HG-UiHxk8~xg!Pot{>F3ZbNXOngo@>5;R;5e~h{T-bBAGL9K!XNZ(|=~Gd+RHzmaBqjIDdpJ>V^Mr`*QG zonY*ZN9B>v-2q?+_z-a6B^cW`lKU|dyij|vCknW5PoSNG|EvRr0-&n!+5veHr-v08 z6$#DJYkVhgO!SIh0$M(G^aVSOV07*qoM6N<$f?W3yV*mgE diff --git a/effects/shadow.cpp b/effects/shadow.cpp index dbac01d9c0..0e6ce06a8d 100644 --- a/effects/shadow.cpp +++ b/effects/shadow.cpp @@ -25,6 +25,7 @@ along with this program. If not, see . #include #include #include +#include namespace KWin { @@ -39,6 +40,7 @@ ShadowEffect::ShadowEffect() shadowOpacity = conf.readEntry( "Opacity", 0.25 ); shadowFuzzyness = conf.readEntry( "Fuzzyness", 10 ); shadowSize = conf.readEntry( "Size", 5 ); + shadowColor = conf.readEntry( "Color", KColorScheme::shade( Qt::white, KColorScheme::ShadowShade ) ); intensifyActiveShadow = conf.readEntry( "IntensifyActiveShadow", true ); QString shadowtexture = KGlobal::dirs()->findResource("data", "kwin/shadow-texture.png"); @@ -215,7 +217,7 @@ void ShadowEffect::drawShadow( EffectWindow* window, int mask, QRegion region, W { opacity = 1 - (1 - shadowOpacity)*(1 - shadowOpacity); } - glColor4f(0, 0, 0, opacity * data.opacity * (window->width() / (double)w) * (window->height() / (double)h)); + glColor4f(shadowColor.redF(), shadowColor.greenF(), shadowColor.blueF(), opacity * data.opacity * (window->width() / (double)w) * (window->height() / (double)h)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // We have two elements per vertex in the verts array int verticesCount = verts.count() / 2; diff --git a/effects/shadow.h b/effects/shadow.h index 24e1b0ef9f..b34669ae29 100644 --- a/effects/shadow.h +++ b/effects/shadow.h @@ -52,6 +52,7 @@ class ShadowEffect int shadowFuzzyness; int shadowSize; bool intensifyActiveShadow; + QColor shadowColor; GLTexture* mShadowTexture; struct ShadowData diff --git a/effects/shadow_config.cpp b/effects/shadow_config.cpp index 96c598abee..dd09b2c8fd 100644 --- a/effects/shadow_config.cpp +++ b/effects/shadow_config.cpp @@ -25,6 +25,8 @@ along with this program. If not, see . #include #include #include +#include +#include #include #include @@ -36,6 +38,12 @@ along with this program. If not, see . KWIN_EFFECT_CONFIG_FACTORY #endif +// Save some typing +static QColor schemeShadowColor() +{ + return KColorScheme::shade(Qt::white, KColorScheme::ShadowShade); +} + namespace KWin { @@ -77,9 +85,15 @@ ShadowEffectConfig::ShadowEffectConfig(QWidget* parent, const QVariantList& args connect(mShadowSize, SIGNAL(valueChanged(int)), this, SLOT(changed())); layout->addWidget(mShadowSize, 4, 1); + layout->addWidget(new QLabel(i18n("Shadow color:"), this), 5, 0); + mShadowColor = new KColorButton(this); + mShadowColor->setDefaultColor(schemeShadowColor()); + connect(mShadowColor, SIGNAL(changed(QColor)), this, SLOT(changed())); + layout->addWidget(mShadowColor, 5, 1); + mIntensifyActiveShadow = new QCheckBox(i18n("Active window has stronger shadow"), this); connect(mIntensifyActiveShadow, SIGNAL(toggled(bool)), this, SLOT(changed())); - layout->addWidget(mIntensifyActiveShadow, 5, 0, 1, 2); + layout->addWidget(mIntensifyActiveShadow, 6, 0, 1, 2); layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 6, 0, 1, 2); @@ -102,6 +116,7 @@ void ShadowEffectConfig::load() mShadowOpacity->setValue( (int)( conf.readEntry( "Opacity", 0.25 ) * 100 ) ); mShadowFuzzyness->setValue( conf.readEntry( "Fuzzyness", 10 ) ); mShadowSize->setValue( conf.readEntry( "Size", 5 ) ); + mShadowColor->setColor( conf.readEntry( "Color", schemeShadowColor() ) ); mIntensifyActiveShadow->setChecked( conf.readEntry( "IntensifyActiveShadow", true ) ); emit changed(false); @@ -118,6 +133,14 @@ void ShadowEffectConfig::save() conf.writeEntry( "Opacity", mShadowOpacity->value() / 100.0 ); conf.writeEntry( "Fuzzyness", mShadowFuzzyness->value() ); conf.writeEntry( "Size", mShadowSize->value() ); + QColor userColor = mShadowColor->color(); + if (userColor == schemeShadowColor()) { + // If the user has reset the color to the default we want to start + // picking up color scheme changes again in the shadow effect + conf.deleteEntry( "Color" ); + } else { + conf.writeEntry( "Color", userColor ); + } conf.writeEntry( "IntensifyActiveShadow", mIntensifyActiveShadow->isChecked() ); conf.sync(); @@ -134,6 +157,7 @@ void ShadowEffectConfig::defaults() mShadowFuzzyness->setValue( 10 ); mShadowSize->setValue( 5 ); mIntensifyActiveShadow->setChecked( true ); + mShadowColor->setColor( schemeShadowColor() ); emit changed(true); } diff --git a/effects/shadow_config.h b/effects/shadow_config.h index 1bd59a286b..d311a8310f 100644 --- a/effects/shadow_config.h +++ b/effects/shadow_config.h @@ -27,6 +27,7 @@ along with this program. If not, see . class QSpinBox; class QCheckBox; +class KColorButton; namespace KWin { @@ -48,6 +49,7 @@ class ShadowEffectConfig : public KCModule QSpinBox* mShadowOpacity; QSpinBox* mShadowFuzzyness; QSpinBox* mShadowSize; + KColorButton* mShadowColor; QCheckBox* mIntensifyActiveShadow; };