1870 { |
1870 { |
1871 // calculate view center based on CEikListBoxView::iTopItemIndex |
1871 // calculate view center based on CEikListBoxView::iTopItemIndex |
1872 TInt topItemIndex = iListBox.iView->TopItemIndex(); |
1872 TInt topItemIndex = iListBox.iView->TopItemIndex(); |
1873 TInt itemHeight = iListBox.iView->ItemHeight(); |
1873 TInt itemHeight = iListBox.iView->ItemHeight(); |
1874 TInt numberOfItems = iListBox.iModel->NumberOfItems(); |
1874 TInt numberOfItems = iListBox.iModel->NumberOfItems(); |
1875 |
1875 TInt emptySpaceOffset ( 0 ); |
|
1876 |
1876 TSize viewSize( iListBox.iView->ViewRect().Size() ); |
1877 TSize viewSize( iListBox.iView->ViewRect().Size() ); |
1877 TSize worldSize( viewSize.iWidth, itemHeight * numberOfItems ); |
1878 TSize worldSize( viewSize.iWidth, itemHeight * numberOfItems ); |
1878 |
1879 |
1879 // grid has several items in one line |
1880 // grid has several items in one line |
1880 if ( iItemsInSingleLine > 1 ) |
1881 if ( iItemsInSingleLine > 1 ) |
1885 // handle non-full grid row |
1886 // handle non-full grid row |
1886 if ( numberOfItems % iItemsInSingleLine ) |
1887 if ( numberOfItems % iItemsInSingleLine ) |
1887 { |
1888 { |
1888 worldSize.iHeight += itemHeight; |
1889 worldSize.iHeight += itemHeight; |
1889 } |
1890 } |
|
1891 |
|
1892 // Check empty space below the grid |
|
1893 if ( topItemIndex != 0 ) |
|
1894 { |
|
1895 TInt lastItemBottomY = |
|
1896 iListBox.iView->ItemPos( |
|
1897 numberOfItems - 1 ).iY + itemHeight +1; |
|
1898 emptySpaceOffset = Min( 0, lastItemBottomY - viewSize.iHeight ); |
|
1899 } |
1890 } |
1900 } |
1891 |
1901 |
1892 // Reset offset if view's size has changed - this is needed if e.g. |
1902 // Reset offset if view's size has changed - this is needed if e.g. |
1893 // HandleResourceChange is overridden by a derived implementation. |
1903 // HandleResourceChange is overridden by a derived implementation. |
1894 if ( viewSize != iViewSize && iViewSize != TSize( 0, 0 ) ) |
1904 if ( viewSize != iViewSize && iViewSize != TSize( 0, 0 ) ) |
1895 { |
1905 { |
1896 iListBox.iView->SetItemOffsetInPixels( 0 ); |
1906 iListBox.iView->SetItemOffsetInPixels( 0 ); |
1897 } |
1907 } |
1898 |
1908 |
1899 TPoint viewCenter( viewSize.iWidth / 2, ( topItemIndex / iItemsInSingleLine ) * itemHeight - iListBox.iView->ItemOffsetInPixels() + ( viewSize.iHeight / 2 ) ); |
1909 TPoint viewCenter( viewSize.iWidth / 2, ( topItemIndex / iItemsInSingleLine ) * itemHeight - iListBox.iView->ItemOffsetInPixels() + ( viewSize.iHeight / 2 ) ); |
|
1910 viewCenter.iY += emptySpaceOffset; |
1900 |
1911 |
1901 // Make sure that world's size is always at least view size. |
1912 // Make sure that world's size is always at least view size. |
1902 worldSize.iHeight = Max( worldSize.iHeight, viewSize.iHeight ); |
1913 worldSize.iHeight = Max( worldSize.iHeight, viewSize.iHeight ); |
1903 |
1914 |
1904 iPhysics->InitPhysicsL( worldSize, viewSize, EFalse ); |
1915 iPhysics->InitPhysicsL( worldSize, viewSize, EFalse ); |
6785 { |
6796 { |
6786 if( ( newListBottomPos < iListBoxExt->ListBottomLimit() && newListTopPos > 0 ) || |
6797 if( ( newListBottomPos < iListBoxExt->ListBottomLimit() && newListTopPos > 0 ) || |
6787 ( newListBottomPos >= iListBoxExt->ListBottomLimit() ) || |
6798 ( newListBottomPos >= iListBoxExt->ListBottomLimit() ) || |
6788 ( newListTopPos <= 0 && newListTopPos + viewHeight >= 0 && newListLastItemPos > viewHeight ) ) |
6799 ( newListTopPos <= 0 && newListTopPos + viewHeight >= 0 && newListLastItemPos > viewHeight ) ) |
6789 { |
6800 { |
6790 if ( CAknPhysics::EAknPhysicsActionFlicking == iListBoxExt->iPhysics->OngoingPhysicsAction() || |
6801 switch(iListBoxExt->iPhysics->OngoingPhysicsAction()) |
6791 CAknPhysics::EAknPhysicsActionBouncing == iListBoxExt->iPhysics->OngoingPhysicsAction() ) |
|
6792 { |
6802 { |
6793 iListBoxExt->ImmediateFeedback( ETouchFeedbackSensitiveList, |
6803 case CAknPhysics::EAknPhysicsActionBouncing: |
6794 TTouchFeedbackType( ETouchFeedbackVibra ), |
6804 case CAknPhysics::EAknPhysicsActionDragging: |
6795 TPointerEvent() ); |
6805 case CAknPhysics::EAknPhysicsActionFlicking: |
6796 } |
6806 iListBoxExt->ImmediateFeedback( |
6797 else if ( CAknPhysics::EAknPhysicsActionDragging == iListBoxExt->iPhysics->OngoingPhysicsAction() ) |
6807 ETouchFeedbackSensitiveList, |
6798 { |
6808 TTouchFeedbackType( ETouchFeedbackVibra ), |
6799 iListBoxExt->ImmediateFeedback( ETouchFeedbackSensitiveList, |
6809 TPointerEvent() ); |
6800 TTouchFeedbackType( ETouchFeedbackVibra | ETouchFeedbackAudio ), |
6810 break; |
6801 TPointerEvent() ); |
6811 default: |
|
6812 break; |
6802 } |
6813 } |
6803 } |
6814 } |
6804 } |
6815 } |
6805 } |
6816 } |
6806 newTopItemIndex = newTopItemIndexBck; |
6817 newTopItemIndex = newTopItemIndexBck; |