Sync r980471 from Oxygen.
svn path=/trunk/KDE/kdebase/workspace/; revision=982625
This commit is contained in:
parent
f9cbed1c1a
commit
787de98e98
2 changed files with 52 additions and 31 deletions
|
@ -79,7 +79,6 @@ static void oxkwincleanupBefore()
|
|||
|
||||
void OxygenClient::invalidateCaches()
|
||||
{
|
||||
shadowCache_.clear();
|
||||
}
|
||||
|
||||
void renderDot(QPainter *p, const QPointF &point, qreal diameter)
|
||||
|
@ -94,9 +93,6 @@ OxygenClient::OxygenClient(KDecorationBridge *b, KDecorationFactory *f)
|
|||
, helper_(*globalHelper)
|
||||
{
|
||||
qAddPostRoutine(oxkwincleanupBefore);
|
||||
|
||||
// cache active and inactive states
|
||||
shadowCache_.setMaxCost(2);
|
||||
}
|
||||
|
||||
OxygenClient::~OxygenClient()
|
||||
|
@ -337,8 +333,9 @@ void OxygenClient::paintEvent(QPaintEvent *e)
|
|||
// draw shadow
|
||||
|
||||
if (compositingActive())
|
||||
shadowTiles(color, SHADOW_WIDTH)->render(
|
||||
frame.adjusted(-SHADOW_WIDTH+4, -SHADOW_WIDTH+4, SHADOW_WIDTH-4, SHADOW_WIDTH-4),
|
||||
shadowTiles(color,KDecoration::options()->color(ColorTitleBar),
|
||||
SHADOW_WIDTH, isActive())->render( frame.adjusted(-SHADOW_WIDTH+4,
|
||||
-SHADOW_WIDTH+4, SHADOW_WIDTH-4, SHADOW_WIDTH-4),
|
||||
&painter, TileSet::Ring);
|
||||
|
||||
// draw window background
|
||||
|
@ -473,8 +470,8 @@ void OxygenClient::drawStripes(QPainter *p, QPalette &palette, const int start,
|
|||
void OxygenClient::updateWindowShape()
|
||||
{
|
||||
bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
|
||||
int w=widget()->width();
|
||||
int h=widget()->height();
|
||||
int w=widget()->width() - (int)SHADOW_WIDTH;
|
||||
int h=widget()->height() - (int)SHADOW_WIDTH;
|
||||
|
||||
if(maximized) {
|
||||
QRegion mask(0,0,w,h);
|
||||
|
@ -483,26 +480,44 @@ void OxygenClient::updateWindowShape()
|
|||
}
|
||||
|
||||
if (!compositingActive()) {
|
||||
QRegion mask(4, 0, w-8, h);
|
||||
mask += QRegion(0, 4, w, h-8);
|
||||
mask += QRegion(2, 1, w-4, h-2);
|
||||
mask += QRegion(1, 2, w-2, h-4);
|
||||
int sw = SHADOW_WIDTH;
|
||||
QRegion mask(sw+4, sw+0, -sw+w-8, -sw+h);
|
||||
mask += QRegion(sw+0, sw+4, -sw+w, -sw+h-8);
|
||||
mask += QRegion(sw+2, sw+1, -sw+w-4, -sw+h-2);
|
||||
mask += QRegion(sw+1, sw+2, -sw+w-2, -sw+h-4);
|
||||
|
||||
setMask(mask);
|
||||
}
|
||||
}
|
||||
|
||||
TileSet *OxygenClient::shadowTiles(const QColor &color, qreal size)
|
||||
TileSet *OxygenClient::shadowTiles(const QColor& color, const QColor& glow, qreal size, bool active)
|
||||
{
|
||||
quint64 key = (quint64(color.rgba()) << 32) | quint64(size*10);
|
||||
TileSet *tileSet = shadowCache_.object(key);
|
||||
ShadowTilesOption opt;
|
||||
opt.active = active;
|
||||
opt.width = size;
|
||||
opt.windowColor = color;
|
||||
opt.glowColor = glow;
|
||||
|
||||
ShadowTilesOption currentOpt = active ? shadowTilesOption_ : glowTilesOption_;
|
||||
|
||||
bool optionChanged = true;
|
||||
if (currentOpt.active == opt.active
|
||||
&& currentOpt.width == opt.width
|
||||
&& opt.windowColor == opt.windowColor
|
||||
&& opt.glowColor == opt.glowColor)
|
||||
optionChanged = false;
|
||||
|
||||
if (active && glowTiles_ && !optionChanged)
|
||||
return glowTiles_;
|
||||
else if (!active && shadowTiles_ && !optionChanged)
|
||||
return shadowTiles_;
|
||||
|
||||
TileSet *tileSet;
|
||||
|
||||
if (!tileSet)
|
||||
{
|
||||
QColor light = oxygenHelper()->calcLightColor(oxygenHelper()->backgroundTopColor(color));
|
||||
QColor dark = oxygenHelper()->calcDarkColor(oxygenHelper()->backgroundBottomColor(color));
|
||||
QColor glow = KDecoration::options()->color(ColorFrame);
|
||||
QColor glow2 = KDecoration::options()->color(ColorTitleBar);
|
||||
|
||||
QPixmap shadow = QPixmap( size*2, size*2 );
|
||||
shadow.fill( Qt::transparent );
|
||||
|
@ -516,7 +531,7 @@ TileSet *OxygenClient::shadowTiles(const QColor &color, qreal size)
|
|||
p.setRenderHint( QPainter::Antialiasing );
|
||||
p.setPen( Qt::NoPen );
|
||||
|
||||
if (isActive())
|
||||
if (active)
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Active shadow texture
|
||||
|
@ -524,7 +539,6 @@ TileSet *OxygenClient::shadowTiles(const QColor &color, qreal size)
|
|||
QRadialGradient rg( size, size, size );
|
||||
QColor c = color;
|
||||
c.setAlpha( 255 ); rg.setColorAt( 4.4/size, c );
|
||||
c = glow;
|
||||
c.setAlpha( 220 ); rg.setColorAt( 4.5/size, c );
|
||||
c.setAlpha( 180 ); rg.setColorAt( 5/size, c );
|
||||
c.setAlpha( 25 ); rg.setColorAt( 5.5/size, c );
|
||||
|
@ -536,7 +550,7 @@ TileSet *OxygenClient::shadowTiles(const QColor &color, qreal size)
|
|||
rg = QRadialGradient( size, size, size );
|
||||
c = color;
|
||||
c.setAlpha( 255 ); rg.setColorAt( 4.4/size, c );
|
||||
c = glow2;
|
||||
c = glow;
|
||||
c.setAlpha( 0.58*255 ); rg.setColorAt( 4.5/size, c );
|
||||
c.setAlpha( 0.43*255 ); rg.setColorAt( 5.5/size, c );
|
||||
c.setAlpha( 0.30*255 ); rg.setColorAt( 6.5/size, c );
|
||||
|
@ -555,7 +569,8 @@ TileSet *OxygenClient::shadowTiles(const QColor &color, qreal size)
|
|||
p.end();
|
||||
|
||||
tileSet = new TileSet(shadow, size, size, 1, 1);
|
||||
shadowCache_.insert(key, tileSet);
|
||||
glowTilesOption_ = opt;
|
||||
glowTiles_ = tileSet;
|
||||
} else {
|
||||
//---------------------------------------------------------------
|
||||
// Inactive shadow texture
|
||||
|
@ -618,18 +633,13 @@ TileSet *OxygenClient::shadowTiles(const QColor &color, qreal size)
|
|||
p.end();
|
||||
|
||||
tileSet = new TileSet(shadow, size, size, 1, 1);
|
||||
shadowCache_.insert(key, tileSet);
|
||||
shadowTilesOption_ = opt;
|
||||
shadowTiles_ = tileSet;
|
||||
}
|
||||
}
|
||||
return tileSet;
|
||||
}
|
||||
|
||||
void OxygenClient::activeChange()
|
||||
{
|
||||
invalidateCaches();
|
||||
KCommonDecoration::activeChange();
|
||||
}
|
||||
|
||||
} //namespace Oxygen
|
||||
} //namespace Ozone
|
||||
|
||||
|
|
|
@ -54,7 +54,14 @@ public:
|
|||
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
|
||||
virtual void updateWindowShape();
|
||||
virtual void init();
|
||||
virtual void activeChange();
|
||||
|
||||
private:
|
||||
struct ShadowTilesOption {
|
||||
QColor windowColor;
|
||||
QColor glowColor;
|
||||
qreal width;
|
||||
bool active;
|
||||
};
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
@ -63,8 +70,12 @@ private:
|
|||
bool colorCacheInvalid_;
|
||||
QColor cachedTitlebarTextColor_;
|
||||
|
||||
TileSet *shadowTiles(const QColor&, qreal size);
|
||||
QCache<quint64, TileSet> shadowCache_;
|
||||
TileSet *shadowTiles(const QColor& color, const QColor& glow, qreal size, bool active);
|
||||
|
||||
ShadowTilesOption shadowTilesOption_;
|
||||
ShadowTilesOption glowTilesOption_;
|
||||
TileSet *shadowTiles_;
|
||||
TileSet *glowTiles_;
|
||||
|
||||
protected:
|
||||
friend class OxygenButton;
|
||||
|
|
Loading…
Reference in a new issue