|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbCore module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 #include <hbglobal.h> |
|
26 #ifdef HB_FILTER_EFFECTS |
|
27 |
|
28 #include "hbeffecthsl_p.h" |
|
29 #include "hbeffectgroup_p.h" |
|
30 #include "hbeffectdef_p.h" |
|
31 #include "hbvgchainedeffect_p.h" |
|
32 #include "hbvghsleffect_p.h" |
|
33 #include "hbeffectfilter_p.h" |
|
34 #include <QGraphicsItem> |
|
35 #include <QtDebug> |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 |
|
39 // HbEffectHsl |
|
40 |
|
41 HbEffectHsl::HbEffectHsl( |
|
42 const HbEffectFxmlFilterData &data, |
|
43 QGraphicsItem *item, |
|
44 HbEffectGroup *group) : |
|
45 HbEffectFilter(0, item, group), |
|
46 mAnimationO(0), |
|
47 mAnimationH(0), |
|
48 mAnimationS(0), |
|
49 mAnimationL(0), |
|
50 mVgHsl(0) |
|
51 { |
|
52 // Default values of if something is not passed in FXML |
|
53 qreal opacity_start = 1; |
|
54 qreal opacity_end = 1; |
|
55 qreal hue_start = 0; |
|
56 qreal hue_end = 0; |
|
57 qreal saturation_start = 1; |
|
58 qreal saturation_end = 1; |
|
59 qreal lightness_start = 0; |
|
60 qreal lightness_end = 0; |
|
61 |
|
62 QList<HbEffectFxmlParamData> params = data.paramData(); |
|
63 |
|
64 // Handle FXML parameters |
|
65 Q_FOREACH(const HbEffectFxmlParamData ¶m, params) { |
|
66 if (param.name() == FXML_KEYWORD_HSL_OPACITY) { |
|
67 mAnimationO = createAnimation(param, opacity_start, opacity_end, group); |
|
68 } |
|
69 else if (param.name() == FXML_KEYWORD_HSL_HUE) { |
|
70 mAnimationH = createAnimation(param, hue_start, hue_end, group); |
|
71 } |
|
72 else if (param.name() == FXML_KEYWORD_HSL_SATURATION) { |
|
73 mAnimationS = createAnimation(param, saturation_start, saturation_end, group); |
|
74 } |
|
75 else if (param.name() == FXML_KEYWORD_HSL_LIGHTNESS) { |
|
76 mAnimationL = createAnimation(param, lightness_start, lightness_end, group); |
|
77 } |
|
78 } |
|
79 |
|
80 // Create VG effect if there were effect parameters defined |
|
81 if (mEffectDefined) { |
|
82 // Add blur effect to the filter effect chain in the effect group |
|
83 HbVgChainedEffect *chain = HbEffectAbstract::group()->vgEffect(); |
|
84 |
|
85 mVgHsl = new HbVgHslEffect(); |
|
86 mVgHsl->setCaching(true); |
|
87 |
|
88 chain->add(mVgHsl); |
|
89 |
|
90 // Set initial values for the effect |
|
91 mVgHsl->setOpacity(opacity_start); |
|
92 mVgHsl->setHue(hue_start); |
|
93 mVgHsl->setSaturation(saturation_start); |
|
94 mVgHsl->setLightness(lightness_start); |
|
95 } |
|
96 } |
|
97 |
|
98 HbEffectHsl::~HbEffectHsl() |
|
99 { |
|
100 } |
|
101 |
|
102 QString HbEffectHsl::name() const |
|
103 { |
|
104 return HB_EFFECT_NAME_HSL; |
|
105 } |
|
106 |
|
107 void HbEffectHsl::updateFilterEffect() |
|
108 { |
|
109 // Only update the graphics effect if the effect is running |
|
110 if (group()->isRunning()) { |
|
111 if (mAnimationO) { |
|
112 mVgHsl->setOpacity(qVariantValue<qreal>(mAnimationO->currentValue())); |
|
113 } |
|
114 if (mAnimationH) { |
|
115 mVgHsl->setHue(qVariantValue<qreal>(mAnimationH->currentValue())); |
|
116 } |
|
117 if (mAnimationS) { |
|
118 mVgHsl->setSaturation(qVariantValue<qreal>(mAnimationS->currentValue())); |
|
119 } |
|
120 if (mAnimationL) { |
|
121 mVgHsl->setLightness(qVariantValue<qreal>(mAnimationL->currentValue())); |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 #endif |