|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * Sharpness plugin plugin base class. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /// INCLUDES |
|
22 #include <sharpness.mbg> |
|
23 #include "ImageEditorSharpnessPlugin.h" |
|
24 #include "SingleParamControl.h" |
|
25 |
|
26 /// CONSTANTS |
|
27 _LIT (KPgnResourceFile, "sharpness.rsc"); |
|
28 |
|
29 const long KParamMin = -100; |
|
30 const long KParamMax = 100; |
|
31 const long KParamStep = 10; |
|
32 const long KParamDef = 0; |
|
33 const TInt KSharpnessHSTitleIndex = 0; |
|
34 |
|
35 _LIT (KSharpnessTag, "sharpness "); |
|
36 _LIT (KResourceDir, "\\resource\\apps\\"); |
|
37 |
|
38 //============================================================================= |
|
39 EXPORT_C CImageEditorPluginBase * CreateImageEditorPlugin () |
|
40 { |
|
41 CImageEditorSharpnessPlugin * plugin = new (ELeave) CImageEditorSharpnessPlugin; |
|
42 CleanupStack::PushL(plugin); |
|
43 plugin->ConstructL(); |
|
44 CleanupStack::Pop(); // plugin |
|
45 return plugin; |
|
46 } |
|
47 |
|
48 //============================================================================= |
|
49 CImageEditorSharpnessPlugin::CImageEditorSharpnessPlugin () : |
|
50 CImageEditorPluginBase() |
|
51 { |
|
52 |
|
53 } |
|
54 |
|
55 //============================================================================= |
|
56 void CImageEditorSharpnessPlugin::ConstructL () |
|
57 { |
|
58 CImageEditorPluginBase::ConstructL (KPgnResourcePath, KPgnResourceFile); |
|
59 } |
|
60 |
|
61 //============================================================================= |
|
62 CImageEditorSharpnessPlugin::~CImageEditorSharpnessPlugin () |
|
63 { |
|
64 ReleasePlugin(); |
|
65 iControl = NULL; |
|
66 } |
|
67 |
|
68 //============================================================================= |
|
69 TInt CImageEditorSharpnessPlugin::SetProperty ( |
|
70 TInt /*aPropertyId*/, |
|
71 TDesC & /*aPropertyValue*/ |
|
72 ) |
|
73 { |
|
74 return KErrNotSupported; |
|
75 } |
|
76 |
|
77 //============================================================================= |
|
78 TInt CImageEditorSharpnessPlugin::GetProperty ( |
|
79 TInt aPropertyId, |
|
80 TDes & aPropertyValue |
|
81 ) |
|
82 { |
|
83 // Clean buffer |
|
84 aPropertyValue.Zero(); |
|
85 |
|
86 // Copy data |
|
87 switch (aPropertyId) |
|
88 { |
|
89 case KCapParamStruct: |
|
90 { |
|
91 aPropertyValue.Copy (KSharpnessTag); |
|
92 aPropertyValue.AppendNum (iSharpness); |
|
93 return KErrNone; |
|
94 } |
|
95 default: |
|
96 { |
|
97 return CImageEditorPluginBase::GetProperty (aPropertyId, aPropertyValue); |
|
98 } |
|
99 } |
|
100 } |
|
101 |
|
102 //============================================================================= |
|
103 TInt CImageEditorSharpnessPlugin::InitPluginL ( |
|
104 const TRect & aRect, |
|
105 CCoeControl * aParent, |
|
106 CCoeControl *& aPluginControl |
|
107 ) |
|
108 { |
|
109 ReleasePlugin(); |
|
110 iControl = CSingleParamControl::NewL (aRect, aParent, ETrue); |
|
111 ((CSingleParamControl *)iControl)->SetParObserver ( (MSingleParControlObserver*)this ); |
|
112 aPluginControl = iControl; |
|
113 |
|
114 // initialize vertical slider |
|
115 ((CSingleParamControl *)iControl)->SetSliderMinimumAndMaximum(KParamMin, KParamMax); |
|
116 ((CSingleParamControl *)iControl)->SetSliderStep(KParamStep); |
|
117 ((CSingleParamControl *)iControl)->SetSliderPosition(KParamDef); |
|
118 TFileName iconFile (KResourceDir); |
|
119 TBuf<256> readbuf; |
|
120 User::LeaveIfError ( GetProperty (KCapIconName, readbuf) ); |
|
121 iconFile.Append(readbuf); |
|
122 CEikImage* icon = new (ELeave) CEikImage; |
|
123 icon->CreatePictureFromFileL(iconFile, |
|
124 EMbmSharpnessQgn_indi_imed_sharpness_super, |
|
125 EMbmSharpnessQgn_indi_imed_sharpness_super_mask); |
|
126 ((CSingleParamControl *)iControl)->SetIcon(icon); |
|
127 |
|
128 // Get caption from plugin properties |
|
129 User::LeaveIfError ( GetProperty (KCapPluginParamNames, readbuf) ); |
|
130 TLex parser; |
|
131 parser.Assign (readbuf); |
|
132 TInt tempval = 0; |
|
133 parser.Val ( tempval ); |
|
134 CDesCArray * parameters = (CDesCArray *)tempval; |
|
135 ((CSingleParamControl *)iControl)->SetCaption( (*parameters)[KSharpnessHSTitleIndex] ); |
|
136 |
|
137 |
|
138 return KErrNone; |
|
139 } |
|
140 |
|
141 //============================================================================= |
|
142 void CImageEditorSharpnessPlugin::ProcessImageL (CEditorImage * /*aImage*/ ) |
|
143 { |
|
144 // Own image processing functionality here |
|
145 } |
|
146 |
|
147 //============================================================================= |
|
148 void CImageEditorSharpnessPlugin::ReleasePlugin () |
|
149 { |
|
150 delete iControl; |
|
151 iControl = 0; |
|
152 } |
|
153 |
|
154 //============================================================================= |
|
155 void CImageEditorSharpnessPlugin::ParamOperation (const TParamOperation aOperation) |
|
156 { |
|
157 switch (aOperation) |
|
158 { |
|
159 case EParamOperationSubtract: |
|
160 { |
|
161 iSharpness += KParamStep; |
|
162 if (iSharpness < KParamMin) |
|
163 { |
|
164 iSharpness = KParamMin; |
|
165 } |
|
166 break; |
|
167 } |
|
168 case EParamOperationAdd: |
|
169 { |
|
170 iSharpness -= KParamStep; |
|
171 if (iSharpness > KParamMax) |
|
172 { |
|
173 iSharpness = KParamMax; |
|
174 } |
|
175 break; |
|
176 } |
|
177 case EParamOperationDefault: |
|
178 { |
|
179 iSharpness = KParamDef; |
|
180 break; |
|
181 } |
|
182 default: |
|
183 { |
|
184 break; |
|
185 } |
|
186 } |
|
187 } |
|
188 |
|
189 //============================================================================= |
|
190 TReal CImageEditorSharpnessPlugin::GetParam () const |
|
191 { |
|
192 return (TReal)(iSharpness) / (KParamMax - KParamMin); |
|
193 } |
|
194 |
|
195 // End of File |
|
196 |