67 |
67 |
68 const TInt KRedrawTime = 250000; // 0.25 sec |
68 const TInt KRedrawTime = 250000; // 0.25 sec |
69 const TInt KRedrawTimeForLayoutSwitch = 700000; // 0.7 sec |
69 const TInt KRedrawTimeForLayoutSwitch = 700000; // 0.7 sec |
70 const TInt KHighlighActivationTime = 100000; // 100 ms |
70 const TInt KHighlighActivationTime = 100000; // 100 ms |
71 const TInt KUpdateGridTime = 0; // imediately |
71 const TInt KUpdateGridTime = 0; // imediately |
|
72 const TInt KOrientationSwitchTime = 1000000; // 1 sec |
72 |
73 |
73 const TInt KMaxGranularity = 4; |
74 const TInt KMaxGranularity = 4; |
74 |
75 |
75 // ----------------------------------------------------------------------------- |
76 // ----------------------------------------------------------------------------- |
76 // CTsFastSwapArea::NewL |
77 // CTsFastSwapArea::NewL |
107 // |
108 // |
108 CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent, |
109 CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent, |
109 CTsDeviceState& aDeviceState, |
110 CTsDeviceState& aDeviceState, |
110 CTsEventControler& aEventHandler) : |
111 CTsEventControler& aEventHandler) : |
111 iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler), |
112 iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler), |
112 iPreviousNoOfItems(0) |
113 iPreviousNoOfItems(0), iIgnoreLayoutSwitch(EFalse) |
113 { |
114 { |
114 // no implementation required |
115 // no implementation required |
115 } |
116 } |
116 |
117 |
117 // ----------------------------------------------------------------------------- |
118 // ----------------------------------------------------------------------------- |
159 iRedrawTimer = new (ELeave) CTsFastSwapTimer( *this ); |
161 iRedrawTimer = new (ELeave) CTsFastSwapTimer( *this ); |
160 iRedrawTimer->ConstructL(); |
162 iRedrawTimer->ConstructL(); |
161 |
163 |
162 iUpdateGridTimer = new (ELeave) CTsFastSwapTimer( *this ); |
164 iUpdateGridTimer = new (ELeave) CTsFastSwapTimer( *this ); |
163 iUpdateGridTimer->ConstructL(); |
165 iUpdateGridTimer->ConstructL(); |
|
166 |
|
167 iOrientationSignalTimer = new (ELeave) CTsFastSwapTimer( *this ); |
|
168 iOrientationSignalTimer->ConstructL(); |
164 |
169 |
165 ActivateL(); |
170 ActivateL(); |
166 } |
171 } |
167 |
172 |
168 // ----------------------------------------------------------------------------- |
173 // ----------------------------------------------------------------------------- |
324 void CTsFastSwapArea::SizeChanged() |
329 void CTsFastSwapArea::SizeChanged() |
325 { |
330 { |
326 TSLOG_CONTEXT( CTsFastSwapArea::SizeChanged, TSLOG_LOCAL ); |
331 TSLOG_CONTEXT( CTsFastSwapArea::SizeChanged, TSLOG_LOCAL ); |
327 TSLOG_IN(); |
332 TSLOG_IN(); |
328 |
333 |
329 if ( iGrid ) |
334 if ( iGrid && !iIgnoreLayoutSwitch ) |
330 { |
335 { |
331 // Grid needs to be recreated to proper reinitilize |
336 // Grid needs to be recreated to proper reinitilize |
332 // data with new layout values |
337 // data with new layout values |
333 TInt selIdx = SelectedIndex(); |
338 TInt selIdx = SelectedIndex(); |
334 TRAPD(err, |
339 TRAPD(err, |
335 ReCreateGridL(); |
340 ReCreateGridL(); |
336 iEvtHandler.ReInitPhysicsL(GridWorldSize(), ViewSize(), ETrue);); |
341 /*iEvtHandler.ReInitPhysicsL(GridWorldSize(), ViewSize(), ETrue);*/); |
337 if ( err != KErrNone ) |
342 if ( err != KErrNone ) |
338 { |
343 { |
339 TSLOG1( TSLOG_INFO, "ReCreateGridL leaves with %d", err ); |
344 TSLOG1( TSLOG_INFO, "ReCreateGridL leaves with %d", err ); |
340 } |
345 } |
341 HandleFswContentChanged(); |
346 HandleFswContentChanged(); |
381 TInt wgId = iArray[aIndex]->WgId(); |
386 TInt wgId = iArray[aIndex]->WgId(); |
382 // Move other app to foreground and then move ourselves to background. |
387 // Move other app to foreground and then move ourselves to background. |
383 // Order is important and cannot be reversed. |
388 // Order is important and cannot be reversed. |
384 iFSClient->SwitchToApp( wgId ); |
389 iFSClient->SwitchToApp( wgId ); |
385 // We do not want to come back to ts if the activated app is closed. |
390 // We do not want to come back to ts if the activated app is closed. |
386 // Therefore ts must be moved to background. |
391 // Therefore ts must be moved to background. Ignore orientation updates, it |
|
392 // will be done after task switcher is sent to background |
|
393 iIgnoreLayoutSwitch = ETrue; |
387 CTsAppUi* appui = |
394 CTsAppUi* appui = |
388 static_cast<CTsAppUi*>( iEikonEnv->AppUi() ); |
395 static_cast<CTsAppUi*>( iEikonEnv->AppUi() ); |
389 appui->MoveAppToBackground( CTsAppUi::EActivationTransition ); |
396 appui->MoveAppToBackground( CTsAppUi::EActivationTransition ); |
|
397 iIgnoreLayoutSwitch = EFalse; |
|
398 |
|
399 // Orientation update |
|
400 iPrevScreenOrientation = -1; // force orientation reinit |
|
401 iOrientationSignalTimer->Cancel(); |
|
402 iOrientationSignalTimer->After(KOrientationSwitchTime); |
390 } |
403 } |
391 } |
404 } |
392 |
405 |
393 // -------------------------------------------------------------------------- |
406 // -------------------------------------------------------------------------- |
394 // CTsFastSwapArea::TryCloseAppL |
407 // CTsFastSwapArea::TryCloseAppL |
1022 } |
1040 } |
1023 else if( aSource == iUpdateGridTimer ) |
1041 else if( aSource == iUpdateGridTimer ) |
1024 { |
1042 { |
1025 UpdateGrid(ETrue, ETrue); |
1043 UpdateGrid(ETrue, ETrue); |
1026 } |
1044 } |
|
1045 else if ( aSource == iOrientationSignalTimer ) |
|
1046 { |
|
1047 TInt currentOrientation = GetCurrentScreenOrientation(); |
|
1048 if ( currentOrientation != iPrevScreenOrientation ) |
|
1049 { |
|
1050 // Order layout change |
|
1051 static_cast<CAknAppUi*>(iCoeEnv->AppUi())->HandleResourceChangeL(KEikDynamicLayoutVariantSwitch); |
|
1052 iRedrawTimer->Cancel(); |
|
1053 iRedrawTimer->After(KRedrawTime); |
|
1054 } |
|
1055 } |
1027 } |
1056 } |
1028 |
1057 |
1029 |
1058 |
1030 // ----------------------------------------------------------------------------- |
1059 // ----------------------------------------------------------------------------- |
1031 // CTsFastSwapArea::PreCreatePopupL |
1060 // CTsFastSwapArea::PreCreatePopupL |
1322 |
1350 |
1323 // -------------------------------------------------------------------------- |
1351 // -------------------------------------------------------------------------- |
1324 // CTsFastSwapArea::MoveOffset |
1352 // CTsFastSwapArea::MoveOffset |
1325 // -------------------------------------------------------------------------- |
1353 // -------------------------------------------------------------------------- |
1326 // |
1354 // |
1327 void CTsFastSwapArea::MoveOffset(const TPoint& aPoint) |
1355 void CTsFastSwapArea::MoveOffset(const TPoint& aPoint, TBool aDrawNow) |
1328 { |
1356 { |
1329 TSLOG_CONTEXT( CTsFastSwapArea::MoveOffset, TSLOG_LOCAL ); |
1357 TSLOG_CONTEXT( CTsFastSwapArea::MoveOffset, TSLOG_LOCAL ); |
1330 TSLOG2_IN("Old position x: %d, y:%d", ViewPos().iX, ViewPos().iY); |
1358 TSLOG2_IN("Old position x: %d, y:%d", ViewPos().iX, ViewPos().iY); |
1331 TSLOG2_IN("New position x: %d, y:%d", aPoint.iX, aPoint.iY); |
1359 TSLOG2_IN("New position x: %d, y:%d", aPoint.iX, aPoint.iY); |
1332 TSLOG_OUT(); |
1360 TSLOG_OUT(); |
1333 |
1361 |
1334 //ignore case when drag occurs outside owned area |
|
1335 if( iIgnorePhysicsMove ) |
|
1336 { |
|
1337 return; |
|
1338 } |
|
1339 //postpone center item request in case of being moved |
1362 //postpone center item request in case of being moved |
1340 if(iUpdateGridTimer->IsActive()) |
1363 if(iUpdateGridTimer->IsActive()) |
1341 { |
1364 { |
1342 iUpdateGridTimer->Cancel(); |
1365 iUpdateGridTimer->Cancel(); |
1343 iUpdateGridTimer->After(KUpdateGridTime); |
1366 iUpdateGridTimer->After(KUpdateGridTime); |
1344 } |
1367 } |
1345 |
1368 |
1346 TInt currentXPos = aPoint.iX; |
1369 if ( aDrawNow ) |
1347 currentXPos -= Rect().Width() / 2; |
1370 { |
1348 TRect gridViewRect = Rect(); |
1371 TInt currentXPos = aPoint.iX; |
1349 gridViewRect.iTl.iX = -currentXPos; |
1372 currentXPos -= Rect().Width() / 2; |
1350 // Take edge offset into account |
1373 TRect gridViewRect = Rect(); |
1351 gridViewRect.iTl.iX += Rect().iTl.iX; |
1374 gridViewRect.iTl.iX = -currentXPos; |
1352 if(GridItemCount() <= iMaxItemsOnScreen) |
1375 // Take edge offset into account |
1353 { |
1376 gridViewRect.iTl.iX += Rect().iTl.iX; |
1354 // Center view |
1377 if(GridItemCount() <= iMaxItemsOnScreen) |
1355 gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
1378 { |
1356 } |
1379 // Center view |
1357 iGrid->SetRect( gridViewRect ); |
1380 gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
1358 DrawDeferred(); |
1381 } |
|
1382 iGrid->SetRect( gridViewRect ); |
|
1383 DrawDeferred(); |
|
1384 iLogicalViewPosOffset = 0; |
|
1385 } |
|
1386 else |
|
1387 { |
|
1388 // Update logical view position |
|
1389 iLogicalViewPosOffset = aPoint.iX - ViewPos().iX; |
|
1390 } |
1359 } |
1391 } |
1360 |
1392 |
1361 // -------------------------------------------------------------------------- |
1393 // -------------------------------------------------------------------------- |
1362 // CTsFastSwapArea::Tap |
1394 // CTsFastSwapArea::Tap |
1363 // -------------------------------------------------------------------------- |
1395 // -------------------------------------------------------------------------- |
1413 const MAknTouchGestureFwDragEvent& aEvent) |
1445 const MAknTouchGestureFwDragEvent& aEvent) |
1414 { |
1446 { |
1415 if( aEvent.State() == EAknTouchGestureFwStop) |
1447 if( aEvent.State() == EAknTouchGestureFwStop) |
1416 { |
1448 { |
1417 CenterItem( KUpdateGridTime ); |
1449 CenterItem( KUpdateGridTime ); |
1418 } |
|
1419 if( !Rect().Contains(aEvent.CurrentPosition()) ) |
|
1420 { |
|
1421 iIgnorePhysicsMove = ETrue; |
|
1422 return; |
|
1423 } |
|
1424 else |
|
1425 { |
|
1426 iIgnorePhysicsMove = EFalse; |
|
1427 } |
1450 } |
1428 |
1451 |
1429 iGrid->SetTactileFeedbackSupport(ETrue); |
1452 iGrid->SetTactileFeedbackSupport(ETrue); |
1430 iGrid->HideHighlight(); |
1453 iGrid->HideHighlight(); |
1431 } |
1454 } |
1638 TRAP_IGNORE( scrollBar->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
1662 TRAP_IGNORE( scrollBar->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
1639 CEikScrollBarFrame::EOff)); |
1663 CEikScrollBarFrame::EOff)); |
1640 } |
1664 } |
1641 } |
1665 } |
1642 |
1666 |
|
1667 |
|
1668 // ----------------------------------------------------------------------------- |
|
1669 // CTsFastSwapArea::GetCurrentScreenOrientation |
|
1670 // ----------------------------------------------------------------------------- |
|
1671 // |
|
1672 TInt CTsFastSwapArea::GetCurrentScreenOrientation() |
|
1673 { |
|
1674 TPixelsAndRotation availableRect; |
|
1675 iEikonEnv->ScreenDevice()->GetDefaultScreenSizeAndRotation(availableRect); |
|
1676 return availableRect.iPixelSize.iWidth > availableRect.iPixelSize.iHeight; |
|
1677 } |
|
1678 |
1643 // End of file |
1679 // End of file |