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
This commit is contained in:
Rivo Laks 2008-03-12 22:12:55 +00:00
parent 8344f4c8d9
commit 9fa1b86285
5 changed files with 31 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 689 B

View file

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kconfiggroup.h> #include <kconfiggroup.h>
#include <kdebug.h> #include <kdebug.h>
#include <KStandardDirs> #include <KStandardDirs>
#include <kcolorscheme.h>
namespace KWin namespace KWin
{ {
@ -39,6 +40,7 @@ ShadowEffect::ShadowEffect()
shadowOpacity = conf.readEntry( "Opacity", 0.25 ); shadowOpacity = conf.readEntry( "Opacity", 0.25 );
shadowFuzzyness = conf.readEntry( "Fuzzyness", 10 ); shadowFuzzyness = conf.readEntry( "Fuzzyness", 10 );
shadowSize = conf.readEntry( "Size", 5 ); shadowSize = conf.readEntry( "Size", 5 );
shadowColor = conf.readEntry( "Color", KColorScheme::shade( Qt::white, KColorScheme::ShadowShade ) );
intensifyActiveShadow = conf.readEntry( "IntensifyActiveShadow", true ); intensifyActiveShadow = conf.readEntry( "IntensifyActiveShadow", true );
QString shadowtexture = KGlobal::dirs()->findResource("data", "kwin/shadow-texture.png"); 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); 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); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// We have two elements per vertex in the verts array // We have two elements per vertex in the verts array
int verticesCount = verts.count() / 2; int verticesCount = verts.count() / 2;

View file

@ -52,6 +52,7 @@ class ShadowEffect
int shadowFuzzyness; int shadowFuzzyness;
int shadowSize; int shadowSize;
bool intensifyActiveShadow; bool intensifyActiveShadow;
QColor shadowColor;
GLTexture* mShadowTexture; GLTexture* mShadowTexture;
struct ShadowData struct ShadowData

View file

@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <klocale.h> #include <klocale.h>
#include <kdebug.h> #include <kdebug.h>
#include <kconfiggroup.h> #include <kconfiggroup.h>
#include <kcolorbutton.h>
#include <kcolorscheme.h>
#include <QWidget> #include <QWidget>
#include <QGridLayout> #include <QGridLayout>
@ -36,6 +38,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
KWIN_EFFECT_CONFIG_FACTORY KWIN_EFFECT_CONFIG_FACTORY
#endif #endif
// Save some typing
static QColor schemeShadowColor()
{
return KColorScheme::shade(Qt::white, KColorScheme::ShadowShade);
}
namespace KWin namespace KWin
{ {
@ -77,9 +85,15 @@ ShadowEffectConfig::ShadowEffectConfig(QWidget* parent, const QVariantList& args
connect(mShadowSize, SIGNAL(valueChanged(int)), this, SLOT(changed())); connect(mShadowSize, SIGNAL(valueChanged(int)), this, SLOT(changed()));
layout->addWidget(mShadowSize, 4, 1); 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); mIntensifyActiveShadow = new QCheckBox(i18n("Active window has stronger shadow"), this);
connect(mIntensifyActiveShadow, SIGNAL(toggled(bool)), this, SLOT(changed())); 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); 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 ) ); mShadowOpacity->setValue( (int)( conf.readEntry( "Opacity", 0.25 ) * 100 ) );
mShadowFuzzyness->setValue( conf.readEntry( "Fuzzyness", 10 ) ); mShadowFuzzyness->setValue( conf.readEntry( "Fuzzyness", 10 ) );
mShadowSize->setValue( conf.readEntry( "Size", 5 ) ); mShadowSize->setValue( conf.readEntry( "Size", 5 ) );
mShadowColor->setColor( conf.readEntry( "Color", schemeShadowColor() ) );
mIntensifyActiveShadow->setChecked( conf.readEntry( "IntensifyActiveShadow", true ) ); mIntensifyActiveShadow->setChecked( conf.readEntry( "IntensifyActiveShadow", true ) );
emit changed(false); emit changed(false);
@ -118,6 +133,14 @@ void ShadowEffectConfig::save()
conf.writeEntry( "Opacity", mShadowOpacity->value() / 100.0 ); conf.writeEntry( "Opacity", mShadowOpacity->value() / 100.0 );
conf.writeEntry( "Fuzzyness", mShadowFuzzyness->value() ); conf.writeEntry( "Fuzzyness", mShadowFuzzyness->value() );
conf.writeEntry( "Size", mShadowSize->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.writeEntry( "IntensifyActiveShadow", mIntensifyActiveShadow->isChecked() );
conf.sync(); conf.sync();
@ -134,6 +157,7 @@ void ShadowEffectConfig::defaults()
mShadowFuzzyness->setValue( 10 ); mShadowFuzzyness->setValue( 10 );
mShadowSize->setValue( 5 ); mShadowSize->setValue( 5 );
mIntensifyActiveShadow->setChecked( true ); mIntensifyActiveShadow->setChecked( true );
mShadowColor->setColor( schemeShadowColor() );
emit changed(true); emit changed(true);
} }

View file

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class QSpinBox; class QSpinBox;
class QCheckBox; class QCheckBox;
class KColorButton;
namespace KWin namespace KWin
{ {
@ -48,6 +49,7 @@ class ShadowEffectConfig : public KCModule
QSpinBox* mShadowOpacity; QSpinBox* mShadowOpacity;
QSpinBox* mShadowFuzzyness; QSpinBox* mShadowFuzzyness;
QSpinBox* mShadowSize; QSpinBox* mShadowSize;
KColorButton* mShadowColor;
QCheckBox* mIntensifyActiveShadow; QCheckBox* mIntensifyActiveShadow;
}; };