Skip to content

Commit cf2fa39

Browse files
committed
[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.
1 parent e57c59b commit cf2fa39

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

python/core/effects/qgspainteffectregistry.sip

+7
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ class QgsPaintEffectRegistry
102102
*/
103103
QStringList effects() const;
104104

105+
/** Returns a new effect stack consisting of a sensible selection of default
106+
* effects. All effects except the standard draw source effect are disabled,
107+
* but are included so that they can be easily drawn just by enabling the effect.
108+
* @returns default effects stack
109+
*/
110+
static QgsPaintEffect* defaultStack() /Factory/;
111+
105112
protected:
106113
QgsPaintEffectRegistry();
107114
~QgsPaintEffectRegistry();

src/core/effects/qgspainteffectregistry.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,22 @@ QStringList QgsPaintEffectRegistry::effects() const
119119
}
120120
return lst;
121121
}
122+
123+
QgsPaintEffect* QgsPaintEffectRegistry::defaultStack()
124+
{
125+
QgsEffectStack* stack = new QgsEffectStack();
126+
QgsDropShadowEffect* dropShadow = new QgsDropShadowEffect();
127+
dropShadow->setEnabled( false );
128+
stack->appendEffect( dropShadow );
129+
QgsOuterGlowEffect* outerGlow = new QgsOuterGlowEffect();
130+
outerGlow->setEnabled( false );
131+
stack->appendEffect( outerGlow );
132+
stack->appendEffect( new QgsDrawSourceEffect() );
133+
QgsInnerShadowEffect* innerShadow = new QgsInnerShadowEffect();
134+
innerShadow->setEnabled( false );
135+
stack->appendEffect( innerShadow );
136+
QgsInnerGlowEffect* innerGlow = new QgsInnerGlowEffect();
137+
innerGlow->setEnabled( false );
138+
stack->appendEffect( innerGlow );
139+
return stack;
140+
}

src/core/effects/qgspainteffectregistry.h

+7
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ class CORE_EXPORT QgsPaintEffectRegistry
189189
*/
190190
QStringList effects() const;
191191

192+
/** Returns a new effect stack consisting of a sensible selection of default
193+
* effects. All effects except the standard draw source effect are disabled,
194+
* but are included so that they can be easily drawn just by enabling the effect.
195+
* @returns default effects stack
196+
*/
197+
static QgsPaintEffect* defaultStack();
198+
192199
protected:
193200
QgsPaintEffectRegistry();
194201
~QgsPaintEffectRegistry();

src/core/symbology-ng/qgsrendererv2.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ QgsFeatureRendererV2::QgsFeatureRendererV2( QString type )
210210
, mCurrentVertexMarkerSize( 3 )
211211
, mPaintEffect( 0 )
212212
{
213-
QgsEffectStack* stack = new QgsEffectStack();
214-
stack->appendEffect( new QgsDrawSourceEffect() );
215-
mPaintEffect = stack;
213+
mPaintEffect = QgsPaintEffectRegistry::defaultStack();
216214
mPaintEffect->setEnabled( false );
217215
}
218216

src/core/symbology-ng/qgssymbollayerv2.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "qgsgeometrysimplifier.h"
2323
#include "qgspainteffect.h"
2424
#include "qgseffectstack.h"
25+
#include "qgspainteffectregistry.h"
2526
#include "qgsdatadefined.h"
2627

2728
#include <QSize>
@@ -291,9 +292,7 @@ QgsSymbolLayerV2::QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked )
291292
, mRenderingPass( 0 )
292293
, mPaintEffect( 0 )
293294
{
294-
QgsEffectStack* stack = new QgsEffectStack();
295-
stack->appendEffect( new QgsDrawSourceEffect() );
296-
mPaintEffect = stack;
295+
mPaintEffect = QgsPaintEffectRegistry::defaultStack();
297296
mPaintEffect->setEnabled( false );
298297
}
299298

0 commit comments

Comments
 (0)