re-organized ::shadowtiles code to 1/ fix bug on storing created tiles 2/ avoid duplicated code. 3/ handle options properly to store active and inactive shadowTiles.
svn path=/trunk/KDE/kdebase/workspace/; revision=1020690
This commit is contained in:
parent
6eb3f0ef51
commit
8c9049e425
1 changed files with 47 additions and 43 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include <KGlobal>
|
#include <KGlobal>
|
||||||
#include <KLocale>
|
#include <KLocale>
|
||||||
#include <KColorUtils>
|
#include <KColorUtils>
|
||||||
|
#include <KDebug>
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -655,9 +656,8 @@ namespace Nitrogen
|
||||||
shadowTiles(
|
shadowTiles(
|
||||||
backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ),
|
backgroundPalette( widget(), palette ).color( widget()->backgroundRole() ),
|
||||||
KDecoration::options()->color(ColorTitleBar),
|
KDecoration::options()->color(ColorTitleBar),
|
||||||
SHADOW_WIDTH, configuration().useOxygenShadows() && isActive() )->render( frame.adjusted( 4, 4, -4, -4),
|
SHADOW_WIDTH, isActive() )->render( frame.adjusted( 4, 4, -4, -4),
|
||||||
&painter, TileSet::Ring);
|
&painter, TileSet::Ring);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust frame
|
// adjust frame
|
||||||
|
@ -893,7 +893,7 @@ namespace Nitrogen
|
||||||
opt.windowColor = color;
|
opt.windowColor = color;
|
||||||
opt.glowColor = glow;
|
opt.glowColor = glow;
|
||||||
|
|
||||||
ShadowTilesOption currentOpt = active ? shadowTilesOption_ : glowTilesOption_;
|
ShadowTilesOption currentOpt = active ? glowTilesOption_:shadowTilesOption_;
|
||||||
|
|
||||||
bool optionChanged = !(currentOpt == opt );
|
bool optionChanged = !(currentOpt == opt );
|
||||||
if (active && glowTiles_ )
|
if (active && glowTiles_ )
|
||||||
|
@ -909,38 +909,19 @@ namespace Nitrogen
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kDebug( 1212 ) << " creating tiles - active: " << active << endl;
|
||||||
TileSet *tileSet = 0;
|
TileSet *tileSet = 0;
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// Create new glow/shadow tiles
|
// Create new glow/shadow tiles
|
||||||
|
|
||||||
QColor light = helper().calcLightColor( helper().backgroundTopColor(color) );
|
|
||||||
QColor dark = helper().calcDarkColor(helper().backgroundBottomColor(color));
|
|
||||||
|
|
||||||
QPixmap shadow = QPixmap( size*2, size*2 );
|
QPixmap shadow = QPixmap( size*2, size*2 );
|
||||||
shadow.fill( Qt::transparent );
|
shadow.fill( Qt::transparent );
|
||||||
|
|
||||||
// draw the corner of the window - actually all 4 corners as one circle
|
|
||||||
QLinearGradient lg = QLinearGradient(0.0, size-4.5, 0.0, size+4.5);
|
|
||||||
if( configuration().frameBorder() < NitrogenConfiguration::BorderTiny )
|
|
||||||
{
|
|
||||||
|
|
||||||
lg.setColorAt(0, helper().backgroundTopColor(color) );
|
|
||||||
lg.setColorAt(0.52, helper().backgroundTopColor(color));
|
|
||||||
lg.setColorAt(1.0, helper().backgroundBottomColor(color) );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
lg.setColorAt(0.52, light);
|
|
||||||
lg.setColorAt(1.0, dark);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QPainter p( &shadow );
|
QPainter p( &shadow );
|
||||||
p.setRenderHint( QPainter::Antialiasing );
|
p.setRenderHint( QPainter::Antialiasing );
|
||||||
p.setPen( Qt::NoPen );
|
p.setPen( Qt::NoPen );
|
||||||
|
|
||||||
if (active)
|
if( active && configuration().useOxygenShadows() )
|
||||||
{
|
{
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
// Active shadow texture
|
// Active shadow texture
|
||||||
|
@ -971,15 +952,6 @@ namespace Nitrogen
|
||||||
p.setBrush( rg );
|
p.setBrush( rg );
|
||||||
p.drawRect( shadow.rect() );
|
p.drawRect( shadow.rect() );
|
||||||
|
|
||||||
p.setBrush( Qt::NoBrush );
|
|
||||||
p.setPen(QPen(lg, 0.8));
|
|
||||||
p.drawEllipse(QRectF(size-4, size-4, 8, 8));
|
|
||||||
|
|
||||||
p.end();
|
|
||||||
|
|
||||||
tileSet = new TileSet(shadow, size, size, 1, 1);
|
|
||||||
glowTilesOption_ = opt;
|
|
||||||
glowTiles_ = tileSet;
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
|
@ -1035,7 +1007,28 @@ namespace Nitrogen
|
||||||
p.setBrush( rg );
|
p.setBrush( rg );
|
||||||
p.drawRect( shadow.rect() );
|
p.drawRect( shadow.rect() );
|
||||||
|
|
||||||
|
tileSet = new TileSet(shadow, size, size, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// draw the corner of the window - actually all 4 corners as one circle
|
// draw the corner of the window - actually all 4 corners as one circle
|
||||||
|
QLinearGradient lg = QLinearGradient(0.0, size-4.5, 0.0, size+4.5);
|
||||||
|
if( configuration().frameBorder() < NitrogenConfiguration::BorderTiny )
|
||||||
|
{
|
||||||
|
|
||||||
|
// for no
|
||||||
|
lg.setColorAt(0.52, helper().backgroundTopColor(color));
|
||||||
|
lg.setColorAt(1.0, helper().backgroundBottomColor(color) );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
QColor light = helper().calcLightColor( helper().backgroundTopColor(color) );
|
||||||
|
QColor dark = helper().calcDarkColor(helper().backgroundBottomColor(color));
|
||||||
|
|
||||||
|
lg.setColorAt(0.52, light);
|
||||||
|
lg.setColorAt(1.0, dark);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
p.setBrush( Qt::NoBrush );
|
p.setBrush( Qt::NoBrush );
|
||||||
p.setPen(QPen(lg, 0.8));
|
p.setPen(QPen(lg, 0.8));
|
||||||
p.drawEllipse(QRectF(size-4, size-4, 8, 8));
|
p.drawEllipse(QRectF(size-4, size-4, 8, 8));
|
||||||
|
@ -1043,8 +1036,19 @@ namespace Nitrogen
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
tileSet = new TileSet(shadow, size, size, 1, 1);
|
tileSet = new TileSet(shadow, size, size, 1, 1);
|
||||||
|
|
||||||
|
// store option and style
|
||||||
|
if( active )
|
||||||
|
{
|
||||||
|
|
||||||
|
glowTilesOption_ = opt;
|
||||||
|
glowTiles_ = tileSet;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
shadowTilesOption_ = opt;
|
shadowTilesOption_ = opt;
|
||||||
shadowTiles_ = tileSet;
|
shadowTiles_ = tileSet;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tileSet;
|
return tileSet;
|
||||||
|
|
Loading…
Reference in a new issue