56
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef HGVGMEDIAWALLRENDERER_H_
|
|
19 |
#define HGVGMEDIAWALLRENDERER_H_
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <VG/openvg.h>
|
|
24 |
#include <ganes/HgVgMediaWall.h>
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Helper abstract base class for drawing mediawall.
|
|
28 |
*/
|
|
29 |
NONSHARABLE_CLASS(CHgVgMediaWallRenderer) : public CBase
|
|
30 |
{
|
|
31 |
public:
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Factory method for constructing new MediaWallRenderer-Object
|
|
35 |
*/
|
|
36 |
static CHgVgMediaWallRenderer* NewL(TInt aMaxQuads, const TRect& aWindowRect,
|
|
37 |
const TRect& aFrontRect, TReal aZOffset);
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Destructor
|
|
41 |
*/
|
|
42 |
virtual ~CHgVgMediaWallRenderer();
|
|
43 |
|
|
44 |
|
|
45 |
private:
|
|
46 |
|
|
47 |
CHgVgMediaWallRenderer(const TRect& aWindowRect,
|
|
48 |
const TRect& aFrontRect, TReal aZOffset);
|
|
49 |
|
|
50 |
void ConstructL(TInt aMaxQuads);
|
|
51 |
|
|
52 |
public:
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Draws the mediawall.
|
|
56 |
*
|
|
57 |
* @param aItems items to draw.
|
|
58 |
* @param aSelectedIndex index of the selected item.
|
|
59 |
* @param aViewPosition views position
|
|
60 |
* @param aAnimationAlpha alpha from going from 0-1 during animation states.
|
|
61 |
* @param aState current state of the animation.
|
|
62 |
* @param aSelectionAnimationType type of the selection animation to use
|
|
63 |
*/
|
|
64 |
void Draw(RPointerArray<CHgVgItem>& aItems,
|
|
65 |
TInt aSelectedIndex, TReal aNextIndex,
|
|
66 |
TReal aViewPosition,
|
|
67 |
TReal aAnimationAlpha,
|
|
68 |
CHgVgMediaWall::THgVgAnimationState aAnimationState,
|
|
69 |
CHgVgMediaWall::THgVgOpeningAnimationType aSelectionAnimationType,
|
|
70 |
CHgVgMediaWall::THgVgMediaWallStyle aStyle,
|
|
71 |
TReal aStartIndex,
|
|
72 |
TReal aSpringVelocity);
|
|
73 |
|
|
74 |
/**
|
|
75 |
*
|
|
76 |
*/
|
|
77 |
void DrawGrid(
|
|
78 |
TInt aRowCount,
|
|
79 |
RPointerArray<CHgVgItem>& aItems,
|
|
80 |
TReal aViewX, TReal aViewY,
|
|
81 |
TInt aCurItem,
|
|
82 |
TInt aPrevItem,
|
|
83 |
TReal aAnimationAlpha,
|
|
84 |
CHgVgMediaWall::THgVgAnimationState aAnimationState,
|
|
85 |
TInt aPickedItem,
|
|
86 |
CHgVgMediaWall::THgVgOpeningAnimationType aAnimationType);
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Sets default icon for rendering items with no icons.
|
|
90 |
* Ownership of the icon is not transfered.
|
|
91 |
*
|
|
92 |
* @param aIcon reference to CGulIcon-object
|
|
93 |
*/
|
|
94 |
void SetDefaultIconL(const CGulIcon& aIcon);
|
|
95 |
|
|
96 |
/**
|
|
97 |
* Sets Camera position modifier to use in rendering.
|
|
98 |
*
|
|
99 |
* @param aCameraPosition camera position
|
|
100 |
*/
|
|
101 |
void SetCameraPosition(TReal aX, TReal aY, TReal aZ);
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Sets camera rotation modifiers to use in rendering.
|
|
105 |
*
|
|
106 |
* @param aAngle angle in radians.
|
|
107 |
*/
|
|
108 |
void SetCameraRotation(TReal aAngle);
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Gets ItemIndex of a quad at pointer position.
|
|
112 |
* NOTE: This is only valid after drawing.
|
|
113 |
*
|
|
114 |
* @param aPointerPosition position of the pointer
|
|
115 |
* @return ItemIndex or KErrNotFound if nothings if no hit.
|
|
116 |
*/
|
|
117 |
TInt GetItemIndex(const TPoint& aPointerPosition) const;
|
|
118 |
|
|
119 |
/**
|
|
120 |
* This should be called by the client. When skin change event is triggered.
|
|
121 |
* This rebuilds all renderers skin related internal resources.
|
|
122 |
*/
|
|
123 |
void HandleSkinChange();
|
|
124 |
|
|
125 |
/**
|
|
126 |
*
|
|
127 |
*/
|
|
128 |
TReal GetWorldSpaceRowHeight() const;
|
|
129 |
|
|
130 |
/**
|
|
131 |
*
|
|
132 |
*/
|
|
133 |
void SetReflections(TBool aEnabled);
|
|
134 |
|
|
135 |
|
|
136 |
/**
|
|
137 |
*
|
|
138 |
*/
|
|
139 |
TBool ReflectionsEnabled() const;
|
|
140 |
|
|
141 |
/**
|
|
142 |
*
|
|
143 |
*/
|
|
144 |
TSize ImageSize() const;
|
|
145 |
|
|
146 |
/**
|
|
147 |
*
|
|
148 |
*/
|
|
149 |
void SetFlippedRect(const TRect& aFlippedRect);
|
|
150 |
|
|
151 |
/*
|
|
152 |
*
|
|
153 |
*/
|
|
154 |
void SetFlipAngle(TReal aAngle);
|
|
155 |
|
|
156 |
/**
|
|
157 |
*
|
|
158 |
*/
|
|
159 |
void EnableBlurOnFlip(TBool aEnabled, TReal aBlurX, TReal aBlurY);
|
|
160 |
|
|
161 |
|
|
162 |
/**
|
|
163 |
*
|
|
164 |
*/
|
|
165 |
void SetOffset(const TPoint& aOffset);
|
|
166 |
|
|
167 |
/**
|
|
168 |
*
|
|
169 |
*/
|
|
170 |
void EnableFlipXY(TBool aEnabled);
|
|
171 |
|
|
172 |
/**
|
|
173 |
*
|
|
174 |
*/
|
|
175 |
void EnableLandscapeMode(TBool enabled);
|
|
176 |
|
|
177 |
|
|
178 |
private:
|
|
179 |
|
|
180 |
class TQuad
|
|
181 |
{
|
|
182 |
public:
|
|
183 |
// quads world-space position
|
|
184 |
VGfloat iX;
|
|
185 |
VGfloat iY;
|
|
186 |
VGfloat iZ;
|
|
187 |
// quads angle
|
|
188 |
VGfloat iAngle;
|
|
189 |
// image used to draw this quad
|
|
190 |
VGImage iImage;
|
|
191 |
// transform constructed in TransformQuads for rendering
|
|
192 |
VGfloat iTM[9];
|
|
193 |
// transformed 2d points
|
|
194 |
VGfloat iPoints[2*4];
|
|
195 |
// index from CHgVgItem
|
|
196 |
TInt iItemIndex;
|
|
197 |
// flag indicating iImage is not valid, uses iDefaultImage then.
|
|
198 |
TBool iNoImage;
|
|
199 |
//
|
|
200 |
VGfloat iAlpha;
|
|
201 |
VGfloat iMirroredPoints[2*4];
|
|
202 |
VGfloat iMirroredTM[9];
|
|
203 |
|
|
204 |
TBool iFlipped;
|
|
205 |
};
|
|
206 |
|
|
207 |
/**
|
|
208 |
*
|
|
209 |
*/
|
|
210 |
void GetGroundColorFromSkin(VGfloat* aColor);
|
|
211 |
|
|
212 |
/**
|
|
213 |
* Transforms quads
|
|
214 |
*/
|
|
215 |
void TransformQuads(TInt aNumVisibleQuads, TBool aMirrored,
|
|
216 |
VGfloat aFov, CHgVgMediaWall::THgVgOpeningAnimationType aOpeningAnimationType);
|
|
217 |
|
|
218 |
/**
|
|
219 |
* Sorts quads by z from iQuads to sorted quads.
|
|
220 |
*/
|
|
221 |
void SortQuadsL(TInt aNumVisibleNumQuads);
|
|
222 |
|
|
223 |
/**
|
|
224 |
* Draws quads using VG
|
|
225 |
*/
|
|
226 |
void DrawQuads(TBool aDrawMirrored);
|
|
227 |
|
|
228 |
/**
|
|
229 |
* Draws one quad using OpenVG
|
|
230 |
*/
|
|
231 |
void DrawQuad(TQuad* q, TBool aDrawMirrored);
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Setups quads into their positions/orientations, after this they can by transformed
|
|
235 |
* and rendered.
|
|
236 |
*/
|
|
237 |
TInt SetupQuads(RPointerArray<CHgVgItem>& aItems,
|
|
238 |
TInt aSelectedIndex, TReal aNextIndex,
|
|
239 |
VGfloat aViewPosition,
|
|
240 |
VGfloat aAnimationAlpha,
|
|
241 |
CHgVgMediaWall::THgVgAnimationState aState,
|
|
242 |
CHgVgMediaWall::THgVgOpeningAnimationType aAnimationType,
|
|
243 |
TReal aStartIndex,
|
|
244 |
TReal aSpringVelocity);
|
|
245 |
|
|
246 |
|
|
247 |
/**
|
|
248 |
* Setups quads for grid mediawall style.
|
|
249 |
*/
|
|
250 |
void SetupQuadsToRow(
|
|
251 |
TInt aRow,
|
|
252 |
TInt aRowCount,
|
|
253 |
TInt& aItemsOnScreen,
|
|
254 |
RPointerArray<CHgVgItem>& aItems,
|
|
255 |
TReal aViewX, TReal aViewY,
|
|
256 |
TInt aCurItem, TInt aPrevItem,
|
|
257 |
TReal aAnimationAlpha,
|
|
258 |
CHgVgMediaWall::THgVgAnimationState aAnimationState,
|
|
259 |
TInt aPickedItem,
|
|
260 |
CHgVgMediaWall::THgVgOpeningAnimationType aAnimationType);
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Applies flip animation to a quad.
|
|
264 |
*/
|
|
265 |
void ApplyOpeningAnimation(CHgVgMediaWallRenderer::TQuad* aQuad,
|
|
266 |
TReal aAnimationAlpha, TReal aZNear, CHgVgMediaWall::THgVgMediaWallStyle aMediaWallStyle,
|
|
267 |
CHgVgMediaWall::THgVgOpeningAnimationType aAnimationStyle);
|
|
268 |
|
|
269 |
/**
|
|
270 |
* Creates path and paint for ground.
|
|
271 |
*/
|
|
272 |
void CreateGround();
|
|
273 |
|
|
274 |
/**
|
|
275 |
* Draws ground.
|
|
276 |
* @param aWidth width of the ground.
|
|
277 |
* @param aHeight height of the ground.
|
|
278 |
*/
|
|
279 |
void DrawGround(TInt aWidth, TInt aHeight);
|
|
280 |
|
|
281 |
|
|
282 |
/**
|
|
283 |
*
|
|
284 |
*/
|
|
285 |
void TransformAndDraw(TInt itemsOnScreen,
|
|
286 |
CHgVgMediaWall::THgVgOpeningAnimationType aOpeningAnimationType);
|
|
287 |
|
|
288 |
/**
|
|
289 |
*
|
|
290 |
*/
|
|
291 |
void AdjustSettingsBasedOnRects(const TRect& aFrontRect,
|
|
292 |
TReal aZOffset);
|
|
293 |
|
|
294 |
/**
|
|
295 |
*
|
|
296 |
*/
|
|
297 |
VGfloat GetZInWorldSpaceBasedOnWidth(VGfloat aWidth);
|
|
298 |
|
|
299 |
/**
|
|
300 |
*
|
|
301 |
*/
|
|
302 |
void UpdateBlurChildImage(VGImage aImage);
|
|
303 |
|
|
304 |
private:
|
|
305 |
|
|
306 |
VGint iMaxQuads;
|
|
307 |
TRect iRect;
|
|
308 |
VGfloat iCameraX;
|
|
309 |
VGfloat iCameraY;
|
|
310 |
VGfloat iCameraZ;
|
|
311 |
VGfloat iCameraRotation;
|
|
312 |
VGImage iDefaultImage;
|
|
313 |
RPointerArray<TQuad> iQuads;
|
|
314 |
RPointerArray<TQuad> iSortedQuads;
|
|
315 |
|
|
316 |
VGPaint iGroundPaint;
|
|
317 |
VGPath iGroundPath;
|
|
318 |
|
|
319 |
VGfloat iSelectedQuadStartX;
|
|
320 |
VGfloat iSelectedQuadStartY;
|
|
321 |
|
|
322 |
TBool iReflectionsEnabled;
|
|
323 |
|
|
324 |
TSize iImageSize;
|
|
325 |
|
|
326 |
VGfloat iCameraBaseX;
|
|
327 |
VGfloat iCameraBaseY;
|
|
328 |
VGfloat iCameraBaseZ;
|
|
329 |
|
|
330 |
VGfloat iFlippedX;
|
|
331 |
VGfloat iFlippedY;
|
|
332 |
VGfloat iFlippedZ;
|
|
333 |
|
|
334 |
// Which item is the front item in coverflow
|
|
335 |
TInt iSelectedItemIndex;
|
|
336 |
// Ending position of the left album stack
|
|
337 |
TReal iLeftStackEndX;
|
|
338 |
// Ending position of the right album stack
|
|
339 |
TReal iRightStackStartX;
|
|
340 |
// Z-coordinate of the frontmost album
|
|
341 |
TReal iZNear;
|
|
342 |
// Z-coordinate of the albums on the back
|
|
343 |
TReal iZFar;
|
|
344 |
// Space between albums in stacks
|
|
345 |
TReal iSpaceBetween;
|
|
346 |
// How much to zoom when fast swiped
|
|
347 |
TReal iFov;
|
|
348 |
// angle to flip the item around X-axis in flip opening animation
|
|
349 |
TReal iFlipAngle;
|
|
350 |
|
|
351 |
VGImage iBlurImage;
|
|
352 |
VGfloat iBlurAlpha;
|
|
353 |
VGfloat iBlurDeviationX;
|
|
354 |
VGfloat iBlurDeviationY;
|
|
355 |
|
|
356 |
VGfloat iFlippedWidth;
|
|
357 |
VGfloat iFlippedHeight;
|
|
358 |
|
|
359 |
VGint iBlurImageWidth;
|
|
360 |
VGint iBlurImageHeight;
|
|
361 |
VGImage iChildBlurImage;
|
|
362 |
|
|
363 |
TPoint iOffset;
|
|
364 |
|
|
365 |
TBool iFlipXY;
|
|
366 |
|
|
367 |
TBool iLandscape;
|
|
368 |
};
|
|
369 |
|
|
370 |
#endif /* HGVGMEDIAWALLRENDERER */
|