changeset 1 | 5315654608de |
parent 0 | f72a12da539e |
child 2 | 08c6ee43b396 |
0:f72a12da539e | 1:5315654608de |
---|---|
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * Version : %version: MM_92 % << Don't touch! Updated by Synergy at check-out. |
15 * Version : %version: MM_94 % << Don't touch! Updated by Synergy at check-out. |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 |
19 |
20 #include <AknsDrawUtils.h> |
20 #include <AknsDrawUtils.h> |
183 } |
183 } |
184 |
184 |
185 // ----------------------------------------------------------------------------- |
185 // ----------------------------------------------------------------------------- |
186 // |
186 // |
187 // ----------------------------------------------------------------------------- |
187 // ----------------------------------------------------------------------------- |
188 // |
188 // |
189 void CMmGrid::CreateItemDrawerL() |
189 void CMmGrid::CreateItemDrawerL() |
190 { |
190 { |
191 iItemDrawer = iMmDrawer; |
191 iItemDrawer = iMmDrawer; |
192 } |
192 } |
193 |
193 |
233 aEventType == EEikScrollPageDown ) |
233 aEventType == EEikScrollPageDown ) |
234 { |
234 { |
235 DrawNow(); |
235 DrawNow(); |
236 } |
236 } |
237 #endif |
237 #endif |
238 |
238 |
239 } |
239 } |
240 } |
240 } |
241 |
241 |
242 // ----------------------------------------------------------------------------- |
242 // ----------------------------------------------------------------------------- |
243 // |
243 // |
282 // ----------------------------------------------------------------------------- |
282 // ----------------------------------------------------------------------------- |
283 // |
283 // |
284 void CMmGrid::HandlePointerEventInNormalModeL( const TPointerEvent& aPointerEvent ) |
284 void CMmGrid::HandlePointerEventInNormalModeL( const TPointerEvent& aPointerEvent ) |
285 { |
285 { |
286 CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() ); |
286 CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() ); |
287 if ( aPointerEvent.iType == TPointerEvent::EButton1Down && !parent->FlipOpen() ) |
287 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
288 { |
288 { |
289 const TInt KIgnoreRectSize = 40; |
289 const TInt KIgnoreRectSize = 40; |
290 TRect ignoreDragRect(aPointerEvent.iPosition, |
290 TRect ignoreDragRect(aPointerEvent.iPosition, |
291 TSize(KIgnoreRectSize, KIgnoreRectSize)); |
291 TSize(KIgnoreRectSize, KIgnoreRectSize)); |
292 ignoreDragRect.Move( - KIgnoreRectSize / 2, - KIgnoreRectSize / 2 ); |
292 ignoreDragRect.Move( - KIgnoreRectSize / 2, - KIgnoreRectSize / 2 ); |
315 } |
315 } |
316 |
316 |
317 View()->ItemDrawer()->SetFlags( CListItemDrawer::EPressedDownState ); |
317 View()->ItemDrawer()->SetFlags( CListItemDrawer::EPressedDownState ); |
318 CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() ); |
318 CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() ); |
319 TBool highlightWasVisible = parent->IsHighlightVisible(); |
319 TBool highlightWasVisible = parent->IsHighlightVisible(); |
320 |
320 |
321 if( itemUnderPointerIndex == View()->CurrentItemIndex() ) |
321 if( itemUnderPointerIndex == View()->CurrentItemIndex() ) |
322 { |
322 { |
323 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
323 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
324 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( |
324 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( |
325 iMmDrawer->Gc() ); |
325 iMmDrawer->Gc() ); |
337 View()->DrawItem( itemUnderPointerIndex ); |
337 View()->DrawItem( itemUnderPointerIndex ); |
338 } |
338 } |
339 #else |
339 #else |
340 View()->DrawItem( itemUnderPointerIndex ); |
340 View()->DrawItem( itemUnderPointerIndex ); |
341 #endif |
341 #endif |
342 } |
342 } |
343 else |
343 else |
344 { |
344 { |
345 TInt previouslyHighlightedItemIndex = View()->CurrentItemIndex(); |
345 TInt previouslyHighlightedItemIndex = View()->CurrentItemIndex(); |
346 parent->SetManualHighlightL( itemUnderPointerIndex , EFalse ); |
346 parent->SetManualHighlightL( itemUnderPointerIndex , EFalse ); |
347 if ( highlightWasVisible ) |
347 if ( highlightWasVisible ) |
348 { |
348 { |
349 View()->DrawItem( previouslyHighlightedItemIndex ); |
349 View()->DrawItem( previouslyHighlightedItemIndex ); |
350 } |
350 } |
351 } |
351 } |
352 } |
352 } |
353 |
353 |
354 // ----------------------------------------------------------------------------- |
354 // ----------------------------------------------------------------------------- |
355 // |
355 // |
356 // ----------------------------------------------------------------------------- |
356 // ----------------------------------------------------------------------------- |
357 // |
357 // |
358 void CMmGrid::HandleScrollingInEditMode( const TPointerEvent& aPointerEvent ) |
358 void CMmGrid::HandleScrollingInEditMode( const TPointerEvent& aPointerEvent ) |
405 |
405 |
406 // ----------------------------------------------------------------------------- |
406 // ----------------------------------------------------------------------------- |
407 // |
407 // |
408 // ----------------------------------------------------------------------------- |
408 // ----------------------------------------------------------------------------- |
409 // |
409 // |
410 void CMmGrid::ScrollWithoutRedraw( TInt distanceInPixels ) |
|
411 { |
|
412 CAknGridView* view = static_cast<CAknGridView*>( iView ); |
|
413 const TInt rowHeight = ItemHeight(); |
|
414 const TInt numOfCols = view->NumberOfColsInView(); |
|
415 const TInt itemCount = iModel->NumberOfItems(); |
|
416 TInt totalNumberOfRows = itemCount / numOfCols; |
|
417 if ( itemCount % numOfCols ) |
|
418 { |
|
419 ++totalNumberOfRows; |
|
420 } |
|
421 const TInt topItemRowIndex = TopItemIndex() / numOfCols; |
|
422 |
|
423 // desired view position relative to the first item in grid (always positive) |
|
424 TInt desiredViewPosition = rowHeight * topItemRowIndex - VerticalItemOffset(); |
|
425 |
|
426 desiredViewPosition += distanceInPixels; |
|
427 |
|
428 const TInt viewPositionMin = 0; |
|
429 const TInt viewPositionMax = |
|
430 Max( 0, ( totalNumberOfRows * rowHeight ) - view->ViewRect().Height() ); |
|
431 |
|
432 desiredViewPosition = Min( desiredViewPosition, viewPositionMax ); |
|
433 desiredViewPosition = Max( desiredViewPosition, viewPositionMin ); |
|
434 |
|
435 ASSERT( desiredViewPosition >= 0 ); |
|
436 |
|
437 TInt newTopItemIndex = ( desiredViewPosition / rowHeight ) * numOfCols; |
|
438 TInt newVerticalOffset = -( desiredViewPosition % rowHeight ); |
|
439 SetTopItemIndex( newTopItemIndex ); |
|
440 SetVerticalItemOffset( newVerticalOffset ); |
|
441 } |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
410 TInt CMmGrid::ScrollIfNeeded( const TPointerEvent& aPointerEvent ) |
447 TInt CMmGrid::ScrollIfNeeded( const TPointerEvent& aPointerEvent ) |
411 { |
448 { |
412 CAknGridView* view = static_cast<CAknGridView*>( View() ); |
449 CAknGridView* view = static_cast<CAknGridView*>( View() ); |
413 TInt nextScrollDelay = 0; |
450 TInt nextScrollDelay = 0; |
414 |
451 |
415 TBool readyForScrolling = iMmDrawer->GetAnimator()->IsReadyForNewAnimation() |
452 TBool readyForScrolling = iMmDrawer->GetAnimator()->IsReadyForNewAnimation() |
416 && iMmDrawer->GetFloatingItemCount() != 0; |
453 && iMmDrawer->GetFloatingItemCount() != 0; |
417 |
454 |
418 if ( IsPointerInTopScrollingThreshold( aPointerEvent ) ) |
455 if ( IsPointerInTopScrollingThreshold( aPointerEvent ) ) |
419 { |
456 { |
420 // scroll up by one row |
457 // scroll up by one row |
421 TInt newCurrentItemIndex = CurrentItemIndex() - view->NumberOfColsInView(); |
458 TInt newCurrentItemIndex = CurrentItemIndex() - view->NumberOfColsInView(); |
422 if ( newCurrentItemIndex < 0 ) |
459 if ( newCurrentItemIndex < 0 ) |
423 { |
460 { |
424 newCurrentItemIndex = CurrentItemIndex(); |
461 newCurrentItemIndex = CurrentItemIndex(); |
425 } |
462 } |
426 |
463 |
427 if ( !View()->ItemIsVisible( 0 ) ) |
464 nextScrollDelay = MmEffects::KEditModeScrollingDelayFactor * |
428 { |
465 Max( 1, aPointerEvent.iPosition.iY - Rect().iTl.iY ); |
429 nextScrollDelay = MmEffects::KEditModeScrollingDelayFactor * |
466 |
430 Max( 1, aPointerEvent.iPosition.iY - Rect().iTl.iY ); |
467 if ( readyForScrolling ) |
431 |
468 { |
432 if ( readyForScrolling ) |
469 ScrollWithoutRedraw( -iItemHeight ); |
433 { |
470 View()->SetCurrentItemIndex( newCurrentItemIndex ); |
434 TRAP_IGNORE( HandlePhysicsScrollEventL( -iItemHeight ) ); |
471 } |
435 View()->SetCurrentItemIndex( newCurrentItemIndex ); |
|
436 } |
|
437 } |
|
438 else |
|
439 { |
|
440 if ( readyForScrolling ) |
|
441 { |
|
442 TBool redrawDisabledBefore = View()->RedrawDisabled(); |
|
443 View()->SetDisableRedraw( EFalse ); |
|
444 CMmWidgetContainer* parent = static_cast<CMmWidgetContainer*>( Parent() ); |
|
445 parent->ResetWidgetPosition(); |
|
446 DrawNow(); |
|
447 View()->SetDisableRedraw( redrawDisabledBefore ); |
|
448 } |
|
449 } |
|
450 } |
472 } |
451 else if ( IsPointerInBottomScrollingThreshold( aPointerEvent) ) |
473 else if ( IsPointerInBottomScrollingThreshold( aPointerEvent) ) |
452 { |
474 { |
453 // scroll down by one row |
475 TInt newCurrentItemIndex = CurrentItemIndex() + view->NumberOfColsInView(); |
454 TInt lastItemIndex = iModel->NumberOfItems() - 1; |
476 if ( newCurrentItemIndex > iModel->NumberOfItems() - 1 ) |
455 |
|
456 // maximum top item index that can be set (greater top item index value would |
|
457 // cause an empty row at the bottom of the menu) |
|
458 TInt maxTopItemIndex = View()->CalcNewTopItemIndexSoItemIsVisible( lastItemIndex ); |
|
459 TInt currentItemIndex = CurrentItemIndex(); |
|
460 TInt newCurrentItemIndex = currentItemIndex + view->NumberOfColsInView(); |
|
461 TInt distanceToScroll( iItemHeight ); |
|
462 if ( View()->ItemIsVisible( lastItemIndex ) ) |
|
463 { |
477 { |
464 TPoint lastItemPos( View()->ItemPos( lastItemIndex ) ); |
478 newCurrentItemIndex = CurrentItemIndex(); |
465 distanceToScroll = iItemHeight - ( Rect().iBr.iY - lastItemPos.iY ) |
|
466 + Rect().Height() - iViewLayout.iHeight * iItemHeight; |
|
467 } |
479 } |
468 |
480 |
469 if ( newCurrentItemIndex <= lastItemIndex ) |
481 nextScrollDelay = MmEffects::KEditModeScrollingDelayFactor * |
482 Max( 1, Rect().iBr.iY - aPointerEvent.iPosition.iY ); |
|
483 |
|
484 if ( readyForScrolling ) |
|
470 { |
485 { |
471 nextScrollDelay = MmEffects::KEditModeScrollingDelayFactor * |
486 ScrollWithoutRedraw( iItemHeight ); |
472 Max( 1, Rect().iBr.iY - aPointerEvent.iPosition.iY ); |
487 View()->SetCurrentItemIndex( newCurrentItemIndex ); |
473 |
|
474 if ( readyForScrolling ) |
|
475 { |
|
476 TRAP_IGNORE( HandlePhysicsScrollEventL( distanceToScroll ) ); |
|
477 View()->SetCurrentItemIndex( newCurrentItemIndex ); |
|
478 } |
|
479 } |
|
480 else if ( TopItemIndex() < maxTopItemIndex ) |
|
481 { |
|
482 if ( readyForScrolling ) |
|
483 { |
|
484 TRAP_IGNORE( HandlePhysicsScrollEventL( distanceToScroll ) ); |
|
485 View()->SetCurrentItemIndex( currentItemIndex ); |
|
486 } |
|
487 } |
488 } |
488 } |
489 } |
489 |
490 |
490 return nextScrollDelay; |
491 return nextScrollDelay; |
491 } |
492 } |
492 |
493 |
493 // ----------------------------------------------------------------------------- |
494 // ----------------------------------------------------------------------------- |
494 // |
495 // |
685 { |
686 { |
686 if ( !AknLayoutUtils::LayoutMirrored() ) |
687 if ( !AknLayoutUtils::LayoutMirrored() ) |
687 { |
688 { |
688 CAknGrid::HandleViewRectSizeChangeL(); |
689 CAknGrid::HandleViewRectSizeChangeL(); |
689 } |
690 } |
690 else |
691 else |
691 { |
692 { |
692 // for mirrored layout this function should do |
693 // for mirrored layout this function should do |
693 // exactly the same things as CAknGrid::HandleViewRectSizeChangeL |
694 // exactly the same things as CAknGrid::HandleViewRectSizeChangeL |
694 // would do for normal layout |
695 // would do for normal layout |
695 iView->CalcBottomItemIndex(); |
696 iView->CalcBottomItemIndex(); |
711 { |
712 { |
712 CAknGridView* view = static_cast<CAknGridView*>( iView ); |
713 CAknGridView* view = static_cast<CAknGridView*>( iView ); |
713 const TInt numOfCols = view->NumberOfColsInView(); |
714 const TInt numOfCols = view->NumberOfColsInView(); |
714 const TInt numOfRows = view->NumberOfRowsInView(); |
715 const TInt numOfRows = view->NumberOfRowsInView(); |
715 const TInt itemCount = iModel->NumberOfItems(); |
716 const TInt itemCount = iModel->NumberOfItems(); |
716 |
717 |
717 ASSERT( numOfCols > 0 ); |
718 ASSERT( numOfCols > 0 ); |
718 |
719 |
719 TInt lastRow = 0; |
720 TInt lastRow = 0; |
720 if ( itemCount > 0 ) |
721 if ( itemCount > 0 ) |
721 { |
722 { |
722 lastRow = ( itemCount - 1 ) / numOfCols; |
723 lastRow = ( itemCount - 1 ) / numOfCols; |
723 } |
724 } |
724 TInt maxPossibleTopRow = Max( 0, lastRow - numOfRows + 1 ); |
725 TInt maxPossibleTopRow = Max( 0, lastRow - numOfRows + 1 ); |
725 |
726 |
726 TInt topRow = TopItemIndex() / numOfCols; |
727 TInt topRow = TopItemIndex() / numOfCols; |
727 |
728 |
728 if ( !( TopItemIndex() % numOfCols == 0 && |
729 if ( !( TopItemIndex() % numOfCols == 0 && |
729 topRow <= maxPossibleTopRow ) ) |
730 topRow <= maxPossibleTopRow ) ) |
730 { |
731 { |