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:
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 |
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <kconfiggroup.h>
|
||||
#include <kdebug.h>
|
||||
#include <KStandardDirs>
|
||||
#include <kcolorscheme.h>
|
||||
|
||||
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;
|
||||
|
|
|
@ -52,6 +52,7 @@ class ShadowEffect
|
|||
int shadowFuzzyness;
|
||||
int shadowSize;
|
||||
bool intensifyActiveShadow;
|
||||
QColor shadowColor;
|
||||
GLTexture* mShadowTexture;
|
||||
|
||||
struct ShadowData
|
||||
|
|
|
@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <klocale.h>
|
||||
#include <kdebug.h>
|
||||
#include <kconfiggroup.h>
|
||||
#include <kcolorbutton.h>
|
||||
#include <kcolorscheme.h>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGridLayout>
|
||||
|
@ -36,6 +38,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue