removed usage of static global variables (static is bad afaik). Everything is controled by the factory.
svn path=/trunk/KDE/kdebase/workspace/; revision=1034554icc-effect-5.14.5
parent
fa4daf121d
commit
7f6ff0dd02
|
@ -27,8 +27,6 @@
|
|||
#include "oxygen.h"
|
||||
#include "oxygen.moc"
|
||||
#include "oxygenclient.h"
|
||||
#include "oxygenshadowcache.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <KConfigGroup>
|
||||
|
@ -46,30 +44,11 @@ extern "C"
|
|||
namespace Oxygen
|
||||
{
|
||||
|
||||
K_GLOBAL_STATIC_WITH_ARGS(OxygenHelper, globalHelper, ("oxygenDeco"))
|
||||
K_GLOBAL_STATIC_WITH_ARGS(OxygenShadowCache, globalShadowCache, (maxAnimationIndex))
|
||||
|
||||
//___________________________________________
|
||||
OxygenHelper *oxygenHelper()
|
||||
{
|
||||
OxygenHelper *helper = globalHelper;
|
||||
return helper;
|
||||
}
|
||||
|
||||
//___________________________________________
|
||||
OxygenShadowCache *oxygenShadowCache()
|
||||
{
|
||||
OxygenShadowCache* cache = globalShadowCache;
|
||||
return cache;
|
||||
}
|
||||
|
||||
// initialize static members
|
||||
bool OxygenFactory::initialized_ = false;
|
||||
OxygenConfiguration OxygenFactory::defaultConfiguration_;
|
||||
OxygenExceptionList OxygenFactory::exceptions_;
|
||||
|
||||
//___________________________________________________
|
||||
OxygenFactory::OxygenFactory()
|
||||
OxygenFactory::OxygenFactory():
|
||||
initialized_( false ),
|
||||
helper_( "oxygenDeco" ),
|
||||
shadowCache_( helper_, maxAnimationIndex)
|
||||
{
|
||||
readConfig();
|
||||
setInitialized( true );
|
||||
|
@ -104,7 +83,7 @@ namespace Oxygen
|
|||
|
||||
} else {
|
||||
|
||||
if( changed & SettingColors ) oxygenShadowCache()->invalidateCaches();
|
||||
if( changed & SettingColors ) shadowCache().invalidateCaches();
|
||||
resetDecorations(changed);
|
||||
return false;
|
||||
|
||||
|
@ -138,25 +117,25 @@ namespace Oxygen
|
|||
|
||||
// read shadow configurations
|
||||
OxygenShadowConfiguration activeShadowConfiguration( QPalette::Active, config.group( "ActiveShadow" ) );
|
||||
if( oxygenShadowCache()->shadowConfigurationChanged( activeShadowConfiguration ) )
|
||||
if( shadowCache().shadowConfigurationChanged( activeShadowConfiguration ) )
|
||||
{
|
||||
oxygenShadowCache()->setShadowConfiguration( activeShadowConfiguration );
|
||||
shadowCache().setShadowConfiguration( activeShadowConfiguration );
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// read shadow configurations
|
||||
OxygenShadowConfiguration inactiveShadowConfiguration( QPalette::Inactive, config.group( "InactiveShadow" ) );
|
||||
if( oxygenShadowCache()->shadowConfigurationChanged( inactiveShadowConfiguration ) )
|
||||
if( shadowCache().shadowConfigurationChanged( inactiveShadowConfiguration ) )
|
||||
{
|
||||
oxygenShadowCache()->setShadowConfiguration( inactiveShadowConfiguration );
|
||||
shadowCache().setShadowConfiguration( inactiveShadowConfiguration );
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if( changed )
|
||||
{
|
||||
|
||||
oxygenShadowCache()->invalidateCaches();
|
||||
oxygenHelper()->invalidateCaches();
|
||||
shadowCache().invalidateCaches();
|
||||
helper().invalidateCaches();
|
||||
return true;
|
||||
|
||||
} else return false;
|
||||
|
|
|
@ -34,19 +34,13 @@
|
|||
#include "oxygenconfiguration.h"
|
||||
#include "oxygenexceptionlist.h"
|
||||
|
||||
class OxygenHelper;
|
||||
#include "oxygenshadowcache.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
namespace Oxygen
|
||||
{
|
||||
|
||||
class OxygenClient;
|
||||
class OxygenShadowCache;
|
||||
|
||||
//! helper singleton
|
||||
OxygenHelper* oxygenHelper();
|
||||
|
||||
//! shadow cache singleton
|
||||
OxygenShadowCache* oxygenShadowCache();
|
||||
|
||||
//! buttons
|
||||
enum ButtonType
|
||||
|
@ -63,24 +57,29 @@ namespace Oxygen
|
|||
ButtonTypeCount
|
||||
};
|
||||
|
||||
//! maximum index/frame used for animations
|
||||
static const int maxAnimationIndex = 256;
|
||||
|
||||
/*
|
||||
If non zero, this possibly allow one to have an additional space
|
||||
around window that is clickable although it is part of the shadow
|
||||
*/
|
||||
static const int EXTENDED_HITAREA = 0;
|
||||
|
||||
// this is the top title bar edge
|
||||
static const int TFRAMESIZE = 3;
|
||||
|
||||
// this is the extra title bar top and bottom edges
|
||||
// needed to outline active window title bar
|
||||
static const int HFRAMESIZE = 4;
|
||||
|
||||
Q_DECLARE_FLAGS(ButtonTypes, ButtonType)
|
||||
|
||||
enum
|
||||
{
|
||||
//! maximum index/frame used for animations
|
||||
maxAnimationIndex = 256,
|
||||
|
||||
/*!
|
||||
If non zero, this possibly allow one to have an additional space
|
||||
around window that is clickable although it is part of the shadow
|
||||
*/
|
||||
EXTENDED_HITAREA = 0,
|
||||
|
||||
//! this is the top title bar edge
|
||||
TFRAMESIZE = 3,
|
||||
|
||||
/*!
|
||||
this is the extra title bar top and bottom edges
|
||||
needed to outline active window title bar
|
||||
*/
|
||||
HFRAMESIZE = 4
|
||||
};
|
||||
|
||||
//! window decoration factory
|
||||
class OxygenFactory: public QObject, public KDecorationFactoryUnstable
|
||||
{
|
||||
|
@ -105,11 +104,19 @@ namespace Oxygen
|
|||
virtual bool supports( Ability ability ) const;
|
||||
|
||||
//! true if initialized
|
||||
static bool initialized()
|
||||
virtual bool initialized()
|
||||
{ return initialized_; }
|
||||
|
||||
//! helper
|
||||
virtual OxygenHelper& helper( void )
|
||||
{ return helper_; }
|
||||
|
||||
//! shadow cache
|
||||
virtual OxygenShadowCache& shadowCache( void )
|
||||
{ return shadowCache_; }
|
||||
|
||||
//! get configuration for a give client
|
||||
static OxygenConfiguration configuration( const OxygenClient& );
|
||||
virtual OxygenConfiguration configuration( const OxygenClient& );
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -122,25 +129,31 @@ namespace Oxygen
|
|||
bool readConfig();
|
||||
|
||||
//! default configuration
|
||||
static OxygenConfiguration defaultConfiguration( void )
|
||||
OxygenConfiguration defaultConfiguration( void )
|
||||
{ return defaultConfiguration_; }
|
||||
|
||||
//! initialization
|
||||
static void setInitialized( bool value )
|
||||
void setInitialized( bool value )
|
||||
{ initialized_ = value; }
|
||||
|
||||
//! set default configuration
|
||||
static void setDefaultConfiguration( OxygenConfiguration value )
|
||||
void setDefaultConfiguration( OxygenConfiguration value )
|
||||
{ defaultConfiguration_ = value; }
|
||||
|
||||
//! initialization flag
|
||||
static bool initialized_;
|
||||
bool initialized_;
|
||||
|
||||
//! helper
|
||||
OxygenHelper helper_;
|
||||
|
||||
//! shadow cache
|
||||
OxygenShadowCache shadowCache_;
|
||||
|
||||
//! default configuration
|
||||
static OxygenConfiguration defaultConfiguration_;
|
||||
OxygenConfiguration defaultConfiguration_;
|
||||
|
||||
//! exceptions
|
||||
static OxygenExceptionList exceptions_;
|
||||
OxygenExceptionList exceptions_;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -48,15 +48,6 @@
|
|||
namespace Oxygen
|
||||
{
|
||||
|
||||
//___________________________________________
|
||||
static void oxkwincleanupBefore()
|
||||
{
|
||||
|
||||
oxygenHelper()->invalidateCaches();
|
||||
oxygenShadowCache()->invalidateCaches();
|
||||
|
||||
}
|
||||
|
||||
//___________________________________________
|
||||
void renderDot(QPainter *p, const QPointF &point, qreal diameter)
|
||||
{
|
||||
|
@ -64,15 +55,15 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
//___________________________________________
|
||||
OxygenClient::OxygenClient(KDecorationBridge *b, KDecorationFactory *f):
|
||||
OxygenClient::OxygenClient(KDecorationBridge *b, OxygenFactory *f):
|
||||
KCommonDecorationUnstable(b, f),
|
||||
colorCacheInvalid_(true),
|
||||
factory_( f ),
|
||||
sizeGrip_( 0 ),
|
||||
timeLine_( 200, this ),
|
||||
titleTimeLine_( 200, this ),
|
||||
helper_(*oxygenHelper()),
|
||||
initialized_( false )
|
||||
{ qAddPostRoutine(oxkwincleanupBefore); }
|
||||
{}
|
||||
|
||||
//___________________________________________
|
||||
OxygenClient::~OxygenClient()
|
||||
|
@ -263,7 +254,7 @@ namespace Oxygen
|
|||
case LM_OuterPaddingRight:
|
||||
case LM_OuterPaddingTop:
|
||||
case LM_OuterPaddingBottom:
|
||||
return oxygenShadowCache()->shadowSize() - extraBorder;
|
||||
return shadowCache().shadowSize() - extraBorder;
|
||||
|
||||
default:
|
||||
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
|
||||
|
@ -457,7 +448,7 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
QRect r = (isPreview()) ? OxygenClient::widget()->rect():window->rect();
|
||||
qreal shadowSize( oxygenShadowCache()->shadowSize() );
|
||||
qreal shadowSize( shadowCache().shadowSize() );
|
||||
r.adjust( shadowSize, shadowSize, -shadowSize, -shadowSize );
|
||||
r.adjust(0,0, 1, 1);
|
||||
|
||||
|
@ -481,7 +472,7 @@ namespace Oxygen
|
|||
// bottom line
|
||||
if( configuration().frameBorder() > OxygenConfiguration::BorderNone && (tiles&TileSet::Bottom) )
|
||||
{
|
||||
int height = qMin( HFRAMESIZE, layoutMetric( LM_BorderBottom ) )-1;
|
||||
int height = qMin( (int) HFRAMESIZE, layoutMetric( LM_BorderBottom ) )-1;
|
||||
QColor shadow( helper().backgroundBottomColor( widget->palette().color( widget->backgroundRole() ) ) );
|
||||
painter->setPen( shadow );
|
||||
QRect rect( r.bottomLeft()-position-QPoint(0,height), QSize( r.width(), height ) );
|
||||
|
@ -502,7 +493,7 @@ namespace Oxygen
|
|||
painter->setPen( shadow );
|
||||
if( tiles&TileSet::Left )
|
||||
{
|
||||
int width = qMin( HFRAMESIZE, layoutMetric( LM_BorderLeft ) )-1;
|
||||
int width = qMin( (int)HFRAMESIZE, layoutMetric( LM_BorderLeft ) )-1;
|
||||
QRect rect( r.topLeft()-position, QSize( width, r.height() ) );
|
||||
painter->drawLine( r.topLeft()-position-QPoint(width+1,HFRAMESIZE), r.bottomLeft()-position-QPoint(width+1,-HFRAMESIZE) );
|
||||
|
||||
|
@ -513,7 +504,7 @@ namespace Oxygen
|
|||
// right
|
||||
if( tiles&TileSet::Right )
|
||||
{
|
||||
int width = qMin( HFRAMESIZE, layoutMetric( LM_BorderRight ) )-1;
|
||||
int width = qMin( (int)HFRAMESIZE, layoutMetric( LM_BorderRight ) )-1;
|
||||
QRect rect( r.topRight()-position-QPoint(width,0), QSize( width, r.height() ) );
|
||||
painter->drawLine( r.topRight()-position-QPoint(-width-1,HFRAMESIZE), r.bottomRight()-position-QPoint(-width-1,-HFRAMESIZE) );
|
||||
|
||||
|
@ -562,7 +553,7 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
QRect r = (isPreview()) ? OxygenClient::widget()->rect():window->rect();
|
||||
qreal shadowSize( oxygenShadowCache()->shadowSize() );
|
||||
qreal shadowSize( shadowCache().shadowSize() );
|
||||
r.adjust( shadowSize, shadowSize, -shadowSize, -shadowSize );
|
||||
r.adjust(0,0, 1, 1);
|
||||
|
||||
|
@ -795,7 +786,7 @@ namespace Oxygen
|
|||
|
||||
if( !initialized_ ) return;
|
||||
|
||||
configuration_ = OxygenFactory::configuration( *this );
|
||||
configuration_ = factory_->configuration( *this );
|
||||
|
||||
// animations duration
|
||||
timeLine_.setDuration( configuration_.animationsDuration() );
|
||||
|
@ -819,7 +810,7 @@ namespace Oxygen
|
|||
{
|
||||
|
||||
// factory
|
||||
if(!( initialized_ && OxygenFactory::initialized() ) ) return;
|
||||
if(!( initialized_ && factory_->initialized() ) ) return;
|
||||
|
||||
// palette
|
||||
QPalette palette = widget()->palette();
|
||||
|
@ -845,9 +836,9 @@ namespace Oxygen
|
|||
|
||||
int frame = timeLine_.currentFrame();
|
||||
if( timeLine_.direction() == QTimeLine::Backward ) frame -= timeLine_.startFrame();
|
||||
tileSet = oxygenShadowCache()->tileSet( this, frame );
|
||||
tileSet = shadowCache().tileSet( this, frame );
|
||||
|
||||
} else tileSet = oxygenShadowCache()->tileSet( this );
|
||||
} else tileSet = shadowCache().tileSet( this );
|
||||
|
||||
if( !isMaximized() ) tileSet->render( frame.adjusted( 4, 4, -4, -4), &painter, TileSet::Ring);
|
||||
else if( isShade() ) tileSet->render( frame.adjusted( 0, 4, 0, -4), &painter, TileSet::Bottom);
|
||||
|
@ -855,7 +846,7 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
// adjust frame
|
||||
qreal shadowSize( oxygenShadowCache()->shadowSize() );
|
||||
qreal shadowSize( shadowCache().shadowSize() );
|
||||
frame.adjust( shadowSize, shadowSize, -shadowSize, -shadowSize );
|
||||
|
||||
// adjust mask
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <kcommondecoration.h>
|
||||
#include <QtCore/QTimeLine>
|
||||
|
||||
#include "oxygen.h"
|
||||
#include "oxygenconfiguration.h"
|
||||
#include "lib/helper.h"
|
||||
#include "lib/tileset.h"
|
||||
|
@ -40,7 +41,6 @@ namespace Oxygen
|
|||
{
|
||||
|
||||
class OxygenSizeGrip;
|
||||
|
||||
class OxygenClient : public KCommonDecorationUnstable
|
||||
{
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace Oxygen
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
OxygenClient(KDecorationBridge *b, KDecorationFactory *f);
|
||||
OxygenClient(KDecorationBridge *b, OxygenFactory *f);
|
||||
|
||||
//! destructor
|
||||
virtual ~OxygenClient();
|
||||
|
@ -110,7 +110,11 @@ namespace Oxygen
|
|||
|
||||
//! helper class
|
||||
OxygenHelper& helper( void ) const
|
||||
{ return helper_; }
|
||||
{ return factory_->helper(); }
|
||||
|
||||
//! helper class
|
||||
OxygenShadowCache& shadowCache( void ) const
|
||||
{ return factory_->shadowCache(); }
|
||||
|
||||
//! return animation opacity
|
||||
qreal opacity( void ) const
|
||||
|
@ -248,6 +252,9 @@ namespace Oxygen
|
|||
//! stored color
|
||||
QColor cachedTitlebarTextColor_;
|
||||
|
||||
//! factory
|
||||
OxygenFactory* factory_;
|
||||
|
||||
//! size grip widget
|
||||
OxygenSizeGrip* sizeGrip_;
|
||||
|
||||
|
@ -260,9 +267,6 @@ namespace Oxygen
|
|||
//! old caption
|
||||
QString oldCaption_;
|
||||
|
||||
//! helper
|
||||
OxygenHelper& helper_;
|
||||
|
||||
//! true when initialized
|
||||
bool initialized_;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "oxygenshadowcache.h"
|
||||
#include "oxygenclient.h"
|
||||
#include "oxygen.h"
|
||||
#include "lib/helper.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <KColorUtils>
|
||||
|
@ -37,7 +38,8 @@ namespace Oxygen
|
|||
{
|
||||
|
||||
//_______________________________________________________
|
||||
OxygenShadowCache::OxygenShadowCache( int maxIndex ):
|
||||
OxygenShadowCache::OxygenShadowCache( OxygenHelper& helper, int maxIndex ):
|
||||
helper_( helper ),
|
||||
maxIndex_( maxIndex ),
|
||||
activeShadowConfiguration_( OxygenShadowConfiguration( QPalette::Active ) ),
|
||||
inactiveShadowConfiguration_( OxygenShadowConfiguration( QPalette::Inactive ) )
|
||||
|
@ -291,9 +293,9 @@ namespace Oxygen
|
|||
// draw the corner of the window - actually all 4 corners as one circle
|
||||
// this is all fixedSize. Does not scale with shadow size
|
||||
QLinearGradient lg = QLinearGradient(0.0, size-4.5, 0.0, size+4.5);
|
||||
lg.setColorAt(0.0, oxygenHelper()->calcLightColor( oxygenHelper()->backgroundTopColor(color) ));
|
||||
lg.setColorAt(0.52, oxygenHelper()->backgroundTopColor(color) );
|
||||
lg.setColorAt(1.0, oxygenHelper()->backgroundBottomColor(color) );
|
||||
lg.setColorAt(0.0, helper().calcLightColor( helper().backgroundTopColor(color) ));
|
||||
lg.setColorAt(0.52, helper().backgroundTopColor(color) );
|
||||
lg.setColorAt(1.0, helper().backgroundBottomColor(color) );
|
||||
|
||||
// draw ellipse.
|
||||
p.setBrush( lg );
|
||||
|
@ -412,4 +414,22 @@ namespace Oxygen
|
|||
|
||||
}
|
||||
|
||||
OxygenShadowCache::Key::Key( const OxygenClient* client):
|
||||
index(0)
|
||||
{
|
||||
|
||||
active = client->isActive();
|
||||
useOxygenShadows = client->configuration().useOxygenShadows();
|
||||
isShade = client->isShade();
|
||||
hasTitleOutline = client->configuration().drawTitleOutline();
|
||||
switch( client->configuration().frameBorder() )
|
||||
{
|
||||
case OxygenConfiguration::BorderNone: frameBorder = Key::BorderNone; break;
|
||||
case OxygenConfiguration::BorderNoSide: frameBorder = Key::BorderNoSide; break;
|
||||
default: frameBorder = Key::BorderAny; break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -30,20 +30,21 @@
|
|||
#include <QtCore/QCache>
|
||||
#include <QtGui/QRadialGradient>
|
||||
|
||||
#include "oxygenclient.h"
|
||||
#include "oxygenshadowconfiguration.h"
|
||||
#include "lib/tileset.h"
|
||||
|
||||
class OxygenHelper;
|
||||
|
||||
namespace Oxygen
|
||||
{
|
||||
|
||||
|
||||
class OxygenClient;
|
||||
class OxygenShadowCache
|
||||
{
|
||||
public:
|
||||
|
||||
//! constructor
|
||||
OxygenShadowCache( int maxIndex );
|
||||
OxygenShadowCache( OxygenHelper& helper, int maxIndex );
|
||||
|
||||
//! destructor
|
||||
virtual ~OxygenShadowCache( void )
|
||||
|
@ -106,22 +107,7 @@ namespace Oxygen
|
|||
{}
|
||||
|
||||
//! constructor from client
|
||||
Key( const OxygenClient* client ):
|
||||
index(0)
|
||||
{
|
||||
|
||||
active = client->isActive();
|
||||
useOxygenShadows = client->configuration().useOxygenShadows();
|
||||
isShade = client->isShade();
|
||||
hasTitleOutline = client->configuration().drawTitleOutline();
|
||||
switch( client->configuration().frameBorder() )
|
||||
{
|
||||
case OxygenConfiguration::BorderNone: frameBorder = Key::BorderNone; break;
|
||||
case OxygenConfiguration::BorderNoSide: frameBorder = Key::BorderNoSide; break;
|
||||
default: frameBorder = Key::BorderAny; break;
|
||||
}
|
||||
|
||||
}
|
||||
Key( const OxygenClient* );
|
||||
|
||||
//! constructor from int
|
||||
Key( int hash ):
|
||||
|
@ -169,12 +155,20 @@ namespace Oxygen
|
|||
//! simple pixmap
|
||||
QPixmap simpleShadowPixmap( const QColor&, const Key&, bool active ) const;
|
||||
|
||||
protected:
|
||||
|
||||
OxygenHelper& helper( void ) const
|
||||
{ return helper_; }
|
||||
|
||||
private:
|
||||
|
||||
//! draw gradient into rect
|
||||
/*! a separate method is used in order to properly account for corners */
|
||||
void renderGradient( QPainter&, const QRectF&, const QRadialGradient&, bool noBorder = false ) const;
|
||||
|
||||
//! helper
|
||||
OxygenHelper& helper_;
|
||||
|
||||
//! max index
|
||||
/*! it is used to set caches max cost, and calculate animation opacity */
|
||||
int maxIndex_;
|
||||
|
|
Loading…
Reference in New Issue