videoplayback/videoplaybackcontrols/src/mpxvideoplaybackvolumebar.cpp
changeset 0 96612d01cf9f
child 6 7d91903f795f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     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: Volume bar control
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 15 %
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <eikenv.h>
       
    23 #include <gulicon.h>
       
    24 #include <gulfont.h>
       
    25 #include <AknUtils.h>
       
    26 #include <AknIconUtils.h>
       
    27 #include <StringLoader.h>
       
    28 #include <AknsDrawUtils.h>
       
    29 #include <data_caging_path_literals.hrh>
       
    30 #include <aknlayoutscalable_avkon.cdl.h>
       
    31 #include <mpxvideoplaybackcontrols.mbg>
       
    32 
       
    33 #include "mpxcommonvideoplaybackview.hrh"
       
    34 #include "mpxvideoplaybackvolumebar.h"
       
    35 #include "mpxvideoplaybackviewfiledetails.h"
       
    36 #include "mpxvideoplaybackcontrolscontroller.h"
       
    37 #include "mpxvideo_debug.h"
       
    38 
       
    39 #ifdef RD_TACTILE_FEEDBACK
       
    40 #include <touchfeedback.h>
       
    41 #endif //RD_TACTILE_FEEDBACK
       
    42 
       
    43 // CONSTANTS
       
    44 const TInt KMPXSliderHeight = 30;
       
    45 const TInt KMPXSliderWidth = 18;
       
    46 const TInt KMPXVolumeBarWidth = 24;
       
    47 const TInt KMPXVolumeDragEventTimeOut = 100000;
       
    48 const TInt KMPXPtrEventRepeatRequestTime = 200000;
       
    49 
       
    50 // ============================ MEMBER FUNCTIONS ===================================================
       
    51 
       
    52 CMPXVideoPlaybackVolumeBar::CMPXVideoPlaybackVolumeBar(
       
    53     CMPXVideoPlaybackControlsController* aController, TRect aRect )
       
    54     : iOneVolumeIncrementHeight(0)
       
    55     , iMuted(EFalse)
       
    56     , iRect(aRect)
       
    57     , iDragging(EVolumeNotDragging)
       
    58     , iController(aController)
       
    59 {
       
    60 }
       
    61 
       
    62 // -------------------------------------------------------------------------------------------------
       
    63 // CMPXVideoPlaybackVolumeBar::ConstructL()
       
    64 // Symbian 2nd phase constructor can leave.
       
    65 // -------------------------------------------------------------------------------------------------
       
    66 //
       
    67 void CMPXVideoPlaybackVolumeBar::ConstructL()
       
    68 {
       
    69     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::ConstructL()"));
       
    70 
       
    71     SetLayout();
       
    72     SkinChangeL();
       
    73 
       
    74     iDraggingHandlerTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
    75 
       
    76 #ifdef RD_TACTILE_FEEDBACK
       
    77     iFeedback = MTouchFeedback::Instance();
       
    78 #endif //RD_TACTILE_FEEDBACK
       
    79 }
       
    80 
       
    81 // -------------------------------------------------------------------------------------------------
       
    82 // CMPXVideoPlaybackVolumeBar::NewL()
       
    83 // Two-phased constructor.
       
    84 // -------------------------------------------------------------------------------------------------
       
    85 //
       
    86 CMPXVideoPlaybackVolumeBar* CMPXVideoPlaybackVolumeBar::NewL(
       
    87     CMPXVideoPlaybackControlsController* aController, TRect aRect )
       
    88 {
       
    89     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::NewL()"));
       
    90 
       
    91     CMPXVideoPlaybackVolumeBar* self =
       
    92         new ( ELeave ) CMPXVideoPlaybackVolumeBar( aController, aRect );
       
    93 
       
    94     CleanupStack::PushL( self );
       
    95     self->ConstructL();
       
    96     CleanupStack::Pop();
       
    97     return self;
       
    98 }
       
    99 
       
   100 // -------------------------------------------------------------------------------------------------
       
   101 // CMPXVideoPlaybackVolumeBar::~CMPXVideoPlaybackVolumeBar()
       
   102 // Destructor.
       
   103 // -------------------------------------------------------------------------------------------------
       
   104 //
       
   105 CMPXVideoPlaybackVolumeBar::~CMPXVideoPlaybackVolumeBar()
       
   106 {
       
   107     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::~CMPXVideoPlaybackVolumeBar()"));
       
   108 
       
   109     if ( iDraggingHandlerTimer )
       
   110     {
       
   111         iDraggingHandlerTimer->Cancel();
       
   112         delete iDraggingHandlerTimer;
       
   113         iDraggingHandlerTimer = NULL;
       
   114     }
       
   115 
       
   116     if (iSpeakerIcon)
       
   117     {
       
   118        delete iSpeakerIcon;
       
   119        iSpeakerIcon = NULL;
       
   120     }
       
   121 
       
   122     if (iSpeakerMuteIcon)
       
   123     {
       
   124        delete iSpeakerMuteIcon;
       
   125        iSpeakerMuteIcon = NULL;
       
   126     }
       
   127 
       
   128     if (iSliderIcon)
       
   129     {
       
   130        delete iSliderIcon;
       
   131        iSliderIcon = NULL;
       
   132     }
       
   133 
       
   134     if (iSliderSelectedIcon)
       
   135     {
       
   136        delete iSliderSelectedIcon;
       
   137        iSliderSelectedIcon = NULL;
       
   138     }
       
   139 
       
   140     if (iVolumeUpIcon)
       
   141     {
       
   142        delete iVolumeUpIcon;
       
   143        iVolumeUpIcon = NULL;
       
   144     }
       
   145 
       
   146     if (iVolumeDownIcon)
       
   147     {
       
   148        delete iVolumeDownIcon;
       
   149        iVolumeDownIcon = NULL;
       
   150     }
       
   151 
       
   152     if (iVolumeFrameIconTop)
       
   153     {
       
   154         delete iVolumeFrameIconTop;
       
   155         iVolumeFrameIconTop = NULL;
       
   156     }
       
   157 
       
   158     if (iVolumeFrameIconMiddle)
       
   159     {
       
   160         delete iVolumeFrameIconMiddle;
       
   161         iVolumeFrameIconMiddle = NULL;
       
   162     }
       
   163 
       
   164     if (iVolumeFrameIconBottom)
       
   165     {
       
   166         delete iVolumeFrameIconBottom;
       
   167         iVolumeFrameIconBottom = NULL;
       
   168     }
       
   169 
       
   170     if (iNoAudioIcon)
       
   171     {
       
   172        delete iNoAudioIcon;
       
   173        iNoAudioIcon = NULL;
       
   174     }
       
   175 
       
   176 #ifdef RD_TACTILE_FEEDBACK
       
   177     if (iFeedback)
       
   178     {
       
   179         iFeedback->RemoveFeedbackForControl(this);
       
   180     }
       
   181 #endif //RD_TACTILE_FEEDBACK
       
   182 
       
   183 }
       
   184 
       
   185 // -------------------------------------------------------------------------------------------------
       
   186 // CMPXVideoPlaybackVolumeBar::HandleResourceChange()
       
   187 // -------------------------------------------------------------------------------------------------
       
   188 //
       
   189 void CMPXVideoPlaybackVolumeBar::HandleResourceChange( TInt aType )
       
   190 {
       
   191     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::HandleResourceChange(0x%X)"), aType);
       
   192 
       
   193     if ( aType == KAknsMessageSkinChange )
       
   194     {
       
   195         TRAP_IGNORE( SkinChangeL() );
       
   196     }
       
   197 
       
   198     CCoeControl::HandleResourceChange( aType );
       
   199 }
       
   200 
       
   201 // -------------------------------------------------------------------------------------------------
       
   202 // CMPXVideoPlaybackVolumeBar::SetLayout()
       
   203 // -------------------------------------------------------------------------------------------------
       
   204 //
       
   205 void CMPXVideoPlaybackVolumeBar::SetLayout()
       
   206 {
       
   207     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::SetLayout()"));
       
   208 
       
   209     //
       
   210     // Calculate icon rects
       
   211     //
       
   212     iRect = TRect(0, 0, iRect.Width(), iRect.Height() );
       
   213     TInt volumeUpDownIndicatorSize = iRect.Width() / 3;
       
   214 
       
   215     iVolumeControlRect = TRect( volumeUpDownIndicatorSize,
       
   216                                 iRect.iTl.iY,
       
   217                                 iRect.iBr.iX,
       
   218                                 iRect.iTl.iY + iRect.Height() * 4 / 5 );
       
   219 
       
   220     iVolumeBarRect =  TRect( iVolumeControlRect.iTl.iX + iVolumeControlRect.Width() / 3,
       
   221                              iVolumeControlRect.iTl.iY + iVolumeControlRect.Height() / 20,
       
   222                              iVolumeControlRect.iTl.iX + iVolumeControlRect.Width() / 3 * 2,
       
   223                              iVolumeControlRect.iTl.iY + iVolumeControlRect.Height() );
       
   224 
       
   225     iVolumeBarRectTop = TRect( iRect.Width() / 2 - KMPXVolumeBarWidth / 2 ,
       
   226                                iVolumeBarRect.iTl.iY,
       
   227                                iRect.Width() / 2 + KMPXVolumeBarWidth / 2,
       
   228                                iVolumeBarRect.iTl.iY + iVolumeBarRect.Height() / 10 );
       
   229 
       
   230     iVolumeBarRectMiddle = TRect( iVolumeBarRectTop.iTl.iX,
       
   231                                   iVolumeBarRectTop.iBr.iY,
       
   232                                   iVolumeBarRectTop.iBr.iX,
       
   233                                   iVolumeBarRectTop.iBr.iY + iVolumeBarRectTop.Height() * 8 );
       
   234 
       
   235     iVolumeBarRectBottom = TRect( iVolumeBarRectTop.iTl.iX,
       
   236                                   iVolumeBarRectMiddle.iBr.iY,
       
   237                                   iVolumeBarRectTop.iBr.iX,
       
   238                                   iVolumeBarRect.iBr.iY );
       
   239 
       
   240     iSliderRect = TRect( iRect.Width() / 2 - KMPXSliderWidth / 2 + 3,
       
   241                          iVolumeBarRect.iBr.iY - KMPXSliderHeight,
       
   242                          iRect.Width() / 2 + KMPXSliderWidth / 2 + 3,
       
   243                          iVolumeBarRect.iBr.iY );
       
   244 
       
   245     iVolumeUpControlRect = TRect( iRect.iTl,
       
   246                            TSize( volumeUpDownIndicatorSize,
       
   247                                   iVolumeControlRect.Height() / 2 ) );
       
   248 
       
   249     iVolumeDownControlRect = TRect( TPoint ( iRect.iTl.iX, iVolumeControlRect.Height() / 2 ),
       
   250                                     iVolumeUpControlRect.Size() );
       
   251 
       
   252     iVolumeUpRect = TRect( iVolumeUpControlRect.iTl.iX + 2,
       
   253                            iVolumeUpControlRect.iTl.iY + 8,
       
   254                            iVolumeUpControlRect.iBr.iX + 2,
       
   255                            iVolumeUpControlRect.iTl.iY + volumeUpDownIndicatorSize );
       
   256 
       
   257     iVolumeDownRect = TRect( iVolumeUpRect.iTl.iX,
       
   258                              iVolumeDownControlRect.iBr.iY - volumeUpDownIndicatorSize,
       
   259                              iVolumeUpRect.iBr.iX,
       
   260                              iVolumeDownControlRect.iBr.iY  );
       
   261 
       
   262     iSpeakerControlRect = TRect( TPoint( iRect.iTl.iX, iVolumeControlRect.iBr.iY ),
       
   263                                  iRect.iBr );
       
   264 
       
   265     iSpeakerRect = TRect( iSpeakerControlRect.iTl.iX + iSpeakerControlRect.Width() / 5,
       
   266                           iSpeakerControlRect.iTl.iY + iSpeakerControlRect.Height() / 5,
       
   267                           iSpeakerControlRect.iBr.iX - iSpeakerControlRect.Width() / 5,
       
   268                           iSpeakerControlRect.iBr.iY - iSpeakerControlRect.Height() / 5 );
       
   269 
       
   270     iOneVolumeIncrementHeight = (TReal)( iVolumeBarRect.Height() - KMPXSliderHeight )
       
   271                                 / (TReal)KPbPlaybackVolumeLevelMax;
       
   272 }
       
   273 
       
   274 // -------------------------------------------------------------------------------------------------
       
   275 // CMPXVideoPlaybackVolumeBar::SkinChangeL()
       
   276 // -------------------------------------------------------------------------------------------------
       
   277 //
       
   278 void CMPXVideoPlaybackVolumeBar::SkinChangeL()
       
   279 {
       
   280     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::SkinChangeL()"));
       
   281 
       
   282     //
       
   283     // Create icons
       
   284     //
       
   285     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   286 
       
   287     TFileName iconsPath;
       
   288     iController->LocateBitmapFileL( iconsPath );
       
   289 
       
   290     delete iSpeakerIcon;
       
   291     iSpeakerIcon = NULL;
       
   292     iSpeakerIcon = AknsUtils::CreateGulIconL(
       
   293             skin,
       
   294 		    KAknsIIDQgnIndiNsliderUnmuted,
       
   295 		    iconsPath,
       
   296 		    EMbmMpxvideoplaybackcontrolsQgn_indi_nslider_unmuted,
       
   297 		    EMbmMpxvideoplaybackcontrolsQgn_indi_nslider_unmuted_mask );
       
   298 
       
   299     if ( iSpeakerIcon )
       
   300     {
       
   301         AknIconUtils::SetSize( iSpeakerIcon->Bitmap(),
       
   302                                iSpeakerRect.Size(),
       
   303                                EAspectRatioPreserved );
       
   304     }
       
   305 
       
   306     delete iSpeakerMuteIcon;
       
   307     iSpeakerMuteIcon = NULL;
       
   308     iSpeakerMuteIcon = AknsUtils::CreateGulIconL(
       
   309             skin,
       
   310 		    KAknsIIDQgnIndiNsliderMuted,
       
   311 		    iconsPath,
       
   312 		    EMbmMpxvideoplaybackcontrolsQgn_indi_nslider_muted,
       
   313 		    EMbmMpxvideoplaybackcontrolsQgn_indi_nslider_muted_mask );
       
   314 
       
   315 
       
   316     if ( iSpeakerMuteIcon )
       
   317     {
       
   318         AknIconUtils::SetSize( iSpeakerMuteIcon->Bitmap(),
       
   319                                iSpeakerRect.Size(),
       
   320                                EAspectRatioPreserved );
       
   321     }
       
   322 
       
   323     delete iNoAudioIcon;
       
   324     iNoAudioIcon = NULL;
       
   325     iNoAudioIcon = AknsUtils::CreateGulIconL(
       
   326             skin,
       
   327             KAknsIIDQgnGrafMupLstCorrupttrack,
       
   328             iconsPath,
       
   329             EMbmMpxvideoplaybackcontrolsQgn_graf_mup_lst_corrupttrack,
       
   330             EMbmMpxvideoplaybackcontrolsQgn_graf_mup_lst_corrupttrack_mask );
       
   331 
       
   332 
       
   333     if ( iNoAudioIcon )
       
   334     {
       
   335         AknIconUtils::SetSize( iNoAudioIcon->Bitmap(),
       
   336                                iSpeakerRect.Size(),
       
   337                                EAspectRatioPreserved );
       
   338     }
       
   339 
       
   340     delete iSliderIcon;
       
   341     iSliderIcon = NULL;
       
   342     iSliderIcon = AknsUtils::CreateGulIconL(
       
   343             skin,
       
   344 		    KAknsIIDQgnGrafNsliderVerticalMarker,
       
   345 		    iconsPath,
       
   346 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_marker,
       
   347 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_marker_mask );
       
   348 
       
   349     if ( iSliderIcon )
       
   350     {
       
   351         AknIconUtils::SetSize( iSliderIcon->Bitmap(),
       
   352                                TSize(KMPXSliderWidth, KMPXSliderHeight),
       
   353                                EAspectRatioNotPreserved );
       
   354     }
       
   355 
       
   356     delete iSliderSelectedIcon;
       
   357     iSliderSelectedIcon = NULL;
       
   358     iSliderSelectedIcon = AknsUtils::CreateGulIconL(
       
   359             skin,
       
   360 		    KAknsIIDQgnGrafNsliderVerticalMarkerSelected,
       
   361 		    iconsPath,
       
   362 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_marker_selected,
       
   363 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_marker_selected_mask );
       
   364 
       
   365     if ( iSliderSelectedIcon )
       
   366     {
       
   367         AknIconUtils::SetSize( iSliderSelectedIcon->Bitmap(),
       
   368                                TSize(KMPXSliderWidth, KMPXSliderHeight),
       
   369                                EAspectRatioNotPreserved );
       
   370     }
       
   371 
       
   372     delete iVolumeUpIcon;
       
   373     iVolumeUpIcon = NULL;
       
   374     iVolumeUpIcon = AknsUtils::CreateGulIconL(
       
   375             skin,
       
   376 		    KAknsIIDQgnIndiCam4ZoomMax,
       
   377 		    iconsPath,
       
   378 		    EMbmMpxvideoplaybackcontrolsQgn_indi_nslider_level_increase,
       
   379 		    EMbmMpxvideoplaybackcontrolsQgn_indi_nslider_level_increase_mask );
       
   380 
       
   381     if ( iVolumeUpIcon )
       
   382     {
       
   383         AknIconUtils::SetSize( iVolumeUpIcon->Bitmap(),
       
   384                                iVolumeUpRect.Size(),
       
   385                                EAspectRatioPreserved );
       
   386     }
       
   387 
       
   388     delete iVolumeDownIcon;
       
   389     iVolumeDownIcon = NULL;
       
   390     iVolumeDownIcon = AknsUtils::CreateGulIconL(
       
   391             skin,
       
   392 		    KAknsIIDQgnIndiCam4ZoomMin,
       
   393 		    iconsPath,
       
   394 		    EMbmMpxvideoplaybackcontrolsQgn_indi_nslider_level_decrease,
       
   395 		    EMbmMpxvideoplaybackcontrolsQgn_indi_nslider_level_decrease_mask );
       
   396 
       
   397     if ( iVolumeDownIcon )
       
   398     {
       
   399         AknIconUtils::SetSize( iVolumeDownIcon->Bitmap(),
       
   400                                iVolumeDownRect.Size(),
       
   401                                EAspectRatioPreserved );
       
   402     }
       
   403 
       
   404     delete iVolumeFrameIconTop;
       
   405     iVolumeFrameIconTop = NULL;
       
   406     iVolumeFrameIconTop = AknsUtils::CreateGulIconL(
       
   407             skin,
       
   408 		    KAknsIIDQgnIndiCam4ZoomTop,
       
   409 		    iconsPath,
       
   410 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_top,
       
   411 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_top_mask );
       
   412 
       
   413     if ( iVolumeFrameIconTop )
       
   414     {
       
   415         AknIconUtils::SetSize( iVolumeFrameIconTop->Bitmap(),
       
   416                                TSize( KMPXVolumeBarWidth, iVolumeBarRectTop.Height() ),
       
   417                                EAspectRatioNotPreserved );
       
   418     }
       
   419 
       
   420     delete iVolumeFrameIconMiddle;
       
   421     iVolumeFrameIconMiddle = NULL;
       
   422     iVolumeFrameIconMiddle = AknsUtils::CreateGulIconL(
       
   423             skin,
       
   424 		    KAknsIIDQgnIndiCam4ZoomMiddle,
       
   425 		    iconsPath,
       
   426 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_middle,
       
   427 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_middle_mask );
       
   428 
       
   429     if ( iVolumeFrameIconMiddle )
       
   430     {
       
   431         AknIconUtils::SetSize( iVolumeFrameIconMiddle->Bitmap(),
       
   432                                TSize( KMPXVolumeBarWidth, iVolumeBarRectMiddle.Height() ),
       
   433                                EAspectRatioNotPreserved );
       
   434     }
       
   435 
       
   436     delete iVolumeFrameIconBottom;
       
   437     iVolumeFrameIconBottom = NULL;
       
   438     iVolumeFrameIconBottom = AknsUtils::CreateGulIconL(
       
   439             skin,
       
   440 		    KAknsIIDQgnIndiCam4ZoomBottom,
       
   441 		    iconsPath,
       
   442 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_bottom,
       
   443 		    EMbmMpxvideoplaybackcontrolsQgn_graf_nslider_vertical_bottom_mask );
       
   444 
       
   445     if ( iVolumeFrameIconBottom )
       
   446     {
       
   447         AknIconUtils::SetSize( iVolumeFrameIconBottom->Bitmap(),
       
   448                                TSize( KMPXVolumeBarWidth, iVolumeBarRectBottom.Height() ),
       
   449                                EAspectRatioNotPreserved );
       
   450     }
       
   451 }
       
   452 
       
   453 // -------------------------------------------------------------------------------------------------
       
   454 //   CMPXVideoPlaybackVolumeBar::HandleVolumeIncreaseL
       
   455 // -------------------------------------------------------------------------------------------------
       
   456 //
       
   457 void CMPXVideoPlaybackVolumeBar::HandleVolumeIncreaseL( const TPointerEvent& aPointerEvent )
       
   458 {
       
   459     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackVolumeBar::HandleVolumeIncreaseL()"));
       
   460 
       
   461     switch ( aPointerEvent.iType )
       
   462     {
       
   463         case TPointerEvent::EButtonRepeat: 
       
   464         {    
       
   465 #ifdef RD_TACTILE_FEEDBACK 
       
   466             if ( iFeedback ) 
       
   467             { 
       
   468 #ifdef SYMBIAN_BUILD_GCE
       
   469                 iFeedback->InstantFeedback( ETouchFeedbackSlider );
       
   470 #else
       
   471                 iFeedback->InstantFeedback( ETouchFeedbackSensitive );
       
   472 #endif //SYMBIAN_BUILD_GCE 
       
   473             } 
       
   474 #endif //RD_TACTILE_FEEDBACK                 
       
   475             iController->HandleCommandL( EMPXPbvCmdIncreaseVolume );
       
   476             iDragging = EVolumeIncreaseDragging;
       
   477             
       
   478         }    
       
   479         case TPointerEvent::EButton1Down: 
       
   480         { 
       
   481             Window().RequestPointerRepeatEvent( 
       
   482                          TTimeIntervalMicroSeconds32(KMPXPtrEventRepeatRequestTime) 
       
   483                          ,iVolumeUpControlRect); 
       
   484 
       
   485             break;
       
   486         } 
       
   487         case TPointerEvent::EDrag:
       
   488         {
       
   489             iDragging = EVolumeIncreaseDragging;
       
   490 
       
   491             break;
       
   492         }
       
   493         case TPointerEvent::EButton1Up:
       
   494         {
       
   495 #ifdef RD_TACTILE_FEEDBACK
       
   496             if ( iFeedback )
       
   497             {
       
   498 #ifdef SYMBIAN_BUILD_GCE
       
   499                 iFeedback->InstantFeedback( ETouchFeedbackSlider );
       
   500 #else
       
   501                 iFeedback->InstantFeedback( ETouchFeedbackBasic );
       
   502 #endif //SYMBIAN_BUILD_GCE       
       
   503             }
       
   504 #endif //RD_TACTILE_FEEDBACK
       
   505 
       
   506             iController->HandleCommandL( EMPXPbvCmdIncreaseVolume );
       
   507 
       
   508             iDragging = EVolumeNotDragging;
       
   509 
       
   510             break;
       
   511         }
       
   512     }
       
   513 }
       
   514 
       
   515 // -------------------------------------------------------------------------------------------------
       
   516 //   CMPXVideoPlaybackVolumeBar::HandleVolumeDecreaseL
       
   517 // -------------------------------------------------------------------------------------------------
       
   518 //
       
   519 void CMPXVideoPlaybackVolumeBar::HandleVolumeDecreaseL( const TPointerEvent& aPointerEvent )
       
   520 {
       
   521     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackVolumeBar::HandleVolumeDecreaseL()"));
       
   522 
       
   523     switch ( aPointerEvent.iType )
       
   524     {
       
   525         case TPointerEvent::EButtonRepeat: 
       
   526         {    
       
   527 #ifdef RD_TACTILE_FEEDBACK 
       
   528             if ( iFeedback ) 
       
   529             { 
       
   530 #ifdef SYMBIAN_BUILD_GCE
       
   531                 iFeedback->InstantFeedback( ETouchFeedbackSlider );
       
   532 #else
       
   533                 iFeedback->InstantFeedback( ETouchFeedbackSensitive ); 
       
   534 #endif //SYMBIAN_BUILD_GCE 
       
   535             } 
       
   536 #endif //RD_TACTILE_FEEDBACK                 
       
   537             iController->HandleCommandL( EMPXPbvCmdDecreaseVolume );
       
   538             iDragging = EVolumeDecreaseDragging;
       
   539             
       
   540         }    
       
   541         case TPointerEvent::EButton1Down: 
       
   542         { 
       
   543             Window().RequestPointerRepeatEvent( 
       
   544                          TTimeIntervalMicroSeconds32(KMPXPtrEventRepeatRequestTime) 
       
   545                          ,iVolumeDownControlRect); 
       
   546 
       
   547             break;
       
   548         } 
       
   549         case TPointerEvent::EDrag:
       
   550         {
       
   551             iDragging = EVolumeDecreaseDragging;
       
   552             break;
       
   553         }
       
   554         case TPointerEvent::EButton1Up:
       
   555         {
       
   556 #ifdef RD_TACTILE_FEEDBACK
       
   557             if ( iFeedback )
       
   558             {
       
   559 #ifdef SYMBIAN_BUILD_GCE           	
       
   560                 iFeedback->InstantFeedback( ETouchFeedbackSlider );
       
   561 #else
       
   562                 iFeedback->InstantFeedback( ETouchFeedbackBasic );
       
   563 #endif //SYMBIAN_BUILD_GCE
       
   564             }
       
   565 #endif //RD_TACTILE_FEEDBACK
       
   566 
       
   567             iController->HandleCommandL( EMPXPbvCmdDecreaseVolume );
       
   568 
       
   569             iDragging = EVolumeNotDragging;
       
   570 
       
   571             break;
       
   572         }
       
   573     }
       
   574 }
       
   575 
       
   576 // -------------------------------------------------------------------------------------------------
       
   577 //   CMPXVideoPlaybackVolumeBar::HandleSpeakerControlEventL
       
   578 // -------------------------------------------------------------------------------------------------
       
   579 //
       
   580 void CMPXVideoPlaybackVolumeBar::HandleSpeakerControlEventL( const TPointerEvent& aPointerEvent )
       
   581 {
       
   582     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackVolumeBar::HandleSpeakerControlEventL()"));
       
   583 
       
   584     switch ( aPointerEvent.iType )
       
   585     {
       
   586         case TPointerEvent::EButton1Up:
       
   587         {
       
   588 #ifdef RD_TACTILE_FEEDBACK
       
   589             if ( iFeedback )
       
   590             {
       
   591 #ifdef SYMBIAN_BUILD_GCE
       
   592                 iFeedback->InstantFeedback( ETouchFeedbackBasicButton );
       
   593 #else
       
   594                 iFeedback->InstantFeedback( ETouchFeedbackBasic );
       
   595 #endif //SYMBIAN_BUILD_GCE
       
   596             }
       
   597 #endif //RD_TACTILE_FEEDBACK
       
   598 
       
   599             if ( iMuted )
       
   600             {
       
   601                 iController->HandleCommandL( EMPXPbvCmdUnMute );
       
   602             }
       
   603             else
       
   604             {
       
   605                 iController->HandleCommandL( EMPXPbvCmdMute );
       
   606             }
       
   607 
       
   608             iDragging = EVolumeNotDragging;
       
   609 
       
   610             break;
       
   611         }
       
   612         case TPointerEvent::EDrag:
       
   613         {
       
   614             iDragging = EVolumeSpeakerDragging;
       
   615 
       
   616             break;
       
   617         }
       
   618         case TPointerEvent::EButton1Down:
       
   619         {
       
   620             iDragging = EVolumeNotDragging;
       
   621 
       
   622             break;
       
   623         }
       
   624     }
       
   625 }
       
   626 
       
   627 // -------------------------------------------------------------------------------------------------
       
   628 //   CMPXVideoPlaybackVolumeBar::HandleVolumeBarEventL
       
   629 // -------------------------------------------------------------------------------------------------
       
   630 //
       
   631 void CMPXVideoPlaybackVolumeBar::HandleVolumeBarEventL( const TPointerEvent& aPointerEvent )
       
   632 {
       
   633     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackVolumeBar::HandleVolumeBarEventL()"));
       
   634 
       
   635     TInt vol = 0;
       
   636 
       
   637     if ( aPointerEvent.iPosition.iY < iVolumeBarRect.iTl.iY + KMPXSliderHeight / 2 )
       
   638     {
       
   639         vol = KPbPlaybackVolumeLevelMax;
       
   640     }
       
   641     else if ( aPointerEvent.iPosition.iY > iVolumeBarRect.iBr.iY - KMPXSliderHeight / 2 )
       
   642     {
       
   643         vol = 0;
       
   644     }
       
   645     else
       
   646     {
       
   647         vol = ( iVolumeBarRect.iBr.iY - KMPXSliderHeight / 2 - aPointerEvent.iPosition.iY ) /
       
   648               iOneVolumeIncrementHeight;
       
   649     }
       
   650 
       
   651     switch ( aPointerEvent.iType )
       
   652     {
       
   653         case TPointerEvent::EButton1Down:
       
   654         {
       
   655 #ifdef RD_TACTILE_FEEDBACK
       
   656             if ( iFeedback )
       
   657             {
       
   658 #ifdef SYMBIAN_BUILD_GCE
       
   659                 iFeedback->InstantFeedback( ETouchFeedbackSlider );
       
   660 #else
       
   661                 iFeedback->InstantFeedback( ETouchFeedbackBasic );
       
   662 #endif //SYMBIAN_BUILD_GCE
       
   663             }
       
   664 #endif //RD_TACTILE_FEEDBACK
       
   665 
       
   666             if ( ! iDraggingHandlerTimer->IsActive() )
       
   667             {
       
   668                 iDraggingHandlerTimer->Start(
       
   669                     KMPXVolumeDragEventTimeOut,
       
   670                     KMPXVolumeDragEventTimeOut,
       
   671                     TCallBack( CMPXVideoPlaybackVolumeBar::HandleVolumeDragEventTimeOut, this ) );
       
   672             }
       
   673 
       
   674             iDragging = EVolumeNotDragging;
       
   675 
       
   676             break;
       
   677         }
       
   678         case TPointerEvent::EDrag:
       
   679         {
       
   680 #ifdef RD_TACTILE_FEEDBACK
       
   681             if ( iFeedback )
       
   682             {
       
   683 #ifdef SYMBIAN_BUILD_GCE           	
       
   684                 iFeedback->InstantFeedback( ETouchFeedbackSlider );
       
   685 #else
       
   686                 iFeedback->InstantFeedback( ETouchFeedbackSensitive );
       
   687 #endif //SYMBIAN_BUILD_GCE
       
   688             }
       
   689 #endif //RD_TACTILE_FEEDBACK
       
   690 
       
   691             iVolumeWhileDraggingEvent = vol;
       
   692             iDragging = EVolumeBarDragging;
       
   693 
       
   694             break;
       
   695         }
       
   696         case TPointerEvent::EButton1Up:
       
   697         {
       
   698             if ( iDraggingHandlerTimer->IsActive() )
       
   699             {
       
   700                 iDraggingHandlerTimer->Cancel();
       
   701             }
       
   702 
       
   703             SetVolumeL( vol );
       
   704 
       
   705             if ( iDragging == EVolumeBarDragging && vol == 0 )
       
   706             {
       
   707                 //
       
   708                 // volume & mute levels are kept track in playbackplugin.
       
   709                 // 
       
   710                 iController->HandleCommandL( EMPXPbvCmdMute );
       
   711             }
       
   712 
       
   713             iDragging = EVolumeNotDragging;
       
   714 
       
   715             if ( IsVisible() )
       
   716             {
       
   717                 DrawNow();
       
   718             }
       
   719 
       
   720             break;
       
   721         }
       
   722     }
       
   723 }
       
   724 
       
   725 // -------------------------------------------------------------------------------------------------
       
   726 // CMPXVideoPlaybackVolumeBar::HandleVolumeDragEventTimeOut
       
   727 // -------------------------------------------------------------------------------------------------
       
   728 //
       
   729 TInt CMPXVideoPlaybackVolumeBar::HandleVolumeDragEventTimeOut( TAny* aPtr )
       
   730 {
       
   731     static_cast<CMPXVideoPlaybackVolumeBar*>(aPtr)->DoHandleVolumeDragEventTimeOut();
       
   732     return KErrNone;
       
   733 }
       
   734 
       
   735 // -------------------------------------------------------------------------------------------------
       
   736 // CMPXVideoPlaybackVolumeBar::DoHandleVolumeDragEventTimeOut
       
   737 // -------------------------------------------------------------------------------------------------
       
   738 //
       
   739 void CMPXVideoPlaybackVolumeBar::DoHandleVolumeDragEventTimeOut()
       
   740 {
       
   741     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackController::DoHandleVolumeDragEventTimeOut()"));
       
   742 
       
   743     if ( iDragging == EVolumeBarDragging )
       
   744     {
       
   745         SetVolumeL( iVolumeWhileDraggingEvent );
       
   746     }
       
   747 }
       
   748 
       
   749 // -------------------------------------------------------------------------------------------------
       
   750 //   CMPXVideoPlaybackVolumeBar::HandlePointerEventL
       
   751 // -------------------------------------------------------------------------------------------------
       
   752 //
       
   753 void CMPXVideoPlaybackVolumeBar::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   754 {
       
   755     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackVolumeBar::HandlePointerEventL()"));
       
   756 
       
   757     //
       
   758     //  Block pointer events in the following cases:
       
   759     //  - If TV-Out is connected and the clip is DRM protected
       
   760     //
       
   761     if ( iController->IsTvOutPlaybackAllowed() && iController->FileDetails()->iAudioEnabled )
       
   762     {
       
   763         //
       
   764         //  Volume up
       
   765         //
       
   766         if ( iDragging == EVolumeIncreaseDragging ||
       
   767              ( iVolumeUpControlRect.Contains( aPointerEvent.iPosition ) &&
       
   768                iDragging == EVolumeNotDragging ) )
       
   769         {
       
   770             HandleVolumeIncreaseL( aPointerEvent );
       
   771         }
       
   772         //
       
   773         // Volume down
       
   774         //
       
   775         else if ( iDragging == EVolumeDecreaseDragging ||
       
   776                   ( iVolumeDownControlRect.Contains( aPointerEvent.iPosition ) &&
       
   777                     iDragging == EVolumeNotDragging ) )
       
   778         {
       
   779             HandleVolumeDecreaseL( aPointerEvent );
       
   780         }
       
   781         //
       
   782         // Speaker/Mute
       
   783         //
       
   784         else if ( iDragging == EVolumeSpeakerDragging ||
       
   785                   ( iSpeakerControlRect.Contains( aPointerEvent.iPosition ) &&
       
   786                     iDragging == EVolumeNotDragging ) )
       
   787         {
       
   788             HandleSpeakerControlEventL( aPointerEvent );
       
   789         }
       
   790         //
       
   791         // Volume Bar
       
   792         //
       
   793         else
       
   794         {
       
   795             HandleVolumeBarEventL( aPointerEvent );
       
   796         }
       
   797     }
       
   798 }
       
   799 
       
   800 // -------------------------------------------------------------------------------------------------
       
   801 //   CMPXVideoPlaybackVolumeBar::Draw()
       
   802 // -------------------------------------------------------------------------------------------------
       
   803 //
       
   804 void CMPXVideoPlaybackVolumeBar::Draw( const TRect& aRect ) const
       
   805 {
       
   806     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::Draw()"));
       
   807 
       
   808     CWindowGc& gc = SystemGc();
       
   809     gc.SetClippingRect( aRect );
       
   810 
       
   811     if ( Window().DisplayMode() == EColor16MAP )
       
   812     {
       
   813         gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
       
   814         gc.SetBrushColor( TRgb::Color16MAP( 255 ) );
       
   815         gc.Clear( aRect );
       
   816     }
       
   817     else if ( Window().DisplayMode() == EColor16MA )
       
   818     {
       
   819         gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
       
   820         gc.SetBrushColor( TRgb::Color16MA( 0 ) );
       
   821         gc.Clear( aRect );
       
   822     }
       
   823     else
       
   824     {
       
   825         // draw a solid background so that the entire progress
       
   826         // bar is shown not just the area representing the
       
   827         // portion that has been played.
       
   828         gc.SetBrushColor( KRgbBlack );
       
   829         gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   830         gc.DrawRect( aRect );
       
   831         gc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   832     }
       
   833 
       
   834     if ( ! iController->FileDetails()->iAudioEnabled || iMuted )
       
   835     {
       
   836         if ( iController->FileDetails()->iAudioEnabled )
       
   837         {
       
   838             //
       
   839             // use "Mute" icon for media clip with audio supported
       
   840             //
       
   841             gc.BitBltMasked( iSpeakerRect.iTl,
       
   842                              iSpeakerMuteIcon->Bitmap(),
       
   843                              TRect(iSpeakerRect.Size()),
       
   844                              iSpeakerMuteIcon->Mask(),
       
   845                              ETrue );
       
   846         }
       
   847         else
       
   848         {
       
   849             //
       
   850             // use "No Audio" icon instead of the generic "Mute" icon
       
   851             // for media clip with audio not supported
       
   852             //
       
   853             gc.BitBltMasked( iSpeakerRect.iTl,
       
   854                              iNoAudioIcon->Bitmap(),
       
   855                              TRect(iSpeakerRect.Size()),
       
   856                              iNoAudioIcon->Mask(),
       
   857                              ETrue );
       
   858         }
       
   859     }
       
   860     else
       
   861     {
       
   862         gc.BitBltMasked( iSpeakerRect.iTl,
       
   863                          iSpeakerIcon->Bitmap(),
       
   864                          TRect(iSpeakerRect.Size()),
       
   865                          iSpeakerIcon->Mask(),
       
   866                          ETrue );
       
   867     }
       
   868 
       
   869     if ( iVolumeUpIcon )
       
   870     {
       
   871         gc.BitBltMasked( iVolumeUpRect.iTl,
       
   872                          iVolumeUpIcon->Bitmap(),
       
   873                          TRect(iVolumeUpRect.Size()),
       
   874                          iVolumeUpIcon->Mask(),
       
   875                          ETrue );
       
   876     }
       
   877 
       
   878     if ( iVolumeDownIcon )
       
   879     {
       
   880         gc.BitBltMasked( iVolumeDownRect.iTl,
       
   881                          iVolumeDownIcon->Bitmap(),
       
   882                          TRect(iVolumeDownRect.Size()),
       
   883                          iVolumeDownIcon->Mask(),
       
   884                          ETrue );
       
   885     }
       
   886 
       
   887     if ( iVolumeFrameIconTop )
       
   888     {
       
   889         gc.BitBltMasked( iVolumeBarRectTop.iTl,
       
   890                          iVolumeFrameIconTop->Bitmap(),
       
   891                          TRect(iVolumeBarRectTop.Size()),
       
   892                          iVolumeFrameIconTop->Mask(),
       
   893                          ETrue );
       
   894     }
       
   895 
       
   896     if ( iVolumeFrameIconMiddle )
       
   897     {
       
   898         gc.BitBltMasked( iVolumeBarRectMiddle.iTl,
       
   899                          iVolumeFrameIconMiddle->Bitmap(),
       
   900                          TRect(iVolumeBarRectMiddle.Size()),
       
   901                          iVolumeFrameIconMiddle->Mask(),
       
   902                          ETrue );
       
   903     }
       
   904 
       
   905     if ( iVolumeFrameIconBottom )
       
   906     {
       
   907         gc.BitBltMasked( iVolumeBarRectBottom.iTl,
       
   908                          iVolumeFrameIconBottom->Bitmap(),
       
   909                          TRect(iVolumeBarRectBottom.Size()),
       
   910                          iVolumeFrameIconBottom->Mask(),
       
   911                          ETrue );
       
   912     }
       
   913 
       
   914     if ( iController->FileDetails() &&
       
   915          iController->FileDetails()->iAudioEnabled &&
       
   916          iSliderIcon &&
       
   917          iSliderSelectedIcon )
       
   918     {
       
   919         if ( iDragging == EVolumeBarDragging )
       
   920         {
       
   921             gc.BitBltMasked( iSliderRect.iTl,
       
   922                              iSliderSelectedIcon->Bitmap(),
       
   923                              TRect(iSliderRect.Size()),
       
   924                              iSliderSelectedIcon->Mask(),
       
   925                              ETrue );
       
   926         }
       
   927         else
       
   928         {
       
   929             gc.BitBltMasked( iSliderRect.iTl,
       
   930                              iSliderIcon->Bitmap(),
       
   931                              TRect(iSliderRect.Size()),
       
   932                              iSliderIcon->Mask(),
       
   933                              ETrue );
       
   934         }
       
   935     }
       
   936 }
       
   937 
       
   938 // -------------------------------------------------------------------------------------------------
       
   939 // CMPXVideoPlaybackVolumeBar::CountComponentControls()
       
   940 // -------------------------------------------------------------------------------------------------
       
   941 //
       
   942 TInt CMPXVideoPlaybackVolumeBar::CountComponentControls() const
       
   943 {
       
   944     return 0;
       
   945 }
       
   946 
       
   947 // -------------------------------------------------------------------------------------------------
       
   948 // CMPXVideoPlaybackVolumeBar::VolumeChanged()
       
   949 // -------------------------------------------------------------------------------------------------
       
   950 //
       
   951 void CMPXVideoPlaybackVolumeBar::VolumeChanged( TInt aVolume )
       
   952 {
       
   953     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::VolumeChanged() [%d]"), aVolume);
       
   954 
       
   955     iMuted = (aVolume == 0)? ETrue:EFalse;
       
   956 
       
   957     TReal volumeBarHeight = (TReal)iVolumeBarRect.iBr.iY -
       
   958                             iOneVolumeIncrementHeight * (TReal)aVolume;
       
   959 
       
   960     iSliderRect.iTl.iY = volumeBarHeight - KMPXSliderHeight;
       
   961     iSliderRect.iBr.iY = volumeBarHeight;
       
   962 
       
   963     if ( IsVisible() )
       
   964     {
       
   965         DrawNow();
       
   966     }
       
   967 }
       
   968 
       
   969 // -------------------------------------------------------------------------------------------------
       
   970 // CMPXVideoPlaybackVolumeBar::Reset
       
   971 // -------------------------------------------------------------------------------------------------
       
   972 //
       
   973 void CMPXVideoPlaybackVolumeBar::Reset()
       
   974 {
       
   975 	MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::Reset()"));
       
   976 
       
   977     if ( iDragging != EVolumeNotDragging )
       
   978     {
       
   979     	iDragging = EVolumeNotDragging;
       
   980     }
       
   981 }
       
   982 
       
   983 // -------------------------------------------------------------------------------------------------
       
   984 // CMPXVideoPlaybackVolumeBar::SetVolumeL()
       
   985 // -------------------------------------------------------------------------------------------------
       
   986 //
       
   987 void CMPXVideoPlaybackVolumeBar::SetVolumeL( TInt aVolume )
       
   988 {
       
   989     MPX_DEBUG(_L("CMPXVideoPlaybackVolumeBar::SetVolumeL(%d)"), aVolume);
       
   990        
       
   991     iController->HandleCommandL( EMPXPbvCmdSetVolume, aVolume );
       
   992 }
       
   993 
       
   994 //  End of File