138 delete iOrientationSignalTimer; |
138 delete iOrientationSignalTimer; |
139 delete iLongTapAnimation; |
139 delete iLongTapAnimation; |
140 delete iLongTapAnimationTimer; |
140 delete iLongTapAnimationTimer; |
141 delete iFastSwapExt; |
141 delete iFastSwapExt; |
142 iPrevScreenshots.Close(); |
142 iPrevScreenshots.Close(); |
|
143 iPrevWgIds.Close(); |
143 delete iEventSupressor; |
144 delete iEventSupressor; |
144 } |
145 } |
145 |
146 |
146 // ----------------------------------------------------------------------------- |
147 // ----------------------------------------------------------------------------- |
147 // CTsFastSwapArea::ConstructL |
148 // CTsFastSwapArea::ConstructL |
271 TAknLayoutRect gridItem = rects[1]; |
272 TAknLayoutRect gridItem = rects[1]; |
272 TAknLayoutRect gridImage = rects[2]; |
273 TAknLayoutRect gridImage = rects[2]; |
273 |
274 |
274 CleanupStack::PopAndDestroy(&rects); |
275 CleanupStack::PopAndDestroy(&rects); |
275 |
276 |
276 iGrid->SetRect(gridAppPane.Rect()); |
277 TPoint position = iFastSwapExt->ItemViewPosition( SelectedIndex() ); |
|
278 iGrid->SetRect( CountCenteredGridRect( position ) ); |
|
279 |
|
280 |
277 |
281 |
278 CTsAppUi* appUi = static_cast<CTsAppUi*>(iEikonEnv->AppUi()); |
282 CTsAppUi* appUi = static_cast<CTsAppUi*>(iEikonEnv->AppUi()); |
279 |
283 |
280 TInt variety; |
284 TInt variety; |
281 TBool disable = iFastSwapExt->GetVariety(variety); |
285 TBool disable = iFastSwapExt->GetVariety(variety); |
690 CleanupClosePushL(closeItemArray); |
694 CleanupClosePushL(closeItemArray); |
691 RArray<TInt> strokeItemArray; |
695 RArray<TInt> strokeItemArray; |
692 CleanupClosePushL(strokeItemArray); |
696 CleanupClosePushL(strokeItemArray); |
693 RArray<TInt> screenshotList; |
697 RArray<TInt> screenshotList; |
694 CleanupClosePushL(screenshotList); |
698 CleanupClosePushL(screenshotList); |
|
699 RArray<TInt> wgIdList; |
|
700 CleanupClosePushL(wgIdList); |
695 |
701 |
696 // Update view based on number of items |
702 // Update view based on number of items |
697 LayoutGridViewL( iArray.Count() ); |
703 LayoutGridViewL( iArray.Count() ); |
698 |
704 |
699 CArrayPtr<CGulIcon>* oldIconArray = |
705 CArrayPtr<CGulIcon>* oldIconArray = |
709 formAppName.AppendNum(i); |
715 formAppName.AppendNum(i); |
710 formAppName.Append(KSeparator); |
716 formAppName.Append(KSeparator); |
711 formAppName.Append(appName); |
717 formAppName.Append(appName); |
712 textArray->AppendL(formAppName); |
718 textArray->AppendL(formAppName); |
713 CleanupStack::PopAndDestroy(&formAppName); |
719 CleanupStack::PopAndDestroy(&formAppName); |
714 TSize sz = iFastSwapExt->PreferredImageSize(); |
|
715 |
720 |
716 // take the screenshot or appicon+mask and make a copy and scale |
721 // take the screenshot or appicon+mask and make a copy and scale |
717 CFbsBitmap* bitmap = 0; |
|
718 TInt h = iArray[i]->ScreenshotHandle(); |
722 TInt h = iArray[i]->ScreenshotHandle(); |
719 TSLOG2( TSLOG_INFO, "'%S' screenshot handle %d", &appName, h ); |
723 TSLOG2( TSLOG_INFO, "'%S' screenshot handle %d", &appName, h ); |
720 TInt maskh = 0; |
|
721 CFbsBitmap* mask = 0; |
|
722 TBool isScreenshot( ETrue ); |
724 TBool isScreenshot( ETrue ); |
723 if ( !h ) |
725 if ( !h ) |
724 { |
726 { |
725 // No screenshot, take app icon |
727 // No screenshot, take app icon |
726 h = iArray[i]->AppIconBitmapHandle(); |
728 h = iArray[i]->AppIconBitmapHandle(); |
727 maskh = iArray[i]->AppIconMaskHandle(); |
|
728 isScreenshot = EFalse; |
729 isScreenshot = EFalse; |
729 TSLOG1( TSLOG_INFO, "using appicon, handle = %d", h ); |
730 TSLOG1( TSLOG_INFO, "using appicon, handle = %d", h ); |
730 } |
731 } |
731 else |
732 else |
732 { |
733 { |
735 } |
736 } |
736 __ASSERT_DEBUG( h, User::Invariant() ); |
737 __ASSERT_DEBUG( h, User::Invariant() ); |
737 |
738 |
738 // check screenshot - if it exists already, use it |
739 // check screenshot - if it exists already, use it |
739 // so there is no unnecessary scaling performed |
740 // so there is no unnecessary scaling performed |
|
741 CGulIcon* icon = CreateItemIconLC( iArray[i], isScreenshot ); |
|
742 iconArray->AppendL(icon); |
|
743 CleanupStack::Pop( icon ); //icon |
|
744 |
740 screenshotList.AppendL( h ); |
745 screenshotList.AppendL( h ); |
741 TInt idx = iPrevScreenshots.Find( h ); |
746 wgIdList.AppendL( iArray[i]->WgId() ); |
742 if ( idx != KErrNotFound && oldIconArray && idx < oldIconArray->Count() ) |
747 |
743 { |
|
744 CGulIcon* existingIcon = oldIconArray->At( idx ); |
|
745 if ( existingIcon->Bitmap() ) |
|
746 { |
|
747 h = existingIcon->Bitmap()->Handle(); |
|
748 if ( existingIcon->Mask() ) |
|
749 { |
|
750 maskh = existingIcon->Mask()->Handle(); |
|
751 } |
|
752 isScreenshot = EFalse; |
|
753 } |
|
754 } |
|
755 |
|
756 // create bitmap for grid item |
|
757 bitmap = iFastSwapExt->CopyBitmapL( h, sz, isScreenshot ); |
|
758 CleanupStack::PushL( bitmap ); |
|
759 if ( maskh ) |
|
760 { |
|
761 mask = iFastSwapExt->CopyBitmapL( maskh, sz, EFalse ); |
|
762 } |
|
763 CleanupStack::PushL( mask ); |
|
764 |
|
765 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
766 CleanupStack::PushL(icon); |
|
767 iconArray->AppendL(icon); |
|
768 CleanupStack::Pop( 3, bitmap ); // mask, bitmap, icon |
|
769 |
|
770 // Check if item can be closed |
748 // Check if item can be closed |
771 if ( CanClose(i) && AknLayoutUtils::PenEnabled() ) |
749 if ( CanClose(i) && AknLayoutUtils::PenEnabled() ) |
772 { |
750 { |
773 closeItemArray.AppendL(i); |
751 closeItemArray.AppendL(i); |
774 } |
752 } |
775 } |
753 } |
776 // Update screenshot list |
754 // Update screenshot list |
777 iPrevScreenshots.Reset(); |
755 iPrevScreenshots.Reset(); |
778 for ( TInt i = 0; i < screenshotList.Count(); i++ ) |
756 iPrevWgIds.Reset(); |
|
757 for ( TInt i = 0; |
|
758 i < screenshotList.Count() && i < wgIdList.Count(); i++ ) |
779 { |
759 { |
780 iPrevScreenshots.AppendL( screenshotList[i] ); |
760 iPrevScreenshots.AppendL( screenshotList[i] ); |
781 } |
761 iPrevWgIds.AppendL( wgIdList[i] ); |
|
762 } |
|
763 CleanupStack::PopAndDestroy( &wgIdList ); |
782 CleanupStack::PopAndDestroy( &screenshotList ); |
764 CleanupStack::PopAndDestroy( &screenshotList ); |
783 |
765 |
784 // Setup grid |
766 // Setup grid |
785 iGrid->Model()->SetItemTextArray(textArray); |
767 iGrid->Model()->SetItemTextArray(textArray); |
786 if(oldIconArray) |
768 if(oldIconArray) |
810 if ( SelectedIndex() >= GridItemCount() && GridItemCount() ) |
792 if ( SelectedIndex() >= GridItemCount() && GridItemCount() ) |
811 { |
793 { |
812 iGrid->SetCurrentDataIndex( GridItemCount() - 1 ); |
794 iGrid->SetCurrentDataIndex( GridItemCount() - 1 ); |
813 } |
795 } |
814 TSLOG_OUT(); |
796 TSLOG_OUT(); |
|
797 } |
|
798 |
|
799 // -------------------------------------------------------------------------- |
|
800 // CTsFastSwapArea::CreateItemIconLC |
|
801 // -------------------------------------------------------------------------- |
|
802 // |
|
803 CGulIcon* CTsFastSwapArea::CreateItemIconLC( CTsFswEntry* aEntry, |
|
804 TBool aIsScreenshot ) |
|
805 { |
|
806 TSize sz = iFastSwapExt->PreferredImageSize(); |
|
807 CArrayPtr<CGulIcon>* oldIconArray = |
|
808 iGrid->ItemDrawer()->FormattedCellData()->IconArray(); |
|
809 |
|
810 CFbsBitmap* bitmap = NULL; |
|
811 CFbsBitmap* mask = NULL; |
|
812 |
|
813 TInt h = 0; |
|
814 TInt maskh = 0; |
|
815 if ( aIsScreenshot ) |
|
816 { |
|
817 h = aEntry->ScreenshotHandle(); |
|
818 } |
|
819 else |
|
820 { |
|
821 h = aEntry->AppIconBitmapHandle(); |
|
822 maskh = aEntry->AppIconMaskHandle(); |
|
823 } |
|
824 |
|
825 TInt idx = iPrevScreenshots.Find( h ); |
|
826 TInt wgIdIdx = iPrevWgIds.Find( aEntry->WgId() ); |
|
827 |
|
828 if ( idx != KErrNotFound && idx == wgIdIdx |
|
829 && oldIconArray && idx < oldIconArray->Count() ) |
|
830 { |
|
831 CGulIcon* existingIcon = oldIconArray->At( idx ); |
|
832 if ( existingIcon->Bitmap() ) |
|
833 { |
|
834 bitmap = iFastSwapExt->DuplicateBitmapLC( |
|
835 existingIcon->Bitmap()->Handle() ); |
|
836 if ( existingIcon->Mask() ) |
|
837 { |
|
838 maskh = existingIcon->Mask()->Handle(); |
|
839 mask = iFastSwapExt->DuplicateBitmapLC( maskh ); |
|
840 } |
|
841 } |
|
842 } |
|
843 else if ( idx == KErrNotFound && wgIdIdx != KErrNotFound |
|
844 && oldIconArray && wgIdIdx < oldIconArray->Count() ) |
|
845 { |
|
846 CGulIcon* existingIcon = oldIconArray->At( wgIdIdx ); |
|
847 if ( existingIcon->Bitmap() |
|
848 && !existingIcon->Mask() ) |
|
849 { |
|
850 bitmap = iFastSwapExt->DuplicateBitmapLC( |
|
851 existingIcon->Bitmap()->Handle() ); |
|
852 CFbsBitmap* source = iFastSwapExt->DuplicateBitmapLC( h ); |
|
853 iFastSwapExt->ScaleBitmapL( source, bitmap ); |
|
854 CleanupStack::Pop( source ); |
|
855 } |
|
856 } |
|
857 |
|
858 // create bitmap for grid item |
|
859 if ( !bitmap ) |
|
860 { |
|
861 bitmap = iFastSwapExt->CopyBitmapL( h, sz, aIsScreenshot ); |
|
862 CleanupStack::PushL( bitmap ); |
|
863 } |
|
864 if ( !mask && maskh ) |
|
865 { |
|
866 mask = iFastSwapExt->CopyBitmapL( maskh, sz, EFalse ); |
|
867 CleanupStack::PushL( mask ); |
|
868 } |
|
869 else if ( !mask ) |
|
870 { |
|
871 CleanupStack::PushL( mask ); |
|
872 } |
|
873 |
|
874 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
875 CleanupStack::Pop( 2, bitmap ); |
|
876 CleanupStack::PushL( icon ); |
|
877 return icon; |
815 } |
878 } |
816 |
879 |
817 |
880 |
818 // -------------------------------------------------------------------------- |
881 // -------------------------------------------------------------------------- |
819 // CTsFastSwapArea::CountComponentControls |
882 // CTsFastSwapArea::CountComponentControls |
1072 iSupressDrag = supressed; |
1135 iSupressDrag = supressed; |
1073 } |
1136 } |
1074 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
1137 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
1075 { |
1138 { |
1076 CancelLongTapAnimation( EFalse ); |
1139 CancelLongTapAnimation( EFalse ); |
1077 if( iActivateOnPointerRelease != TPoint() || |
1140 if( iActivateOnPointerRelease != TPoint() ) |
1078 iSupressDrag) |
|
1079 { |
1141 { |
1080 iHandlePointerCandidate = ETrue; |
1142 iHandlePointerCandidate = ETrue; |
1081 TapL(iActivateOnPointerRelease); |
1143 TapL( iActivateOnPointerRelease ); |
1082 iActivateOnPointerRelease = TPoint(); |
1144 iActivateOnPointerRelease = TPoint(); |
|
1145 } |
|
1146 else if( iSupressDrag ) |
|
1147 { |
|
1148 iSupressDrag = EFalse; |
|
1149 iHandlePointerCandidate = ETrue; |
|
1150 TapL( iTapEvent.iParentPosition ); |
1083 } |
1151 } |
1084 } |
1152 } |
1085 } |
1153 } |
1086 |
1154 |
1087 // ----------------------------------------------------------------------------- |
1155 // ----------------------------------------------------------------------------- |
1523 iUpdateGridTimer->After(KUpdateGridTime); |
1591 iUpdateGridTimer->After(KUpdateGridTime); |
1524 } |
1592 } |
1525 |
1593 |
1526 if ( aDrawNow ) |
1594 if ( aDrawNow ) |
1527 { |
1595 { |
1528 TInt currentXPos = aPoint.iX; |
1596 TRect gridViewRect = CountCenteredGridRect( aPoint ); |
1529 currentXPos -= Rect().Width() / 2; |
|
1530 TRect gridViewRect = Rect(); |
|
1531 gridViewRect.iTl.iX = -currentXPos; |
|
1532 // Take edge offset into account |
|
1533 gridViewRect.iTl.iX += Rect().iTl.iX; |
|
1534 if(GridItemCount() && GridItemCount() <= iMaxItemsOnScreen) |
|
1535 { |
|
1536 // Center view |
|
1537 gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
|
1538 } |
|
1539 //iParent.DrawDeferred(); |
1597 //iParent.DrawDeferred(); |
1540 iGrid->DrawDeferred(); |
1598 iGrid->DrawDeferred(); |
1541 iGrid->SetRect( gridViewRect ); |
1599 iGrid->SetRect( gridViewRect ); |
1542 iLogicalViewPosOffset = 0; |
1600 iLogicalViewPosOffset = 0; |
1543 } |
1601 } |
1595 iGrid->SetCurrentItemIndex(index); |
1653 iGrid->SetCurrentItemIndex(index); |
1596 SaveSelectedIndex(); |
1654 SaveSelectedIndex(); |
1597 if ( !ShowPopupL(iSavedSelectedIndex, aPoint) ) |
1655 if ( !ShowPopupL(iSavedSelectedIndex, aPoint) ) |
1598 { |
1656 { |
1599 iActivateOnPointerRelease = aPoint; |
1657 iActivateOnPointerRelease = aPoint; |
|
1658 } |
|
1659 else |
|
1660 { |
|
1661 iSupressDrag = EFalse; |
1600 } |
1662 } |
1601 iGrid->ShowHighlight(); |
1663 iGrid->ShowHighlight(); |
1602 DrawNow(); |
1664 DrawNow(); |
1603 } |
1665 } |
1604 iHandlePointerCandidate = EFalse; |
1666 iHandlePointerCandidate = EFalse; |
1759 } |
1821 } |
1760 } |
1822 } |
1761 return EFalse; |
1823 return EFalse; |
1762 } |
1824 } |
1763 |
1825 |
|
1826 // ----------------------------------------------------------------------------- |
|
1827 // CTsFastSwapArea::CountCenteredGridRect |
|
1828 // ----------------------------------------------------------------------------- |
|
1829 // |
|
1830 TRect CTsFastSwapArea::CountCenteredGridRect( TPoint aItemPosition) |
|
1831 { |
|
1832 TInt currentXPos = aItemPosition.iX; |
|
1833 currentXPos -= Rect().Width() / 2; |
|
1834 TRect gridViewRect = Rect(); |
|
1835 gridViewRect.iTl.iX = -currentXPos; |
|
1836 // Take edge offset into account |
|
1837 gridViewRect.iTl.iX += Rect().iTl.iX; |
|
1838 if(GridItemCount() && GridItemCount() <= iMaxItemsOnScreen) |
|
1839 { |
|
1840 // Center view |
|
1841 gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
|
1842 } |
|
1843 return gridViewRect; |
|
1844 } |
|
1845 |
1764 // End of file |
1846 // End of file |