mpxplugins/viewplugins/views/commonplaybackview/src/mpxcommonplaybackviewcontainer.cpp
changeset 1 8118492f1bdf
parent 0 ff3acec5bc43
child 11 943ff5625028
equal deleted inserted replaced
0:ff3acec5bc43 1:8118492f1bdf
    99     CreateWindowL();
    99     CreateWindowL();
   100 
   100 
   101     TAknWindowLineLayout screenLayout =
   101     TAknWindowLineLayout screenLayout =
   102         AknLayout::screen();
   102         AknLayout::screen();
   103     TRect screenRect = screenLayout.Rect();
   103     TRect screenRect = screenLayout.Rect();
   104     iBackground = CAknsBasicBackgroundControlContext::NewL(
   104 	iBackground = CAknsBasicBackgroundControlContext::NewL(
   105         KAknsIIDQsnBgAreaMainMp, screenRect, EFalse );
   105 			KAknsIIDQsnBgAreaMain, screenRect, EFalse );
   106 
   106 
   107 	iSeekTimer = CPeriodic::NewL( EPriorityLow );
   107 	iSeekTimer = CPeriodic::NewL( EPriorityLow );
   108 
   108 
   109     TInt flags( 0 );
   109     TInt flags( 0 );
   110     CRepository* repository = CRepository::NewL( KCRUidMPXMPFeatures );
   110     CRepository* repository = CRepository::NewL( KCRUidMPXMPFeatures );
   114 
   114 
   115     iEnableMarquee = static_cast<TBool>( flags & KMPXMarqueeArtistName );
   115     iEnableMarquee = static_cast<TBool>( flags & KMPXMarqueeArtistName );
   116 
   116 
   117     iEnableButtons = static_cast<TBool>( flags & KMPXRockerMappingSupport );
   117     iEnableButtons = static_cast<TBool>( flags & KMPXRockerMappingSupport );
   118 
   118 
   119     CreateBackgroundImagesL();
       
   120 
   119 
   121     // Create labels
   120     // Create labels
   122     CreateLabelsL();
   121     CreateLabelsL();
   123     iLabels[ETextPlaylistCount]->MakeVisible( ETrue );
   122     iLabels[ETextPlaylistCount]->MakeVisible( ETrue );
   124 
   123 
   203     iLabels.ResetAndDestroy();
   202     iLabels.ResetAndDestroy();
   204     delete iMinSecFormatString;
   203     delete iMinSecFormatString;
   205     delete iShortFormatString;
   204     delete iShortFormatString;
   206     delete iCommonUiHelper;
   205     delete iCommonUiHelper;
   207 
   206 
   208     delete iOffScreenBitmap;
   207 
   209     delete iOSBitmapContext;
   208 
   210     delete iOSBitmapDevice;
   209 
   211 
   210 
   212     delete iButtonManager;
   211     delete iButtonManager;
   213 
   212 
   214    MTouchFeedback* feedback = MTouchFeedback::Instance();
   213    MTouchFeedback* feedback = MTouchFeedback::Instance();
   215    if (feedback)
   214    if (feedback)
   776     {
   775     {
   777     CCoeControl::HandleResourceChange( aType );
   776     CCoeControl::HandleResourceChange( aType );
   778 
   777 
   779     if ( aType == KAknsMessageSkinChange )
   778     if ( aType == KAknsMessageSkinChange )
   780         {
   779         {
   781 		iRefreshBackBuffer = ETrue;
       
   782         // Reload icons
   780         // Reload icons
   783         TRAP_IGNORE(
   781         TRAP_IGNORE(
   784             {
   782             {
   785             CreateIconsL();
   783             CreateIconsL();
   786             } );
   784             } );
   792     else if ( aType == KEikDynamicLayoutVariantSwitch )
   790     else if ( aType == KEikDynamicLayoutVariantSwitch )
   793         {
   791         {
   794         iLayoutObserver->HandleLayoutChange();
   792         iLayoutObserver->HandleLayoutChange();
   795         UpdateBackgroundSkinControlContext( Rect() );
   793         UpdateBackgroundSkinControlContext( Rect() );
   796 
   794 
   797         // recreate background image
       
   798         TRAP_IGNORE( CreateBackgroundImagesL() );
       
   799         }
   795         }
   800     else
   796     else
   801         {
   797         {
   802         // pass
   798         // pass
   803         }
   799         }
   841             {
   837             {
   842             label->StartMarquee();
   838             label->StartMarquee();
   843             label->DrawDeferred();
   839             label->DrawDeferred();
   844             }
   840             }
   845         }
   841         }
   846     }
       
   847 
       
   848 // ---------------------------------------------------------------------------
       
   849 // Creates background images
       
   850 // ---------------------------------------------------------------------------
       
   851 //
       
   852 EXPORT_C void CMPXCommonPlaybackViewContainer::CreateBackgroundImagesL()
       
   853     {
       
   854 
       
   855     CWindowGc& gc( SystemGc() );
       
   856     CGraphicsDevice* device( gc.Device() );
       
   857     TSize size( device->SizeInPixels() );
       
   858     TDisplayMode mode( device->DisplayMode() );
       
   859 
       
   860     if( iOffScreenBitmap && 
       
   861 		size == iOffScreenBitmap->SizeInPixels() &&
       
   862 		mode == iOffScreenBitmap->DisplayMode() )
       
   863     	{
       
   864 		// No need to update backbuffer
       
   865     	return;
       
   866     	}
       
   867 
       
   868     delete iOffScreenBitmap;
       
   869     iOffScreenBitmap = NULL;
       
   870     delete iOSBitmapContext;
       
   871     iOSBitmapContext = NULL;
       
   872     delete iOSBitmapDevice;
       
   873     iOSBitmapDevice = NULL;
       
   874 
       
   875     iOffScreenBitmap = new (ELeave) CFbsBitmap();
       
   876     TInt err( iOffScreenBitmap->Create( size, mode ));
       
   877     if ( KErrNone != err )
       
   878         {
       
   879         delete iOffScreenBitmap;
       
   880         iOffScreenBitmap = NULL;
       
   881         User::Leave( err );
       
   882         }
       
   883 
       
   884     iOSBitmapDevice = CFbsBitmapDevice::NewL( iOffScreenBitmap );
       
   885     err = iOSBitmapDevice->CreateContext( iOSBitmapContext );
       
   886     if ( KErrNone != err )
       
   887         {
       
   888         delete iOSBitmapDevice;
       
   889         iOSBitmapDevice = NULL;
       
   890         User::Leave( err );
       
   891         }
       
   892     iRefreshBackBuffer = ETrue;
       
   893     }
   842     }
   894 
   843 
   895 // ---------------------------------------------------------------------------
   844 // ---------------------------------------------------------------------------
   896 // Creates labels.
   845 // Creates labels.
   897 // ---------------------------------------------------------------------------
   846 // ---------------------------------------------------------------------------
   987 // ---------------------------------------------------------------------------
   936 // ---------------------------------------------------------------------------
   988 // Draw an icon
   937 // Draw an icon
   989 // ---------------------------------------------------------------------------
   938 // ---------------------------------------------------------------------------
   990 //
   939 //
   991 EXPORT_C void CMPXCommonPlaybackViewContainer::DrawIndicator(
   940 EXPORT_C void CMPXCommonPlaybackViewContainer::DrawIndicator(
   992     CBitmapContext& aGc,
   941     CWindowGc& aGc ,
   993     const TRect& aDirtyRect,
   942     const TRect& aDirtyRect,
   994     const TRect& aIndicatorRect,
   943     const TRect& aIndicatorRect,
   995     const CGulIcon* aIcon,
   944     const CGulIcon* aIcon,
   996     TBool aInvertMask ) const
   945     TBool aInvertMask ) const
   997     {
   946     {
  1009 // ---------------------------------------------------------------------------
   958 // ---------------------------------------------------------------------------
  1010 // Redraw part of the screen.
   959 // Redraw part of the screen.
  1011 // ---------------------------------------------------------------------------
   960 // ---------------------------------------------------------------------------
  1012 //
   961 //
  1013 EXPORT_C void CMPXCommonPlaybackViewContainer::RedrawRect(
   962 EXPORT_C void CMPXCommonPlaybackViewContainer::RedrawRect(
  1014     const TRect& aRect,
   963     const TRect& aRect) const
  1015     CBitmapContext& aGc) const
   964     {
  1016     {
   965 	CWindowGc& gc = SystemGc();
  1017     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   966     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  1018     AknsDrawUtils::DrawBackground(
   967 
  1019         skin,
   968 	AknsDrawUtils::Background( skin, iBackground,
  1020         iBackground,
   969 			this, gc, aRect );
  1021         this,
       
  1022         aGc,
       
  1023         aRect.iTl,
       
  1024         aRect,
       
  1025         KAknsDrawParamDefault );
       
  1026 
       
  1027 
   970 
  1028     TBool embedded = iEikonEnv->StartedAsServerApp();
   971     TBool embedded = iEikonEnv->StartedAsServerApp();
  1029 
   972 
  1030     if ( iPrerollCompleted )
   973     if ( iPrerollCompleted )
  1031         {
   974         {
  1032         if ( iRepeatAllMode && !embedded )
   975         if ( iRepeatAllMode && !embedded )
  1033             {
   976             {
  1034             DrawIndicator( aGc, aRect, iRepeatIconRect, iRepeatAllIcon );
   977             DrawIndicator( gc, aRect, iRepeatIconRect, iRepeatAllIcon );
  1035             }
   978             }
  1036 
   979 
  1037         if ( iRepeatOneMode && !embedded )
   980         if ( iRepeatOneMode && !embedded )
  1038             {
   981             {
  1039             DrawIndicator(aGc, aRect, iRepeatIconRect, iRepeatOneIcon);
   982             DrawIndicator(gc, aRect, iRepeatIconRect, iRepeatOneIcon);
  1040             }
   983             }
  1041 
   984 
  1042         if ( iRandomMode && !embedded )
   985         if ( iRandomMode && !embedded )
  1043             {
   986             {
  1044             DrawIndicator(aGc, aRect, iRandomIconRect, iRandomIcon);
   987             DrawIndicator(gc, aRect, iRandomIconRect, iRandomIcon);
  1045             }
   988             }
  1046 
   989 
  1047 #ifdef RD_RA_SUPPORT_FOR_MUSIC_PLAYER
   990 #ifdef RD_RA_SUPPORT_FOR_MUSIC_PLAYER
  1048         if ( iRealAudioMode )
   991         if ( iRealAudioMode )
  1049             {
   992             {
  1050             DrawIndicator( aGc, aRect, iRealIconRect, iRealIcon );
   993             DrawIndicator( gc, aRect, iRealIconRect, iRealIcon );
  1051             }
   994             }
  1052 #endif
   995 #endif
  1053 
   996 
  1054         DrawIndicator( aGc, aRect, iSliderBackgroundRect, iSliderBackground );
   997         DrawIndicator( gc, aRect, iSliderBackgroundRect, iSliderBackground );
  1055         if ( iMode == EPlayMode || iMode == EPauseMode )
   998         if ( iMode == EPlayMode || iMode == EPauseMode )
  1056             {
   999             {
  1057 
  1000 
  1058             DrawIndicator( aGc, aRect, TRect(iDownloadSliderRect.iTl,
  1001             DrawIndicator( gc, aRect, TRect(iDownloadSliderRect.iTl,
  1059                     iDownloadSlider->Bitmap()->SizeInPixels()),
  1002                     iDownloadSlider->Bitmap()->SizeInPixels()),
  1060                     iDownloadSlider );
  1003                     iDownloadSlider );
  1061             DrawIndicator(aGc, aRect, TRect(iPlaybackSliderRect.iTl,
  1004             DrawIndicator(gc, aRect, TRect(iPlaybackSliderRect.iTl,
  1062                     iPlaybackSlider->Bitmap()->SizeInPixels() ),
  1005                     iPlaybackSlider->Bitmap()->SizeInPixels() ),
  1063                     iPlaybackSlider );
  1006                     iPlaybackSlider );
  1064             }
  1007             }
  1065 
  1008 
  1066         if ( iDisplayAlbumArt && aRect.Intersects( iAlbumArtRect ) )
  1009         if ( iDisplayAlbumArt && aRect.Intersects( iAlbumArtRect ) )
  1077                 TPoint Centerpos = TPoint(xPos, yPos );
  1020                 TPoint Centerpos = TPoint(xPos, yPos );
  1078                 // bitmap top left corner position
  1021                 // bitmap top left corner position
  1079                 Centerpos += iAlbumArtRect.iTl;
  1022                 Centerpos += iAlbumArtRect.iTl;
  1080 
  1023 
  1081                 // Draw album art and frame
  1024                 // Draw album art and frame
  1082                 aGc.BitBlt( Centerpos, iTrackAlbumArt);
  1025                 gc.BitBlt( Centerpos, iTrackAlbumArt);
  1083                 TRgb color = KRgbBlack;
  1026                 TRgb color = KRgbBlack;
  1084                 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors,
  1027                 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors,
  1085                         EAknsCIQsnTextColorsCG50 );
  1028                         EAknsCIQsnTextColorsCG50 );
  1086                 TRect imageRect( Centerpos, iTrackAlbumArt->SizeInPixels() );
  1029                 TRect imageRect( Centerpos, iTrackAlbumArt->SizeInPixels() );
  1087                 aGc.SetPenStyle( CGraphicsContext::ESolidPen );
  1030                 gc.SetPenStyle( CGraphicsContext::ESolidPen );
  1088                 aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
  1031                 gc.SetBrushStyle( CGraphicsContext::ENullBrush );
  1089                 aGc.SetPenColor( color );
  1032                 gc.SetPenColor( color );
  1090                 aGc.DrawRect( imageRect );
  1033                 gc.DrawRect( imageRect );
  1091                 }
  1034                 }
  1092             else
  1035             else
  1093                 {
  1036                 {
  1094                 DrawIndicator( aGc, aRect, iAlbumArtRect, iDefaultAlbumArt );
  1037                 DrawIndicator( gc, aRect, iAlbumArtRect, iDefaultAlbumArt );
  1095                 }
  1038                 }
  1096             }
  1039             }
  1097         }
  1040         }
  1098     }
  1041     }
  1099 
  1042 
  1161 EXPORT_C void CMPXCommonPlaybackViewContainer::UpdateBackgroundSkinControlContext(
  1104 EXPORT_C void CMPXCommonPlaybackViewContainer::UpdateBackgroundSkinControlContext(
  1162     const TRect& aRect )
  1105     const TRect& aRect )
  1163     {
  1106     {
  1164     CAknsBasicBackgroundControlContext* background =
  1107     CAknsBasicBackgroundControlContext* background =
  1165         static_cast<CAknsBasicBackgroundControlContext*>( iBackground );
  1108         static_cast<CAknsBasicBackgroundControlContext*>( iBackground );
  1166 
       
  1167     if ( Layout_Meta_Data::IsLandscapeOrientation() )
  1109     if ( Layout_Meta_Data::IsLandscapeOrientation() )
  1168         {
  1110         {
  1169         TAknWindowLineLayout screenLayout =
  1111         TAknWindowLineLayout screenLayout =
  1170             AknLayout::screen();
  1112             AknLayout::screen();
  1171         TRect screenRect = screenLayout.Rect();
  1113         TRect screenRect = screenLayout.Rect();
  1172         background->SetBitmap( KAknsIIDQsnBgAreaMainMp );
  1114         background->SetBitmap( KAknsIIDQsnBgAreaMain );
  1173         background->SetRect( screenRect );
  1115         background->SetRect( screenRect );
       
  1116 
  1174         }
  1117         }
  1175     else
  1118     else
  1176         {
  1119         {
  1177         background->SetBitmap( KAknsIIDQsnBgAreaMainMp );
  1120         background->SetBitmap( KAknsIIDQsnBgAreaMain );
  1178         background->SetRect( aRect );
  1121         background->SetRect( aRect );        
  1179         }
  1122         }
  1180     iRefreshBackBuffer = ETrue;
  1123 
  1181     }
  1124     }
  1182 
  1125 
  1183 // ---------------------------------------------------------------------------
  1126 // ---------------------------------------------------------------------------
  1184 // Set FMTX mode.
  1127 // Set FMTX mode.
  1185 // FMTX label shouldn't appear in some playback views
  1128 // FMTX label shouldn't appear in some playback views
  1252 // Draws the control.
  1195 // Draws the control.
  1253 // ---------------------------------------------------------------------------
  1196 // ---------------------------------------------------------------------------
  1254 //
  1197 //
  1255 EXPORT_C void CMPXCommonPlaybackViewContainer::Draw( const TRect& aRect ) const
  1198 EXPORT_C void CMPXCommonPlaybackViewContainer::Draw( const TRect& aRect ) const
  1256     {
  1199     {
  1257     if( iActiveView || iRefreshBackBuffer )
  1200     RedrawRect(aRect);
  1258         {
       
  1259         if ( iOSBitmapContext )
       
  1260             {
       
  1261             RedrawRect( aRect, *iOSBitmapContext );
       
  1262             iRefreshBackBuffer = EFalse;
       
  1263             }
       
  1264         }
       
  1265 
       
  1266     // Draw off-screen bitmap to display
       
  1267     if ( iOffScreenBitmap )
       
  1268         {
       
  1269         CWindowGc& gc = SystemGc();
       
  1270 		gc.BitBlt( TPoint(),iOffScreenBitmap );
       
  1271         }
       
  1272     }
  1201     }
  1273 
  1202 
  1274 // -----------------------------------------------------------------------------
  1203 // -----------------------------------------------------------------------------
  1275 // CMPXCommonPlaybackViewContainer::HandleButtonCommandL
  1204 // CMPXCommonPlaybackViewContainer::HandleButtonCommandL
  1276 // -----------------------------------------------------------------------------
  1205 // -----------------------------------------------------------------------------
  1494         {
  1423         {
  1495         // Layout has not changed, do nothing
  1424         // Layout has not changed, do nothing
  1496         return;
  1425         return;
  1497         }
  1426         }
  1498 
  1427 
  1499     CreateBackgroundImagesL();
       
  1500 
  1428 
  1501     MPX_DEBUG5( "CMPXCommonPlaybackViewContainer::DoUpdateLayoutL() -- new layout: top-left (%d, %d) size (%d, %d)",
  1429     MPX_DEBUG5( "CMPXCommonPlaybackViewContainer::DoUpdateLayoutL() -- new layout: top-left (%d, %d) size (%d, %d)",
  1502         myRect.iTl.iX, myRect.iTl.iY, myRect.Size().iWidth, myRect.Size().iHeight );
  1430         myRect.iTl.iX, myRect.iTl.iY, myRect.Size().iWidth, myRect.Size().iHeight );
  1503 
  1431 
  1504     // Get layout data
  1432     // Get layout data