diff -r 9674c1a575e9 -r b8fae6b8a148 taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp --- a/taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp Mon Mar 15 12:39:47 2010 +0200 +++ b/taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp Wed Mar 31 21:17:19 2010 +0300 @@ -50,15 +50,8 @@ /** Number of closable applications, to show "close all" option. */ const TInt KTsMaxClosableApps = 2; -/** Uid of Active Idle application. - Used when movind Ai to specified position.*/ -const TUid KAiUid = TUid::Uid( 0x102750F0 ); - -/** Position of Ai in fsw grid.*/ -const TInt KAiPosition = 0; - /** Default grid item to highlight.*/ -const TInt KItemToHighlight = 3; +const TInt KItemToHighlight = 2; const TInt KAppKeyTypeShort = 1; const TInt KAppKeyTypeLong = 2; @@ -110,7 +103,7 @@ CTsDeviceState& aDeviceState, CTsEventControler& aEventHandler) : iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler), - iPreviousNoOfItems(0), iIgnoreLayoutSwitch(EFalse) + iIgnoreLayoutSwitch(EFalse) { // no implementation required } @@ -224,16 +217,17 @@ // Text colors TRgb textColor; AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, - KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); + KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); TRgb highlightTextColor; AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), highlightTextColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 ); CFormattedCellListBoxData::TColors colors; - colors.iText = textColor; + colors.iText = textColor; colors.iBack = iGrid->ItemDrawer()->BackColor(); colors.iHighlightedText = highlightTextColor; colors.iHighlightedBack = iGrid->ItemDrawer()->HighlightedBackColor(); iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL(1, colors); + iGrid->SetStrokeColors(textColor, highlightTextColor); // Setup grid observers if ( obs ) @@ -264,8 +258,6 @@ } iGridItemWidth = gridItem.Rect().Width(); - iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(EFalse); - // Update state HandleDeviceStateChanged( EDeviceType ); if( wasHighlight ) @@ -277,6 +269,10 @@ iGrid->HideHighlight(); } + HBufC* text = StringLoader::LoadLC( R_TS_FSW_NO_APPS ); + iGrid->SetEmptyGridTextL( *text ); + CleanupStack::PopAndDestroy( text ); + // Make sure that there is an ActivateL call even when we are not // called from ConstructL. (in order to have the grid's parent ptr set properly) ActivateL(); @@ -432,12 +428,14 @@ delete iArray[aIndex]; iArray.Remove( aIndex ); NotifyChange(); - if ( !aSuppressRendering ) + + // Hide highlight + if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly ) { - RenderContentL( ETrue ); + iGrid->HideHighlight(); } - // Update item selection on the screen if last item was deleted - TInt newItemCount = GridItemCount(); + // Update selection + TInt newItemCount = GridItemCount() - 1; if ( aIndex == newItemCount ) { newItemCount--; @@ -445,9 +443,13 @@ } else { - DrawDeferred(); iGrid->SetCurrentDataIndex(selIdx); } + // Render contect + if ( !aSuppressRendering ) + { + RenderContentL( ETrue ); + } // Orientation update iPrevScreenOrientation = GetCurrentScreenOrientation(); @@ -479,7 +481,7 @@ { RenderContentL(); RestoreSelectedIndex(); - UpdateGrid(); + UpdateGrid( ETrue, EFalse ); } } @@ -544,7 +546,6 @@ // get current content from fastswap server iFSClient->GetContentL( iArray ); - SwapApplicationOrder( iArray ); #ifdef _DEBUG for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) @@ -581,6 +582,8 @@ CleanupStack::PushL( textArray ); RArray closeItemArray; CleanupClosePushL(closeItemArray); + RArray strokeItemArray; + CleanupClosePushL(strokeItemArray); TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; RArray rects; @@ -591,6 +594,8 @@ CleanupStack::PopAndDestroy(&rects); if ( iArray.Count() ) { + iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(EFalse); + static_cast(&iParent)->EnableDragEvents(ETrue); if ( AknLayoutUtils::LayoutMirrored() ) { iGrid->SetLayoutL( EFalse, EFalse, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); @@ -600,6 +605,11 @@ iGrid->SetLayoutL( EFalse, ETrue, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); } } + else + { + iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); + static_cast(&iParent)->EnableDragEvents(EFalse); + } for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) { @@ -623,10 +633,16 @@ CFbsBitmap* mask = 0; if ( !h ) { + // No screenshot, take app icon h = iArray[i]->AppIconBitmapHandle(); maskh = iArray[i]->AppIconMaskHandle(); TSLOG1( TSLOG_INFO, "using appicon, handle = %d", h ); } + else + { + // Screenshot exists, mark it for stroke + strokeItemArray.AppendL(i); + } __ASSERT_DEBUG( h, User::Invariant() ); bitmap = CopyBitmapL( h, sz ); CleanupStack::PushL( bitmap ); @@ -658,8 +674,10 @@ } iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray); iGrid->SetCloseItemsL(closeItemArray); + iGrid->SetStrokeItemsL(strokeItemArray); // Cleanup + CleanupStack::PopAndDestroy(&strokeItemArray); CleanupStack::PopAndDestroy(&closeItemArray); CleanupStack::Pop(textArray); CleanupStack::Pop(iconArray); @@ -671,15 +689,7 @@ } // refresh the items in the grid - if(iPreviousNoOfItems < iArray.Count()) - { - iGrid->HandleItemAdditionL(); - } - else if(iPreviousNoOfItems > iArray.Count()) - { - iGrid->HandleItemRemovalL(); - } - iPreviousNoOfItems = iArray.Count(); + iGrid->HandleItemAdditionL(); iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); UpdateGrid( ETrue, !aSuppressAnimation ); @@ -703,7 +713,6 @@ // do not always use aSize, preserving the aspect ratio is quite // important when showing app icons instead of screenshots TSize sz = CalculateSizePreserveRatio( aSize, bmp->SizeInPixels() ); - User::LeaveIfError( ret->Create( sz, bmp->DisplayMode() ) ); AknIconUtils::ScaleBitmapL( sz, ret, bmp ); @@ -757,12 +766,6 @@ // Reset grid TRAP_IGNORE( ReCreateGridL() ); - - // get the current task list - HandleFswContentChanged(); - // and then start listening for changes - iFSClient->Subscribe( *this ); - if ( iDeviceState.DeviceType() == CTsDeviceState::EFullTouch ) { iGrid->HideHighlight(); @@ -772,6 +775,11 @@ iGrid->ShowHighlight(); } + // get the current task list + HandleFswContentChanged(); + // and then start listening for changes + iFSClient->Subscribe( *this ); + RestoreSelectedIndex(); UpdateGrid(EFalse, EFalse); @@ -816,7 +824,6 @@ TEventCode aType ) { iKeyEvent = ETrue; - iGrid->SetTactileFeedbackSupport(EFalse); // handle the 'clear' key if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace ) { @@ -913,7 +920,6 @@ void CTsFastSwapArea::HandlePointerEventL( const TPointerEvent& aPointerEvent ) { iKeyEvent = EFalse; - iGrid->SetTactileFeedbackSupport(ETrue); if(aPointerEvent.iType == TPointerEvent::EButton1Down) { iTapEvent = aPointerEvent; @@ -947,7 +953,7 @@ iSavedSelectedIndex = KErrNotFound; if ( GridItemCount() ) { - // highlight second recent item (that has index 2) if possible + // highlight second recent item (that has index 1) if possible TInt highlightItem = 0; TInt count = GridItemCount(); while( highlightItem < count @@ -1137,26 +1143,6 @@ } // ----------------------------------------------------------------------------- -// CTsFastSwapArea::SwapApplicationOrder -// ----------------------------------------------------------------------------- -// -void CTsFastSwapArea::SwapApplicationOrder( - RPointerArray& aArray ) - { - for ( TInt i = 0; i < aArray.Count(); ++i ) - { - if( aArray[i]->AppUid() == KAiUid ) - { - CTsFswEntry* homescreenEntry(0); - homescreenEntry = aArray[i]; - aArray.Remove(i); - aArray.Insert(homescreenEntry, KAiPosition); - break; - } - } - } - -// ----------------------------------------------------------------------------- // CTsFastSwapArea::PreferredImageSize // ----------------------------------------------------------------------------- // @@ -1219,20 +1205,16 @@ const TSize& aTargetAreaSize, const TSize& aSourceSize ) { - TSize sz; - if ( aSourceSize.iWidth > aSourceSize.iHeight ) - { - sz.iWidth = aTargetAreaSize.iWidth; - TReal ratio = aSourceSize.iWidth / (TReal) aSourceSize.iHeight; - sz.iHeight = sz.iWidth / ratio; - } - else - { - sz.iHeight = aTargetAreaSize.iHeight; - TReal ratio = aSourceSize.iHeight / (TReal) aSourceSize.iWidth; - sz.iWidth = sz.iHeight / ratio; - } - return sz; + const TReal + resizedAspectRatio(aTargetAreaSize.iWidth/(TReal)aTargetAreaSize.iHeight); + const TReal + orginalAspectRatio(aSourceSize.iWidth/(TReal)aSourceSize.iHeight); + //this condition avoid empty margins ( bigger output ). to realy fit area change it + const TReal scaleFactor = + ( orginalAspectRatio > resizedAspectRatio ) ? + (aTargetAreaSize.iHeight /(TReal)aSourceSize.iHeight) ://scale by height + (aTargetAreaSize.iWidth /(TReal)aSourceSize.iWidth) ;//scale by width + return TSize(aSourceSize.iWidth * scaleFactor, aSourceSize.iHeight * scaleFactor); } // -------------------------------------------------------------------------- @@ -1242,7 +1224,6 @@ void CTsFastSwapArea::SelectNextItem() { iKeyEvent = ETrue; - iGrid->SetTactileFeedbackSupport(EFalse); TBool forceRedraw(ETrue); TBool animate(ETrue); TInt selectedItem = SelectedIndex(); @@ -1282,7 +1263,7 @@ TPoint absViewPos = ViewPos(); absViewPos.iX -= Rect().Width() / 2; if( !iEvtHandler.IsPhysicsRunning() && - ( absViewPos.iX < 0 || absViewPos.iX + Rect().Width() > GridWorldSize().iWidth ) + ( absViewPos.iX < 0 ||( absViewPos.iX + Rect().Width() > GridWorldSize().iWidth && GridItemCount() ) ) ) { // View is outside of grid world - update view @@ -1320,6 +1301,7 @@ } if ( aForceRedraw ) { + iParent.DrawDeferred(); iGrid->DrawNow(); } } @@ -1331,20 +1313,27 @@ // void CTsFastSwapArea::HandleAppKey(TInt aType) { - if( aType == KAppKeyTypeShort ) + if ( iArray.Count() ) { - if(iGrid->IsHighlightVisible()) + if( aType == KAppKeyTypeShort ) { - SelectNextItem(); + if(iGrid->IsHighlightVisible()) + { + SelectNextItem(); + } + else + { + iGrid->ShowHighlight(); + } } - else + else if( aType == KAppKeyTypeLong ) { - iGrid->ShowHighlight(); + SwitchToApp( SelectedIndex() ); } } - else if( aType == KAppKeyTypeLong ) + else { - SwitchToApp( SelectedIndex() ); + TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); } } @@ -1374,13 +1363,13 @@ gridViewRect.iTl.iX = -currentXPos; // Take edge offset into account gridViewRect.iTl.iX += Rect().iTl.iX; - if(GridItemCount() <= iMaxItemsOnScreen) + if(GridItemCount() && GridItemCount() <= iMaxItemsOnScreen) { // Center view gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; } + DrawDeferred(); iGrid->SetRect( gridViewRect ); - DrawDeferred(); iLogicalViewPosOffset = 0; } else @@ -1396,7 +1385,7 @@ // void CTsFastSwapArea::TapL(const TPoint& aPoint) { - if(Rect().Contains(aPoint)) + if(Rect().Contains(aPoint) && iArray.Count()) { //provide tap pointer event to grid iGrid->HandlePointerEventL(iTapEvent); @@ -1417,7 +1406,7 @@ void CTsFastSwapArea::LongTapL(const TPoint& aPoint) { TInt index(KErrNotFound); - if( iGrid->GridView()->XYPosToItemIndex(aPoint,index) ) + if( iGrid->GridView()->XYPosToItemIndex(aPoint,index) && iArray.Count() ) { iGrid->SetCurrentItemIndex(index); SaveSelectedIndex(); @@ -1448,8 +1437,7 @@ { CenterItem( KUpdateGridTime ); } - - iGrid->SetTactileFeedbackSupport(ETrue); + iGrid->HideHighlight(); } @@ -1482,7 +1470,7 @@ retVal.iY = iGrid->Rect().iTl.iY + Rect().Height() / 2; retVal.iX = - (iGrid->Rect().iTl.iX - Rect().iTl.iX) + Rect().Width() / 2 ; TInt gridItemCount = iGrid->Model()->ItemTextArray()->MdcaCount(); - if( gridItemCount <= iMaxItemsOnScreen) + if(gridItemCount && gridItemCount <= iMaxItemsOnScreen) { // View centered retVal.iX += ( Rect().Width() - gridItemCount * iGridItemWidth ) / 2; @@ -1498,7 +1486,12 @@ TPoint CTsFastSwapArea::ItemViewPosition( TInt aItemIdx ) { TPoint retVal = Rect().iTl; - if ( aItemIdx == 0 ) + if ( aItemIdx < 0 ) + { + // No items + retVal.iX = 0; + } + else if ( aItemIdx == 0 ) { // First item if( AknLayoutUtils::LayoutMirrored() )