|
1 /* |
|
2 * Copyright (c) 2005-2006 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: This class provides the functionality for the animation |
|
15 element as specified in the SVG 1.2 specification |
|
16 * |
|
17 */ |
|
18 |
|
19 #if !defined(__E32BASE_H__) |
|
20 #include <e32base.h> |
|
21 #endif |
|
22 |
|
23 #ifndef C_SVGMediaAnimationElementImpl_H |
|
24 #define C_SVGMediaAnimationElementImpl_H |
|
25 |
|
26 #include "SVGMediaElementBase.h" |
|
27 #include "SVGTimeContainer.h" |
|
28 #include "SVGListener.h" |
|
29 |
|
30 class CSvgDocumentImpl; |
|
31 class MXmlDocument; |
|
32 class CSvgFitToViewBoxImpl; |
|
33 class CSvgErrorImpl; |
|
34 |
|
35 NONSHARABLE_CLASS( CSvgMediaAnimationElementImpl ): |
|
36 public CSvgMediaElementBase, |
|
37 public MSvgMouseListener, |
|
38 public MSvgTimeContainerObserver |
|
39 { |
|
40 |
|
41 public: |
|
42 /** |
|
43 * Two Phase Constructor |
|
44 * |
|
45 * since S60 3.2 |
|
46 * @param animation element id and document pointer |
|
47 * @return Animation element object |
|
48 */ |
|
49 static CSvgMediaAnimationElementImpl* NewL( const TUint8 aElemID, |
|
50 CSvgDocumentImpl* aDoc ); |
|
51 /** |
|
52 * Two Phase Constructor |
|
53 * |
|
54 * since S60 3.2 |
|
55 * @param animation element id and document pointer |
|
56 * @return Animation element object |
|
57 */ |
|
58 |
|
59 static CSvgMediaAnimationElementImpl* NewLC( const TUint8 aElemID, |
|
60 CSvgDocumentImpl* aDoc ); |
|
61 /** |
|
62 * Set the Synchronised behaviour for the animation element |
|
63 * @since S60 3.2 |
|
64 * @param aValue "canSlip" | "locked" | "independent" | "default" |
|
65 * @return none. |
|
66 */ |
|
67 virtual void SetSyncBehavior( const TDesC& aValue ); |
|
68 |
|
69 /** |
|
70 * Set the Synchronised Tolerance for the animation element |
|
71 * @since S60 3.2 |
|
72 * @param aValue Clock-value | "default" |
|
73 * @return none. |
|
74 */ |
|
75 virtual void SetSyncTolerance( const TDesC& aValue ); |
|
76 |
|
77 /** |
|
78 * Set the animation element as Synchronised Master |
|
79 * @since S60 3.2 |
|
80 * @param aValue "true" | "false" |
|
81 * @return none. |
|
82 */ |
|
83 virtual void SetSyncMaster( const TDesC& aValue ); |
|
84 |
|
85 |
|
86 private: |
|
87 |
|
88 /** |
|
89 * Two Phase Constructor |
|
90 * |
|
91 * since S60 3.2 |
|
92 * @param animation element id and document pointer |
|
93 * @return Animation element object |
|
94 */ |
|
95 void ConstructL( const TUint8 aElemID, |
|
96 CSvgDocumentImpl* aDoc ); |
|
97 |
|
98 /** |
|
99 * Constructor |
|
100 * |
|
101 * since S60 3.2 |
|
102 * @param aDoc a document pointer |
|
103 * @return none |
|
104 */ |
|
105 CSvgMediaAnimationElementImpl( CSvgDocumentImpl* aDoc ); |
|
106 public: |
|
107 /** |
|
108 * A method to (deep) clone the current element |
|
109 * |
|
110 * since S60 3.2 |
|
111 * @param None |
|
112 * @return An MXmlElement pointer to the object that is a copy of |
|
113 * the current element |
|
114 */ |
|
115 MXmlElement* CloneL(MXmlElement* aParentElement); |
|
116 |
|
117 /** |
|
118 * Destructor |
|
119 * |
|
120 * since S60 3.2 |
|
121 * @param none |
|
122 * @return none |
|
123 */ |
|
124 virtual ~CSvgMediaAnimationElementImpl(); |
|
125 |
|
126 // From MXmlElement API |
|
127 |
|
128 |
|
129 /** |
|
130 * Set attribute interface for Animation element |
|
131 * |
|
132 * since S60 3.2 |
|
133 * @param aName - A string buffer containing the name of the attribute |
|
134 * @param aValue - A string buffer containing the value of the attribute |
|
135 * @return An integer containing success/failure for this action |
|
136 */ |
|
137 TInt SetAttributeL( const TDesC& aName, |
|
138 const TDesC& aValue ); |
|
139 |
|
140 /** |
|
141 * Set attribute interface for Animation element |
|
142 * |
|
143 * since S60 3.2 |
|
144 * @param aName - A string buffer containing the name of the attribute |
|
145 * @return An integer containing success/failure for this action |
|
146 */ |
|
147 TInt SetAttributeDesL( const TInt aNameId, |
|
148 const TDesC& aValue ); |
|
149 |
|
150 |
|
151 /** |
|
152 * Returns x-y or width-height attributes for Animation element |
|
153 * |
|
154 * since S60 3.2 |
|
155 * @param |
|
156 * @return An integer containing success/failure for this action |
|
157 */ |
|
158 TInt GetAttributeFloat( const TInt aNameId, |
|
159 TFloatFixPt& aValue ); |
|
160 |
|
161 /** |
|
162 * Sets x-y or width-height attributes for Animatione element |
|
163 * |
|
164 * since S60 3.2 |
|
165 * @param |
|
166 * @return An integer containing success/failure for this action |
|
167 */ |
|
168 TInt SetAttributeFloatL( const TInt aNameId, |
|
169 TFloatFixPt aValue ); |
|
170 |
|
171 |
|
172 /** |
|
173 * ReceiveEventL: This function will be called whenever the registered |
|
174 * event was happened. |
|
175 * |
|
176 * @since Series 60 3.1 |
|
177 * @param MSvgEvent* aEvent |
|
178 * @return TBool ETrue if redraw is needed |
|
179 */ |
|
180 TBool ReceiveEventL( MSvgEvent* aEvent ); |
|
181 |
|
182 /** |
|
183 * Resets the animation element,starts from initial position |
|
184 * |
|
185 * since S60 3.2 |
|
186 * @param none |
|
187 * @return none |
|
188 */ |
|
189 void ResetAnimationL(); |
|
190 |
|
191 /** |
|
192 * Need method description |
|
193 * |
|
194 * since S60 3.2 |
|
195 * @param MSvgEvent |
|
196 * @return none |
|
197 */ |
|
198 void Reset( MSvgEvent* aEvent ); |
|
199 |
|
200 /** |
|
201 * Calls AnimProcL of animation element |
|
202 * |
|
203 * since S60 3.2 |
|
204 * @param |
|
205 * @return TBool ETrue if child svg document is there |
|
206 */ |
|
207 TBool DoAnimProcL(MSvgEvent* aEvent); |
|
208 |
|
209 |
|
210 /** |
|
211 * Return wether an svg element is displayable, such as <rect>, <circle>, or |
|
212 * an abstract element, such as <g>, <animate>. |
|
213 * |
|
214 * since S60 3.2 |
|
215 * @param None |
|
216 * @return ETrue if element is viewable. |
|
217 */ |
|
218 TBool IsViewable(); |
|
219 |
|
220 /** |
|
221 * |
|
222 * since S60 3.2 |
|
223 * @param TBool |
|
224 * @return none |
|
225 */ |
|
226 void Print( TBool aIsEncodeOn ); |
|
227 |
|
228 /** |
|
229 * Draws the child svg in the animation element |
|
230 * since S60 3.2 |
|
231 * @param GraphicsContext and SVGElement |
|
232 * @return ETrue if draw is successful else EFalse |
|
233 */ |
|
234 TBool DrawL( CGfx2dGc* aGc, CSvgElementImpl* aElement ); |
|
235 |
|
236 /** |
|
237 * Sets the initial CTM on animation element |
|
238 * since S60 3.2 |
|
239 * @param none |
|
240 * @return none |
|
241 */ |
|
242 void SetInitialCTM(); |
|
243 |
|
244 /** |
|
245 * Accessor function for obtaining the child SVG document |
|
246 * @since S60 3.2 |
|
247 * @param none. |
|
248 * @return CSvgDocumentImpl* Pointer to the document else NULL |
|
249 */ |
|
250 CSvgDocumentImpl* GetChildDocument(); |
|
251 |
|
252 /** |
|
253 * |
|
254 * since S60 3.2 |
|
255 * @param align variabel to indicate alignment method, aMeetSlice which |
|
256 is for new viewport. |
|
257 * @return none |
|
258 */ |
|
259 void SetPreserveAspectRatioL( TSvgPreserveAspectAlignType aAlign, |
|
260 TSvgMeetOrSliceType aMeetSlice ); |
|
261 |
|
262 /** |
|
263 * Sets the width of animation element |
|
264 * since S60 3.2 |
|
265 * @param aValue a Width attribute value from Svg file |
|
266 * @return |
|
267 */ |
|
268 void SetWidth(TReal32 aValue); |
|
269 |
|
270 /** |
|
271 * Sets the height of animation element |
|
272 * since S60 3.2 |
|
273 * @param aValue a Height attribute value from Svg file |
|
274 * @return none |
|
275 */ |
|
276 void SetHeight(TReal32 aValue); |
|
277 |
|
278 /** |
|
279 * prepares child svg document |
|
280 * since S60 3.2 |
|
281 * @param aFileHandle for child svg |
|
282 * @return MSvgError object |
|
283 */ |
|
284 MSvgError* PrepareDomChildSvg( RFile& aFileHandle, TInt& aHandle, TInt aEngine); |
|
285 |
|
286 /** |
|
287 * prepares child svg document |
|
288 * @param aFileHandle for child svg |
|
289 * @return MSvgError object |
|
290 */ |
|
291 MSvgError* PrepareDomChildSvg (const TDesC& aFileName,TInt& aHandle, TInt aEngine); |
|
292 |
|
293 /** |
|
294 * prepares child svg document |
|
295 * since S60 3.2 |
|
296 * @param aFileHandle for child svg |
|
297 * @return MSvgError object |
|
298 */ |
|
299 MSvgError* PrepareDomChildSvg(const TDesC8& aByteData, TInt& aHandle, TInt aEngine ); |
|
300 |
|
301 public: // From CSvgMediaElementBase |
|
302 /** |
|
303 * From MSvgTimedEntityInterface |
|
304 * The parent time container provides the timing clock to |
|
305 * the timed entity (audio, video, animation, document) |
|
306 * using this routine. |
|
307 * @since Series 3.2 |
|
308 * @param aTick Current tick information |
|
309 * @return none. |
|
310 */ |
|
311 void ParentTimeContainerTick( TSvgTick aTick ); |
|
312 |
|
313 /** |
|
314 * From MSvgTimedEntityInterface |
|
315 * When the timed entity acts as timing master in the time container, |
|
316 * the time container gets the timed entity clock using this method |
|
317 * and feeds to rest of timed entities. |
|
318 * @since Series 3.2 |
|
319 * @param aEntityCurTime Current Entity Time in msecs. |
|
320 * @return none. |
|
321 */ |
|
322 void GetEntityCurrentTime( TUint32& |
|
323 aEntityCurTime ); |
|
324 |
|
325 /** |
|
326 * From MSvgTimedEntityInterface |
|
327 * If some other element is resolved as syncMaster in the time container group, |
|
328 * this element can not act as sync master. |
|
329 * @since Series 3.2 |
|
330 * @param aSyncMasterStatus Indicates whether the element is currrently |
|
331 * Sync Master. |
|
332 * @return none. |
|
333 */ |
|
334 void SetCurSyncMasterStatus( TBool aSyncMasterStatus ); |
|
335 |
|
336 /** |
|
337 * From MSvgTimedEntityInterface |
|
338 * Check if timed entity can provide timing ticks to rest of time |
|
339 * container elements. This behavior could change dynamically. |
|
340 * For example, if audio clip is over, the audio element can't generate |
|
341 * ticks for others. |
|
342 * @since Series 3.2 |
|
343 * @param none. |
|
344 * @return TBool True if can generate timing tick. |
|
345 */ |
|
346 TBool CanGenerateTick(); |
|
347 |
|
348 /** |
|
349 * From MSvgTimedEntityInterface |
|
350 * If the timed entity needs to be in sync with the time container and |
|
351 * it has slipped beyond the sync tolerance limit, the method is called to |
|
352 * bring the element in sync with the time container. |
|
353 * @since Series 3.2 |
|
354 * @param aSynctime Time for resync in msecs. |
|
355 * @return none. |
|
356 */ |
|
357 void ResyncTimedEntity( TUint32 aSynctime ); |
|
358 |
|
359 /** |
|
360 * From CSvgMediaElementBase |
|
361 * This would be used for pausing the timed entity while other locked |
|
362 * timed entities get loaded. |
|
363 * @since S60 3.2 |
|
364 * @param none. |
|
365 * @return none. |
|
366 */ |
|
367 void PauseTimedEntity(); |
|
368 |
|
369 /** |
|
370 * From CSvgMediaElementBase |
|
371 * This would be used for resuming the timed entity once all locked |
|
372 * timed entities get loaded. |
|
373 * @since S60 3.2 |
|
374 * @param none. |
|
375 * @return none. |
|
376 */ |
|
377 void ResumeTimedEntity(); |
|
378 |
|
379 /** |
|
380 * From CSvgMediaElementBase |
|
381 * This would be used for stoping the timed entity once all locked |
|
382 * timed entities get loaded. |
|
383 * @since S60 3.2 |
|
384 * @param none. |
|
385 * @return none. |
|
386 */ |
|
387 void StopTimedEntity(); |
|
388 |
|
389 |
|
390 /* |
|
391 From MSvgTimedEntityInterface |
|
392 Would return the type of object |
|
393 @param none |
|
394 @return type of object |
|
395 */ |
|
396 TSvgObjectType ObjectType(); |
|
397 |
|
398 /* |
|
399 From MSvgTimedEntityInterface |
|
400 Return CSvgTimeContainer object |
|
401 @param none |
|
402 @return CSvgTimeContainer |
|
403 */ |
|
404 CSvgTimeContainer* GetChildTimeContainer(); |
|
405 |
|
406 private: // From MSvgTimeContainerObserver |
|
407 /** |
|
408 * From MSvgTimeContainerObserver |
|
409 * Indicates that all locked elements in child container are ready |
|
410 * to render. |
|
411 * @since S60 3.2 |
|
412 * @param none. |
|
413 * @return none. |
|
414 */ |
|
415 void TimeContainerReady(); |
|
416 |
|
417 /** |
|
418 * From MSvgTimeContainerObserver |
|
419 * Indicates that at least one locked element in child container |
|
420 * is not ready to render. |
|
421 * @since S60 3.2 |
|
422 * @param none. |
|
423 * @return none. |
|
424 */ |
|
425 void TimeContainerNotReady(); |
|
426 |
|
427 private: |
|
428 // From CSvgAnimationBase |
|
429 |
|
430 /** |
|
431 * |
|
432 * |
|
433 * |
|
434 * @since S60 3.2 |
|
435 * @param MSvgTimerEvent. |
|
436 * @return TBool. |
|
437 */ |
|
438 virtual TBool AnimProcL( MSvgTimerEvent* aEvent ); |
|
439 |
|
440 /** |
|
441 * Creates key times and set animation time according to calcmode |
|
442 * Sets first begin time, adds target element to event listener |
|
443 * @since S60 3.2 |
|
444 * @param none. |
|
445 * @return none. |
|
446 */ |
|
447 virtual void InitAnimationL(); |
|
448 |
|
449 /** |
|
450 * |
|
451 * @since S60 3.2 |
|
452 * @param MSvgPreserveAspectRatio. |
|
453 * @return none. |
|
454 */ |
|
455 void GetPreserveAspectRatio( MSvgPreserveAspectRatio*& aAspectRatio ); |
|
456 |
|
457 /** |
|
458 * X co-ordinate is returned |
|
459 * |
|
460 * since S60 3.2 |
|
461 * @param none |
|
462 * @return X position of Animation element |
|
463 */ |
|
464 |
|
465 TFloatFixPt X(); |
|
466 |
|
467 |
|
468 /** |
|
469 * Y co-ordinate is returned |
|
470 * |
|
471 * since S60 3.2 |
|
472 * @param none |
|
473 * @return Y position of Animation element |
|
474 */ |
|
475 TFloatFixPt Y(); |
|
476 |
|
477 |
|
478 /** |
|
479 * Width is returned |
|
480 * |
|
481 * since S60 3.2 |
|
482 * @param none |
|
483 * @return Width of Animation element |
|
484 */ |
|
485 TFloatFixPt Width(); |
|
486 |
|
487 |
|
488 /** |
|
489 * Height is returned |
|
490 * |
|
491 * since S60 3.2 |
|
492 * @param none |
|
493 * @return Height of Animation element |
|
494 */ |
|
495 TFloatFixPt Height(); |
|
496 |
|
497 |
|
498 /** |
|
499 * |
|
500 * |
|
501 * since S60 3.2 |
|
502 * @param TGfxRectangle2D |
|
503 * @return |
|
504 */ |
|
505 void GetBBox( TGfxRectangle2D& aBbox ); |
|
506 |
|
507 /** |
|
508 * |
|
509 * |
|
510 * since S60 3.2 |
|
511 * @param TSvgFourPointRect |
|
512 * @return none |
|
513 */ |
|
514 void GetFourPointBBox(TSvgFourPointRect& aFourPointBbox); |
|
515 |
|
516 |
|
517 /** |
|
518 * |
|
519 * |
|
520 * since S60 3.2 |
|
521 * @param none |
|
522 * @return |
|
523 */ |
|
524 void GetUnscaledBBox( TGfxRectangle2D& aBbox ); |
|
525 |
|
526 |
|
527 /** |
|
528 * Notified when the mouse pointer enters a visible svg element. |
|
529 * |
|
530 * since S60 3.2 |
|
531 * param : aElements -- SVG elements containing the mouse point. |
|
532 * param : aX -- x coordinate of mouse pointer. |
|
533 * param : aY -- y coordinate of mouse pointer. |
|
534 * @return : For future use. Value is ignored. |
|
535 */ |
|
536 virtual TBool MouseEntered( RPointerArray<CSvgElementImpl>& aElements, |
|
537 TInt aX, TInt aY ); |
|
538 |
|
539 /** |
|
540 * Notified when the mouse pointer exits a visible svg element. |
|
541 * |
|
542 * since S60 3.2 |
|
543 * param : aElements -- SVG elements containing the mouse point. |
|
544 * param : aX -- x coordinate of mouse pointer. |
|
545 * param : aY -- y coordinate of mouse pointer. |
|
546 * @return : For future use. Value is ignored. |
|
547 */ |
|
548 virtual TBool MouseExited( RPointerArray<CSvgElementImpl>& aElements, |
|
549 TInt aX, TInt aY ); |
|
550 |
|
551 |
|
552 /** |
|
553 * Notified when the mouse pointer has already entered a visible |
|
554 * svg element and just moved but remains inside its bounding-box. |
|
555 * |
|
556 * since S60 3.2 |
|
557 * param : aElements -- SVG elements containing the mouse point. |
|
558 * param : aX -- x coordinate of mouse pointer. |
|
559 * param : aY -- y coordinate of mouse pointer. |
|
560 * @return : For future use. Value is ignored. |
|
561 */ |
|
562 virtual TBool MouseMoved( RPointerArray<CSvgElementImpl>& aElements, |
|
563 TInt aX, TInt aY ); |
|
564 |
|
565 /** |
|
566 * Notified when the mouse pointer is pressed down on visible svg element. |
|
567 * |
|
568 * since S60 3.2 |
|
569 * param : aElements -- SVG elements containing the mouse point. |
|
570 * param : aX -- x coordinate of mouse pointer. |
|
571 * param : aY -- y coordinate of mouse pointer. |
|
572 * @return : For future use. Value is ignored. |
|
573 */ |
|
574 virtual TBool MousePressed( RPointerArray<CSvgElementImpl>& aElements, |
|
575 TInt aX, TInt aY ); |
|
576 |
|
577 /** |
|
578 * Notified when the mouse pointer is released on on visible svg element. |
|
579 * |
|
580 * since S60 3.2 |
|
581 * param : aElements -- SVG elements containing the mouse point. |
|
582 * param : aX -- x coordinate of mouse pointer. |
|
583 * param : aY -- y coordinate of mouse pointer. |
|
584 * @return : For future use. Value is ignored. |
|
585 */ |
|
586 virtual TBool MouseReleased( RPointerArray<CSvgElementImpl>& aElements, |
|
587 TInt aX, TInt aY ); |
|
588 |
|
589 |
|
590 /** |
|
591 * updates the CTM |
|
592 * |
|
593 * since S60 3.2 |
|
594 * @param none |
|
595 * @return none |
|
596 */ |
|
597 virtual void UpdateCTM(); |
|
598 |
|
599 |
|
600 /** |
|
601 * |
|
602 * |
|
603 * since S60 3.2 |
|
604 * @param none |
|
605 * @return none |
|
606 */ |
|
607 void DeactivateAnimation(); |
|
608 |
|
609 protected: |
|
610 |
|
611 /** |
|
612 * does a deep copy of mediaanimation element |
|
613 * |
|
614 * since S60 3.2 |
|
615 * @param CSvgMediaAnimationElementImpl element |
|
616 * @return none |
|
617 */ |
|
618 void CopyL( CSvgMediaAnimationElementImpl* aDestElement ); |
|
619 private: |
|
620 // DRM related |
|
621 TBool iDrmEnabled; |
|
622 |
|
623 // Thumbnail mode |
|
624 TBool iIsThumbNailMode; |
|
625 |
|
626 // MSvgLoadingListener list |
|
627 RPointerArray<MSvgLoadingListener> iSvgLoadingListeners; |
|
628 |
|
629 // Keep track of elements currently having mouse pointer inside |
|
630 // to report mouse-exit when it is moved. |
|
631 RPointerArray<CSvgElementImpl> iSvgMouseEnteredElements; |
|
632 |
|
633 // Flag to indicate Load or PrepareDom call. |
|
634 TBool iIsLoadingRequest; |
|
635 |
|
636 TBool iMouseDownFlag; |
|
637 |
|
638 TBool iFileIsLoaded; //checks for parsing error |
|
639 |
|
640 |
|
641 |
|
642 TFloatFixPt iScale; |
|
643 CSvgFitToViewBoxImpl* iViewBoxImpl; |
|
644 TFloatFixPt iX; |
|
645 TFloatFixPt iY; |
|
646 TBool iIsFocusable; // To be implemented |
|
647 // TBool iInitialVisibility; // InitialVisibility of the Animatin element |
|
648 // Referenced (target) element |
|
649 CSvgElementImpl* iReferencedElement; |
|
650 |
|
651 |
|
652 CSvgErrorImpl* iSvgError; // error object |
|
653 CSvgDocumentImpl* iNewDocument; // Document pointer for child svg |
|
654 TGfxAffineTransform iOriginalRootTr; // For Transform |
|
655 TBool iIsOriginalRootTrSet; |
|
656 TFloatFixPt iWidth; |
|
657 TFloatFixPt iHeight; |
|
658 |
|
659 enum TAnimationState // State of animation element |
|
660 { |
|
661 EPlayerStateIdle, |
|
662 EPlayerStatePlaying, |
|
663 EPlayerStatePaused, |
|
664 EPlayerStateStop, |
|
665 EPlayerProhibit |
|
666 }; |
|
667 |
|
668 TAnimationState iAnimationStatus; |
|
669 |
|
670 enum TAnimationVisible // Visibility State of animation element |
|
671 { |
|
672 EAnimationNotVisible, |
|
673 EAnimationInitialised, |
|
674 EAnimationVisible |
|
675 }; |
|
676 |
|
677 TAnimationVisible iInitialVisibility; |
|
678 // Save the tick at the time animation starts |
|
679 TSvgTick iBeginTick; |
|
680 // Indicates whether time container issued a pause command |
|
681 TBool iIsSyncPauseIssued; |
|
682 TBool iDurMediaTime; // if duration is media |
|
683 HBufC* iChildSvgName ; |
|
684 |
|
685 |
|
686 }; |
|
687 |
|
688 #endif // C_SVGMediaAnimationElementImpl_H |