vtuis/videotelui/src/features/toolbar/cvtuifixedtoolbar.cpp
changeset 0 ed9695c8bcbe
child 12 3e521e99f813
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     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:  Fixed toolbar UI feature implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include    "cvtuifixedtoolbar.h"
       
    22 #include    "cvtuifeaturemanager.h"
       
    23 #include    "mvtuicomponentmanager.h"
       
    24 #include    "mvtuicommandmanager.h"
       
    25 #include    "videotelui.hrh"
       
    26 #include    "tvtuistates.h"
       
    27 #include    "cvtuitoolbarcmdpolicy.h"
       
    28 #include    "cvtuitoolbarskmodifier.h"
       
    29 #include    "CVtUiAppUi.h"
       
    30 #include    <videotelui.rsg>
       
    31 #include    <cvtlogger.h>
       
    32 #include    <akntoolbar.h>
       
    33 #include    "tvtuistates.h"
       
    34 #include    <layoutmetadata.cdl.h>
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CVtUiFixedToolbar::NewL
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CVtUiFixedToolbar* CVtUiFixedToolbar::NewL( CVtUiFeatureManager&
       
    41      aFeatureManager )
       
    42     {
       
    43     __VTPRINTENTER( "FixedToolbar.NewL" )
       
    44     CVtUiFixedToolbar* self = new ( ELeave ) CVtUiFixedToolbar(
       
    45         aFeatureManager );
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop( self );
       
    49     __VTPRINTEXIT( "FixedToolbar.NewL" )
       
    50     return self;
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CVtUiFixedToolbar::CVtUiFixedToolbar
       
    55 // C++ constructor can NOT contain any code, that
       
    56 // might leave.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CVtUiFixedToolbar::CVtUiFixedToolbar( CVtUiFeatureManager&
       
    60     aFeatureManager ) : CVtUiToolbarBase( aFeatureManager )
       
    61     {
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CVtUiFixedToolbar::ConstructL
       
    66 // Symbian 2nd phase constructor.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 void CVtUiFixedToolbar::ConstructL()
       
    70     {
       
    71     __VTPRINTENTER( "FixedToolbar.ConstructL" )
       
    72     BaseConstructL();
       
    73 
       
    74     //create toolbar
       
    75     iToolbar = iFeatureManager.AppUi().CurrentFixedToolbar();
       
    76 
       
    77     // create and add items into the toolbar
       
    78     CreateToolbarButtonsL();
       
    79 
       
    80     // Dim all toolbar buttons until first refresh is called
       
    81     DimToolbarbuttons( ETrue );
       
    82 
       
    83     if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
    84         {
       
    85         MakeToolbarVisible( EFalse );
       
    86         }
       
    87 
       
    88     __VTPRINTEXIT( "FixedToolbar.ConstructL" )
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CVtUiFixedToolbar::~CVtUiFixedToolbar
       
    93 // Destructor.
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 CVtUiFixedToolbar::~CVtUiFixedToolbar()
       
    97     {
       
    98     __VTPRINTENTER( "FixedToolbar.~" )
       
    99     delete iIdle;
       
   100     __VTPRINTEXIT( "FixedToolbar.~" )
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CVtUiFixedToolbar::CreateToolbarButtons
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CVtUiFixedToolbar::CreateToolbarButtonsL()
       
   108     {
       
   109     __VTPRINTENTER( "FixedToolbar.CreateToolbarButtons" )
       
   110     // Default buttons created in base clase
       
   111     CVtUiToolbarBase::CreateToolbarButtonsL();
       
   112 
       
   113     // toggle microphone
       
   114     CreateToolbarItemL( R_AVKONBUTTON_AUDIO_ROUTING_BUTTON,
       
   115         EVtUiCmdToolbarAudioRouting, iFeatureManager.AppUi() );
       
   116 
       
   117 
       
   118     __VTPRINTEXIT( "FixedToolbar.CreateToolbarButtons" )
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CVtUiFixedToolbar::PopulateCmdsIdsL
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CVtUiFixedToolbar::PopulateCmdsIdsL()
       
   126     {
       
   127     __VTPRINTENTER( "FixedToolbar.PopulateCmdsIdsL" )
       
   128     // Default commands populated in base clase
       
   129     CVtUiToolbarBase::PopulateCmdsIdsL();
       
   130 
       
   131     CVtUiAppUi& appUi = iFeatureManager.AppUi();
       
   132 
       
   133     iCmdIds.AppendL( EVtUiCmdActivateBT );
       
   134     iCmdIds.AppendL( EVtUiCmdSwitchFromBTToIHF );
       
   135     iCmdIds.AppendL( EVtUiCmdActivateLoudspeaker );
       
   136     iCmdIds.AppendL( EVtUiCmdDeactivateLoudspeaker );
       
   137 
       
   138     __VTPRINTEXIT( "FixedToolbar.PopulateCmdsIdsL" )
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CVtUiFixedToolbar::SetToolbarVisibilityAfterLayoutChangeL
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 void CVtUiFixedToolbar::SetToolbarVisibilityAfterLayoutChangeL( TBool aVisible )
       
   146     {
       
   147     // Portrait to landscape show tb
       
   148         __VTPRINTENTER( "FixedToolbar.SetToolbarVisibilityAfterLayoutChangeL" )
       
   149     if( aVisible )
       
   150         {
       
   151         __VTPRINT(DEBUG_GEN, "FixedToolbar.SetToolbarVisibilityAfterLayoutChangeL.1" )
       
   152         // Set flag
       
   153         iFeatureManager.UiStates().SetIsFixedToolbarVisible( ETrue );
       
   154         // set visible
       
   155         iFeatureManager.AppUi().CurrentFixedToolbar()
       
   156             ->SetToolbarVisibility( ETrue );
       
   157         // Set callback to dim toolbarbuttons
       
   158         if ( !iIdle )
       
   159             {
       
   160             iIdle = CIdle::NewL( CActive::EPriorityIdle );
       
   161             }
       
   162         iIdle->Start( TCallBack( &DoDimToolbarButtons, this ) );
       
   163         }
       
   164     // Landsacpe to portrait hide tb
       
   165     else
       
   166         {
       
   167         __VTPRINT(DEBUG_GEN, "FixedToolbar.SetToolbarVisibilityAfterLayoutChangeL.2" )
       
   168         DimToolbarbuttons( EFalse );
       
   169         iFeatureManager.AppUi().CurrentFixedToolbar()
       
   170             ->SetToolbarVisibility( EFalse );
       
   171          // Set flag
       
   172         iFeatureManager.UiStates().SetIsFixedToolbarVisible( EFalse );
       
   173         }
       
   174     __VTPRINTEXIT( "FixedToolbar.SetToolbarVisibilityAfterLayoutChangeL" )
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CVtUiFixedToolbar::DimToolbarbuttons
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 void CVtUiFixedToolbar::DimToolbarbuttons( TBool aIsDimmed )
       
   182     {
       
   183     __VTPRINTENTER( "FixedToolbar.DimToolbarbuttons" )
       
   184     iToolbar->SetItemDimmed( EVtUiCmdToolbarToggleVideo, aIsDimmed, EFalse );
       
   185     iToolbar->SetItemDimmed( EVtUiCmdToolbarToggleMicrophone, aIsDimmed, EFalse );
       
   186     iToolbar->SetItemDimmed( EVtUiCmdToolbarAudioRouting, aIsDimmed, ETrue );
       
   187     __VTPRINTEXITR( "FixedToolbar.DimToolbarbuttons %d", aIsDimmed )
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CVtUiFixedToolbar::MakeToolbarVisible
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 void CVtUiFixedToolbar::MakeToolbarVisible( const TBool aVisible )
       
   195     {
       
   196     __VTPRINTENTER( "FixedToolbar.MakeToolbarVisible" )
       
   197     iFeatureManager.AppUi().CurrentFixedToolbar()->
       
   198         SetToolbarVisibility( aVisible );
       
   199     iFeatureManager.UiStates().SetIsFixedToolbarVisible( aVisible );
       
   200     __VTPRINTEXITR( "FixedToolbar.MakeToolbarVisible %d", aVisible )
       
   201     }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // CVtUiFixedToolbar::DoShowToolbarL
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 TInt CVtUiFixedToolbar::DoShowToolbarL( TAny* aAny )
       
   208     {
       
   209     __VTPRINTENTER( "FixedToolbar.DoShowToolbarL" )
       
   210     CVtUiFixedToolbar* self = static_cast< CVtUiFixedToolbar* >( aAny );
       
   211     self->iFeatureManager.AppUi().CurrentFixedToolbar()
       
   212         ->SetToolbarVisibility( ETrue );
       
   213     __VTPRINTEXIT( "FixedToolbar.DoShowToolbarL" )
       
   214     return KErrNone;
       
   215     }
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // CVtUiFixedToolbar::DoToolbarButton
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 TInt CVtUiFixedToolbar::DoDimToolbarButtons( TAny* aAny )
       
   222     {
       
   223     __VTPRINTENTER( "FixedToolbar.DoDimToolbarButtons" )
       
   224     CVtUiFixedToolbar* self = static_cast< CVtUiFixedToolbar* >( aAny );
       
   225     self->DimToolbarbuttons( ETrue );
       
   226     __VTPRINTEXIT( "FixedToolbar.DoDimToolbarButtons" )
       
   227     return EFalse;
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CVtUiFixedToolbar::DoActivateL
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 void CVtUiFixedToolbar::DoActivateL()
       
   235     {
       
   236     __VTPRINTENTER( "FixedToolbar.DoActivateL" )
       
   237     if ( !iFeatureManager.UiStates().IsFixedToolbarVisible() &&
       
   238          !Layout_Meta_Data::IsLandscapeOrientation() )
       
   239         {
       
   240         // reset flag
       
   241         iFeatureManager.UiStates().SetIsFixedToolbarVisible( ETrue );
       
   242         // Show toolbar with delay in order to prevent overdrawing
       
   243         // witht other components.
       
   244         iAsyncCallback->Cancel();
       
   245         iAsyncCallback->Set( TCallBack( &DoShowToolbarL, this ) );
       
   246         iAsyncCallback->CallBack();
       
   247         }
       
   248     else
       
   249         {
       
   250         // Undim buttons
       
   251         __VTPRINT( DEBUG_GEN, "FixedToolbar.DoDeactivateL.DTB EFalse" )
       
   252         // toolbar might be unvisible, because condition in the contructor 
       
   253         // "if ( !Layout_Meta_Data::IsLandscapeOrientation() )"
       
   254         // will be evaluated ture eventhough the orientation is forced to be landsacepe
       
   255         // because it seems that the orientation is still portrait in the constructor phase
       
   256         MakeToolbarVisible( ETrue );
       
   257         DimToolbarbuttons( EFalse );
       
   258         }
       
   259     // Start blocking pointer events
       
   260     BlockPointerEvents( ETrue );
       
   261     // Base class
       
   262     CVtUiToolbarBase::DoActivateL();
       
   263     __VTPRINTEXIT( "FixedToolbar.DoActivateL" )
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // CVtUiFixedToolbar::DoDeactivateL
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 void CVtUiFixedToolbar::DoDeactivateL()
       
   271     {
       
   272     __VTPRINTENTER( "FixedToolbar.DoDeactivateL" )
       
   273     iAsyncCallback->Cancel();
       
   274     if ( !iFeatureManager.UiStates().IsFixedToolbarVisible() &&
       
   275          !Layout_Meta_Data::IsLandscapeOrientation() )
       
   276         {
       
   277         iFeatureManager.AppUi().CurrentFixedToolbar()
       
   278             ->SetToolbarVisibility( EFalse );
       
   279         __VTPRINT( DEBUG_GEN, "FixedToolbar.DoDeactivateL.Vs" )
       
   280         }
       
   281     else
       
   282         {
       
   283         // Dim all buttons
       
   284         __VTPRINT( DEBUG_GEN, "FixedToolbar.DoDeactivateL.DTB ETrue" )
       
   285         DimToolbarbuttons( ETrue );
       
   286         }
       
   287     // Stop blocking pointer events
       
   288     BlockPointerEvents( EFalse );
       
   289     // Base class
       
   290     CVtUiToolbarBase::DoDeactivateL();
       
   291     __VTPRINTEXIT( "FixedToolbar.DoDeactivateL" )
       
   292     }
       
   293 
       
   294 //  End of File