Skip to content

Commit

Permalink
[effects] Initially populate effects with a default list of effects
Browse files Browse the repository at this point in the history
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 cf2fa39
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
7 changes: 7 additions & 0 deletions python/core/effects/qgspainteffectregistry.sip
Expand Up @@ -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();
Expand Down
19 changes: 19 additions & 0 deletions src/core/effects/qgspainteffectregistry.cpp
Expand Up @@ -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;
}
7 changes: 7 additions & 0 deletions src/core/effects/qgspainteffectregistry.h
Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions src/core/symbology-ng/qgsrendererv2.cpp
Expand Up @@ -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 );
}

Expand Down
5 changes: 2 additions & 3 deletions src/core/symbology-ng/qgssymbollayerv2.cpp
Expand Up @@ -22,6 +22,7 @@
#include "qgsgeometrysimplifier.h"
#include "qgspainteffect.h"
#include "qgseffectstack.h"
#include "qgspainteffectregistry.h"
#include "qgsdatadefined.h"

#include <QSize>
Expand Down Expand Up @@ -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 );
}

Expand Down

0 comments on commit cf2fa39

Please sign in to comment.