Skip to content
Permalink
Browse files

[effects] Initially populate effects with a default list of effects

Default list shows a number of common effects like drop shadows,
but they are disabled. This allows users to easily enable them
just by checking them in the list. End result is a more user
friendly and familiar effects interface.

Advanced users can still reorder, add/remove effects as before.
  • Loading branch information
nyalldawson committed Jun 16, 2015
1 parent e57c59b commit cf2fa396910f3eaf841967fd6f251c611228ce37
@@ -102,6 +102,13 @@ class QgsPaintEffectRegistry
*/
QStringList effects() const;

/** Returns a new effect stack consisting of a sensible selection of default
* effects. All effects except the standard draw source effect are disabled,
* but are included so that they can be easily drawn just by enabling the effect.
* @returns default effects stack
*/
static QgsPaintEffect* defaultStack() /Factory/;

protected:
QgsPaintEffectRegistry();
~QgsPaintEffectRegistry();
@@ -119,3 +119,22 @@ QStringList QgsPaintEffectRegistry::effects() const
}
return lst;
}

QgsPaintEffect* QgsPaintEffectRegistry::defaultStack()
{
QgsEffectStack* stack = new QgsEffectStack();
QgsDropShadowEffect* dropShadow = new QgsDropShadowEffect();
dropShadow->setEnabled( false );
stack->appendEffect( dropShadow );
QgsOuterGlowEffect* outerGlow = new QgsOuterGlowEffect();
outerGlow->setEnabled( false );
stack->appendEffect( outerGlow );
stack->appendEffect( new QgsDrawSourceEffect() );
QgsInnerShadowEffect* innerShadow = new QgsInnerShadowEffect();
innerShadow->setEnabled( false );
stack->appendEffect( innerShadow );
QgsInnerGlowEffect* innerGlow = new QgsInnerGlowEffect();
innerGlow->setEnabled( false );
stack->appendEffect( innerGlow );
return stack;
}
@@ -189,6 +189,13 @@ class CORE_EXPORT QgsPaintEffectRegistry
*/
QStringList effects() const;

/** Returns a new effect stack consisting of a sensible selection of default
* effects. All effects except the standard draw source effect are disabled,
* but are included so that they can be easily drawn just by enabling the effect.
* @returns default effects stack
*/
static QgsPaintEffect* defaultStack();

protected:
QgsPaintEffectRegistry();
~QgsPaintEffectRegistry();
@@ -210,9 +210,7 @@ QgsFeatureRendererV2::QgsFeatureRendererV2( QString type )
, mCurrentVertexMarkerSize( 3 )
, mPaintEffect( 0 )
{
QgsEffectStack* stack = new QgsEffectStack();
stack->appendEffect( new QgsDrawSourceEffect() );
mPaintEffect = stack;
mPaintEffect = QgsPaintEffectRegistry::defaultStack();
mPaintEffect->setEnabled( false );
}

@@ -22,6 +22,7 @@
#include "qgsgeometrysimplifier.h"
#include "qgspainteffect.h"
#include "qgseffectstack.h"
#include "qgspainteffectregistry.h"
#include "qgsdatadefined.h"

#include <QSize>
@@ -291,9 +292,7 @@ QgsSymbolLayerV2::QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked )
, mRenderingPass( 0 )
, mPaintEffect( 0 )
{
QgsEffectStack* stack = new QgsEffectStack();
stack->appendEffect( new QgsDrawSourceEffect() );
mPaintEffect = stack;
mPaintEffect = QgsPaintEffectRegistry::defaultStack();
mPaintEffect->setEnabled( false );
}

0 comments on commit cf2fa39

Please sign in to comment.
You can’t perform that action at this time.