--- a/taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp Fri Mar 12 15:41:49 2010 +0200
+++ b/taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswaparea.cpp Mon Mar 15 12:39:47 2010 +0200
@@ -69,6 +69,7 @@
const TInt KRedrawTimeForLayoutSwitch = 700000; // 0.7 sec
const TInt KHighlighActivationTime = 100000; // 100 ms
const TInt KUpdateGridTime = 0; // imediately
+const TInt KOrientationSwitchTime = 1000000; // 1 sec
const TInt KMaxGranularity = 4;
@@ -109,7 +110,7 @@
CTsDeviceState& aDeviceState,
CTsEventControler& aEventHandler) :
iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler),
- iPreviousNoOfItems(0)
+ iPreviousNoOfItems(0), iIgnoreLayoutSwitch(EFalse)
{
// no implementation required
}
@@ -127,6 +128,7 @@
delete iHighlightTimer;
delete iRedrawTimer;
delete iUpdateGridTimer;
+ delete iOrientationSignalTimer;
}
// -----------------------------------------------------------------------------
@@ -162,6 +164,9 @@
iUpdateGridTimer = new (ELeave) CTsFastSwapTimer( *this );
iUpdateGridTimer->ConstructL();
+ iOrientationSignalTimer = new (ELeave) CTsFastSwapTimer( *this );
+ iOrientationSignalTimer->ConstructL();
+
ActivateL();
}
@@ -326,14 +331,14 @@
TSLOG_CONTEXT( CTsFastSwapArea::SizeChanged, TSLOG_LOCAL );
TSLOG_IN();
- if ( iGrid )
+ if ( iGrid && !iIgnoreLayoutSwitch )
{
// Grid needs to be recreated to proper reinitilize
// data with new layout values
TInt selIdx = SelectedIndex();
TRAPD(err,
ReCreateGridL();
- iEvtHandler.ReInitPhysicsL(GridWorldSize(), ViewSize(), ETrue););
+ /*iEvtHandler.ReInitPhysicsL(GridWorldSize(), ViewSize(), ETrue);*/);
if ( err != KErrNone )
{
TSLOG1( TSLOG_INFO, "ReCreateGridL leaves with %d", err );
@@ -383,10 +388,18 @@
// Order is important and cannot be reversed.
iFSClient->SwitchToApp( wgId );
// We do not want to come back to ts if the activated app is closed.
- // Therefore ts must be moved to background.
+ // Therefore ts must be moved to background. Ignore orientation updates, it
+ // will be done after task switcher is sent to background
+ iIgnoreLayoutSwitch = ETrue;
CTsAppUi* appui =
static_cast<CTsAppUi*>( iEikonEnv->AppUi() );
appui->MoveAppToBackground( CTsAppUi::EActivationTransition );
+ iIgnoreLayoutSwitch = EFalse;
+
+ // Orientation update
+ iPrevScreenOrientation = -1; // force orientation reinit
+ iOrientationSignalTimer->Cancel();
+ iOrientationSignalTimer->After(KOrientationSwitchTime);
}
}
@@ -435,6 +448,11 @@
DrawDeferred();
iGrid->SetCurrentDataIndex(selIdx);
}
+
+ // Orientation update
+ iPrevScreenOrientation = GetCurrentScreenOrientation();
+ iOrientationSignalTimer->Cancel();
+ iOrientationSignalTimer->After(KOrientationSwitchTime);
}
TSLOG_OUT();
@@ -1024,6 +1042,17 @@
{
UpdateGrid(ETrue, ETrue);
}
+ else if ( aSource == iOrientationSignalTimer )
+ {
+ TInt currentOrientation = GetCurrentScreenOrientation();
+ if ( currentOrientation != iPrevScreenOrientation )
+ {
+ // Order layout change
+ static_cast<CAknAppUi*>(iCoeEnv->AppUi())->HandleResourceChangeL(KEikDynamicLayoutVariantSwitch);
+ iRedrawTimer->Cancel();
+ iRedrawTimer->After(KRedrawTime);
+ }
+ }
}
@@ -1282,12 +1311,11 @@
{
if ( aAnimate )
{
- iIgnorePhysicsMove = EFalse;
iEvtHandler.Animate( targetPoint );
}
else
{
- MoveOffset(targetPoint);
+ MoveOffset(targetPoint, ETrue);
iEvtHandler.StopAnimation();
}
if ( aForceRedraw )
@@ -1324,18 +1352,13 @@
// CTsFastSwapArea::MoveOffset
// --------------------------------------------------------------------------
//
-void CTsFastSwapArea::MoveOffset(const TPoint& aPoint)
+void CTsFastSwapArea::MoveOffset(const TPoint& aPoint, TBool aDrawNow)
{
TSLOG_CONTEXT( CTsFastSwapArea::MoveOffset, TSLOG_LOCAL );
TSLOG2_IN("Old position x: %d, y:%d", ViewPos().iX, ViewPos().iY);
TSLOG2_IN("New position x: %d, y:%d", aPoint.iX, aPoint.iY);
TSLOG_OUT();
-
- //ignore case when drag occurs outside owned area
- if( iIgnorePhysicsMove )
- {
- return;
- }
+
//postpone center item request in case of being moved
if(iUpdateGridTimer->IsActive())
{
@@ -1343,19 +1366,28 @@
iUpdateGridTimer->After(KUpdateGridTime);
}
- TInt currentXPos = aPoint.iX;
- currentXPos -= Rect().Width() / 2;
- TRect gridViewRect = Rect();
- gridViewRect.iTl.iX = -currentXPos;
- // Take edge offset into account
- gridViewRect.iTl.iX += Rect().iTl.iX;
- if(GridItemCount() <= iMaxItemsOnScreen)
+ if ( aDrawNow )
{
- // Center view
- gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2;
+ TInt currentXPos = aPoint.iX;
+ currentXPos -= Rect().Width() / 2;
+ TRect gridViewRect = Rect();
+ gridViewRect.iTl.iX = -currentXPos;
+ // Take edge offset into account
+ gridViewRect.iTl.iX += Rect().iTl.iX;
+ if(GridItemCount() <= iMaxItemsOnScreen)
+ {
+ // Center view
+ gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2;
+ }
+ iGrid->SetRect( gridViewRect );
+ DrawDeferred();
+ iLogicalViewPosOffset = 0;
}
- iGrid->SetRect( gridViewRect );
- DrawDeferred();
+ else
+ {
+ // Update logical view position
+ iLogicalViewPosOffset = aPoint.iX - ViewPos().iX;
+ }
}
// --------------------------------------------------------------------------
@@ -1416,15 +1448,6 @@
{
CenterItem( KUpdateGridTime );
}
- if( !Rect().Contains(aEvent.CurrentPosition()) )
- {
- iIgnorePhysicsMove = ETrue;
- return;
- }
- else
- {
- iIgnorePhysicsMove = EFalse;
- }
iGrid->SetTactileFeedbackSupport(ETrue);
iGrid->HideHighlight();
@@ -1464,6 +1487,7 @@
// View centered
retVal.iX += ( Rect().Width() - gridItemCount * iGridItemWidth ) / 2;
}
+ retVal.iX += iLogicalViewPosOffset;
return retVal;
}
@@ -1640,4 +1664,16 @@
}
}
+
+// -----------------------------------------------------------------------------
+// CTsFastSwapArea::GetCurrentScreenOrientation
+// -----------------------------------------------------------------------------
+//
+TInt CTsFastSwapArea::GetCurrentScreenOrientation()
+ {
+ TPixelsAndRotation availableRect;
+ iEikonEnv->ScreenDevice()->GetDefaultScreenSizeAndRotation(availableRect);
+ return availableRect.iPixelSize.iWidth > availableRect.iPixelSize.iHeight;
+ }
+
// End of file