videoplayback/videoplaybackcontrols/src/mpxvideoplaybackbuttonbar.cpp
branchRCL_3
changeset 15 8f0df5c82986
parent 14 55fa1ec415c6
equal deleted inserted replaced
14:55fa1ec415c6 15:8f0df5c82986
    14 * Description: Button bar control
    14 * Description: Button bar control
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // Version : %version: 19 %
    19 // Version : %version: 20 %
    20 
    20 
    21 
    21 
    22 // INCLUDE FILES
    22 // INCLUDE FILES
    23 #include <eikenv.h>
    23 #include <eikenv.h>
    24 #include <barsread.h>
    24 #include <barsread.h>
   131 
   131 
   132     TFileName iconsPath;
   132     TFileName iconsPath;
   133     iController->LocateBitmapFileL( iconsPath );
   133     iController->LocateBitmapFileL( iconsPath );
   134 
   134 
   135     //
   135     //
   136     // Since button bar has 3 visible buttons - divide the height of aRect by 3
   136     //  Since button bar has 3 visible buttons - divide the height of aRect by 3
   137     //
   137     //
   138     TInt iconSize = Rect().Height() / 3;
   138     TInt iconSize = Rect().Height() / 3;
   139     TInt leftOffset = ( Rect().Width() - iconSize ) / 2 ;
   139     TInt leftOffset = ( Rect().Width() - iconSize ) / 2 ;
   140 
   140 
   141     //
   141     //
   277 // CMPXVideoPlaybackButtonBar::HandlePointerEventL()
   277 // CMPXVideoPlaybackButtonBar::HandlePointerEventL()
   278 // -------------------------------------------------------------------------------------------------
   278 // -------------------------------------------------------------------------------------------------
   279 //
   279 //
   280 void CMPXVideoPlaybackButtonBar::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   280 void CMPXVideoPlaybackButtonBar::HandlePointerEventL( const TPointerEvent& aPointerEvent )
   281 {
   281 {
   282     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::HandlePointerEventL()"));
   282     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackButtonBar::HandlePointerEventL()"));
   283 
   283 
   284     switch ( aPointerEvent.iType )
   284     switch ( aPointerEvent.iType )
   285     {
   285     {
   286         case TPointerEvent::EButton1Down:
   286         case TPointerEvent::EButton1Down:
   287         {
   287         {
   288             HandleButtonDownEventL( aPointerEvent );
   288             HandleButtonDownEventL( aPointerEvent );
   289 
       
   290             break;
   289             break;
   291         }
   290         }
   292         case TPointerEvent::EButton1Up:
   291         case TPointerEvent::EButton1Up:
   293         {
   292         {
   294             if ( iButtonPressed == EMPXTopButtonPressed ||
   293             if ( iButtonPressed == EMPXTopButtonPressed ||
   307                       ( iMiddleButtonRect.Contains( aPointerEvent.iPosition ) &&
   306                       ( iMiddleButtonRect.Contains( aPointerEvent.iPosition ) &&
   308                         iButtonPressed == EMPXNotPressed ) )
   307                         iButtonPressed == EMPXNotPressed ) )
   309             {
   308             {
   310                 HandleMiddleButtonUpEventL();
   309                 HandleMiddleButtonUpEventL();
   311             }
   310             }
   312             else
       
   313             {
       
   314                 //Pass an event to controller to call toggle visibility
       
   315             }
       
   316 
   311 
   317             iButtonPressed = EMPXNotPressed;
   312             iButtonPressed = EMPXNotPressed;
   318             break;
   313             break;
   319         }
   314         }
   320     }
   315     }
   324 // CMPXVideoPlaybackButtonBar::HandleButtonDownEventL()
   319 // CMPXVideoPlaybackButtonBar::HandleButtonDownEventL()
   325 // -------------------------------------------------------------------------------------------------
   320 // -------------------------------------------------------------------------------------------------
   326 //
   321 //
   327 void CMPXVideoPlaybackButtonBar::HandleButtonDownEventL( const TPointerEvent& aPointerEvent )
   322 void CMPXVideoPlaybackButtonBar::HandleButtonDownEventL( const TPointerEvent& aPointerEvent )
   328 {
   323 {
   329     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::HandleButtonDownEventL()"));
   324     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackButtonBar::HandleButtonDownEventL()"));
   330 
   325 
   331     if ( iSeekingTimer->IsActive() )
   326     if ( iSeekingTimer->IsActive() )
   332     {
   327     {
   333         iSeekingTimer->Cancel();
   328         iSeekingTimer->Cancel();
   334     }
   329     }
   369 // CMPXVideoPlaybackButtonBar::HandleTopButtonUpEventL()
   364 // CMPXVideoPlaybackButtonBar::HandleTopButtonUpEventL()
   370 // -------------------------------------------------------------------------------------------------
   365 // -------------------------------------------------------------------------------------------------
   371 //
   366 //
   372 void CMPXVideoPlaybackButtonBar::HandleTopButtonUpEventL( const TPointerEvent& aPointerEvent )
   367 void CMPXVideoPlaybackButtonBar::HandleTopButtonUpEventL( const TPointerEvent& aPointerEvent )
   373 {
   368 {
   374     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::HandleTopButtonUpEventL()"));
   369     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackButtonBar::HandleTopButtonUpEventL()"));
   375 
   370 
   376     if ( iSeekingTimer->IsActive() )
   371     if ( iSeekingTimer->IsActive() )
   377     {
   372     {
   378         iSeekingTimer->Cancel();
   373         iSeekingTimer->Cancel();
   379     }
   374     }
   414 // CMPXVideoPlaybackButtonBar::HandleMiddleButtonUpEventL()
   409 // CMPXVideoPlaybackButtonBar::HandleMiddleButtonUpEventL()
   415 // -------------------------------------------------------------------------------------------------
   410 // -------------------------------------------------------------------------------------------------
   416 //
   411 //
   417 void CMPXVideoPlaybackButtonBar::HandleMiddleButtonUpEventL()
   412 void CMPXVideoPlaybackButtonBar::HandleMiddleButtonUpEventL()
   418 {
   413 {
   419     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::HandleMiddleButtonUpEventL()"));
   414     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackButtonBar::HandleMiddleButtonUpEventL()"));
   420 
   415 
   421     switch ( iController->State() )
   416     switch ( iController->State() )
   422     {
   417     {
   423         case EPbStatePlaying:
   418         case EPbStatePlaying:
   424         {
   419         {
   464 // CMPXVideoPlaybackButtonBar::HandleBottomButtonUpEventL()
   459 // CMPXVideoPlaybackButtonBar::HandleBottomButtonUpEventL()
   465 // -------------------------------------------------------------------------------------------------
   460 // -------------------------------------------------------------------------------------------------
   466 //
   461 //
   467 void CMPXVideoPlaybackButtonBar::HandleBottomButtonUpEventL( const TPointerEvent& aPointerEvent )
   462 void CMPXVideoPlaybackButtonBar::HandleBottomButtonUpEventL( const TPointerEvent& aPointerEvent )
   468 {
   463 {
   469     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::HandleBottomButtonUpEventL()"));
   464     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackButtonBar::HandleBottomButtonUpEventL()"));
   470 
   465 
   471     if ( iSeekingTimer->IsActive() )
   466     if ( iSeekingTimer->IsActive() )
   472     {
   467     {
   473         iSeekingTimer->Cancel();
   468         iSeekingTimer->Cancel();
   474     }
   469     }
   493             iController->HandleCommandL( EMPXPbvCmdEndSeek );
   488             iController->HandleCommandL( EMPXPbvCmdEndSeek );
   494             iSeeking = EFalse;
   489             iSeeking = EFalse;
   495         }
   490         }
   496         else
   491         else
   497         {
   492         {
   498 			// Short press backward:
   493             // Short press backward:
   499             iController->HandleCommandL( EMPXPbvCmdShortPressBackward );
   494             iController->HandleCommandL( EMPXPbvCmdShortPressBackward );
   500         }
   495         }
   501     }
   496     }
   502 
   497 
   503     iButtons[EMPXButtonRewind]->HandlePointerEventL( aPointerEvent );
   498     iButtons[EMPXButtonRewind]->HandlePointerEventL( aPointerEvent );
   520 //   CMPXVideoPlaybackButtonBar::DoStartSeekingL()
   515 //   CMPXVideoPlaybackButtonBar::DoStartSeekingL()
   521 // -------------------------------------------------------------------------------------------------
   516 // -------------------------------------------------------------------------------------------------
   522 //
   517 //
   523 void CMPXVideoPlaybackButtonBar::DoStartSeekingL()
   518 void CMPXVideoPlaybackButtonBar::DoStartSeekingL()
   524 {
   519 {
   525     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::DoStartSeekingL()"));
   520     MPX_ENTER_EXIT(_L("CMPXVideoPlaybackButtonBar::DoStartSeekingL()"));
   526 
   521 
   527 #ifdef RD_TACTILE_FEEDBACK
   522 #ifdef RD_TACTILE_FEEDBACK
   528     if (iFeedback)
   523     if (iFeedback)
   529     {
   524     {
   530 #ifdef SYMBIAN_BUILD_GCE
   525 #ifdef SYMBIAN_BUILD_GCE
   558     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::Draw()"));
   553     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::Draw()"));
   559 
   554 
   560     CWindowGc& gc = SystemGc();
   555     CWindowGc& gc = SystemGc();
   561     gc.SetClippingRect( aRect );
   556     gc.SetClippingRect( aRect );
   562 
   557 
   563     if ( iController->SetBackgroundBlack() )
   558     if ( Window().DisplayMode() == EColor16MAP )
   564     {
   559     {
   565         if ( Window().DisplayMode() == EColor16MAP )
   560         gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
   566         {
   561         gc.SetBrushColor( TRgb::Color16MAP( 255 ) );
   567             gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
   562         gc.Clear( aRect );
   568             gc.SetBrushColor( TRgb::Color16MAP( 255 ) );
   563     }
   569             gc.Clear( aRect );
   564     else if ( Window().DisplayMode() == EColor16MA )
   570         }
   565     {
   571         else if ( Window().DisplayMode() == EColor16MA )
   566         gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
   572         {
   567         gc.SetBrushColor( TRgb::Color16MA( 0 ) );
   573             gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha );
   568         gc.Clear( aRect );
   574             gc.SetBrushColor( TRgb::Color16MA( 0 ) );
       
   575             gc.Clear( aRect );
       
   576         }
       
   577     }
       
   578     else
       
   579     {
       
   580         // draw a solid background so that the entire progress
       
   581         // bar is shown not just the area representing the
       
   582         // portion that has been played.
       
   583         gc.SetBrushColor( KRgbBlack );
       
   584         gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   585         gc.DrawRect( aRect );
       
   586         gc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   587     }
   569     }
   588 }
   570 }
   589 
   571 
   590 // -------------------------------------------------------------------------------------------------
   572 // -------------------------------------------------------------------------------------------------
   591 // CMPXVideoPlaybackButtonBar::CountComponentControls()
   573 // CMPXVideoPlaybackButtonBar::CountComponentControls()
   608 
   590 
   609     return control;
   591     return control;
   610 }
   592 }
   611 
   593 
   612 // -------------------------------------------------------------------------------------------------
   594 // -------------------------------------------------------------------------------------------------
   613 // CMPXVideoPlaybackButtonBar::StateChanged()
   595 // CMPXVideoPlaybackButtonBar::UpdateStateOnButtonBar()
   614 // -------------------------------------------------------------------------------------------------
   596 // -------------------------------------------------------------------------------------------------
   615 //
   597 //
   616 void CMPXVideoPlaybackButtonBar::UpdateStateOnButtonBar( TMPXPlaybackState aState )
   598 void CMPXVideoPlaybackButtonBar::UpdateStateOnButtonBar( TMPXPlaybackState aState )
   617 {
   599 {
   618     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::StateChanged(%d)"), aState);
   600     MPX_DEBUG(_L("CMPXVideoPlaybackButtonBar::UpdateStateOnButtonBar(%d)"), aState);
   619 
   601 
   620     switch ( aState )
   602     switch ( aState )
   621     {
   603     {
   622         case EPbStatePlaying:
   604         case EPbStatePlaying:
   623         {
   605         {
   654             break;
   636             break;
   655         }
   637         }
   656     }
   638     }
   657 }
   639 }
   658 
   640 
   659 
       
   660 // -------------------------------------------------------------------------------------------------
   641 // -------------------------------------------------------------------------------------------------
   661 // CMPXVideoPlaybackButtonBar::UpdateButtonBarState
   642 // CMPXVideoPlaybackButtonBar::UpdateButtonBarState
   662 // -------------------------------------------------------------------------------------------------
   643 // -------------------------------------------------------------------------------------------------
   663 //
   644 //
   664 void CMPXVideoPlaybackButtonBar::UpdateButtonBarState( CMPXVideoPlaybackViewFileDetails* aDetails )
   645 void CMPXVideoPlaybackButtonBar::UpdateButtonBarState( CMPXVideoPlaybackViewFileDetails* aDetails )
   669     {
   650     {
   670         iButtons[EMPXButtonRewind]->SetDimmed( EFalse );
   651         iButtons[EMPXButtonRewind]->SetDimmed( EFalse );
   671         iButtons[EMPXButtonFastForward]->SetDimmed( EFalse );
   652         iButtons[EMPXButtonFastForward]->SetDimmed( EFalse );
   672     }
   653     }
   673 
   654 
   674     if ( !aDetails->iPausableStream )
   655     if ( ! aDetails->iPausableStream )
   675     {
   656     {
   676         iButtons[EMPXButtonPause]->SetDimmed( ETrue );
   657         iButtons[EMPXButtonPause]->SetDimmed( ETrue );
   677     }
   658     }
   678 }
   659 }
   679 
   660 
   692         event.iType = TPointerEvent::EButton1Up;
   673         event.iType = TPointerEvent::EButton1Up;
   693         MPX_TRAPD( err, HandlePointerEventL(event) );
   674         MPX_TRAPD( err, HandlePointerEventL(event) );
   694     }
   675     }
   695 }
   676 }
   696 
   677 
   697 
       
   698 //  End of File
   678 //  End of File