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: Base class for toolbar. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <centralrepository.h> |
|
21 #include <cvtlogger.h> |
|
22 #include <akntoolbar.h> |
|
23 #include <featmgr.h> |
|
24 #include <StringLoader.h> |
|
25 #include <videotelui.rsg> |
|
26 #include "videotelui.hrh" |
|
27 #include "cvtuitoolbarbase.h" |
|
28 #include "mvtuifeature.h" |
|
29 #include "tvtuistates.h" |
|
30 #include "cvtuitoolbarcontext.h" |
|
31 #include "cvtuitoolbarcmdpolicy.h" |
|
32 #include "cvtuicommandpolicymanager.h" |
|
33 #include "cvtuihidetoolbaritemaction.h" |
|
34 #include "cvtuifeaturemanager.h" |
|
35 #include "CVtUiAppUi.h" |
|
36 #include "mvtuicommandui.h" |
|
37 #include "cvtuitoolbarskmodifier.h" |
|
38 #include "mvtuicommandmanager.h" |
|
39 #include "mvtuicomponentmanager.h" |
|
40 #include "cvtuitoolbarbutton.h" |
|
41 #include "VideoTelephonyInternalCRKeys.h" |
|
42 #include "tVtuifeaturevariation.h" |
|
43 #include "cvtuitoolbarbutton.h" |
|
44 #include <layoutmetadata.cdl.h> |
|
45 |
|
46 // Implementation of TVtUiToolbarComponentState |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // TVtUiToolbarComponentState::TVtUiToolbarComponentState |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 TVtUiToolbarComponentState::TVtUiToolbarComponentState( |
|
53 MVtUiComponent& aComponent ) : |
|
54 TVtUiComponentState( aComponent, |
|
55 TVtUiBlockListBitField( |
|
56 MVtUiComponent::EComponentIdNull ) ) |
|
57 { |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // Used in FindToolbaItemByCommandId method to search toolbar item by cmd id. |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 TInt ToolbarItemIdCmpFunc( const TInt* aId, |
|
65 const CVtUiToolbarButton& aToolbarItem ) |
|
66 { |
|
67 return ( *aId - aToolbarItem.CmdId() ); |
|
68 } |
|
69 |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Used in CreateToolbarItemL method to search feature by cmd id. |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 TInt ToolbarCmpFunc( const CVtUiToolbarButton& aV1, const CVtUiToolbarButton& aV2 ) |
|
76 { |
|
77 return ( aV1.CmdId() - aV2.CmdId() ); |
|
78 } |
|
79 |
|
80 // ============================ MEMBER FUNCTIONS =============================== |
|
81 |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CVtUiToolbarBase::CVtUiToolbarBase |
|
85 // C++ constructor can NOT contain any code, that |
|
86 // might leave. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CVtUiToolbarBase::CVtUiToolbarBase( CVtUiFeatureManager& aFeatureManager ) |
|
90 : CVtUiFeatureBase( EVtUiFeatureIdToolbar, aFeatureManager ), |
|
91 iComponentState( *this ) |
|
92 { |
|
93 __VTPRINTENTER( "Toolbar.CVtUiToolbarBase" ) |
|
94 // Get number of supported buttons. |
|
95 // Six is the default value for floating toolbar |
|
96 // and three buttons for fixed toolbar |
|
97 TVtUiToolbarVariation toolbar; |
|
98 iNumberOfToolbarButtons = toolbar.NumberOfButtons(); |
|
99 iCmdFocus = KErrNotFound; |
|
100 __VTPRINTEXITR( "Toolbar.CVtUiToolbarBase %d", iNumberOfToolbarButtons ) |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CVtUiToolbarBase::BaseConstructL |
|
105 // Symbian 2nd phase constructor. |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CVtUiToolbarBase::BaseConstructL() |
|
109 { |
|
110 __VTPRINTENTER( "Toolbar.ConstructL" ) |
|
111 CVtUiFeatureBase::BaseConstructL(); |
|
112 iFeatureManager.UiStates().SetIsToolbarAvailable( ETrue ); |
|
113 __VTPRINTEXIT( "Toolbar.ConstructL" ) |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CVtUiToolbarBase::~CVtUiToolbarBase |
|
118 // Destructor. |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 CVtUiToolbarBase::~CVtUiToolbarBase() |
|
122 { |
|
123 __VTPRINTENTER( "Toolbar.~" ) |
|
124 // Stop(); |
|
125 // Stop can not be called here if toolbar is asked from ui fw = fixed toolbar. |
|
126 // If stop is called a crash occurs, whose root cause can not be solved. |
|
127 // It is related somehow with focus lost in ui fw. |
|
128 |
|
129 Clean(); |
|
130 // unregister layout change |
|
131 iFeatureManager.ComponentManager().ChangeLayoutChangeRegistration( |
|
132 *this, MVtUiComponentManager::EUnregister ); |
|
133 // no need tot call resetanddestroy because buttons ownership is |
|
134 // transferred to akntoolbar. |
|
135 iToolBarControls.Reset(); |
|
136 delete iToolbarCtx; |
|
137 delete iToolbarCmdPolicy; |
|
138 delete iHideToolbarItemAction; |
|
139 delete iToolbarSKModifier; |
|
140 iCmdIds.Close(); |
|
141 iCmdStates.Close(); |
|
142 __VTPRINTEXIT( "Toolbar.~" ) |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CVtUiToolbarBase::DynInitToolbarL |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CVtUiToolbarBase::DynInitToolbarL( TInt /*aResourceId*/, |
|
150 CAknToolbar* /*aToolbar*/ ) |
|
151 { |
|
152 __VTPRINTENTER( "Toolbar.DynInitToolbarL" ) |
|
153 __VTPRINTEXIT( "Toolbar.DynInitToolbarL" ) |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CVtUiToolbarBase::OfferToolbarEventL |
|
158 // Destructor. |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 void CVtUiToolbarBase::OfferToolbarEventL( TInt aCommand ) |
|
162 { |
|
163 __VTPRINTENTER( "Toolbar.OfferToolbarEventL" ) |
|
164 __VTPRINT2( DEBUG_GEN, "Toolbar.OfferToolbarEventL.aCommand=%d", aCommand ) |
|
165 |
|
166 // if capture mode is on all msk events must be converted to capture command |
|
167 if ( iFeatureManager.UiStates().IsCaptureModeOn() ) |
|
168 { |
|
169 iFeatureManager.AppUi().HandleCommandL( EVtUiCmdCapture ); |
|
170 return; |
|
171 } |
|
172 |
|
173 TInt command = MapCmdIdToChilId( aCommand ); |
|
174 |
|
175 if ( EVtUiCmdSwapImagesPlaces == command ) |
|
176 { |
|
177 if ( !( iFeatureManager.AppUi().CanSwapImagePlaces() ) ) |
|
178 { |
|
179 return; |
|
180 } |
|
181 } |
|
182 |
|
183 iFeatureManager.AppUi().HandleCommandL( command ); |
|
184 |
|
185 __VTPRINTEXITR( "Toolbar.OfferToolbarEventL.cmd %d", aCommand ) |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CVtUiToolbarBase::StartL |
|
190 // Destructor. |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 void CVtUiToolbarBase::StartL() |
|
194 { |
|
195 CVtUiFeatureBase::StartL(); |
|
196 __VTPRINTENTER( "Toolbar.StartL" ) |
|
197 TInt error; |
|
198 if ( iFeatureState == MVtUiFeature::EReady ) |
|
199 { |
|
200 TRAP( error, iFeatureManager.ComponentManager(). |
|
201 RequestActivationL( MVtUiComponent::EComponentIdToolbar ) ); |
|
202 |
|
203 // set state |
|
204 iFeatureState = MVtUiFeature::EActive; |
|
205 } |
|
206 __VTPRINTEXITR( "Toolbar.StartL error = %d", error ) |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CVtUiToolbarBase::Stop |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CVtUiToolbarBase::Stop() |
|
214 { |
|
215 __VTPRINTENTER( "Toolbar.Stop" ) |
|
216 TInt error; |
|
217 if ( iFeatureState == MVtUiFeature::EActive ) |
|
218 { |
|
219 TRAP( error, iFeatureManager.ComponentManager(). |
|
220 DeActivateComponentL ( MVtUiComponent::EComponentIdToolbar ) ); |
|
221 // set state |
|
222 iFeatureState = MVtUiFeature::EReady; |
|
223 } |
|
224 __VTPRINTEXITR( "Toolbar.Stop error = %d", error ) |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // CVtUiToolbarBase::InitFeature |
|
229 // Delayed initialization of the feature |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 void CVtUiToolbarBase::InitFeatureL() |
|
233 { |
|
234 __VTPRINTENTER( "Toolbar.InitFeatureL" ) |
|
235 iFeatureState = EPreparing; |
|
236 iToolBarControls.ReserveL( iNumberOfToolbarButtons ); |
|
237 |
|
238 //create toolbar |
|
239 //iToolbar = CAknToolbar::NewL( R_VIDEOTELUI_TOOLBAR ); |
|
240 |
|
241 iToolbar->SetToolbarObserver( this ); |
|
242 |
|
243 // Prohibit toolbar sliding on UI. |
|
244 iToolbar->SetWithSliding( EFalse ); |
|
245 |
|
246 // create toolbar context and policy |
|
247 iToolbarCtx = |
|
248 CVtUiToolbarContext::NewL( iFeatureManager.CommandManager() ); |
|
249 |
|
250 iToolbarCmdPolicy = CVtUiToolbarCmdPolicy::NewL( *this ); |
|
251 |
|
252 // create toolbaraction |
|
253 iHideToolbarItemAction = CVtUiHideToolbarItemAction::NewL( this, |
|
254 iFeatureManager.UiStates() ); |
|
255 |
|
256 // create sofkey modifier |
|
257 iToolbarSKModifier = CVtUiToolbarSKModifier:: |
|
258 NewL( iFeatureManager.AppUi(), iFeatureManager.UiStates() ); |
|
259 |
|
260 // set supported commands |
|
261 PopulateCmdsIdsL(); |
|
262 |
|
263 User::LeaveIfError( |
|
264 iFeatureManager.ComponentManager().ChangeComponentRegistration( |
|
265 iComponentState, MVtUiComponentManager::ERegister ) ); |
|
266 |
|
267 User::LeaveIfError( |
|
268 iFeatureManager.ComponentManager().ChangeLayoutChangeRegistration( |
|
269 *this, MVtUiComponentManager::ERegister ) ); |
|
270 |
|
271 iFeatureState = EReady; |
|
272 |
|
273 __VTPRINTEXIT( "Toolbar.InitFeatureL" ) |
|
274 } |
|
275 |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CVtUiToolbarBase::MapCmdIdToChilId |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 TInt CVtUiToolbarBase::MapCmdIdToChilId( TInt aCmdId ) |
|
282 { |
|
283 __VTPRINTENTER( "Toolbar.MapCmdIdToChilId" ) |
|
284 __VTPRINT2( DEBUG_GEN, "Toolbar.MapCmdIdToChilId.aCmdId=%d", aCmdId ) |
|
285 TInt result = aCmdId; |
|
286 |
|
287 CVtUiToolbarButton* tbButton = FindToolbarItemByCommandId( aCmdId ); |
|
288 |
|
289 const TInt stateIndexValue( tbButton->StateIndex() ); |
|
290 __VTPRINT2( DEBUG_GEN, "Toolbar.MapCmdIdToChilId.idx=%d", stateIndexValue ) |
|
291 switch( aCmdId ) |
|
292 { |
|
293 case EVtUiCmdToolbarToggleVideo: |
|
294 { |
|
295 switch ( stateIndexValue ) |
|
296 { |
|
297 case 0: |
|
298 case 1: |
|
299 result = EVtUiCmdDisableVideo; |
|
300 break; |
|
301 case 2: |
|
302 case 3: |
|
303 result = EVtUiCmdEnableVideo; |
|
304 break; |
|
305 } |
|
306 } |
|
307 break; |
|
308 |
|
309 case EVtUiCmdToolbarToggleMicrophone: |
|
310 { |
|
311 switch ( stateIndexValue ) |
|
312 { |
|
313 case 0: |
|
314 case 1: |
|
315 result = EVtUiCmdDisableAudio; |
|
316 break; |
|
317 case 2: |
|
318 case 3: |
|
319 result = EVtUiCmdEnableAudio; |
|
320 break; |
|
321 } |
|
322 } |
|
323 break; |
|
324 |
|
325 case EVtUiCmdToolbarAudioRouting: |
|
326 { |
|
327 switch ( stateIndexValue ) |
|
328 { |
|
329 case 0: |
|
330 case 1: |
|
331 result = EVtUiCmdDeactivateLoudspeaker; |
|
332 break; |
|
333 case 2: |
|
334 case 3: |
|
335 result = EVtUiCmdSwitchFromBTToIHF; |
|
336 break; |
|
337 case 4: |
|
338 case 5: |
|
339 result = EVtUiCmdActivateLoudspeaker; |
|
340 break; |
|
341 case 6: |
|
342 case 7: |
|
343 result = EVtUiCmdActivateBT; |
|
344 break; |
|
345 default: |
|
346 break; |
|
347 }; |
|
348 } |
|
349 break; |
|
350 |
|
351 case EVtUiCmdToolbarToggleCamera: |
|
352 { |
|
353 switch ( stateIndexValue ) |
|
354 { |
|
355 case 0: |
|
356 case 1: |
|
357 result = EVtUiCmdUsePrimaryCamera; |
|
358 break; |
|
359 case 2: |
|
360 case 3: |
|
361 result = EVtUiCmdUseSecondaryCamera; |
|
362 break; |
|
363 } |
|
364 } |
|
365 break; |
|
366 |
|
367 default: |
|
368 break; |
|
369 } |
|
370 |
|
371 if ( aCmdId == result ) |
|
372 { |
|
373 TInt index( stateIndexValue - 1 ); |
|
374 if ( index < 0 ) |
|
375 { |
|
376 index = tbButton->StatesCount() - 1; |
|
377 } |
|
378 tbButton->SetCurrentState( index, EFalse ); |
|
379 } |
|
380 |
|
381 __VTPRINTEXITR( "Toolbar.MapCmdIdToChilId.result %d", (TInt)result ) |
|
382 return result; |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CVtUiToolbarBase::MapCmdIdToParentId |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 TInt CVtUiToolbarBase::MapCmdIdToParentId( TInt aCmdId ) |
|
390 { |
|
391 __VTPRINTENTER( "Toolbar.MapCmdIdToParentId" ) |
|
392 TInt result = aCmdId; |
|
393 switch( aCmdId ) |
|
394 { |
|
395 case EVtUiCmdDisableVideo: |
|
396 case EVtUiCmdEnableVideo: |
|
397 result = EVtUiCmdToolbarToggleVideo; |
|
398 break; |
|
399 |
|
400 case EVtUiCmdDisableAudio: |
|
401 case EVtUiCmdEnableAudio: |
|
402 result = EVtUiCmdToolbarToggleMicrophone; |
|
403 break; |
|
404 |
|
405 case EVtUiCmdActivateBT: |
|
406 case EVtUiCmdSwitchFromBTToIHF: |
|
407 case EVtUiCmdActivateLoudspeaker: |
|
408 case EVtUiCmdDeactivateLoudspeaker: |
|
409 result = EVtUiCmdToolbarAudioRouting; |
|
410 break; |
|
411 |
|
412 case EVtUiCmdUsePrimaryCamera: |
|
413 case EVtUiCmdUseSecondaryCamera: |
|
414 result = EVtUiCmdToolbarToggleCamera; |
|
415 break; |
|
416 |
|
417 default: |
|
418 break; |
|
419 } |
|
420 __VTPRINTEXITR( "Toolbar.MapCmdIdToParentId.result %d", (TInt)result ) |
|
421 return result; |
|
422 } |
|
423 |
|
424 // ----------------------------------------------------------------------------- |
|
425 // CVtUiToolbarBase::IsCmdIdVisibleInToggleButton |
|
426 // ----------------------------------------------------------------------------- |
|
427 // |
|
428 TBool CVtUiToolbarBase::IsCmdIdVisibleInToggleButton( TInt aCmdId ) |
|
429 { |
|
430 __VTPRINTENTER( "Toolbar.IsCMdIdVisibleInTogB" ) |
|
431 TBool result( ETrue ); |
|
432 TInt cmdId( MapCmdIdToParentId( aCmdId ) ); |
|
433 TInt targetStateIndex( KErrNotFound ); |
|
434 switch( aCmdId ) |
|
435 { |
|
436 case EVtUiCmdActivateBT: |
|
437 targetStateIndex = 6; |
|
438 break; |
|
439 |
|
440 case EVtUiCmdActivateLoudspeaker: |
|
441 targetStateIndex = 4; |
|
442 break; |
|
443 |
|
444 case EVtUiCmdSwitchFromBTToIHF: |
|
445 case EVtUiCmdEnableVideo: |
|
446 case EVtUiCmdEnableAudio: |
|
447 case EVtUiCmdUseSecondaryCamera: |
|
448 targetStateIndex = 2; |
|
449 break; |
|
450 |
|
451 case EVtUiCmdDisableVideo: |
|
452 case EVtUiCmdDisableAudio: |
|
453 case EVtUiCmdUsePrimaryCamera: |
|
454 case EVtUiCmdDeactivateLoudspeaker: |
|
455 targetStateIndex = 0; |
|
456 break; |
|
457 |
|
458 default: |
|
459 break; |
|
460 } |
|
461 |
|
462 if ( targetStateIndex != KErrNotFound ) |
|
463 { |
|
464 result = ( FindToolbarItemByCommandId( cmdId ) |
|
465 ->StateIndex() == targetStateIndex ); |
|
466 } |
|
467 |
|
468 __VTPRINTEXITR( "Toolbar.IsCMdIdVisibleInTogB.result %d", (TInt)result ) |
|
469 return result; |
|
470 } |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CVtUiToolbarBase::PopulateCmdsIdsL |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 void CVtUiToolbarBase::PopulateCmdsIdsL() |
|
477 { |
|
478 __VTPRINTENTER( "Toolbar.PopulateCmdsIdsL" ) |
|
479 CVtUiAppUi& appUi = iFeatureManager.AppUi(); |
|
480 |
|
481 // default commands |
|
482 iCmdIds.AppendL( EVtUiCmdDisableVideo ); |
|
483 iCmdIds.AppendL( EVtUiCmdEnableVideo ); |
|
484 iCmdIds.AppendL( EVtUiCmdDisableAudio ); |
|
485 iCmdIds.AppendL( EVtUiCmdEnableAudio ); |
|
486 |
|
487 __VTPRINTEXIT( "Toolbar.PopulateCmdsIdsL" ) |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // CVtUiToolbarBase::SetToolbarVisibilityAfterLayoutChangeL |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 void CVtUiToolbarBase::SetToolbarVisibilityAfterLayoutChangeL( TBool /*aVisible*/ ) |
|
495 { |
|
496 __VTPRINTENTER( "Toolbar.SetToolbarVisibilityAfterLayoutChangeL" ) |
|
497 __VTPRINTEXIT( "Toolbar.SetToolbarVisibilityAfterLayoutChangeL" ) |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CVtUiToolbarBase::IsToggleButtonHidden |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 TBool CVtUiToolbarBase::IsToggleButtonHidden(TInt aFirstCmdId, TInt aSecondCmdId ) |
|
505 { |
|
506 __VTPRINTENTER( "Toolbar.IsToggleButtonHidden" ) |
|
507 TInt count = 0; |
|
508 TBool result = EFalse; |
|
509 for ( TInt i = 0; i < iCmdStates.Count(); i++ ) |
|
510 { |
|
511 if ( iCmdStates[ i ].iCmdId == aFirstCmdId || |
|
512 iCmdStates[ i ].iCmdId == aSecondCmdId ) |
|
513 { |
|
514 if ( iCmdStates[ i ].iNewState == EHidden ) |
|
515 { |
|
516 count++; |
|
517 } |
|
518 } |
|
519 } |
|
520 |
|
521 if ( count > 1 ) |
|
522 { |
|
523 __VTPRINT(DEBUG_GEN, "IsToggleButtonHidden.Count>1" ) |
|
524 result = ETrue; |
|
525 } |
|
526 __VTPRINTEXITR( "Toolbar.IsToggleButtonHidden.result%d", result ) |
|
527 return result; |
|
528 } |
|
529 |
|
530 // ----------------------------------------------------------------------------- |
|
531 // CVtUiToolbarBase::Clean |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 void CVtUiToolbarBase::Clean() |
|
535 { |
|
536 __VTPRINTENTER( "Toolbar.Clean" ) |
|
537 TRAP_IGNORE( CVtUiToolbarBase::DoDeactivateL() ); |
|
538 // unregister component change registration |
|
539 iFeatureManager.ComponentManager().ChangeComponentRegistration( |
|
540 iComponentState, MVtUiComponentManager::EUnregister ); |
|
541 __VTPRINTEXIT( "Toolbar.Clean" ) |
|
542 } |
|
543 |
|
544 // ----------------------------------------------------------------------------- |
|
545 // CVtUiToolbarBase::CreateToolbarButtons |
|
546 // ----------------------------------------------------------------------------- |
|
547 // |
|
548 |
|
549 void CVtUiToolbarBase::CreateToolbarButtonsL() |
|
550 { |
|
551 __VTPRINTENTER( "Toolbar.CreateToolbarButtons" ) |
|
552 CVtUiAppUi& appUi = iFeatureManager.AppUi(); |
|
553 |
|
554 // two default buttons |
|
555 // toggle video |
|
556 CreateToolbarItemL( R_AVKONBUTTON_TOGGLE_VIDEO_BUTTON, |
|
557 EVtUiCmdToolbarToggleVideo, appUi ); |
|
558 |
|
559 // toggle microphone |
|
560 CreateToolbarItemL( R_AVKONBUTTON_TOGGLE_MICROPHONE_BUTTON, |
|
561 EVtUiCmdToolbarToggleMicrophone, appUi ); |
|
562 |
|
563 __VTPRINTEXIT( "Toolbar.CreateToolbarButtons" ) |
|
564 } |
|
565 |
|
566 // ----------------------------------------------------------------------------- |
|
567 // CVtUiToolbarBase::CreateToolbarItemL |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 void CVtUiToolbarBase::CreateToolbarItemL( TInt aResourceId, TInt aCommandId, |
|
571 CVtUiAppUi& appUi ) |
|
572 { |
|
573 __VTPRINTENTER( "Toolbar.CreateToolbarItemL" ) |
|
574 |
|
575 CVtUiToolbarButton* toolbarItem = NULL; |
|
576 TLinearOrder< CVtUiToolbarButton > linOrder( ::ToolbarCmpFunc ); |
|
577 |
|
578 // create toolbaritem |
|
579 toolbarItem = CVtUiToolbarButton::NewLC( aResourceId, appUi, aCommandId ); |
|
580 |
|
581 // add toolbar item to toolbar |
|
582 // CVtUiToolbarButton ownership is transferred to akntoolbar |
|
583 iToolbar->AddItemL( toolbarItem, EAknCtButton, |
|
584 aCommandId , NULL ); |
|
585 |
|
586 // add toolbar item to array |
|
587 iToolBarControls.InsertInOrderL( toolbarItem, linOrder ); |
|
588 |
|
589 CleanupStack::Pop(); // toolbaritem |
|
590 |
|
591 __VTPRINTEXIT( "Toolbar.CreateToolbarItemL" ) |
|
592 } |
|
593 |
|
594 |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // CVtUiToolbarBase::HideToolbarButton |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 void CVtUiToolbarBase::HideToolbarButton( const TInt aCommandId, const TBool aHide, |
|
601 const TBool aDrawNow ) |
|
602 { |
|
603 __VTPRINTENTER( "Toolbar.HideToolbarButton" ) |
|
604 __VTPRINT2( DEBUG_GEN, "Toolbar.HideToolbarButton.aCommandId=%d", aCommandId ) |
|
605 TInt cmdId = MapCmdIdToParentId( aCommandId ); |
|
606 |
|
607 // unhide for toggle buttons not handled |
|
608 if ( !aHide && cmdId != aCommandId ) |
|
609 { |
|
610 return; |
|
611 } |
|
612 |
|
613 // Get toolbar item |
|
614 CVtUiToolbarButton* tbItem = FindToolbarItemByCommandId( cmdId ); |
|
615 |
|
616 // get button's current state |
|
617 TInt stateIndex = tbItem->StateIndex(); |
|
618 |
|
619 switch ( cmdId ) |
|
620 { |
|
621 case EVtUiCmdToolbarToggleVideo: |
|
622 // if both items should be hidden in togglebutton, |
|
623 // then dim togglebutton |
|
624 if ( IsToggleButtonHidden( EVtUiCmdDisableVideo, |
|
625 EVtUiCmdEnableVideo ) ) |
|
626 { |
|
627 // update visibility state |
|
628 TRAP_IGNORE( |
|
629 SetCmdIdVisibilityStateL( EVtUiCmdDisableVideo, EDimmed ); |
|
630 SetCmdIdVisibilityStateL( EVtUiCmdEnableVideo, EDimmed ); |
|
631 ); |
|
632 iToolbar->SetItemDimmed( cmdId, ETrue, EFalse ); |
|
633 return; |
|
634 } |
|
635 if ( ( stateIndex == 0 || stateIndex == 1 ) && |
|
636 EVtUiCmdDisableVideo == aCommandId ) |
|
637 { |
|
638 tbItem->SetCurrentState ( 2, EFalse ); |
|
639 } |
|
640 else if( ( stateIndex == 2 || stateIndex == 3 )&& |
|
641 EVtUiCmdEnableVideo == aCommandId ) |
|
642 { |
|
643 tbItem->SetCurrentState ( 0, EFalse ); |
|
644 } |
|
645 break; |
|
646 |
|
647 case EVtUiCmdToolbarToggleMicrophone: |
|
648 // if both items should be hidden in togglebutton, |
|
649 // then dim togglebutton |
|
650 if ( IsToggleButtonHidden( EVtUiCmdDisableAudio, |
|
651 EVtUiCmdEnableAudio ) ) |
|
652 { |
|
653 // update visibility state |
|
654 TRAP_IGNORE( |
|
655 SetCmdIdVisibilityStateL( EVtUiCmdDisableAudio, EDimmed ); |
|
656 SetCmdIdVisibilityStateL( EVtUiCmdEnableAudio, EDimmed ); |
|
657 ); |
|
658 iToolbar->SetItemDimmed( cmdId, ETrue, EFalse ); |
|
659 return; |
|
660 } |
|
661 if ( ( stateIndex == 0 || stateIndex == 1 ) && |
|
662 EVtUiCmdDisableAudio == aCommandId ) |
|
663 { |
|
664 tbItem->SetCurrentState ( 2, EFalse ); |
|
665 } |
|
666 else if( ( stateIndex == 2 || stateIndex == 3 ) && |
|
667 EVtUiCmdEnableAudio == aCommandId ) |
|
668 { |
|
669 tbItem->SetCurrentState ( 0, EFalse ); |
|
670 } |
|
671 break; |
|
672 |
|
673 case EVtUiCmdToolbarAudioRouting: |
|
674 { |
|
675 const TBool isToggleButtonHidden( |
|
676 IsToggleButtonHidden( EVtUiCmdActivateBT, |
|
677 EVtUiCmdSwitchFromBTToIHF ) && |
|
678 IsToggleButtonHidden( EVtUiCmdActivateLoudspeaker, |
|
679 EVtUiCmdDeactivateLoudspeaker ) |
|
680 ); |
|
681 |
|
682 if ( isToggleButtonHidden ) |
|
683 { |
|
684 TRAP_IGNORE( |
|
685 SetCmdIdVisibilityStateL( EVtUiCmdActivateBT, EDimmed ); |
|
686 SetCmdIdVisibilityStateL( EVtUiCmdDeactivateLoudspeaker, |
|
687 EDimmed ); |
|
688 SetCmdIdVisibilityStateL( EVtUiCmdSwitchFromBTToIHF, EDimmed ); |
|
689 SetCmdIdVisibilityStateL( EVtUiCmdActivateLoudspeaker, |
|
690 EDimmed ); |
|
691 ); |
|
692 iToolbar->SetItemDimmed( cmdId, ETrue, EFalse ); |
|
693 return; |
|
694 } |
|
695 else |
|
696 { |
|
697 if ( tbItem ) |
|
698 { |
|
699 const TVtUiAudioState& audioState( |
|
700 iFeatureManager.UiStates().AudioState() ); |
|
701 |
|
702 TInt state( 0 ); // Deactivate loudspeaker |
|
703 |
|
704 if ( audioState.CanDeactivateBtHf() ) |
|
705 { |
|
706 state = 2; // Deactivate bthf |
|
707 } |
|
708 else if ( audioState.CanActivateBtHf() ) |
|
709 { |
|
710 state = 6; // Activate bthf |
|
711 } |
|
712 else if ( audioState.CanActivateLoudspeaker() ) |
|
713 { |
|
714 state = 4; // Activate loudspeaker |
|
715 } |
|
716 __VTPRINT2( DEBUG_GEN, |
|
717 "Toolbar.HideToolbarButton.AudioRoutingState=%d", |
|
718 state ) |
|
719 tbItem->SetCurrentState ( state, EFalse ); |
|
720 } |
|
721 } |
|
722 } |
|
723 break; |
|
724 |
|
725 case EVtUiCmdToolbarToggleCamera: |
|
726 // if both items should be hidden in togglebutton, |
|
727 // then dim togglebutton |
|
728 if ( IsToggleButtonHidden( EVtUiCmdUsePrimaryCamera, |
|
729 EVtUiCmdUseSecondaryCamera ) ) |
|
730 { |
|
731 // update visibility state |
|
732 TRAP_IGNORE( |
|
733 SetCmdIdVisibilityStateL( EVtUiCmdUsePrimaryCamera, EDimmed ); |
|
734 SetCmdIdVisibilityStateL( EVtUiCmdUseSecondaryCamera, EDimmed ); |
|
735 ); |
|
736 iToolbar->SetItemDimmed( cmdId, ETrue, EFalse ); |
|
737 return; |
|
738 } |
|
739 if ( ( stateIndex == 0 || stateIndex == 1 ) && |
|
740 EVtUiCmdUsePrimaryCamera == aCommandId ) |
|
741 { |
|
742 tbItem->SetCurrentState ( 2, EFalse ); |
|
743 } |
|
744 else if( ( stateIndex == 2 || stateIndex == 3 ) && |
|
745 EVtUiCmdUseSecondaryCamera == aCommandId ) |
|
746 { |
|
747 tbItem->SetCurrentState ( 0, EFalse ); |
|
748 } |
|
749 break; |
|
750 |
|
751 default: |
|
752 iToolbar->HideItem( cmdId, aHide, aDrawNow); |
|
753 __VTPRINT( DEBUG_GEN, "Toolbar.HideToolbarButton" ) |
|
754 break; |
|
755 } |
|
756 __VTPRINTEXIT( "Toolbar.HideToolbarButton" ) |
|
757 } |
|
758 |
|
759 // ----------------------------------------------------------------------------- |
|
760 // CVtUiToolbarBase::DimToolbar |
|
761 // ----------------------------------------------------------------------------- |
|
762 // |
|
763 void CVtUiToolbarBase::DimToolbar( const TBool aDimmed, const TBool aDrawNow ) |
|
764 { |
|
765 __VTPRINTENTER( "Toolbar.DimToolbar" ) |
|
766 __VTPRINT2( DEBUG_GEN, "Toolbar.DimToolbar.aDimmed=%d", (TInt)aDimmed ) |
|
767 |
|
768 TInt count = iCmdStates.Count(); |
|
769 for( TInt i = 0; i < count; i++ ) |
|
770 { |
|
771 __VTPRINT2( DEBUG_GEN, "iCmdId = %d", iCmdStates[ i ].iCmdId ) |
|
772 __VTPRINT3( DEBUG_GEN, "iCmdStates.iOldState=%d iCmdStates.iNewState=%d", |
|
773 iCmdStates[ i ].iOldState, iCmdStates[ i ].iNewState ) |
|
774 // dim item |
|
775 if ( iCmdStates[ i ].iNewState == EShown ) |
|
776 { |
|
777 DimToolbarButton( iCmdStates[ i ].iCmdId, aDimmed, aDrawNow ); |
|
778 } |
|
779 } |
|
780 __VTPRINTEXIT( "Toolbar.DimToolbar" ) |
|
781 } |
|
782 |
|
783 // ----------------------------------------------------------------------------- |
|
784 // CVtUiToolbarBase::DimToolbarButton |
|
785 // ----------------------------------------------------------------------------- |
|
786 // |
|
787 void CVtUiToolbarBase::DimToolbarButton( const TInt aCommandId, const TBool aDimmed, |
|
788 const TBool aDrawNow ) |
|
789 { |
|
790 __VTPRINTENTER( "Toolbar.DimToolbarButton" ) |
|
791 __VTPRINT2( DEBUG_GEN, "Toolbar.DimToolbarButton.aCmdId=%d", aCommandId ) |
|
792 |
|
793 // command not visible, no need to update button |
|
794 if ( !IsCmdIdVisibleInToggleButton( aCommandId ) ) |
|
795 { |
|
796 __VTPRINTEXIT("Toolbar.DimToolbarButton.NotVisible" ) |
|
797 return; |
|
798 } |
|
799 TInt cmdId = MapCmdIdToParentId( aCommandId ); |
|
800 // dim item |
|
801 iToolbar->SetItemDimmed( cmdId, aDimmed, aDrawNow ); |
|
802 __VTPRINTEXIT( "Toolbar.DimToolbarButton" ) |
|
803 } |
|
804 |
|
805 // ----------------------------------------------------------------------------- |
|
806 // CVtUiToolbarBase::FindToolbaItemByCommandId |
|
807 // ----------------------------------------------------------------------------- |
|
808 // |
|
809 CVtUiToolbarButton* CVtUiToolbarBase::FindToolbarItemByCommandId |
|
810 ( const TInt aCommandId ) |
|
811 { |
|
812 __VTPRINTENTER( "Toolbar.FindToolbarItemByCmdId" ) |
|
813 CVtUiToolbarButton* result = NULL; |
|
814 |
|
815 TInt index( iToolBarControls. |
|
816 FindInOrder( aCommandId,::ToolbarItemIdCmpFunc ) ); |
|
817 |
|
818 if ( index != KErrNotFound ) |
|
819 { |
|
820 result = iToolBarControls[ index ]; |
|
821 } |
|
822 __VTPRINTEXITR( "Toolbar.FindToolbarItemByCmdId.result %d", (TInt)result ) |
|
823 return result; |
|
824 } |
|
825 |
|
826 // ----------------------------------------------------------------------------- |
|
827 // CVtUiToolbarBase::StartBlocking |
|
828 // ----------------------------------------------------------------------------- |
|
829 // |
|
830 void CVtUiToolbarBase::BlockPointerEvents( TBool aIsBlocking ) |
|
831 { |
|
832 __VTPRINTENTER( "Toolbar.BlockPointerEvents" ) |
|
833 for (TInt i = 0; i < iToolBarControls.Count(); ++i ) |
|
834 { |
|
835 iToolBarControls[ i ]->BlockPointerEvents( aIsBlocking ); |
|
836 } |
|
837 __VTPRINTEXITR( "Toolbar.BlockPointerEvents =%d", aIsBlocking ) |
|
838 } |
|
839 |
|
840 // ----------------------------------------------------------------------------- |
|
841 // CVtUiToolbarBase::StopBlocking |
|
842 // ----------------------------------------------------------------------------- |
|
843 // |
|
844 void CVtUiToolbarBase::BlockKeyEvents( TBool aIsBlocking ) |
|
845 { |
|
846 __VTPRINTENTER( "Toolbar.BlockKeyEvents" ) |
|
847 for ( TInt i = 0; i < iToolBarControls.Count(); ++i ) |
|
848 { |
|
849 iToolBarControls[ i ]->BlockKeyEvents( aIsBlocking ); |
|
850 } |
|
851 __VTPRINTEXITR( "Toolbar.BlockKeyEvents =%d", aIsBlocking ) |
|
852 } |
|
853 |
|
854 // ----------------------------------------------------------------------------- |
|
855 // CVtUiToolbarBase::IsDialerActive |
|
856 // ----------------------------------------------------------------------------- |
|
857 // |
|
858 TBool CVtUiToolbarBase::IsDialerActive() const |
|
859 { |
|
860 __VTPRINTENTER( "Toolbar.IsDialerActive" ) |
|
861 TBool ret( EFalse ); |
|
862 MVtUiFeature* dialer = iFeatureManager. |
|
863 GetFeatureById( EVtUiFeatureIdDialer ); |
|
864 if ( dialer ) |
|
865 { |
|
866 if ( dialer->State() == MVtUiFeature::EActive ) |
|
867 { |
|
868 ret = ETrue; |
|
869 } |
|
870 } |
|
871 __VTPRINTEXITR( "Toolbar.IsDialerActive =%d", ret ) |
|
872 return ret; |
|
873 } |
|
874 |
|
875 // ----------------------------------------------------------------------------- |
|
876 // CVtUiToolbarBase::NumberOfToolbarControls |
|
877 // ----------------------------------------------------------------------------- |
|
878 // |
|
879 TInt CVtUiToolbarBase::NumberOfToolbarControls() const |
|
880 { |
|
881 __VTPRINTENTER( "Toolbar.NumberOfToolbarControls" ) |
|
882 __VTPRINTEXIT( "Toolbar.NumberOfToolbarControls" ) |
|
883 return iCmdIds.Count(); |
|
884 } |
|
885 |
|
886 |
|
887 // ----------------------------------------------------------------------------- |
|
888 // CVtUiToolbarBase::CommandIdByCmdIdsArrayIndex |
|
889 // ----------------------------------------------------------------------------- |
|
890 // |
|
891 TInt CVtUiToolbarBase::CommandIdByCmdIdsArrayIndex( TInt aIndex ) const |
|
892 { |
|
893 __VTPRINTENTER( "Toolbar.CommandIdByCmdIdsArrayIndex" ) |
|
894 __VTPRINTEXIT( "Toolbar.CommandIdByCmdIdsArrayIndex.cmdId" ) |
|
895 return iCmdIds[aIndex]; |
|
896 } |
|
897 |
|
898 // ----------------------------------------------------------------------------- |
|
899 // CVtUiToolbarBase::UpdateToolbar |
|
900 // ----------------------------------------------------------------------------- |
|
901 // |
|
902 void CVtUiToolbarBase::UpdateToolbarL() |
|
903 { |
|
904 __VTPRINTENTER( "Toolbar.UpdateToolbar" ) |
|
905 TVtUiStates& uiStates = iFeatureManager.UiStates(); |
|
906 |
|
907 // Zoom mode can be activated also from options menu |
|
908 // therefore set zoom buttons state to latched |
|
909 if ( uiStates.IsZoomModeOn() && |
|
910 IsCommandInToolbar( EVtUiCmdZoom )&& |
|
911 FindToolbarItemByCommandId( EVtUiCmdZoom ) |
|
912 ->StateIndex() == 0 ) |
|
913 { |
|
914 FindToolbarItemByCommandId( EVtUiCmdZoom ) |
|
915 ->SetCurrentState ( 1, ETrue ); |
|
916 } |
|
917 |
|
918 |
|
919 if ( uiStates.IsCaptureModeOn() && IsCommandInToolbar( EVtUiCmdZoom ) ) |
|
920 { |
|
921 __VTPRINT( DEBUG_GEN, "Toolbar.UpdateToolbarL.IsCaptureModeOn" ) |
|
922 // remove zoom mode button tooltip |
|
923 FindToolbarItemByCommandId( EVtUiCmdZoom ) |
|
924 ->State( 0 )->SetHelpTextL( KNullDesC() ); |
|
925 // set zoom mode button to be focused |
|
926 iToolbar->SetFocusedItemL( EVtUiCmdZoom ); |
|
927 } |
|
928 |
|
929 TInt count = iCmdStates.Count(); |
|
930 for( TInt i = 0; i < count; i++ ) |
|
931 { |
|
932 // no need to do anything |
|
933 if ( iCmdStates[ i ].iOldState == iCmdStates[ i ].iNewState ) |
|
934 { |
|
935 if ( ( iCmdStates[ i ].iCmdId == EVtUiCmdDisableVideo || |
|
936 iCmdStates[ i ].iCmdId == EVtUiCmdEnableVideo ) && |
|
937 iCmdStates[ i ].iNewState != EShown && |
|
938 !( iFeatureManager.UiStates().MediaState().IsSharing() ) ) |
|
939 { |
|
940 CVtUiToolbarButton* tbButton = static_cast< CVtUiToolbarButton* >( |
|
941 FindToolbarItemByCommandId( EVtUiCmdToolbarToggleVideo ) ); |
|
942 tbButton->SetCurrentState( |
|
943 iFeatureManager.UiStates().MediaState().IsVideo() ? 0 : 2 , ETrue ); |
|
944 } |
|
945 // for the case that EVtUiCmdDisableVideo and |
|
946 // EVtUiCmdActivateBT command |
|
947 // need to be shown but it is not visible in |
|
948 // toogle button. |
|
949 if ( ( iCmdStates[ i ].iCmdId == EVtUiCmdSwitchFromBTToIHF || |
|
950 iCmdStates[ i ].iCmdId == EVtUiCmdActivateBT || |
|
951 iCmdStates[ i ].iCmdId == EVtUiCmdActivateLoudspeaker || |
|
952 iCmdStates[ i ].iCmdId == EVtUiCmdDeactivateLoudspeaker || |
|
953 iCmdStates[ i ].iCmdId == EVtUiCmdDisableAudio || |
|
954 iCmdStates[ i ].iCmdId == EVtUiCmdEnableAudio || |
|
955 iCmdStates[ i ].iCmdId == EVtUiCmdDisableVideo || |
|
956 iCmdStates[ i ].iCmdId == EVtUiCmdEnableVideo) && |
|
957 iCmdStates[ i ].iNewState == EShown ) |
|
958 { |
|
959 // Nothing goes here. |
|
960 } |
|
961 else |
|
962 { |
|
963 continue; |
|
964 } |
|
965 } |
|
966 // dim item |
|
967 if ( iCmdStates[ i ].iNewState == EDimmed ) |
|
968 { |
|
969 DimToolbarButton( iCmdStates[ i ].iCmdId, ETrue, EFalse ); |
|
970 } |
|
971 // hide item |
|
972 // currently used only for toggle buttons |
|
973 // otherwise EDrawNow parameter must be updated for last element |
|
974 else if ( iCmdStates[ i ].iNewState == EHidden ) |
|
975 { |
|
976 HideToolbarButton( iCmdStates[ i ].iCmdId, ETrue, EFalse ); |
|
977 } |
|
978 // show item |
|
979 else if ( iCmdStates[ i ].iNewState == EShown ) |
|
980 { |
|
981 // items are undimmed if they were dimmed |
|
982 // iCmdStates[ i ].iOldState == EDimmed comparison does |
|
983 // not work with toggle buttons. |
|
984 // That is why all buttons are undimmed. |
|
985 DimToolbarButton( iCmdStates[ i ].iCmdId, EFalse, EFalse ); |
|
986 |
|
987 HideToolbarButton( iCmdStates[ i ].iCmdId, EFalse, EFalse ); |
|
988 } |
|
989 } |
|
990 |
|
991 // capture mode ended remove zoom button's latched state |
|
992 if ( !uiStates.IsZoomModeOn() && |
|
993 IsCommandInToolbar( EVtUiCmdZoom )&& |
|
994 FindToolbarItemByCommandId( EVtUiCmdZoom )->StateIndex() == 1 ) |
|
995 { |
|
996 FindToolbarItemByCommandId( EVtUiCmdZoom ) |
|
997 ->SetCurrentState ( 0, ETrue ); |
|
998 } |
|
999 |
|
1000 // if capture mode was activated set zoom mode button active |
|
1001 if ( uiStates.IsCaptureModeOn() && IsCommandInToolbar( EVtUiCmdZoom ) ) |
|
1002 { |
|
1003 // set latched (selected) state |
|
1004 FindToolbarItemByCommandId( EVtUiCmdZoom ) |
|
1005 ->SetCurrentState ( 1, ETrue); |
|
1006 } |
|
1007 else |
|
1008 { |
|
1009 // tooltip must be returned to zoom mode button |
|
1010 // only after zoom mode buttons latched state is changed |
|
1011 // because changing the buttons state will draw the tooltip |
|
1012 if ( IsCommandInToolbar( EVtUiCmdZoom ) && |
|
1013 ( KNullDesC() == ( FindToolbarItemByCommandId( EVtUiCmdZoom ) |
|
1014 ->State(0)->HelpText() ) ) ) |
|
1015 { |
|
1016 HBufC* tooltip = StringLoader::LoadLC( R_VIDEOTELUI_TOOLTIP_ZOOM ); |
|
1017 FindToolbarItemByCommandId( EVtUiCmdZoom ) |
|
1018 ->State(0)->SetHelpTextL( *tooltip ); |
|
1019 CleanupStack::PopAndDestroy( ); // tooltip |
|
1020 } |
|
1021 } |
|
1022 |
|
1023 // draw toolbar |
|
1024 //iToolbar->DrawDeferred(); |
|
1025 iToolbar->DrawNow(); |
|
1026 __VTPRINTEXIT( "Toolbar.UpdateToolbar" ) |
|
1027 } |
|
1028 |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // CVtUiToolbarBase::SetCmdIdVisibilityStateL |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // |
|
1033 void CVtUiToolbarBase::SetCmdIdVisibilityStateL( TInt aCmdId, |
|
1034 TCmdStateFlags aNewState ) |
|
1035 { |
|
1036 __VTPRINTENTER( "Toolbar.SetCmdIdVisibilityStateL" ) |
|
1037 __VTPRINT2( DEBUG_GEN, "Toolbar.SetCmdIdVbStateL.aCmdId=%d", aCmdId ) |
|
1038 __VTPRINT2( DEBUG_GEN, "Toolbar.SetCmdIdVbStateL.aNewState=%d", aNewState ) |
|
1039 |
|
1040 TInt result = KErrNotFound; |
|
1041 for ( TInt i = 0; i < iCmdStates.Count(); i++ ) |
|
1042 { |
|
1043 if ( iCmdStates[ i ].iCmdId == aCmdId ) |
|
1044 { |
|
1045 // command found |
|
1046 result = i; |
|
1047 break; |
|
1048 } |
|
1049 } |
|
1050 // new item |
|
1051 // add to array |
|
1052 if( result == KErrNotFound ) |
|
1053 { |
|
1054 TCommandState state; |
|
1055 state.iCmdId = aCmdId; |
|
1056 state.iOldState = ENotInitialized; |
|
1057 state.iNewState = aNewState; |
|
1058 iCmdStates.AppendL( state ); |
|
1059 } |
|
1060 else // old item |
|
1061 { |
|
1062 iCmdStates[ result ].iOldState = iCmdStates[ result ].iNewState; |
|
1063 iCmdStates[ result ].iNewState = aNewState; |
|
1064 } |
|
1065 |
|
1066 __VTPRINTEXIT( "Toolbar.SetCmdIdVbStateL" ) |
|
1067 } |
|
1068 |
|
1069 // ----------------------------------------------------------------------------- |
|
1070 // CVtUiToolbarBase::IsCommandInToolbar |
|
1071 // ----------------------------------------------------------------------------- |
|
1072 // |
|
1073 TBool CVtUiToolbarBase::IsCommandInToolbar( TInt aCmdId ) const |
|
1074 { |
|
1075 __VTPRINTENTER( "Toolbar.SetCmdIdVisibilityStateL" ) |
|
1076 TBool result = EFalse; |
|
1077 for ( TInt i = 0; i < iCmdIds.Count(); i++ ) |
|
1078 { |
|
1079 if ( iCmdIds[ i ] == aCmdId ) |
|
1080 { |
|
1081 result = ETrue; |
|
1082 break; |
|
1083 } |
|
1084 } |
|
1085 __VTPRINTEXITR( "Toolbar.IsCommandInToolbar.result %d", (TInt)result ) |
|
1086 return result; |
|
1087 } |
|
1088 |
|
1089 // ----------------------------------------------------------------------------- |
|
1090 // CVtUiToolbarBase::RefreshL |
|
1091 // ----------------------------------------------------------------------------- |
|
1092 // |
|
1093 void CVtUiToolbarBase::RefreshL() |
|
1094 { |
|
1095 __VTPRINTENTER( "Toolbar.RefreshL" ) |
|
1096 iFeatureManager.CommandManager(). |
|
1097 ValidateToolbarItemsL( *iHideToolbarItemAction ); |
|
1098 __VTPRINTEXIT( "Toolbar.RefreshL" ) |
|
1099 } |
|
1100 |
|
1101 // ----------------------------------------------------------------------------- |
|
1102 // CVtUiToolbarBase::AddCommandModifier |
|
1103 // ----------------------------------------------------------------------------- |
|
1104 // |
|
1105 TInt CVtUiToolbarBase::AddCommandModifier( CVtUiCommandModifyBase& /*aModifier*/ ) |
|
1106 { |
|
1107 __VTPRINTENTER( "Toolbar.AddCommandModifier" ) |
|
1108 __VTPRINTEXIT( "Toolbar.AddCommandModifier" ) |
|
1109 return KErrNone; |
|
1110 } |
|
1111 |
|
1112 // ----------------------------------------------------------------------------- |
|
1113 // CVtUiToolbarBase::RemoveCommandModifier |
|
1114 // ----------------------------------------------------------------------------- |
|
1115 // |
|
1116 void CVtUiToolbarBase::RemoveCommandModifier( CVtUiCommandModifyBase& /*aModifier*/ ) |
|
1117 { |
|
1118 __VTPRINTENTER( "Toolbar.RemoveCommandModifier" ) |
|
1119 __VTPRINTEXIT( "Toolbar.RemoveCommandModifier" ) |
|
1120 } |
|
1121 |
|
1122 // ----------------------------------------------------------------------------- |
|
1123 // CVtUiToolbarBase::ComponentId |
|
1124 // ----------------------------------------------------------------------------- |
|
1125 // |
|
1126 MVtUiComponent::TComponentId CVtUiToolbarBase::ComponentId() const |
|
1127 { |
|
1128 __VTPRINTENTER( "Toolbar.ComponentId" ) |
|
1129 __VTPRINTEXIT( "Toolbar.ComponentId" ) |
|
1130 return MVtUiComponent::EComponentIdToolbar; |
|
1131 } |
|
1132 |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // CVtUiToolbarBase::ComponentAsControl |
|
1135 // ----------------------------------------------------------------------------- |
|
1136 // |
|
1137 CCoeControl* CVtUiToolbarBase::ComponentAsControl() |
|
1138 { |
|
1139 __VTPRINTENTER( "Toolbar.ComponentAsControl" ) |
|
1140 __VTPRINTEXIT( "Toolbar.ComponentAsControl" ) |
|
1141 return NULL; |
|
1142 } |
|
1143 |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // CVtUiToolbarBase::DoActivateL |
|
1146 // ----------------------------------------------------------------------------- |
|
1147 // |
|
1148 void CVtUiToolbarBase::DoActivateL() |
|
1149 { |
|
1150 __VTPRINTENTER( "Toolbar.DoActivateL" ) |
|
1151 // add command ui to commandmanager |
|
1152 User::LeaveIfError( |
|
1153 iFeatureManager.CommandManager().AddCommandUi( *this ) ); |
|
1154 // add command modifier |
|
1155 User::LeaveIfError( iFeatureManager. |
|
1156 CommandManager().AddCommandModifier( *iToolbarSKModifier ) ); |
|
1157 // add validator |
|
1158 User::LeaveIfError( iFeatureManager.CommandManager(). |
|
1159 AddValidator( *iToolbarCmdPolicy ) ); |
|
1160 // refresh |
|
1161 iFeatureManager.CommandManager().RefreshL(); |
|
1162 __VTPRINTEXIT( "Toolbar.DoActivateL" ) |
|
1163 } |
|
1164 |
|
1165 |
|
1166 // ----------------------------------------------------------------------------- |
|
1167 // CVtUiToolbarBase::DoDeactivateL |
|
1168 // ----------------------------------------------------------------------------- |
|
1169 // |
|
1170 void CVtUiToolbarBase::DoDeactivateL() |
|
1171 { |
|
1172 __VTPRINTENTER( "Toolbar.DoDeactivateL" ) |
|
1173 // remove command modifier |
|
1174 iFeatureManager.CommandManager(). |
|
1175 RemoveCommandModifier( *iToolbarSKModifier ); |
|
1176 // remove command validator |
|
1177 iFeatureManager.CommandManager().RemoveValidator( *iToolbarCmdPolicy ); |
|
1178 // remove commandui |
|
1179 iFeatureManager.CommandManager().RemoveCommandUi( *this ); |
|
1180 if ( iToolbar ) |
|
1181 { |
|
1182 __VTPRINT(DEBUG_GEN, "Toolbar.DoDeactivateL, iToolbar is not null" ) |
|
1183 iToolbar->DrawNow(); |
|
1184 } |
|
1185 __VTPRINTEXIT( "Toolbar.DoDeactivateL" ) |
|
1186 } |
|
1187 |
|
1188 // --------------------------------------------------------------------------- |
|
1189 // CVtUiToolbarBase::HandleLayoutChangeL |
|
1190 // --------------------------------------------------------------------------- |
|
1191 // |
|
1192 void CVtUiToolbarBase::HandleLayoutChangeL() |
|
1193 { |
|
1194 __VTPRINTENTER( "CVtUiToolbarBase.HandleLayoutChangeL" ) |
|
1195 TBool isLandscape = Layout_Meta_Data::IsLandscapeOrientation(); |
|
1196 CEikMenuBar* menuBar = CEikonEnv::Static()->AppUiFactory()->MenuBar(); |
|
1197 |
|
1198 // This check prevents toolbar from drawing over the dialer |
|
1199 // when orientation is changed from landscape to portrait |
|
1200 |
|
1201 // Transition from landsacpe to portrait |
|
1202 // toolbar must be hided |
|
1203 if ( !isLandscape && IsDialerActive() ) |
|
1204 { |
|
1205 __VTPRINT( DEBUG_GEN, "ToolbarBase::HandleLayoutChangeL DialerActive." ) |
|
1206 SetToolbarVisibilityAfterLayoutChangeL( EFalse ); |
|
1207 } |
|
1208 else if ( !isLandscape && iFeatureManager.UiStates().IsCaptureModeOn() ) |
|
1209 { |
|
1210 __VTPRINT( DEBUG_GEN, "ToolbarBase::HandleLayoutChangeL CaptureOn." ) |
|
1211 SetToolbarVisibilityAfterLayoutChangeL( EFalse ); |
|
1212 } |
|
1213 else if ( iFeatureManager.UiStates().IsSelectingShare() ) |
|
1214 { |
|
1215 __VTPRINT( DEBUG_GEN, "ToolbarBase::HandleLayoutChangeL ShareImage." ) |
|
1216 SetToolbarVisibilityAfterLayoutChangeL( EFalse ); |
|
1217 } |
|
1218 else if ( !isLandscape && iFeatureManager.UiStates().IsVideoQualityModeOn() ) |
|
1219 { |
|
1220 __VTPRINT( DEBUG_GEN, "ToolbarBase::HandleLayoutChangeL Video Quality." ) |
|
1221 SetToolbarVisibilityAfterLayoutChangeL( EFalse ); |
|
1222 } |
|
1223 else if ( !isLandscape && iFeatureManager.UiStates().IsWhiteBalanceModeOn() ) |
|
1224 { |
|
1225 __VTPRINT( DEBUG_GEN, "ToolbarBase::HandleLayoutChangeL White Balance." ) |
|
1226 SetToolbarVisibilityAfterLayoutChangeL( EFalse ); |
|
1227 } |
|
1228 else if ( !isLandscape && iFeatureManager.UiStates().IsColorToneModeOn() ) |
|
1229 { |
|
1230 __VTPRINT( DEBUG_GEN, "ToolbarBase::HandleLayoutChangeL Color Tone." ) |
|
1231 SetToolbarVisibilityAfterLayoutChangeL( EFalse ); |
|
1232 } |
|
1233 else if ( !isLandscape && iFeatureManager.UiStates().IsVolumeModeOn() ) |
|
1234 { |
|
1235 SetToolbarVisibilityAfterLayoutChangeL( EFalse ); |
|
1236 } |
|
1237 else if ( !isLandscape && menuBar && menuBar->IsDisplayed() ) |
|
1238 { |
|
1239 __VTPRINT( DEBUG_GEN, "ToolbarBase::HandleLayoutChangeL Menu Displayed." ) |
|
1240 SetToolbarVisibilityAfterLayoutChangeL( EFalse ); |
|
1241 } |
|
1242 // Transition from portrait to landsacpe |
|
1243 // toolbar must be set to visible |
|
1244 else if ( isLandscape && ( |
|
1245 IsDialerActive() || |
|
1246 iFeatureManager.UiStates().IsCaptureModeOn() || |
|
1247 iFeatureManager.UiStates().IsVideoQualityModeOn() || |
|
1248 iFeatureManager.UiStates().IsWhiteBalanceModeOn() || |
|
1249 iFeatureManager.UiStates().IsColorToneModeOn() || |
|
1250 iFeatureManager.UiStates().IsVolumeModeOn() || |
|
1251 menuBar && menuBar->IsDisplayed() ) ) |
|
1252 { |
|
1253 __VTPRINT(DEBUG_GEN, "CVtUiToolbarBase.LayoutChangeL.StartL" ) |
|
1254 SetToolbarVisibilityAfterLayoutChangeL( ETrue ); |
|
1255 } |
|
1256 __VTPRINTEXIT( "CVtUiToolbarBase.HandleLayoutChangeL" ) |
|
1257 } |
|
1258 |
|
1259 // End of File |
|
1260 |
|