|
1 /* |
|
2 * Copyright (c) 2007-2008 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: The view control for the slideshow |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "shwviewcontrol.h" |
|
22 |
|
23 #include "shwevent.h" |
|
24 #include "shwslideshowenginepanic.h" |
|
25 |
|
26 #include <mglxmedialist.h> |
|
27 #include <glxlog.h> |
|
28 #include <glxtracer.h> |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // C++ Constructor. Save a few bits of rom with inlining |
|
32 // ----------------------------------------------------------------------------- |
|
33 inline CShwViewControl::CShwViewControl( MGlxMediaList& aList ) |
|
34 : iList( aList ), |
|
35 iReadyToViewReceived( EFalse ), |
|
36 iTransitionReadyReceived( EFalse ), |
|
37 iReadyToAdvanceReceived( EFalse ), |
|
38 iTimerReceived( EFalse ), |
|
39 iUserNavigated( EFalse ), |
|
40 iPaused( EFalse ), |
|
41 iUserNavigatedWhilePaused( EFalse ) |
|
42 { |
|
43 // No implementation required |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // NewL. Static construction |
|
48 // ----------------------------------------------------------------------------- |
|
49 CShwViewControl* CShwViewControl::NewL( |
|
50 MGlxMediaList& aList, TInt aTransitionDuration, TInt aViewDuration ) |
|
51 { |
|
52 TRACER("CShwViewControl::NewL"); |
|
53 GLX_LOG_INFO( "CShwViewControl::NewL" ); |
|
54 CShwViewControl* self = new( ELeave ) CShwViewControl( aList ); |
|
55 CleanupStack::PushL( self ); |
|
56 |
|
57 // set the durations |
|
58 self->iTransitionDuration = aTransitionDuration; |
|
59 self->iViewDuration = aViewDuration; |
|
60 self->ConstructL(); |
|
61 |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // Destructor. |
|
68 // ----------------------------------------------------------------------------- |
|
69 CShwViewControl::~CShwViewControl() |
|
70 { |
|
71 TRACER("CShwViewControl::~CShwViewControl"); |
|
72 GLX_LOG_INFO( "CShwViewControl::~CShwViewControl" ); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // ConstructL. |
|
77 // ----------------------------------------------------------------------------- |
|
78 void CShwViewControl::ConstructL() |
|
79 { |
|
80 TRACER("CShwViewControl::ConstructL"); |
|
81 GLX_LOG_INFO( "CShwViewControl::ConstructL" ); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // NotifyL. |
|
86 // ----------------------------------------------------------------------------- |
|
87 void CShwViewControl::NotifyL( MShwEvent* aEvent ) |
|
88 { |
|
89 TRACER("CShwViewControl::NotifyL"); |
|
90 GLX_LOG_INFO( "CShwViewControl::NotifyL" ); |
|
91 // we got an event, was it start slideshow |
|
92 if( dynamic_cast< TShwEventStart* >( aEvent ) ) |
|
93 { |
|
94 GLX_LOG_INFO( "CShwViewControl::NotifyL - TShwEventStart" ); |
|
95 // start view immediately |
|
96 // as we do not get transition ready before the first slide |
|
97 TShwEventStartView startView( iViewDuration ); |
|
98 SendEventL( &startView ); |
|
99 } |
|
100 // was it ready to view |
|
101 else if( dynamic_cast< TShwEventReadyToView* >( aEvent ) ) |
|
102 { |
|
103 GLX_LOG_INFO( "CShwViewControl::NotifyL - TShwEventReadyToView" ); |
|
104 // set ready to view flag |
|
105 iReadyToViewReceived = ETrue; |
|
106 // is transition ready or user did navigate |
|
107 if( iTransitionReadyReceived || iUserNavigated ) |
|
108 { |
|
109 // reset user navigate flag |
|
110 iUserNavigated = EFalse; |
|
111 // send start view |
|
112 SendStartViewL(); |
|
113 } |
|
114 } |
|
115 // was it transition ready |
|
116 else if( dynamic_cast< TShwEventTransitionReady* >( aEvent ) ) |
|
117 { |
|
118 GLX_LOG_INFO( "CShwViewControl::NotifyL - TShwEventTransitionReady" ); |
|
119 // set transition ready flag |
|
120 iTransitionReadyReceived = ETrue; |
|
121 // are we ready to start view |
|
122 if( iReadyToViewReceived ) |
|
123 { |
|
124 // send start view |
|
125 SendStartViewL(); |
|
126 } |
|
127 } |
|
128 // was it timer beat |
|
129 else if( dynamic_cast< TShwEventTimerBeat* >( aEvent ) ) |
|
130 { |
|
131 GLX_LOG_INFO( "CShwViewControl::NotifyL - TShwEventTimerBeat" ); |
|
132 // we got the timer |
|
133 iTimerReceived = ETrue; |
|
134 // check if we are ok to go to start transition |
|
135 CheckAndSendStartTransitionL(); |
|
136 } |
|
137 // was it ready to advance |
|
138 else if( dynamic_cast< TShwEventReadyToAdvance* >( aEvent ) ) |
|
139 { |
|
140 GLX_LOG_INFO( "CShwViewControl::NotifyL - TShwEventReadyToAdvance" ); |
|
141 // we got ready to advance |
|
142 iReadyToAdvanceReceived = ETrue; |
|
143 // check if we are ok to go to start transition |
|
144 CheckAndSendStartTransitionL(); |
|
145 } |
|
146 // was it next or previous image? |
|
147 else if ( dynamic_cast< TShwEventNextImage* >( aEvent ) || |
|
148 dynamic_cast< TShwEventPreviousImage* >( aEvent ) ) |
|
149 { |
|
150 // user did navigate, reset the state flags |
|
151 iReadyToAdvanceReceived = EFalse; |
|
152 iReadyToViewReceived = EFalse; |
|
153 // user did navigate |
|
154 iUserNavigated = ETrue; |
|
155 iUserNavigatedWhilePaused = iPaused; |
|
156 } |
|
157 // pause event? |
|
158 else if ( dynamic_cast< TShwEventPause* >( aEvent ) ) |
|
159 { |
|
160 // we are paused |
|
161 iPaused = ETrue; |
|
162 iUserNavigatedWhilePaused = EFalse; |
|
163 } |
|
164 // resume event? |
|
165 else if ( dynamic_cast< TShwEventResume* >( aEvent ) ) |
|
166 { |
|
167 // we are not paused |
|
168 iPaused = EFalse; |
|
169 // did user navigate? |
|
170 if( iUserNavigatedWhilePaused ) |
|
171 { |
|
172 // reset the flag |
|
173 iUserNavigatedWhilePaused = EFalse; |
|
174 // user navigated while paused so need to reset view mode |
|
175 // to restart the effect and timer, while on pause it was not |
|
176 // completely started |
|
177 SendStartViewL(); |
|
178 } |
|
179 } |
|
180 else if ( dynamic_cast< TShwEventToggleControlUi* >( aEvent ) ) |
|
181 { |
|
182 GLX_LOG_INFO( "CShwViewControl::NotifyL - TShwEventToggleControlUi" ); |
|
183 // Have to impliment if need comes |
|
184 } |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CheckAndSendStartTransitionL. |
|
189 // ----------------------------------------------------------------------------- |
|
190 void CShwViewControl::CheckAndSendStartTransitionL() |
|
191 { |
|
192 TRACER("CShwViewControl::CheckAndSendStartTransitionL"); |
|
193 GLX_LOG_INFO( "CShwViewControl::CheckAndSendStartTransitionL" ); |
|
194 // check if we got timer and ready to advance and |
|
195 // we are not paused and there is more than one item |
|
196 if( iTimerReceived && iReadyToAdvanceReceived && |
|
197 (!iPaused) && (iList.Count() > 1) ) |
|
198 { |
|
199 GLX_LOG_INFO( "CShwViewControl::Sending TShwEventStartTransition" ); |
|
200 // reset timer and viewready flags |
|
201 iReadyToAdvanceReceived = EFalse; |
|
202 iTimerReceived = EFalse; |
|
203 // send start transition event |
|
204 TShwEventStartTransition startTransition( iTransitionDuration ); |
|
205 SendEventL( &startTransition ); |
|
206 // reset also view flags so that we wait for both before starting view |
|
207 iReadyToViewReceived = EFalse; |
|
208 iTransitionReadyReceived = EFalse; |
|
209 } |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // SendStartViewL. |
|
214 // ----------------------------------------------------------------------------- |
|
215 void CShwViewControl::SendStartViewL() |
|
216 { |
|
217 TRACER("CShwViewControl::SendStartViewL"); |
|
218 GLX_LOG_INFO( "CShwViewControl::SendStartViewL" ); |
|
219 // reset ready to view and transition ready flags |
|
220 iReadyToViewReceived = EFalse; |
|
221 iTransitionReadyReceived = EFalse; |
|
222 // send start view event |
|
223 TShwEventStartView startView( iViewDuration ); |
|
224 SendEventL( &startView ); |
|
225 // reset also transition start flags so that we wait for both |
|
226 // before starting transition |
|
227 iTimerReceived = EFalse; |
|
228 iReadyToAdvanceReceived = EFalse; |
|
229 } |
|
230 |