99 // ----------------------------------------------------------------------------- |
99 // ----------------------------------------------------------------------------- |
100 // |
100 // |
101 CMmWidgetContainer::CMmWidgetContainer() |
101 CMmWidgetContainer::CMmWidgetContainer() |
102 : iMarqueeAdapter( NULL ) |
102 : iMarqueeAdapter( NULL ) |
103 , iLongTapInProgress( EFalse ) |
103 , iLongTapInProgress( EFalse ) |
|
104 , iDragOccured( EFalse ) |
104 , iBgContext( NULL ) |
105 , iBgContext( NULL ) |
105 , iIsFaded( EFalse ) |
106 , iIsFaded( EFalse ) |
106 , iHasFocus( ETrue ) |
107 , iHasFocus( ETrue ) |
107 , iInForeground( ETrue ) |
108 , iInForeground( ETrue ) |
108 , iLongTapDetector( NULL ) |
109 , iLongTapDetector( NULL ) |
208 { |
209 { |
209 iTapPoint = aPointerEvent.iPosition; |
210 iTapPoint = aPointerEvent.iPosition; |
210 iLastDragPoint = aPointerEvent.iPosition; |
211 iLastDragPoint = aPointerEvent.iPosition; |
211 iLastDragHighlight = GetHighlight(); |
212 iLastDragHighlight = GetHighlight(); |
212 if( !iWidget->View()->XYPosToItemIndex( |
213 if( !iWidget->View()->XYPosToItemIndex( |
213 aPointerEvent.iPosition, iDraggedIndex ) ) |
214 aPointerEvent.iPosition, iDraggedIndex ) ) |
214 { |
215 { |
215 iDraggedIndex = KErrNotFound; |
216 iDraggedIndex = KErrNotFound; |
216 } |
217 } |
217 iItemRelativeTapPoint = aPointerEvent.iPosition - iWidget->View()->ItemPos( |
218 iItemRelativeTapPoint = aPointerEvent.iPosition - iWidget->View()->ItemPos( |
218 iDraggedIndex ); |
219 iDraggedIndex ); |
310 |
311 |
311 if( iLastDragHighlight != highlight ) |
312 if( iLastDragHighlight != highlight ) |
312 { |
313 { |
313 iDragAndDropObserver->HandleDragOverL( GetHighlight() ); |
314 iDragAndDropObserver->HandleDragOverL( GetHighlight() ); |
314 } |
315 } |
315 |
316 |
|
317 TPoint centerPoint( aPointerEvent.iPosition ); |
|
318 if( WidgetType() == EGridWidget ) |
|
319 { // move item's TL corner by half width/height to center item horizontally. |
|
320 centerPoint.iX -= ( iWidget->View()->ItemSize( highlight ).iWidth / 2 ); |
|
321 centerPoint.iY -= ( iWidget->View()->ItemSize( highlight ).iHeight / 2 ); |
|
322 } |
|
323 else |
|
324 { // move item's T of corner by relative tap point to align left horizontally. |
|
325 centerPoint.iX -= iItemRelativeTapPoint.iX; |
|
326 // move item's L of corner by half height to center item horizontally. |
|
327 centerPoint.iY -= ( iWidget->View()->ItemSize( highlight ).iHeight / 2 ); |
|
328 } |
|
329 |
316 if( !tooFast ) |
330 if( !tooFast ) |
317 { |
331 { |
318 TSize itemSize = iWidget->View()->ItemSize( highlight ); |
332 TSize itemSize = iWidget->View()->ItemSize( highlight ); |
319 TPoint itemPos = iWidget->View()->ItemPos( highlight ); |
333 TPoint itemPos = iWidget->View()->ItemPos( highlight ); |
320 |
334 |
321 if ( PointInItemReorderAreaL( highlight, aPointerEvent.iPosition ) ) |
335 if ( PointInItemReorderAreaL( highlight, aPointerEvent.iPosition ) ) |
322 { |
|
323 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
|
324 CHnItemModel* onItemModel = model->GetItemModel( model->IdByIndex( highlight )); |
|
325 if (iDrawer->GetAnimator()->IsReadyForNewAnimation() && !aAbortAnimation |
|
326 && onItemModel->GetItemType() != EItemTypeParentFolder |
|
327 && iDraggedIndex != highlight) |
|
328 { |
336 { |
329 GetMmModel()->ReorderModelL( iDraggedIndex, highlight ); |
337 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
330 AnimateShiftL( highlight ); |
338 CHnItemModel* onItemModel = model->GetItemModel( model->IdByIndex( highlight )); |
331 iDrawer->SetDraggedIndexL( highlight, |
339 if( iDrawer->GetAnimator()->IsReadyForNewAnimation() && !aAbortAnimation |
332 aPointerEvent.iPosition - iItemRelativeTapPoint ); |
340 && onItemModel->GetItemType() != EItemTypeParentFolder |
333 iDraggedIndex = highlight; |
341 && iDraggedIndex != highlight ) |
334 iDragAndDropObserver->HandleDraggedIndexUpdatedL( highlight ); |
342 { |
|
343 GetMmModel()->ReorderModelL( iDraggedIndex, highlight ); |
|
344 AnimateShiftL( highlight ); |
|
345 iDrawer->SetDraggedIndexL( highlight, centerPoint ); |
|
346 iDraggedIndex = highlight; |
|
347 iDragAndDropObserver->HandleDraggedIndexUpdatedL( highlight ); |
|
348 } |
335 } |
349 } |
336 } |
350 } |
337 } |
351 |
338 |
352 |
339 if ( DeltaSquare( iTapPoint, aPointerEvent.iPosition ) > KDragDelta && |
353 |
340 !iDrawer->IsDraggable() ) |
354 if ( DeltaSquare( iTapPoint, aPointerEvent.iPosition ) > KDragDelta |
341 { |
355 && !iDrawer->IsDraggable() ) |
342 iDrawer->SetDraggedIndexL( iDraggedIndex, iTapPoint - iItemRelativeTapPoint ); |
356 { |
|
357 if( !tooFast ) |
|
358 { |
|
359 iDrawer->AnimateDragItemStartL( iDraggedIndex, centerPoint ); |
|
360 } |
|
361 iDrawer->SetDraggedIndexL( iDraggedIndex, centerPoint ); |
343 iDrawer->SetDraggableL( ETrue ); |
362 iDrawer->SetDraggableL( ETrue ); |
344 } |
363 } |
345 else if( iDrawer->IsDraggable() ) |
364 else if( iDrawer->IsDraggable() ) |
346 { |
365 { |
347 iDrawer->SetDraggedPointL( aPointerEvent.iPosition - iItemRelativeTapPoint ); |
366 iDrawer->SetDraggedPointL( centerPoint ); |
348 } |
367 } |
349 |
368 |
350 DEBUG(("\t_Mm_:CMmWidgetContainer::HandleDragL: iLastDragHighlight = %d ", iLastDragHighlight )); |
369 DEBUG(("\t_Mm_:CMmWidgetContainer::HandleDragL: iLastDragHighlight = %d ", iLastDragHighlight )); |
351 DEBUG(("\t_Mm_:CMmWidgetContainer::HandleDragL: highlight = %d ", highlight )); |
370 DEBUG(("\t_Mm_:CMmWidgetContainer::HandleDragL: highlight = %d ", highlight )); |
352 iLastDragPoint = aPointerEvent.iPosition; |
371 iLastDragPoint = aPointerEvent.iPosition; |
391 |
410 |
392 iDraggedIndex = -1; |
411 iDraggedIndex = -1; |
393 iDrawer->SetDraggedIndexL( iDraggedIndex, TPoint( 0, 0 ) ); |
412 iDrawer->SetDraggedIndexL( iDraggedIndex, TPoint( 0, 0 ) ); |
394 SetDraggableL( EFalse ); |
413 SetDraggableL( EFalse ); |
395 |
414 |
396 TInt dragFloatingItem; |
415 TInt dragFloatingItem( KErrNotFound ); |
|
416 TInt dragStartFloatingItem( KErrNotFound ); |
397 do |
417 do |
398 { |
418 { |
399 dragFloatingItem = iDrawer->GetFloatingItemIndex( EDrag ); |
419 dragFloatingItem = iDrawer->GetFloatingItemIndex( EDrag ); |
400 iDrawer->RemoveFloatingItem( dragFloatingItem ); |
420 iDrawer->RemoveFloatingItem( dragFloatingItem ); |
401 } |
421 dragStartFloatingItem = iDrawer->GetFloatingItemIndex( EDragStart ); |
402 while( dragFloatingItem != KErrNotFound ); |
422 iDrawer->RemoveFloatingItem( dragStartFloatingItem ); |
|
423 } |
|
424 while( dragFloatingItem != KErrNotFound || dragStartFloatingItem != KErrNotFound); |
403 |
425 |
404 } |
426 } |
405 |
427 |
406 // ----------------------------------------------------------------------------- |
428 // ----------------------------------------------------------------------------- |
407 // |
429 // |
433 // |
455 // |
434 |
456 |
435 TBool CMmWidgetContainer::IsNoItemDragged() |
457 TBool CMmWidgetContainer::IsNoItemDragged() |
436 { |
458 { |
437 TBool noItemDragged = EFalse; |
459 TBool noItemDragged = EFalse; |
438 noItemDragged = ( KErrNotFound == iDraggedIndex ) ? ETrue : noItemDragged; |
460 noItemDragged = ( KErrNotFound == iDraggedIndex ) ? ETrue : noItemDragged; |
439 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
461 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
440 if( !noItemDragged && model ) |
462 if( !noItemDragged && model ) |
441 { |
463 { |
442 CHnItemModel* onItemModel = model->GetItemModel( model->IdByIndex( iDraggedIndex )); |
464 CHnItemModel* onItemModel = model->GetItemModel( model->IdByIndex( iDraggedIndex )); |
443 if( onItemModel ) |
465 if( onItemModel ) |
444 { |
466 { |
445 noItemDragged = ( onItemModel->GetItemType() == EItemTypeParentFolder ); |
467 noItemDragged = ( onItemModel->GetItemType() == EItemTypeParentFolder ); |
446 } |
468 } |
447 } |
469 } |
448 return noItemDragged; |
470 return noItemDragged; |
449 } |
471 } |
450 |
472 |
551 |
573 |
552 // ----------------------------------------------------------------------------- |
574 // ----------------------------------------------------------------------------- |
553 // |
575 // |
554 // ----------------------------------------------------------------------------- |
576 // ----------------------------------------------------------------------------- |
555 // |
577 // |
556 TBool CMmWidgetContainer::IsDeleteLockedL( TInt aItemIndex ) |
578 TMmWidgetPosition CMmWidgetContainer::WidgetPositionCache() const |
|
579 { |
|
580 return iWidgetPositionCache; |
|
581 } |
|
582 |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 // ----------------------------------------------------------------------------- |
|
586 // |
|
587 TBool CMmWidgetContainer::IsDeleteLocked( TInt aItemIndex ) |
557 { |
588 { |
558 TBool result = ETrue; |
589 TBool result = ETrue; |
559 |
590 |
560 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
591 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
561 if( model ) |
592 if( model ) |
714 longTapPointerEvent.iType = TPointerEvent::EDrag; |
745 longTapPointerEvent.iType = TPointerEvent::EDrag; |
715 } |
746 } |
716 iLongTapDetector->PointerEventL( longTapPointerEvent ); |
747 iLongTapDetector->PointerEventL( longTapPointerEvent ); |
717 } |
748 } |
718 |
749 |
719 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
720 |
|
721 if ( aPointerEvent.iType == TPointerEvent::EButton1Down |
750 if ( aPointerEvent.iType == TPointerEvent::EButton1Down |
722 && itemExists ) |
751 && itemExists ) |
723 { |
752 { |
724 SetHighlightL( index ); |
753 SetHighlightL( index ); |
725 } |
754 } |
726 else if( aPointerEvent.iType == TPointerEvent::EDrag |
755 else if( aPointerEvent.iType == TPointerEvent::EDrag |
727 // the line below is needed to enable edit mode in the list widget |
756 // the line below is needed to enable edit mode in the list widget |
728 // because behaviour in the grid and list is different |
757 // because behaviour in the grid and list is different |
729 || (aPointerEvent.iType == TPointerEvent::EButtonRepeat && WidgetType() == EGridWidget )) |
758 || (aPointerEvent.iType == TPointerEvent::EButtonRepeat && WidgetType() == EGridWidget )) |
730 { |
759 { |
731 if( itemExists ) |
760 if( itemExists ) |
732 { |
761 { |
818 // |
850 // |
819 // ----------------------------------------------------------------------------- |
851 // ----------------------------------------------------------------------------- |
820 // |
852 // |
821 EXPORT_C void CMmWidgetContainer::SetHighlightVisibilityL( TBool aEnable ) |
853 EXPORT_C void CMmWidgetContainer::SetHighlightVisibilityL( TBool aEnable ) |
822 { |
854 { |
823 // activate the model |
|
824 CHnSuiteModel* suiteModel = GetMmModel()->GetSuiteModel(); |
|
825 |
|
826 if( suiteModel ) |
|
827 { |
|
828 suiteModel->SetActiveL( aEnable ); |
|
829 } |
|
830 |
|
831 if( ( !!aEnable != !!iPreviousHighlightVisibility ) // Ex-OR |
855 if( ( !!aEnable != !!iPreviousHighlightVisibility ) // Ex-OR |
832 || ( !!aEnable != !!IsHighlightVisible() ) ) // Ex-OR |
856 || ( !!aEnable != !!IsHighlightVisible() ) ) // Ex-OR |
833 { |
857 { |
834 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
858 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
835 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( |
859 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( |
1447 - iWidget->TopItemIndex() / ColumnsInCurrentView() ) <= 1 ) |
1472 - iWidget->TopItemIndex() / ColumnsInCurrentView() ) <= 1 ) |
1448 { |
1473 { |
1449 return; |
1474 return; |
1450 } |
1475 } |
1451 |
1476 |
1452 TBool needToScrollUp = |
1477 TBool needToScrollUp = |
1453 GetHighlight() - iWidget->TopItemIndex() < ColumnsInCurrentView() |
1478 GetHighlight() - iWidget->TopItemIndex() < ColumnsInCurrentView() |
1454 && iWidget->TopItemIndex() != 0; |
1479 && iWidget->TopItemIndex() != 0; |
1455 |
1480 |
1456 TBool needToScrollDown = |
1481 TBool needToScrollDown = |
1457 iWidget->BottomItemIndex() - GetHighlight() < ColumnsInCurrentView() |
1482 iWidget->BottomItemIndex() - GetHighlight() < ColumnsInCurrentView() |
1458 && iWidget->BottomItemIndex() / ColumnsInCurrentView() |
1483 && iWidget->BottomItemIndex() / ColumnsInCurrentView() |
1459 != ( NumberOfItems() - 1 ) / ColumnsInCurrentView(); |
1484 != ( NumberOfItems() - 1 ) / ColumnsInCurrentView(); |
1460 |
1485 |
1461 if( WidgetType() == EGridWidget ) |
1486 if( WidgetType() == EGridWidget ) |
1462 { |
1487 { |
1463 // TODO: temporary - invisible partial items in MCL grid :/ |
1488 // TODO: temporary - invisible partial items in MCL grid :/ |
1464 needToScrollDown = |
1489 needToScrollDown = |
1465 iWidget->BottomItemIndex() - ColumnsInCurrentView() - GetHighlight() < ColumnsInCurrentView() |
1490 iWidget->BottomItemIndex() - ColumnsInCurrentView() - GetHighlight() < ColumnsInCurrentView() |
1466 && ( iWidget->BottomItemIndex() / ColumnsInCurrentView() ) - 1 |
1491 && ( iWidget->BottomItemIndex() / ColumnsInCurrentView() ) - 1 |
1467 != ( NumberOfItems() - 1 ) / ColumnsInCurrentView() |
1492 != ( NumberOfItems() - 1 ) / ColumnsInCurrentView() |
1468 && iWidget->BottomItemIndex() - iWidget->TopItemIndex() |
1493 && iWidget->BottomItemIndex() - iWidget->TopItemIndex() |
1469 > ColumnsInCurrentView() * RowsInCurrentView(); |
1494 > ColumnsInCurrentView() * RowsInCurrentView(); |
1470 } |
1495 } |
1471 |
1496 |
1472 if( needToScrollUp ) |
1497 if( needToScrollUp ) |
1473 { |
1498 { |
1474 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1499 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1475 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iDrawer->Gc() ); |
1500 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iDrawer->Gc() ); |
1476 if( transApi ) |
1501 if( transApi ) |
1477 { |
1502 { |
1478 transApi->SetMoveType( MAknListBoxTfxInternal::EListScrollUp ); |
1503 transApi->SetMoveType( MAknListBoxTfxInternal::EListScrollUp ); |
1479 } |
1504 } |
1480 #endif |
1505 #endif |
1481 iDrawer->RemoveFloatingItems(); |
1506 iDrawer->RemoveFloatingItems(); |
1482 iWidget->View()->VScrollTo( |
1507 iWidget->View()->VScrollTo( |
1483 iWidget->TopItemIndex() - ColumnsInCurrentView() ); |
1508 iWidget->TopItemIndex() - ColumnsInCurrentView() ); |
1484 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1509 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1485 if( transApi ) |
1510 if( transApi ) |
1486 { |
1511 { |
1487 transApi->Draw( Rect() ); |
1512 transApi->Draw( Rect() ); |
1488 } |
1513 } |
1491 } |
1516 } |
1492 else if( needToScrollDown ) |
1517 else if( needToScrollDown ) |
1493 { |
1518 { |
1494 |
1519 |
1495 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1520 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1496 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iDrawer->Gc() ); |
1521 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iDrawer->Gc() ); |
1497 if( transApi ) |
1522 if( transApi ) |
1498 { |
1523 { |
1499 transApi->SetMoveType( MAknListBoxTfxInternal::EListScrollDown ); |
1524 transApi->SetMoveType( MAknListBoxTfxInternal::EListScrollDown ); |
1500 } |
1525 } |
1501 #endif |
1526 #endif |
1502 iDrawer->RemoveFloatingItems(); |
1527 iDrawer->RemoveFloatingItems(); |
1503 iWidget->View()->VScrollTo( |
1528 iWidget->View()->VScrollTo( |
1504 iWidget->TopItemIndex() + ColumnsInCurrentView() ); |
1529 iWidget->TopItemIndex() + ColumnsInCurrentView() ); |
1505 |
1530 |
1506 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1531 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
1507 if( transApi ) |
1532 if( transApi ) |
1508 { |
1533 { |
1509 transApi->Draw( Rect() ); |
1534 transApi->Draw( Rect() ); |
1558 && iDraggedIndex != Widget()->CurrentItemIndex() |
1583 && iDraggedIndex != Widget()->CurrentItemIndex() |
1559 && iDraggedIndex < NumberOfItems() ) |
1584 && iDraggedIndex < NumberOfItems() ) |
1560 { |
1585 { |
1561 TBool isFolder( EFalse ); |
1586 TBool isFolder( EFalse ); |
1562 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
1587 CHnSuiteModel* model = GetMmModel()->GetSuiteModel(); |
1563 CHnItemModel* onItemModel = model->GetItemModel( |
1588 CHnItemModel* onItemModel = model->GetItemModel( |
1564 model->IdByIndex( Widget()->CurrentItemIndex() )); |
1589 model->IdByIndex( Widget()->CurrentItemIndex() )); |
1565 if( onItemModel ) |
1590 if( onItemModel ) |
1566 { |
1591 { |
1567 isFolder = onItemModel->GetItemType() == EItemTypeParentFolder |
1592 isFolder = onItemModel->GetItemType() == EItemTypeParentFolder |
1568 || onItemModel->GetItemType() == EItemTypeFolder; |
1593 || onItemModel->GetItemType() == EItemTypeFolder; |
1998 switch( aEventType ) |
2024 switch( aEventType ) |
1999 { |
2025 { |
2000 case MEikListBoxObserver::EEventFlickStarted: |
2026 case MEikListBoxObserver::EEventFlickStarted: |
2001 case MEikListBoxObserver::EEventPanningStarted: |
2027 case MEikListBoxObserver::EEventPanningStarted: |
2002 { |
2028 { |
2003 static_cast<CMmListBoxItemDrawer*>( |
2029 static_cast<CMmListBoxItemDrawer*>( |
2004 Widget()->View()->ItemDrawer() )-> |
2030 Widget()->View()->ItemDrawer() )-> |
2005 EnableCachedDataUse( ETrue ); |
2031 EnableCachedDataUse( ETrue ); |
2006 break; |
2032 break; |
2007 } |
2033 } |
2008 case MEikListBoxObserver::EEventFlickStopped: |
2034 case MEikListBoxObserver::EEventFlickStopped: |
2009 { |
2035 { |
2010 static_cast<CMmListBoxItemDrawer*>( |
2036 static_cast<CMmListBoxItemDrawer*>( |
2011 Widget()->View()->ItemDrawer() )-> |
2037 Widget()->View()->ItemDrawer() )-> |
2012 EnableCachedDataUse( EFalse ); |
2038 EnableCachedDataUse( EFalse ); |
2013 DrawView(); |
2039 DrawView(); |
2014 break; |
2040 break; |
2015 } |
2041 } |
2016 case MEikListBoxObserver::EEventPanningStopped: |
2042 case MEikListBoxObserver::EEventPanningStopped: |
2017 { |
2043 { |
2018 static_cast<CMmListBoxItemDrawer*>( |
2044 static_cast<CMmListBoxItemDrawer*>( |
2019 Widget()->View()->ItemDrawer() )-> |
2045 Widget()->View()->ItemDrawer() )-> |
2020 EnableCachedDataUse( EFalse ); |
2046 EnableCachedDataUse( EFalse ); |
2021 break; |
2047 break; |
2022 } |
2048 } |
2023 } |
2049 } |
2024 } |
2050 } |
2025 else |
2051 else |
2026 { |
2052 { |