392 TSLOG1( TSLOG_INFO, "LayoutGridL leaves with %d", err ); |
392 TSLOG1( TSLOG_INFO, "LayoutGridL leaves with %d", err ); |
393 } |
393 } |
394 HandleFswContentChanged(); |
394 HandleFswContentChanged(); |
395 iGrid->SetCurrentDataIndex(selIdx); |
395 iGrid->SetCurrentDataIndex(selIdx); |
396 UpdateGrid(ETrue, EFalse); |
396 UpdateGrid(ETrue, EFalse); |
397 DrawDeferred(); |
397 iGrid->DrawDeferred(); |
398 |
398 |
399 // Order full redraw after switch |
399 // Order full redraw after switch |
400 if(iRedrawTimer) |
400 if(iRedrawTimer) |
401 { |
401 { |
402 iRedrawTimer->Cancel(); |
402 iRedrawTimer->Cancel(); |
411 // CTsFastSwapArea::Draw |
411 // CTsFastSwapArea::Draw |
412 // ----------------------------------------------------------------------------- |
412 // ----------------------------------------------------------------------------- |
413 // |
413 // |
414 void CTsFastSwapArea::Draw( const TRect& /*aRect*/ ) const |
414 void CTsFastSwapArea::Draw( const TRect& /*aRect*/ ) const |
415 { |
415 { |
416 CWindowGc& gc = SystemGc(); |
416 // CWindowGc& gc = SystemGc(); |
417 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
417 // MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
418 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
418 // MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
419 AknsDrawUtils::Background( skin, |
419 // AknsDrawUtils::Background( skin, |
420 cc, |
420 // cc, |
421 this, |
421 // this, |
422 gc, |
422 // gc, |
423 Rect() ); |
423 // Rect() ); |
424 } |
424 } |
425 |
425 |
426 // -------------------------------------------------------------------------- |
426 // -------------------------------------------------------------------------- |
427 // CTsFastSwapArea::SwitchToApp |
427 // CTsFastSwapArea::SwitchToApp |
428 // -------------------------------------------------------------------------- |
428 // -------------------------------------------------------------------------- |
718 { |
718 { |
719 iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); |
719 iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); |
720 static_cast<CTsAppView*>(&iParent)->EnableDragEvents(EFalse); |
720 static_cast<CTsAppView*>(&iParent)->EnableDragEvents(EFalse); |
721 } |
721 } |
722 |
722 |
723 for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) |
723 for ( TInt i = 0; i < iArray.Count(); ++i ) |
724 { |
724 { |
725 const TDesC& appName( iArray[i]->AppName() ); |
725 const TDesC& appName( iArray[i]->AppName() ); |
726 const TInt formatLen = 3 + 2; |
726 const TInt formatLen = 3 + 2; |
727 RBuf formAppName; |
727 RBuf formAppName; |
728 CleanupClosePushL(formAppName); |
728 CleanupClosePushL(formAppName); |
783 } |
783 } |
784 iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray); |
784 iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray); |
785 iGrid->SetCloseItemsL(closeItemArray); |
785 iGrid->SetCloseItemsL(closeItemArray); |
786 iGrid->SetStrokeItemsL(strokeItemArray); |
786 iGrid->SetStrokeItemsL(strokeItemArray); |
787 |
787 |
|
788 // Update scrollbar visibility |
|
789 if( iGrid->ScrollBarFrame() ) |
|
790 { |
|
791 iGrid->SetScrollBarFrame(NULL,CEikListBox::EOwnedExternally); |
|
792 } |
|
793 |
788 // Cleanup |
794 // Cleanup |
789 CleanupStack::PopAndDestroy(&strokeItemArray); |
795 CleanupStack::PopAndDestroy(&strokeItemArray); |
790 CleanupStack::PopAndDestroy(&closeItemArray); |
796 CleanupStack::PopAndDestroy(&closeItemArray); |
791 CleanupStack::Pop(textArray); |
797 CleanupStack::Pop(textArray); |
792 CleanupStack::Pop(iconArray); |
798 CleanupStack::Pop(iconArray); |
793 |
799 |
794 if( iGrid->ScrollBarFrame() ) |
|
795 { |
|
796 iGrid->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
797 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff); |
|
798 } |
|
799 |
|
800 // refresh the items in the grid |
800 // refresh the items in the grid |
801 iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
801 iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
802 UpdateGrid( ETrue, !aSuppressAnimation ); |
802 UpdateGrid( ETrue, !aSuppressAnimation ); |
803 iGrid->HandleItemAdditionL(); |
803 iGrid->HandleItemAdditionL(); |
804 |
804 |
866 if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly ) |
866 if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly ) |
867 { |
867 { |
868 iGrid->HideHighlight(); |
868 iGrid->HideHighlight(); |
869 } |
869 } |
870 CancelLongTapAnimation(); |
870 CancelLongTapAnimation(); |
|
871 iGrid->MakeVisible(EFalse); |
|
872 iGrid->DrawNow(); |
871 } |
873 } |
872 |
874 |
873 // ----------------------------------------------------------------------------- |
875 // ----------------------------------------------------------------------------- |
874 // CTsFastSwapArea::HandleSwitchToForegroundEvent |
876 // CTsFastSwapArea::HandleSwitchToForegroundEvent |
875 // ----------------------------------------------------------------------------- |
877 // ----------------------------------------------------------------------------- |
913 UpdateGrid(EFalse, EFalse); |
915 UpdateGrid(EFalse, EFalse); |
914 |
916 |
915 iRedrawTimer->Cancel(); |
917 iRedrawTimer->Cancel(); |
916 iRedrawTimer->After(KRedrawTime); |
918 iRedrawTimer->After(KRedrawTime); |
917 |
919 |
918 itemDrawer->SetRedrawBackground(EFalse); |
|
919 |
|
920 // give feedback |
920 // give feedback |
921 LaunchPopupFeedback(); |
921 LaunchPopupFeedback(); |
922 |
922 |
923 iPrevAppCount = iArray.Count(); |
923 iPrevAppCount = iArray.Count(); |
|
924 |
|
925 iGrid->MakeVisible(ETrue); |
924 |
926 |
925 TSLOG_OUT(); |
927 TSLOG_OUT(); |
926 } |
928 } |
927 |
929 |
928 // ----------------------------------------------------------------------------- |
930 // ----------------------------------------------------------------------------- |
957 TEventCode aType ) |
959 TEventCode aType ) |
958 { |
960 { |
959 CancelLongTapAnimation(); |
961 CancelLongTapAnimation(); |
960 |
962 |
961 iKeyEvent = ETrue; |
963 iKeyEvent = ETrue; |
962 // handle the 'clear' key |
|
963 if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace ) |
|
964 { |
|
965 TInt idx = SelectedIndex(); |
|
966 if ( idx >= 0 ) |
|
967 { |
|
968 TryCloseAppL( idx ); |
|
969 } |
|
970 return EKeyWasConsumed; |
|
971 } |
|
972 |
964 |
973 //do not forward the event until item is higlighted |
965 //do not forward the event until item is higlighted |
974 TKeyResponse response = ShowHighlightOnKeyEvent(aKeyEvent, aType); |
966 TKeyResponse response = ShowHighlightOnKeyEvent(aKeyEvent, aType); |
975 if( response == EKeyWasConsumed ) |
967 if( response == EKeyWasConsumed ) |
976 { |
968 { |
977 return EKeyWasConsumed; |
969 return EKeyWasConsumed; |
978 } |
970 } |
|
971 |
|
972 // handle the 'clear' key |
|
973 if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace ) |
|
974 { |
|
975 TInt idx = SelectedIndex(); |
|
976 if ( idx >= 0 ) |
|
977 { |
|
978 TryCloseAppL( idx ); |
|
979 } |
|
980 return EKeyWasConsumed; |
|
981 } |
979 |
982 |
980 // pass the event to grid |
983 // pass the event to grid |
981 // do not pass down and up arrow key events |
984 // do not pass down and up arrow key events |
982 if ( aKeyEvent.iScanCode != EStdKeyUpArrow && |
985 if ( aKeyEvent.iScanCode != EStdKeyUpArrow && |
983 aKeyEvent.iScanCode != EStdKeyDownArrow && |
986 aKeyEvent.iScanCode != EStdKeyDownArrow && |
1020 const TKeyEvent& aKeyEvent, TEventCode aType) |
1023 const TKeyEvent& aKeyEvent, TEventCode aType) |
1021 { |
1024 { |
1022 TKeyResponse retVal(EKeyWasNotConsumed); |
1025 TKeyResponse retVal(EKeyWasNotConsumed); |
1023 |
1026 |
1024 if (aKeyEvent.iScanCode == EStdKeyLeftArrow || |
1027 if (aKeyEvent.iScanCode == EStdKeyLeftArrow || |
1025 aKeyEvent.iScanCode == EStdKeyRightArrow) |
1028 aKeyEvent.iScanCode == EStdKeyRightArrow || |
1026 { |
1029 aKeyEvent.iScanCode == EStdKeyDevice3 || |
|
1030 aKeyEvent.iScanCode == EStdKeyBackspace || |
|
1031 aKeyEvent.iScanCode == EStdKeyEnter ) |
|
1032 { |
1027 if (!iGrid->IsHighlightVisible()) |
1033 if (!iGrid->IsHighlightVisible()) |
1028 { |
1034 { |
1029 if (aType == EEventKey) |
1035 if (aType == EEventKey) |
1030 { |
1036 { |
1031 iGrid->ShowHighlight(); |
1037 iGrid->ShowHighlight(); |
1073 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
1079 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
1074 { |
1080 { |
1075 CancelLongTapAnimation( EFalse ); |
1081 CancelLongTapAnimation( EFalse ); |
1076 if( iActivateOnPointerRelease != TPoint() ) |
1082 if( iActivateOnPointerRelease != TPoint() ) |
1077 { |
1083 { |
|
1084 iHandlePointerCandidate = ETrue; |
1078 TapL(iActivateOnPointerRelease); |
1085 TapL(iActivateOnPointerRelease); |
1079 iActivateOnPointerRelease = TPoint(); |
1086 iActivateOnPointerRelease = TPoint(); |
1080 } |
1087 } |
1081 } |
1088 } |
1082 } |
1089 } |
1431 visibleItem = SelectedIndex(); |
1438 visibleItem = SelectedIndex(); |
1432 } |
1439 } |
1433 if(visibleItem != SelectedIndex()) |
1440 if(visibleItem != SelectedIndex()) |
1434 { |
1441 { |
1435 iGrid->SetCurrentDataIndex( visibleItem ); |
1442 iGrid->SetCurrentDataIndex( visibleItem ); |
1436 DrawDeferred(); |
1443 iParent.DrawDeferred(); |
|
1444 iGrid->DrawDeferred(); |
1437 } |
1445 } |
1438 } |
1446 } |
1439 |
1447 |
1440 // Check if view is outside of grid world |
1448 // Check if view is outside of grid world |
1441 TPoint absViewPos = ViewPos(); |
1449 TPoint absViewPos = ViewPos(); |
1514 // CTsFastSwapArea::MoveOffset |
1522 // CTsFastSwapArea::MoveOffset |
1515 // -------------------------------------------------------------------------- |
1523 // -------------------------------------------------------------------------- |
1516 // |
1524 // |
1517 void CTsFastSwapArea::MoveOffset(const TPoint& aPoint, TBool aDrawNow) |
1525 void CTsFastSwapArea::MoveOffset(const TPoint& aPoint, TBool aDrawNow) |
1518 { |
1526 { |
1519 TSLOG_CONTEXT( CTsFastSwapArea::MoveOffset, TSLOG_LOCAL ); |
|
1520 TSLOG2_IN("Old position x: %d, y:%d", ViewPos().iX, ViewPos().iY); |
|
1521 TSLOG2_IN("New position x: %d, y:%d", aPoint.iX, aPoint.iY); |
|
1522 TSLOG_OUT(); |
|
1523 |
|
1524 |
|
1525 if( iHandlePointerCandidate ) |
1527 if( iHandlePointerCandidate ) |
1526 { |
1528 { |
1527 //pointer was pressed and it's being waiting for handling |
1529 //pointer was pressed and it's being waiting for handling |
1528 return; |
1530 return; |
1529 } |
1531 } |
1546 if(GridItemCount() && GridItemCount() <= iMaxItemsOnScreen) |
1548 if(GridItemCount() && GridItemCount() <= iMaxItemsOnScreen) |
1547 { |
1549 { |
1548 // Center view |
1550 // Center view |
1549 gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
1551 gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
1550 } |
1552 } |
1551 DrawDeferred(); |
1553 //iParent.DrawDeferred(); |
|
1554 iGrid->DrawDeferred(); |
1552 iGrid->SetRect( gridViewRect ); |
1555 iGrid->SetRect( gridViewRect ); |
1553 iLogicalViewPosOffset = 0; |
1556 iLogicalViewPosOffset = 0; |
1554 } |
1557 } |
1555 else |
1558 else |
1556 { |
1559 { |
1648 // ----------------------------------------------------------------------------- |
1651 // ----------------------------------------------------------------------------- |
1649 // |
1652 // |
1650 void CTsFastSwapArea::Stop() |
1653 void CTsFastSwapArea::Stop() |
1651 { |
1654 { |
1652 CenterItem( KUpdateGridTime ); |
1655 CenterItem( KUpdateGridTime ); |
1653 DrawNow(); |
1656 DrawDeferred(); |
1654 } |
1657 } |
1655 |
1658 |
1656 // ----------------------------------------------------------------------------- |
1659 // ----------------------------------------------------------------------------- |
1657 // CTsFastSwapArea::ViewSize |
1660 // CTsFastSwapArea::ViewSize |
1658 // ----------------------------------------------------------------------------- |
1661 // ----------------------------------------------------------------------------- |
1787 retVal = GridItemCount() - 1; |
1790 retVal = GridItemCount() - 1; |
1788 } |
1791 } |
1789 } |
1792 } |
1790 else |
1793 else |
1791 { |
1794 { |
|
1795 TInt retItemPosX(0); |
1792 TInt offsetCheck = GridWorldSize().iWidth; |
1796 TInt offsetCheck = GridWorldSize().iWidth; |
1793 // View inside of grid world rect |
1797 // View inside of grid world rect |
1794 for ( TInt i = 0 ; i < GridItemCount(); i++ ) |
1798 for ( TInt i = 0 ; i < GridItemCount(); i++ ) |
1795 { |
1799 { |
1796 TInt offset = aViewPos.iX - ItemViewPosition( i ).iX; |
1800 TInt itemPosX = ItemViewPosition( i ).iX; |
|
1801 TInt offset = aViewPos.iX - itemPosX; |
1797 if ( Abs( offset ) <= offsetCheck ) |
1802 if ( Abs( offset ) <= offsetCheck ) |
1798 { |
1803 { |
1799 offsetCheck = Abs( offset ); |
1804 offsetCheck = Abs( offset ); |
1800 retVal = i; |
1805 retVal = i; |
|
1806 retItemPosX = itemPosX; |
1801 } |
1807 } |
1802 else |
1808 else |
1803 { |
1809 { |
1804 break; |
1810 break; |
1805 } |
1811 } |
1806 } |
1812 } |
1807 } |
1813 // Check if item is fully visible. If not |
|
1814 // return next one if possible |
|
1815 if ( retItemPosX - iGridItemWidth / 2 < absViewPos.iX && |
|
1816 retVal + 1 < GridItemCount() ) |
|
1817 { |
|
1818 retVal++; |
|
1819 } |
|
1820 } |
|
1821 |
1808 return retVal; |
1822 return retVal; |
1809 } |
1823 } |
1810 |
1824 |
1811 |
1825 |
1812 // ----------------------------------------------------------------------------- |
1826 // ----------------------------------------------------------------------------- |
1834 } |
1848 } |
1835 } |
1849 } |
1836 |
1850 |
1837 |
1851 |
1838 // ----------------------------------------------------------------------------- |
1852 // ----------------------------------------------------------------------------- |
1839 // CTsFastSwapArea::UpdateComponentVisibility |
|
1840 // ----------------------------------------------------------------------------- |
|
1841 // |
|
1842 void CTsFastSwapArea::UpdateComponentVisibility() |
|
1843 { |
|
1844 // Switch off scrollbars |
|
1845 CEikScrollBarFrame* scrollBar = iGrid->ScrollBarFrame(); |
|
1846 if(scrollBar) |
|
1847 { |
|
1848 TRAP_IGNORE( scrollBar->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
|
1849 CEikScrollBarFrame::EOff)); |
|
1850 } |
|
1851 } |
|
1852 |
|
1853 |
|
1854 // ----------------------------------------------------------------------------- |
|
1855 // CTsFastSwapArea::GetCurrentScreenOrientation |
1853 // CTsFastSwapArea::GetCurrentScreenOrientation |
1856 // ----------------------------------------------------------------------------- |
1854 // ----------------------------------------------------------------------------- |
1857 // |
1855 // |
1858 TInt CTsFastSwapArea::GetCurrentScreenOrientation() |
1856 TInt CTsFastSwapArea::GetCurrentScreenOrientation() |
1859 { |
1857 { |
1914 // |
1912 // |
1915 TBool CTsFastSwapArea::WgOnTaskList( TInt aWgId ) |
1913 TBool CTsFastSwapArea::WgOnTaskList( TInt aWgId ) |
1916 { |
1914 { |
1917 TBool retVal(EFalse); |
1915 TBool retVal(EFalse); |
1918 TInt appCount = iArray.Count(); |
1916 TInt appCount = iArray.Count(); |
|
1917 |
|
1918 TApaTaskList taskList( iEikonEnv->WsSession() ); |
|
1919 TApaTask task = taskList.FindApp( KTsHomescreenUid ); |
|
1920 TInt homescrWgId = task.WgId(); |
|
1921 |
1919 if ( iPrevAppCount != appCount ) |
1922 if ( iPrevAppCount != appCount ) |
1920 { |
1923 { |
1921 TApaTaskList taskList( iEikonEnv->WsSession() ); |
|
1922 TApaTask task = taskList.FindApp( KTsHomescreenUid ); |
|
1923 TInt homescrWgId = task.WgId(); |
|
1924 |
|
1925 for ( TInt i = 0; i < iArray.Count(); i++ ) |
1924 for ( TInt i = 0; i < iArray.Count(); i++ ) |
1926 { |
1925 { |
1927 TInt wgId = iArray[i]->WgId(); |
1926 TInt wgId = iArray[i]->WgId(); |
1928 if ( wgId == aWgId || |
1927 if ( wgId == aWgId || |
1929 homescrWgId == aWgId ) |
1928 homescrWgId == aWgId ) |
1930 { |
1929 { |
1931 retVal = ETrue; |
1930 retVal = ETrue; |
1932 } |
1931 } |
1933 } |
1932 } |
1934 } |
1933 } |
|
1934 else if ( aWgId == homescrWgId ) |
|
1935 { |
|
1936 retVal = ETrue; |
|
1937 } |
1935 iPrevAppCount = appCount; |
1938 iPrevAppCount = appCount; |
1936 return retVal; |
1939 return retVal; |
1937 } |
1940 } |
1938 |
1941 |
1939 // ----------------------------------------------------------------------------- |
1942 // ----------------------------------------------------------------------------- |
1964 // |
1967 // |
1965 TBool CTsFastSwapArea::LongTapAnimForPos( const TPoint& aHitPoint ) |
1968 TBool CTsFastSwapArea::LongTapAnimForPos( const TPoint& aHitPoint ) |
1966 { |
1969 { |
1967 if ( Rect().Contains(aHitPoint) ) |
1970 if ( Rect().Contains(aHitPoint) ) |
1968 { |
1971 { |
1969 for ( TInt i = 0; i < GridItemCount(); i++ ) |
1972 TInt itemIdx; |
1970 { |
1973 TBool isItemHit = iGrid->GridView()->XYPosToItemIndex( aHitPoint, itemIdx ); |
1971 TBool isItemHit = iGrid->GridView()->XYPosToItemIndex( aHitPoint, i ); |
1974 if ( isItemHit && ( CanClose( itemIdx ) || CanCloseAll( itemIdx ) ) ) |
1972 if ( isItemHit && ( CanClose( i ) || CanCloseAll( i ) ) ) |
1975 { |
1973 { |
1976 return ETrue; |
1974 return ETrue; |
|
1975 } |
|
1976 } |
1977 } |
1977 } |
1978 } |
1978 return EFalse; |
1979 return EFalse; |
1979 } |
1980 } |
1980 |
1981 |