diff -r 137ebc85284b -r 1b758917cafc taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp --- a/taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp Tue May 25 12:29:32 2010 +0300 +++ b/taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp Wed Jun 09 09:29:04 2010 +0300 @@ -259,6 +259,8 @@ { TRAP_IGNORE(static_cast(iEikonEnv->AppUi())->RequestPopUpL()); } + variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; // double check to avoid layout panic + TAknLayoutScalableParameterLimits gridParams = AknLayoutScalable_Apps::cell_tport_appsw_pane_ParamLimits( variety ); TPoint empty( ELayoutEmpty, ELayoutEmpty ); @@ -322,6 +324,39 @@ // -------------------------------------------------------------------------- +// CTsFastSwapArea::LayoutGridView +// -------------------------------------------------------------------------- +// +void CTsFastSwapArea::LayoutGridViewL( TInt aItemCount ) + { + RArray rects; + CleanupClosePushL(rects); + rects.ReserveL(KLayoutItemCount); + GetFastSwapAreaRects(rects); + TAknLayoutRect gridItem = rects[1]; + CleanupStack::PopAndDestroy(&rects); + if ( aItemCount ) + { + iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(EFalse); + static_cast(&iParent)->EnableDragEvents(ETrue); + if ( AknLayoutUtils::LayoutMirrored() ) + { + iGrid->SetLayoutL( EFalse, EFalse, ETrue, aItemCount, 1, gridItem.Rect().Size(), iGridItemGap ); + } + else + { + iGrid->SetLayoutL( EFalse, ETrue, ETrue, aItemCount, 1, gridItem.Rect().Size(), iGridItemGap ); + } + } + else + { + iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); + static_cast(&iParent)->EnableDragEvents(EFalse); + } + } + + +// -------------------------------------------------------------------------- // CTsFastSwapArea::GetFastSwapAreaRects // -------------------------------------------------------------------------- // @@ -338,6 +373,7 @@ { TRAP_IGNORE(static_cast(iEikonEnv->AppUi())->RequestPopUpL()); } + variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; // double check to avoid layout panic gridAppPane.LayoutRect( Rect(), AknLayoutScalable_Apps::tport_appsw_pane( variety ) ); @@ -381,17 +417,22 @@ if ( iGrid && !iIgnoreLayoutSwitch ) { + // Cancel ongoing pointer event + iHandlePointerCandidate = EFalse; // Grid needs to be recreated to proper reinitilize // data with new layout values TInt selIdx = SelectedIndex(); - TRAPD(err, - /*ReCreateGridL()*/ - LayoutGridL() ); + TRAPD(err, + LayoutGridL(); + LayoutGridViewL( iArray.Count() ) + ); + if ( err != KErrNone ) { TSLOG1( TSLOG_INFO, "LayoutGridL leaves with %d", err ); } - HandleFswContentChanged(); + + // Update grid view iGrid->SetCurrentDataIndex(selIdx); UpdateGrid(ETrue, EFalse); iGrid->DrawDeferred(); @@ -497,11 +538,6 @@ if ( aIndex >= 0 && aIndex < iArray.Count() && CanClose( aIndex ) ) { - TInt selIdx = SelectedIndex(); - if ( selIdx > aIndex && selIdx > 0 ) - { - selIdx--; - } TInt wgId = iArray[aIndex]->WgId(); iFSClient->CloseApp( wgId ); iIsClosing.Append(wgId); @@ -509,45 +545,11 @@ { iWidgetClosingCount++; } - // The fsw content will change sooner or later - // but the updated content (without the closed app) will not - // come very fast. It looks better to the user if the item - // in the grid is removed right here, right now. - // If the app does not close for some reason then this is - // not fully correct but the app will then reappear on the next - // content-changed notification anyway. - delete iArray[aIndex]; - iArray.Remove( aIndex ); - NotifyChange(); - - // Hide highlight - if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly ) - { - iGrid->HideHighlight(); - } - // Update selection - TInt newItemCount = GridItemCount() - 1; - if ( aIndex == newItemCount ) - { - newItemCount--; - iGrid->SetCurrentDataIndex(newItemCount); - } - else - { - iGrid->SetCurrentDataIndex(selIdx); - } - // Render contect - if ( !aSuppressRendering ) - { - RenderContentL( ETrue ); - } // Orientation update iPrevScreenOrientation = GetCurrentScreenOrientation(); iOrientationSignalTimer->Cancel(); iOrientationSignalTimer->After(KOrientationSwitchTime); - - iPrevAppCount = iArray.Count(); } TSLOG_OUT(); @@ -559,23 +561,13 @@ // void CTsFastSwapArea::TryCloseAllL() { - // note the direction of the loop, this is needed because - // TryCloseAppL may modify the array - TBool changed = EFalse; for ( TInt i = iArray.Count() - 1; i >= 0; --i ) { if ( CanClose( i ) ) { TryCloseAppL( i, ETrue ); - changed = ETrue; } } - if ( changed ) - { - RenderContentL(); - RestoreSelectedIndex(); - UpdateGrid( ETrue, EFalse ); - } } // -------------------------------------------------------------------------- @@ -584,10 +576,14 @@ // TBool CTsFastSwapArea::CanClose( TInt aIndex ) const { - CTsFswEntry* e = iArray[aIndex]; - TBool canClose = !e->AlwaysShown() && !e->SystemApp(); - // Special cases: Menu - canClose |= e->AppUid() == KTsMenuUid; + TBool canClose(EFalse); + if ( aIndex >= 0 && aIndex < iArray.Count() ) + { + CTsFswEntry* e = iArray[aIndex]; + canClose = !e->AlwaysShown() && !e->SystemApp(); + // Special cases: Menu + canClose |= e->AppUid() == KTsMenuUid; + } return canClose; } @@ -695,31 +691,9 @@ RArray strokeItemArray; CleanupClosePushL(strokeItemArray); - RArray rects; - CleanupClosePushL(rects); - rects.ReserveL(KLayoutItemCount); - GetFastSwapAreaRects(rects); - TAknLayoutRect gridItem = rects[1]; - 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 ); - } - else - { - iGrid->SetLayoutL( EFalse, ETrue, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); - } - } - else - { - iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); - static_cast(&iParent)->EnableDragEvents(EFalse); - } - + // Update view based on number of items + LayoutGridViewL( iArray.Count() ); + for ( TInt i = 0; i < iArray.Count(); ++i ) { const TDesC& appName( iArray[i]->AppName() ); @@ -798,9 +772,13 @@ CleanupStack::Pop(iconArray); // refresh the items in the grid + iGrid->HandleItemAdditionL(); iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); + if ( SelectedIndex() >= GridItemCount() && GridItemCount() ) + { + iGrid->SetCurrentDataIndex( GridItemCount() - 1 ); + } UpdateGrid( ETrue, !aSuppressAnimation ); - iGrid->HandleItemAdditionL(); TSLOG_OUT(); } @@ -1503,8 +1481,8 @@ { if( aType == KAppKeyTypeShort ) { - // Switch to homescreen - SwitchToApp( KTsHomescreenUid ); + //SwitchToApp( KTsHomescreenUid ); + TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); } else if( aType == KAppKeyTypeLong ) {