|
1 /* |
|
2 * Copyright (c) 2008-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: Base class for timed animations |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 12/07/2007 by Michael Yip |
|
23 */ |
|
24 |
|
25 #include "glxanimationtimed.h" |
|
26 #include "mglxanimationobserver.h" |
|
27 #include "glxuiutility.h" |
|
28 |
|
29 #include <alf/alfenv.h> |
|
30 #include <alf/alfevent.h> |
|
31 |
|
32 const TInt KGlxEventAnimationComplete = 0; |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // Constructor |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CGlxAnimationTimed::CGlxAnimationTimed() |
|
39 { |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // Destructor |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CGlxAnimationTimed::~CGlxAnimationTimed() |
|
47 { |
|
48 if ( iUiUtility ) |
|
49 { |
|
50 iUiUtility->Env()->CancelCommands(this); |
|
51 |
|
52 iUiUtility->Close(); |
|
53 iUiUtility = NULL; |
|
54 } |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // AnimateL |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CGlxAnimationTimed::AnimateL( TInt aTime, MGlxAnimationObserver* aObserver ) |
|
62 { |
|
63 if ( aObserver ) |
|
64 { |
|
65 iObserver = aObserver; |
|
66 |
|
67 // if we dont yet have ui utility handle, get it now |
|
68 if ( !iUiUtility ) |
|
69 { |
|
70 iUiUtility = CGlxUiUtility::UtilityL(); |
|
71 } |
|
72 |
|
73 // send event once the animation should complete |
|
74 iUiUtility->Env()->Send( |
|
75 TAlfCustomEventCommand( KGlxEventAnimationComplete, this ), aTime ); |
|
76 } |
|
77 |
|
78 // call the abstract method |
|
79 StartTimedAnimationL( aTime ); |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // OfferEventL |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 TBool CGlxAnimationTimed::OfferEventL( const TAlfEvent &aEvent ) |
|
87 { |
|
88 TBool consumed = EFalse; |
|
89 |
|
90 if ( aEvent.IsCustomEvent() ) |
|
91 { |
|
92 // Rowland (30/10/2007) Changed iParam to CustomParameter() |
|
93 if ( KGlxEventAnimationComplete == aEvent.CustomParameter() ) |
|
94 { |
|
95 // we consumed the event |
|
96 consumed = ETrue; |
|
97 |
|
98 if ( iObserver ) |
|
99 { |
|
100 iObserver->AnimationComplete( this ); |
|
101 } |
|
102 // IMPORTANT! |
|
103 // No code after this! Client may delete the animation! |
|
104 } |
|
105 } |
|
106 |
|
107 return consumed; |
|
108 } |