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