1 /* |
|
2 * Copyright (c) 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: Floating toolbar UI feature implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "cvtuifloatingtoolbar.h" |
|
22 #include "cvtuifeaturemanager.h" |
|
23 #include "mvtuicomponentmanager.h" |
|
24 #include "mvtuicommandmanager.h" |
|
25 #include "cvtuitoolbarbutton.h" |
|
26 #include "videotelui.hrh" |
|
27 #include "tVtuifeaturevariation.h" |
|
28 #include "tvtuistates.h" |
|
29 #include "cvtuitoolbarcmdpolicy.h" |
|
30 #include "cvtuitoolbarskmodifier.h" |
|
31 #include "CVtUiAppUi.h" |
|
32 #include <videotelui.rsg> |
|
33 #include <cvtlogger.h> |
|
34 #include <akntoolbar.h> |
|
35 #include <aknutils.h> |
|
36 #include <aknlayoutscalable_apps.cdl.h> |
|
37 #include <layoutmetadata.cdl.h> |
|
38 #include <gfxtranseffect/gfxtranseffect.h> |
|
39 |
|
40 // CONSTANTS |
|
41 static const TInt KThreeToolbarbuttons = 3; |
|
42 static const TInt KFourToolbarbuttons = 4; |
|
43 static const TInt KFiveToolbarbuttons = 5; |
|
44 static const TInt KSixToolbarbuttons = 6; |
|
45 static const TInt KSevenToolbarbuttons = 7; |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CVtUiFloatingToolbar::NewL |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CVtUiFloatingToolbar* CVtUiFloatingToolbar::NewL( CVtUiFeatureManager& |
|
53 aFeatureManager ) |
|
54 { |
|
55 __VTPRINTENTER( "FloatingToolbar.NewL" ) |
|
56 TVtUiSideVolumeKeysVariation svkvariation; |
|
57 if ( !svkvariation.IsSideVolumeKeysSupported() ) |
|
58 { |
|
59 // User of this class should notice that newl could return null, |
|
60 // even if no leave happened. |
|
61 __VTPRINT(DEBUG_GEN, "Toolbar.NewL.NULL" ) |
|
62 return NULL; |
|
63 } |
|
64 CVtUiFloatingToolbar* self = new ( ELeave ) CVtUiFloatingToolbar( |
|
65 aFeatureManager ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop( self ); |
|
69 __VTPRINTEXIT( "FloatingToolbar.NewL" ) |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CVtUiFloatingToolbar::CVtUiFloatingToolbar |
|
75 // C++ constructor can NOT contain any code, that |
|
76 // might leave. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 CVtUiFloatingToolbar::CVtUiFloatingToolbar( CVtUiFeatureManager& |
|
80 aFeatureManager ) : CVtUiToolbarBase( aFeatureManager ) |
|
81 { |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CVtUiFloatingToolbar::ConstructL |
|
86 // Symbian 2nd phase constructor. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CVtUiFloatingToolbar::ConstructL() |
|
90 { |
|
91 __VTPRINTENTER( "FloatingToolbar.ConstructL" ) |
|
92 BaseConstructL(); |
|
93 |
|
94 // fixed toolbar is always visible ( defined in resource) hide it |
|
95 iFeatureManager.AppUi().CurrentFixedToolbar()->SetToolbarVisibility( EFalse ); |
|
96 |
|
97 // create toolbar |
|
98 iToolbar = CAknToolbar::NewL( R_VIDEOTELUI_FLOATING_TOOLBAR ); |
|
99 |
|
100 GfxTransEffect::Register( iToolbar, KNullUid, EFalse ); |
|
101 |
|
102 // create and add items into the toolbar |
|
103 CreateToolbarButtonsL(); |
|
104 |
|
105 iFeatureManager.UiStates().SetIsFloatingToolbarVisible( EFalse ); |
|
106 |
|
107 // layout toolbar |
|
108 LayoutToolbarL(); |
|
109 |
|
110 User::LeaveIfError( |
|
111 iFeatureManager.ComponentManager().ChangeResourceChangeRegistration( |
|
112 *this, MVtUiComponentManager::ERegister ) ); |
|
113 |
|
114 __VTPRINTEXIT( "FloatingToolbar.ConstructL" ) |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CVtUiFloatingToolbar::~CVtUiFloatingToolbar |
|
119 // Destructor. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 CVtUiFloatingToolbar::~CVtUiFloatingToolbar() |
|
123 { |
|
124 __VTPRINTENTER( "FloatingToolbar.~" ) |
|
125 // unregister resource change registration |
|
126 iFeatureManager.ComponentManager().ChangeResourceChangeRegistration( |
|
127 *this, MVtUiComponentManager::EUnregister ); |
|
128 delete iToolbar; |
|
129 iToolbar = NULL; |
|
130 __VTPRINTEXIT( "FloatingToolbar.~" ) |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CVtUiFloatingToolbar::PopulateCmdsIdsL |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CVtUiFloatingToolbar::PopulateCmdsIdsL() |
|
138 { |
|
139 __VTPRINTENTER( "FloatingToolbar.PopulateCmdsIdsL" ) |
|
140 CVtUiAppUi& appUi = iFeatureManager.AppUi(); |
|
141 |
|
142 // Default commands populated in base clase |
|
143 CVtUiToolbarBase::PopulateCmdsIdsL(); |
|
144 |
|
145 iCmdIds.AppendL( EVtUiCmdZoom ); |
|
146 |
|
147 switch( iNumberOfToolbarButtons ) |
|
148 { |
|
149 case KFourToolbarbuttons: |
|
150 iCmdIds.AppendL( EVtUiCmdUsePrimaryCamera ); |
|
151 iCmdIds.AppendL( EVtUiCmdUseSecondaryCamera ); |
|
152 break; |
|
153 |
|
154 case KFiveToolbarbuttons: |
|
155 iCmdIds.AppendL( EVtUiCmdUsePrimaryCamera ); |
|
156 iCmdIds.AppendL( EVtUiCmdUseSecondaryCamera ); |
|
157 iCmdIds.AppendL( EVtUiCmdSwapImagesPlaces ); |
|
158 break; |
|
159 |
|
160 case KSixToolbarbuttons: |
|
161 iCmdIds.AppendL( EVtUiCmdUsePrimaryCamera ); |
|
162 iCmdIds.AppendL( EVtUiCmdUseSecondaryCamera ); |
|
163 iCmdIds.AppendL( EVtUiCmdSwapImagesPlaces ); |
|
164 iCmdIds.AppendL( EVtUiCmdShareObjectImage ); |
|
165 break; |
|
166 /* |
|
167 case KSevenToolbarbuttons: |
|
168 iCmdIds.AppendL( EVtUiCmdUsePrimaryCamera ); |
|
169 iCmdIds.AppendL( EVtUiCmdUseSecondaryCamera ); |
|
170 iCmdIds.AppendL( EVtUiCmdSwapImagesPlaces ); |
|
171 iCmdIds.AppendL( EVtUiCmdShareObjectImage ); |
|
172 iCmdIds.AppendL( EVtUiCmdSnapshot ); |
|
173 break; |
|
174 */ |
|
175 default: |
|
176 break; |
|
177 } |
|
178 |
|
179 __VTPRINTEXIT( "FloatingToolbar.PopulateCmdsIdsL" ) |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CVtUiFloatingToolbar::CreateToolbarButtons |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CVtUiFloatingToolbar::CreateToolbarButtonsL() |
|
187 { |
|
188 __VTPRINTENTER( "FloatingToolbar.CreateToolbarButtons" ) |
|
189 |
|
190 // Default buttons created in base clase |
|
191 CVtUiToolbarBase::CreateToolbarButtonsL(); |
|
192 |
|
193 CVtUiAppUi& appUi = iFeatureManager.AppUi(); |
|
194 |
|
195 // activate zoom mode |
|
196 CreateToolbarItemL( R_AVKONBUTTON_ACTIVATE_ZOOM_MODE_BUTTON, |
|
197 EVtUiCmdZoom, appUi ); |
|
198 // disable tooltip from button's latched state |
|
199 // because tooltip needs to be shown only when |
|
200 // button gets focus not then when button is selected |
|
201 FindToolbarItemByCommandId( EVtUiCmdZoom )->State( 1 ) |
|
202 ->SetHelpTextL( KNullDesC() ); |
|
203 |
|
204 switch( iNumberOfToolbarButtons ) |
|
205 { |
|
206 case KFourToolbarbuttons: |
|
207 // toggle camera |
|
208 CreateToolbarItemL( R_AVKONBUTTON_TOGGLE_CAMERA_BUTTON, |
|
209 EVtUiCmdToolbarToggleCamera, appUi ); |
|
210 break; |
|
211 |
|
212 case KFiveToolbarbuttons: |
|
213 // toggle camera |
|
214 CreateToolbarItemL( R_AVKONBUTTON_TOGGLE_CAMERA_BUTTON, |
|
215 EVtUiCmdToolbarToggleCamera, appUi ); |
|
216 |
|
217 // swap images |
|
218 CreateToolbarItemL( R_AVKONBUTTON_SWAP_IMAGES_BUTTON, |
|
219 EVtUiCmdSwapImagesPlaces, appUi ); |
|
220 break; |
|
221 |
|
222 case KSixToolbarbuttons: |
|
223 // toggle camera |
|
224 CreateToolbarItemL( R_AVKONBUTTON_TOGGLE_CAMERA_BUTTON, |
|
225 EVtUiCmdToolbarToggleCamera, appUi ); |
|
226 |
|
227 // swap images |
|
228 CreateToolbarItemL( R_AVKONBUTTON_SWAP_IMAGES_BUTTON, |
|
229 EVtUiCmdSwapImagesPlaces, appUi ); |
|
230 |
|
231 // share file |
|
232 CreateToolbarItemL(R_AVKONBUTTON_SHARE_FILE_BUTTON, |
|
233 EVtUiCmdShareObjectImage, appUi ); |
|
234 break; |
|
235 /* |
|
236 case KSevenToolbarbuttons: |
|
237 // toggle camera |
|
238 CreateToolbarItemL( R_AVKONBUTTON_TOGGLE_CAMERA_BUTTON, |
|
239 EVtUiCmdToolbarToggleCamera, appUi ); |
|
240 |
|
241 // swap images |
|
242 CreateToolbarItemL( R_AVKONBUTTON_SWAP_IMAGES_BUTTON, |
|
243 EVtUiCmdSwapImagesPlaces, appUi ); |
|
244 |
|
245 // share file |
|
246 CreateToolbarItemL(R_AVKONBUTTON_SHARE_FILE_BUTTON, |
|
247 EVtUiCmdShareObjectImage, appUi ); |
|
248 |
|
249 CreateToolbarItemL( R_AVKONBUTTON_SNAPSHOT_BUTTON, |
|
250 EVtUiCmdSnapshot, appUi ); |
|
251 |
|
252 break; |
|
253 */ |
|
254 default: |
|
255 break; |
|
256 } |
|
257 |
|
258 __VTPRINTEXIT( "FloatingToolbar.CreateToolbarButtons" ) |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CVtUiFloatingToolbar::DoActivateL |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CVtUiFloatingToolbar::DoActivateL() |
|
266 { |
|
267 __VTPRINTENTER( "FloatingToolbar.DoActivateL" ) |
|
268 // start blocking key events |
|
269 BlockKeyEvents( ETrue ); |
|
270 // make toolbar visible |
|
271 if ( !iToolbar->IsVisible() || |
|
272 !iFeatureManager.UiStates().IsFloatingToolbarVisible() ) |
|
273 { |
|
274 // Show toolbar |
|
275 iToolbar->SetToolbarVisibility( ETrue ); |
|
276 } |
|
277 else |
|
278 { |
|
279 // Undim toolbar |
|
280 DimToolbar( EFalse, EFalse ); |
|
281 if ( iCmdFocus != KErrNotFound ) |
|
282 { |
|
283 // Set focus item |
|
284 iToolbar->SetItemDimmed( iCmdFocus, EFalse, ETrue ); |
|
285 iToolbar->SetFocusedItemL( iCmdFocus ); |
|
286 iCmdFocus = KErrNotFound; |
|
287 } |
|
288 } |
|
289 iFeatureManager.UiStates().SetIsFloatingToolbarVisible( EFalse ); |
|
290 CVtUiToolbarBase::DoActivateL(); |
|
291 __VTPRINTEXIT( "FloatingToolbar.DoActivateL" ) |
|
292 } |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CVtUiFloatingToolbar::DoDeactivateL |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CVtUiFloatingToolbar::DoDeactivateL() |
|
299 { |
|
300 __VTPRINTENTER( "FloatingToolbar.DoDeactivateL" ) |
|
301 // stop blocking key events |
|
302 BlockKeyEvents( EFalse ); |
|
303 if ( iToolbar ) |
|
304 { |
|
305 // Save foces item; |
|
306 if ( iToolbar->FocusedItem() != KErrNotFound ) |
|
307 { |
|
308 iCmdFocus = iToolbar->FocusedItem(); |
|
309 } |
|
310 TVtUiStates& uiStates = iFeatureManager.UiStates(); |
|
311 if ( !uiStates.IsFloatingToolbarVisible() ) |
|
312 { |
|
313 __VTPRINT( DEBUG_GEN, "FloatingToolbar.DoDeactivateL.Vs" ) |
|
314 iToolbar->SetToolbarVisibility( EFalse ); |
|
315 } |
|
316 else |
|
317 { |
|
318 // Dim toolbar |
|
319 __VTPRINT( DEBUG_GEN, "FloatingToolbar.DoDeactivateL.Dim ETrue" ) |
|
320 DimToolbar( ETrue, EFalse ); |
|
321 } |
|
322 CVtUiAppUi& appUi = iFeatureManager.AppUi(); |
|
323 const TBool isZoomModeOn( uiStates.IsZoomModeOn() ); |
|
324 if ( isZoomModeOn ) |
|
325 { |
|
326 // set zoom indicator to be hidden |
|
327 appUi.SetZoomModeL( EFalse ); |
|
328 } |
|
329 } |
|
330 CVtUiToolbarBase::DoDeactivateL(); |
|
331 __VTPRINTEXIT( "FloatingToolbar.DoDeactivateL" ) |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CVtUiFloatingToolbar::HandleResourceChangeL |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void CVtUiFloatingToolbar::HandleResourceChangeL( TInt /*aType*/ ) |
|
339 { |
|
340 __VTPRINTENTER( "FloatingToolbar.HandleResourceChangeL" ) |
|
341 // akntoolbar should allways be in the control stack |
|
342 // no need to call |
|
343 // iToolbar->HandleResourceChange |
|
344 LayoutToolbarL(); |
|
345 __VTPRINTEXIT( "FloatingToolbar.HandleResourceChangeL" ) |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // CVtUiFloatingToolbar::RectFromLayout |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 TRect CVtUiFloatingToolbar::RectFromLayout( |
|
353 const TAknWindowComponentLayout& aComponentLayout ) const |
|
354 { |
|
355 __VTPRINTENTER( "FloatingToolbar.RectFromLayout" ) |
|
356 TRect mainPaneRect; |
|
357 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
358 |
|
359 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
|
360 TAknLayoutRect layoutRect; |
|
361 layoutRect.LayoutRect( mainPaneRect, lineLayout ); |
|
362 __VTPRINTEXIT( "FloatingToolbar.RectFromLayout" ) |
|
363 return layoutRect.Rect(); |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // CVtUiFloatingToolbar::LayoutToolbarL |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void CVtUiFloatingToolbar::LayoutToolbarL() |
|
371 { |
|
372 __VTPRINTENTER( "FloatingToolbar.LayoutToolbarL" ) |
|
373 |
|
374 // Get variety |
|
375 TInt variety = GetVariety( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
376 // get toolbar rect from layout |
|
377 TRect toolbarRect = RectFromLayout( AknLayoutScalable_Apps:: |
|
378 popup_toolbar_window_cp04( variety ).LayoutLine() ); |
|
379 //set top left coordinates i.e. placeholder |
|
380 iToolbar->SetPosition( toolbarRect.iTl ); |
|
381 |
|
382 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
383 { |
|
384 __VTPRINT( DEBUG_GEN, "Toolbar.LayoutToolbarL.LS" ) |
|
385 iToolbar->SetOrientation( EAknOrientationVertical ); |
|
386 } |
|
387 else |
|
388 { |
|
389 __VTPRINT( DEBUG_GEN, "Toolbar.LayoutToolbarL.PR" ) |
|
390 iToolbar->SetOrientation( EAknOrientationHorizontal ); |
|
391 } |
|
392 __VTPRINTEXIT( "FloatingToolbar.LayoutToolbarL" ) |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CVtUiFloatingToolbar::GetVariety |
|
397 // ----------------------------------------------------------------------------- |
|
398 // |
|
399 TInt CVtUiFloatingToolbar::GetVariety( TBool aIsLandscapeOrientation ) |
|
400 { |
|
401 __VTPRINTENTER( "FloatingToolbar.GetVariety" ) |
|
402 TInt variety = 0; |
|
403 switch ( iNumberOfToolbarButtons ) |
|
404 { |
|
405 case KThreeToolbarbuttons: |
|
406 if( aIsLandscapeOrientation ) |
|
407 { |
|
408 variety = 5; |
|
409 } |
|
410 else |
|
411 { |
|
412 variety = 9; |
|
413 } |
|
414 break; |
|
415 |
|
416 case KFourToolbarbuttons: |
|
417 if( aIsLandscapeOrientation ) |
|
418 { |
|
419 variety = 4; |
|
420 } |
|
421 else |
|
422 { |
|
423 variety = 8; |
|
424 } |
|
425 break; |
|
426 |
|
427 case KFiveToolbarbuttons: |
|
428 if( aIsLandscapeOrientation ) |
|
429 { |
|
430 variety = 3; |
|
431 } |
|
432 else |
|
433 { |
|
434 variety = 7; |
|
435 } |
|
436 break; |
|
437 |
|
438 case KSixToolbarbuttons: |
|
439 if( aIsLandscapeOrientation ) |
|
440 { |
|
441 variety = 2; |
|
442 } |
|
443 else |
|
444 { |
|
445 variety = 6; |
|
446 } |
|
447 break; |
|
448 |
|
449 case KSevenToolbarbuttons: |
|
450 if( aIsLandscapeOrientation ) |
|
451 { |
|
452 variety = 1; |
|
453 } |
|
454 else |
|
455 { |
|
456 variety = 4; |
|
457 } |
|
458 break; |
|
459 |
|
460 default: |
|
461 |
|
462 break; |
|
463 } |
|
464 __VTPRINTEXITR( "FloatingToolbar.GetVariety =%d",variety ) |
|
465 return variety; |
|
466 } |
|
467 // End of File |
|
468 |
|