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