src/hbcore/effects/hbeffectgroup.cpp
changeset 21 4633027730f5
parent 5 627c4a0fd0e7
child 30 80e4d18b72f5
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    41 #ifdef HB_FILTER_EFFECTS
    41 #ifdef HB_FILTER_EFFECTS
    42 #include "hbvgeffect_p.h"
    42 #include "hbvgeffect_p.h"
    43 #include "hbvgchainedeffect_p.h"
    43 #include "hbvgchainedeffect_p.h"
    44 #endif
    44 #endif
    45 
    45 
       
    46 static const char effect_fw_marker[] = "effw_chain";
       
    47 
    46 HbEffectGroup::HbEffectGroup(
    48 HbEffectGroup::HbEffectGroup(
    47     const QString &effectEventType,
    49     const QString &effectEventType,
    48     QGraphicsItem *registrationItem,
    50     QGraphicsItem *registrationItem,
    49     QGraphicsItem *targetItem,
    51     QGraphicsItem *targetItem,
    50     const QString &itemType)
    52     const QString &itemType)
   163             effect->updateItemTransform(transform);
   165             effect->updateItemTransform(transform);
   164         }
   166         }
   165     }
   167     }
   166     if (!gv) {
   168     if (!gv) {
   167         mTargetItem->setTransform(transform);
   169         mTargetItem->setTransform(transform);
       
   170         if (mEffectFlags.testFlag(HbEffectInternal::UpdateAtEachStep)) {
       
   171             mTargetItem->update();
       
   172         }
   168     } else {
   173     } else {
   169         gv->setTransform(transform);
   174         gv->setTransform(transform);
   170     }
   175     }
   171 }
   176 }
   172 
   177 
   261 
   266 
   262 HbVgChainedEffect *HbEffectGroup::vgEffect()
   267 HbVgChainedEffect *HbEffectGroup::vgEffect()
   263 {
   268 {
   264     if (!mVgEffect) {
   269     if (!mVgEffect) {
   265         mVgEffect = new HbVgChainedEffect;
   270         mVgEffect = new HbVgChainedEffect;
       
   271         mVgEffect->setObjectName(effect_fw_marker);
   266     }
   272     }
   267     return mVgEffect;
   273     return mVgEffect;
   268 }
   274 }
   269 
   275 
   270 void HbEffectGroup::activateVgEffect()
   276 void HbEffectGroup::activateVgEffect()
   271 {
   277 {
   272     if (!mVgEffectActivated) {
   278     if (!mVgEffectActivated) {
   273         mVgEffectGuard = QPointer<QGraphicsEffect>();
   279         mVgEffectGuard = QPointer<QGraphicsEffect>();
       
   280         if (mTargetItem->graphicsEffect()) {
       
   281             // Manually installed effects should not get lost. For example a
       
   282             // pop-up may install a mask effect before or after this
       
   283             // function. To support the 'before' case we have to add all
       
   284             // existing effects to the chain. Supporting the 'after' case is up
       
   285             // to the widget. However we can only support effects that are in a
       
   286             // chain, keeping single effects is not possible due to ownership
       
   287             // issues.
       
   288             HbVgChainedEffect *c = qobject_cast<HbVgChainedEffect *>(mTargetItem->graphicsEffect());
       
   289             // Effects set by another HbEffectGroup instance must be ignored
       
   290             // here, those should go away because they probably would not work
       
   291             // well together anyway.
       
   292             if (c && c->objectName().compare(QLatin1String(effect_fw_marker))) {
       
   293                 QList<HbVgEffect *> effects = c->takeAll();
       
   294                 HbVgChainedEffect *newChain = vgEffect();
       
   295                 foreach (HbVgEffect *effect, effects) {
       
   296                     newChain->add(effect);
       
   297                 }
       
   298             }
       
   299         }
   274         vgEffect()->install(mTargetItem);
   300         vgEffect()->install(mTargetItem);
   275         mVgEffectActivated = true;
   301         mVgEffectActivated = true;
   276     }
   302     }
   277 }
   303 }
   278 
   304