64
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "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 |
*
|
|
14 |
* Description: Image
|
|
15 |
* Version : %version: 20.1.1 %
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include "alf/alfimage.h"
|
|
22 |
#include <alf/alftexture.h>
|
|
23 |
#include <alf/alfconstants.h>
|
|
24 |
#include "alf/alfimageloaderutil.h"
|
|
25 |
#include "alf/alftexturemanager.h"
|
|
26 |
#include "alflogger.h"
|
|
27 |
#include <uiacceltk/HuiUtil.h>
|
|
28 |
|
|
29 |
// ======== MEMBER FUNCTIONS ========
|
|
30 |
|
|
31 |
// ---------------------------------------------------------------------------
|
|
32 |
// Default constructor
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
EXPORT_C TAlfImage::TAlfImage()
|
|
36 |
: iTexture( NULL )
|
|
37 |
{
|
|
38 |
iTl = TAlfTimedPoint(0.f, 0.f);
|
|
39 |
// Target set because of serverside THuiImage
|
|
40 |
iTl.SetTarget(0.f,0);
|
|
41 |
|
|
42 |
iBr = TAlfTimedPoint(0.f, 0.f);
|
|
43 |
// Target set because of serverside THuiImage
|
|
44 |
iBr.SetTarget(0.f,0);
|
|
45 |
|
|
46 |
InitSkinData();
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// Constructor with the texture
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
EXPORT_C TAlfImage::TAlfImage(const CAlfTexture& aTexture,
|
|
54 |
TReal32 aTlX, TReal32 aTlY,
|
|
55 |
TReal32 aBrX, TReal32 aBrY) __SOFTFP
|
|
56 |
: iTexture (&aTexture)
|
|
57 |
{
|
|
58 |
iTl = TAlfTimedPoint(aTlX, aTlY);
|
|
59 |
// Target set because of serverside THuiImage
|
|
60 |
iTl.SetTarget(TAlfRealPoint(aTlX,aTlY));
|
|
61 |
|
|
62 |
iBr = TAlfTimedPoint(aBrX, aBrY);
|
|
63 |
// Target set because of serverside THuiImage
|
|
64 |
iBr.SetTarget(TAlfRealPoint(aBrX,aBrY));
|
|
65 |
|
|
66 |
InitSkinData();
|
|
67 |
}
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
// Destructor
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
EXPORT_C TAlfImage::~TAlfImage()
|
|
76 |
{
|
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// Gets the texture
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
EXPORT_C const CAlfTexture& TAlfImage::Texture() const
|
|
84 |
{
|
|
85 |
__ASSERT_ALWAYS( (TInt)iTexture, USER_INVARIANT());
|
|
86 |
return *iTexture;
|
|
87 |
}
|
|
88 |
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
// Returns TL texture coordinate
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
EXPORT_C TAlfRealPoint TAlfImage::TopLeft() const
|
|
94 |
{
|
|
95 |
TAlfRealPoint retVal;
|
|
96 |
retVal.iX = iTl.iX.ValueNow();
|
|
97 |
retVal.iY = iTl.iY.ValueNow();
|
|
98 |
return retVal;
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// Returns BR texture coordinate
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
EXPORT_C TAlfRealPoint TAlfImage::BottomRight() const
|
|
106 |
{
|
|
107 |
TAlfRealPoint retVal;
|
|
108 |
retVal.iX = iBr.iX.ValueNow();
|
|
109 |
retVal.iY = iBr.iY.ValueNow();
|
|
110 |
return retVal;
|
|
111 |
}
|
|
112 |
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
// Returns ETrue if the texture has been set,
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
EXPORT_C TBool TAlfImage::HasTexture() const
|
|
118 |
{
|
|
119 |
return (iTexture != NULL);
|
|
120 |
}
|
|
121 |
|
|
122 |
// ---------------------------------------------------------------------------
|
|
123 |
// Sets the texture
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
//
|
|
126 |
EXPORT_C void TAlfImage::SetTexture(CAlfTexture& aTexture)
|
|
127 |
{
|
|
128 |
InitSkinData();
|
|
129 |
iTexture = &aTexture;
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
// Moves the texture
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
EXPORT_C void TAlfImage::Translate(TReal32 aDx, TReal32 aDy, TInt aTransitionTime) __SOFTFP
|
|
137 |
{
|
|
138 |
iTl.iX.SetTarget(iTl.iX.Target() + aDx, aTransitionTime);
|
|
139 |
iTl.iY.SetTarget(iTl.iY.Target() + aDy, aTransitionTime);
|
|
140 |
iBr.iX.SetTarget(iBr.iX.Target() + aDx, aTransitionTime);
|
|
141 |
iBr.iY.SetTarget(iBr.iY.Target() + aDy, aTransitionTime);
|
|
142 |
}
|
|
143 |
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
// Scales the texture
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
EXPORT_C void TAlfImage::Scale(TReal32 aScaleX, TReal32 aScaleY, TInt aTransitionTime) __SOFTFP
|
|
149 |
{
|
|
150 |
iTl.iX.SetTarget(iTl.iX.Target() * aScaleX, aTransitionTime);
|
|
151 |
iTl.iY.SetTarget(iTl.iY.Target() * aScaleY, aTransitionTime);
|
|
152 |
iBr.iX.SetTarget(iBr.iX.Target() * aScaleX, aTransitionTime);
|
|
153 |
iBr.iY.SetTarget(iBr.iY.Target() * aScaleY, aTransitionTime);
|
|
154 |
}
|
|
155 |
|
|
156 |
// ---------------------------------------------------------------------------
|
|
157 |
// Sets the texture coordinates
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
//
|
|
160 |
EXPORT_C void TAlfImage::SetTexCoords(TReal32 aTlX, TReal32 aTlY,
|
|
161 |
TReal32 aBrX, TReal32 aBrY,
|
|
162 |
TInt aTransitionTime) __SOFTFP
|
|
163 |
{
|
|
164 |
iTl.iX.SetTarget(aTlX, aTransitionTime);
|
|
165 |
iTl.iY.SetTarget(aTlY, aTransitionTime);
|
|
166 |
iBr.iX.SetTarget(aBrX, aTransitionTime);
|
|
167 |
iBr.iY.SetTarget(aBrY, aTransitionTime);
|
|
168 |
}
|
|
169 |
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
// Returns TL texture coordinates
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
//
|
|
174 |
TAlfTimedPoint TAlfImage::TimedTopLeft() const
|
|
175 |
{
|
|
176 |
return iTl;
|
|
177 |
}
|
|
178 |
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
// Returns BR texture coordinates
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
//
|
|
183 |
TAlfTimedPoint TAlfImage::TimedBottomRight() const
|
|
184 |
{
|
|
185 |
return iBr;
|
|
186 |
}
|
|
187 |
|
|
188 |
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
// Inits skin data
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
void TAlfImage::InitSkinData()
|
|
194 |
{
|
|
195 |
TAknsItemID id;
|
|
196 |
id.Set(0,0);
|
|
197 |
iSkinID = id;
|
|
198 |
iAppIconUid = TUid::Uid(0);
|
|
199 |
iAppIconType = EAknsAppIconTypeList;
|
|
200 |
iPreferredSize = TSize(0,0);
|
|
201 |
iPreferredScaleMode = EAspectRatioPreserved;
|
|
202 |
iFallbackFileName = NULL;
|
|
203 |
iFallbackBitmapId = -1;
|
|
204 |
iFallbackMaskId = -1;
|
|
205 |
iPreferredTextureId = KAlfAutoGeneratedTextureId;
|
|
206 |
iPreferredTextureManager = NULL;
|
|
207 |
iFlags = EAlfTextureFlagSkinContent;
|
|
208 |
iSkinnableImage = EFalse;
|
|
209 |
}
|
|
210 |
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
// Constructor with skin data
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
EXPORT_C TAlfImage::TAlfImage(TAknsItemID aID,
|
|
216 |
TSize aPreferredSize,
|
|
217 |
TScaleMode aPreferredScaleMode,
|
|
218 |
const TDesC* aFallbackFileName,
|
|
219 |
TInt aFallbackBitmapId,
|
|
220 |
TInt aFallbackMaskId,
|
|
221 |
TReal32 aTlX, TReal32 aTlY,
|
|
222 |
TReal32 aBrX, TReal32 aBrY,
|
|
223 |
TAlfTextureFlags aFlags,
|
|
224 |
TInt aPreferredTextureId,
|
|
225 |
CAlfTextureManager* aPreferredTextureManager) __SOFTFP
|
|
226 |
{
|
|
227 |
InitSkinData();
|
|
228 |
iSkinnableImage = ETrue;
|
|
229 |
|
|
230 |
iSkinID = aID;
|
|
231 |
iPreferredSize = aPreferredSize;
|
|
232 |
iPreferredScaleMode = aPreferredScaleMode;
|
|
233 |
|
|
234 |
iFallbackFileName = aFallbackFileName;
|
|
235 |
iFallbackBitmapId = aFallbackBitmapId;
|
|
236 |
iFallbackMaskId = aFallbackMaskId;
|
|
237 |
|
|
238 |
iTl = TAlfTimedPoint(aTlX, aTlY);
|
|
239 |
// Target set because of serverside THuiImage
|
|
240 |
iTl.SetTarget(TAlfRealPoint(aTlX,aTlY));
|
|
241 |
|
|
242 |
iBr = TAlfTimedPoint(aBrX, aBrY);
|
|
243 |
// Target set because of serverside THuiImage
|
|
244 |
iBr.SetTarget(TAlfRealPoint(aBrX,aBrY));
|
|
245 |
|
|
246 |
iFlags = aFlags;
|
|
247 |
iPreferredTextureId = aPreferredTextureId;
|
|
248 |
iPreferredTextureManager = aPreferredTextureManager;
|
|
249 |
|
|
250 |
iTexture = NULL;
|
|
251 |
}
|
|
252 |
|
|
253 |
// ---------------------------------------------------------------------------
|
|
254 |
// Constructor with app icon
|
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
EXPORT_C TAlfImage::TAlfImage(TUid aAppIconUid,
|
|
258 |
TAknsAppIconType aAppIconType,
|
|
259 |
TSize aPreferredSize,
|
|
260 |
TScaleMode aPreferredScaleMode,
|
|
261 |
TReal32 aTlX, TReal32 aTlY,
|
|
262 |
TReal32 aBrX, TReal32 aBrY,
|
|
263 |
TAlfTextureFlags aFlags,
|
|
264 |
TInt aPreferredTextureId,
|
|
265 |
CAlfTextureManager* aPreferredTextureManager) __SOFTFP
|
|
266 |
{
|
|
267 |
InitSkinData();
|
|
268 |
iSkinnableImage = ETrue;
|
|
269 |
iAppIconUid = aAppIconUid;
|
|
270 |
iAppIconType = aAppIconType;
|
|
271 |
|
|
272 |
|
|
273 |
iPreferredSize = aPreferredSize;
|
|
274 |
iPreferredScaleMode = aPreferredScaleMode;
|
|
275 |
|
|
276 |
iTl = TAlfTimedPoint(aTlX, aTlY);
|
|
277 |
// Target set because of serverside THuiImage
|
|
278 |
iTl.SetTarget(TAlfRealPoint(aTlX,aTlY));
|
|
279 |
|
|
280 |
iBr = TAlfTimedPoint(aBrX, aBrY);
|
|
281 |
// Target set because of serverside THuiImage
|
|
282 |
iBr.SetTarget(TAlfRealPoint(aBrX,aBrY));
|
|
283 |
|
|
284 |
iFlags = aFlags;
|
|
285 |
iPreferredTextureId = aPreferredTextureId;
|
|
286 |
iPreferredTextureManager = aPreferredTextureManager;
|
|
287 |
|
|
288 |
iTexture = NULL;
|
|
289 |
}
|
|
290 |
|
|
291 |
// ---------------------------------------------------------------------------
|
|
292 |
// Constructor with logical name
|
|
293 |
// ---------------------------------------------------------------------------
|
|
294 |
//
|
|
295 |
EXPORT_C TAlfImage::TAlfImage(const TDesC* /*aLogicalName*/,
|
|
296 |
TSize /*aPreferredSize*/,
|
|
297 |
TScaleMode /*aPreferredScaleMode*/,
|
|
298 |
const TDesC* /*aFallbackFileName*/,
|
|
299 |
TInt /*aFallbackBitmapId*/,
|
|
300 |
TInt /*aFallbackMaskId*/,
|
|
301 |
TReal32 /*aTlX*/, TReal32 /*aTlY*/,
|
|
302 |
TReal32 /*aBrX*/, TReal32 /*aBrY*/,
|
|
303 |
TAlfTextureFlags /*aFlags*/,
|
|
304 |
TInt /*aPreferredTextureId*/,
|
|
305 |
CAlfTextureManager* /*aPreferredTextureManager*/) __SOFTFP
|
|
306 |
{
|
|
307 |
__ALFLOGSTRING( "TAlfImage::TAlfImage FUNCTIONALITY REMOVED. REFER TO ANTRIKSH PROJECT" );
|
|
308 |
}
|
|
309 |
|
|
310 |
// ---------------------------------------------------------------------------
|
|
311 |
// Returns skin ID.
|
|
312 |
// ---------------------------------------------------------------------------
|
|
313 |
//
|
|
314 |
TAknsItemID TAlfImage::SkinID() const
|
|
315 |
{
|
|
316 |
return iSkinID;
|
|
317 |
}
|
|
318 |
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
// Returns preferred size.
|
|
321 |
// ---------------------------------------------------------------------------
|
|
322 |
//
|
|
323 |
TSize TAlfImage::PreferredSize() const
|
|
324 |
{
|
|
325 |
return iPreferredSize;
|
|
326 |
}
|
|
327 |
|
|
328 |
// ---------------------------------------------------------------------------
|
|
329 |
// Returns preferred scalemode.
|
|
330 |
// ---------------------------------------------------------------------------
|
|
331 |
//
|
|
332 |
TScaleMode TAlfImage::PreferredScaleMode() const
|
|
333 |
{
|
|
334 |
return iPreferredScaleMode;
|
|
335 |
}
|
|
336 |
|
|
337 |
// ---------------------------------------------------------------------------
|
|
338 |
// Returns fallback filename
|
|
339 |
// ---------------------------------------------------------------------------
|
|
340 |
//
|
|
341 |
const TDesC* TAlfImage::FallbackFileName() const
|
|
342 |
{
|
|
343 |
if (!iFallbackFileName)
|
|
344 |
{
|
|
345 |
return &KNullDesC;
|
|
346 |
}
|
|
347 |
return iFallbackFileName;
|
|
348 |
}
|
|
349 |
|
|
350 |
// ---------------------------------------------------------------------------
|
|
351 |
// Returns fallback index
|
|
352 |
// ---------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
TInt TAlfImage::FallbackBitmapId() const
|
|
355 |
{
|
|
356 |
return iFallbackBitmapId;
|
|
357 |
}
|
|
358 |
|
|
359 |
// ---------------------------------------------------------------------------
|
|
360 |
// Returns fallback index for the mask.
|
|
361 |
// ---------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
TInt TAlfImage::FallbackMaskId() const
|
|
364 |
{
|
|
365 |
return iFallbackMaskId;
|
|
366 |
}
|
|
367 |
|
|
368 |
// ---------------------------------------------------------------------------
|
|
369 |
// Returns preferred texture manager
|
|
370 |
// ---------------------------------------------------------------------------
|
|
371 |
//
|
|
372 |
CAlfTextureManager* TAlfImage::PreferredTextureManager() const
|
|
373 |
{
|
|
374 |
return iPreferredTextureManager;
|
|
375 |
}
|
|
376 |
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
// Is image from a skin?
|
|
379 |
// ---------------------------------------------------------------------------
|
|
380 |
//
|
|
381 |
TBool TAlfImage::SkinnableImage() const
|
|
382 |
{
|
|
383 |
return iSkinnableImage;
|
|
384 |
}
|
|
385 |
|
|
386 |
// ---------------------------------------------------------------------------
|
|
387 |
// Returns texture flags
|
|
388 |
// ---------------------------------------------------------------------------
|
|
389 |
//
|
|
390 |
TAlfTextureFlags TAlfImage::TextureFlags() const
|
|
391 |
{
|
|
392 |
return iFlags;
|
|
393 |
}
|
|
394 |
|
|
395 |
// ---------------------------------------------------------------------------
|
|
396 |
// returns preferred texture id
|
|
397 |
// ---------------------------------------------------------------------------
|
|
398 |
//
|
|
399 |
TInt TAlfImage::PreferredTextureId() const
|
|
400 |
{
|
|
401 |
return iPreferredTextureId;
|
|
402 |
}
|
|
403 |
|
|
404 |
// ---------------------------------------------------------------------------
|
|
405 |
// Returns app icon UID
|
|
406 |
// ---------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
TUid TAlfImage::AppIconUid() const
|
|
409 |
{
|
|
410 |
return iAppIconUid;
|
|
411 |
}
|
|
412 |
|
|
413 |
// ---------------------------------------------------------------------------
|
|
414 |
// Returns app icon type
|
|
415 |
// ---------------------------------------------------------------------------
|
|
416 |
//
|
|
417 |
TAknsAppIconType TAlfImage::AppIconType() const
|
|
418 |
{
|
|
419 |
return iAppIconType;
|
|
420 |
}
|
|
421 |
|