menufw/menufwui/mmwidgets/src/mmlistboxitemdrawer.cpp
branchRCL_3
changeset 26 1b758917cafc
parent 25 137ebc85284b
child 28 d721605b30d0
equal deleted inserted replaced
25:137ebc85284b 26:1b758917cafc
   315                 TInt tempZoomRatio = iIconAnimationZoomRatio;
   315                 TInt tempZoomRatio = iIconAnimationZoomRatio;
   316 
   316 
   317                 iZoomIconIndex = iFloatingItems[i].GetDrawnItemIndex();
   317                 iZoomIconIndex = iFloatingItems[i].GetDrawnItemIndex();
   318                 iIconAnimationZoomRatio = iFloatingItems[i].GetCurrentZoomRatio();
   318                 iIconAnimationZoomRatio = iFloatingItems[i].GetCurrentZoomRatio();
   319 
   319 
   320                 if ( ItemHasFloatingType( drawnItemIndex, EDrag) ||
   320                 if ( ItemHasFloatingType( drawnItemIndex, EDrag)
   321                         ItemHasFloatingType( drawnItemIndex, EDragTransition) )
   321                         || ItemHasFloatingType( drawnItemIndex, EDragTransition)
       
   322                         || ItemHasFloatingType( drawnItemIndex, EDragStart ) )
   322                     {
   323                     {
   323                     ClearFlags( CListItemDrawer::EPressedDownState );
   324                     ClearFlags( CListItemDrawer::EPressedDownState );
   324                     }
   325                     }
   325                 type == ESwapTransition ? iIsSwapFloating = ETrue : iIsSwapFloating = EFalse;
   326                 type == ESwapTransition ? iIsSwapFloating = ETrue : iIsSwapFloating = EFalse;
   326                 DrawActualItem( drawnItemIndex, rect, ETrue, EFalse, EFalse, EFalse );
   327                 if( ( type == EDrag && !ItemHasFloatingType( drawnItemIndex, EDragStart ) )
       
   328                         || ( type != EDragTransition && type != EDrag
       
   329                                 && !ItemHasFloatingType( drawnItemIndex, EDragTransition ) )
       
   330                         || ( type == EDragTransition )
       
   331                     )
       
   332 					{
       
   333                     DrawActualItem( drawnItemIndex, rect, ETrue, EFalse, EFalse, EFalse );
       
   334 					}
   327                 iIconAnimationZoomRatio = tempZoomRatio;
   335                 iIconAnimationZoomRatio = tempZoomRatio;
   328                 iZoomIconIndex = tempZoomIconIndex;
   336                 iZoomIconIndex = tempZoomIconIndex;
   329                 }
   337                 }
   330             }
   338             }
   331         else
   339         else
   592             {
   600             {
   593             transApi->StopDrawing();
   601             transApi->StopDrawing();
   594             }
   602             }
   595 #endif
   603 #endif
   596         }
   604         }
       
   605     }
       
   606 
       
   607 // -----------------------------------------------------------------------------
       
   608 //
       
   609 // -----------------------------------------------------------------------------
       
   610 //
       
   611 void CMmListBoxItemDrawer::AnimateDragItemStartL( TInt aDraggedIndex,
       
   612         TPoint aPoint )
       
   613     {
       
   614     iAnimator->AnimateDragItemStartL( aDraggedIndex, aPoint );
       
   615     iAnimator->Trigger();
   597     }
   616     }
   598 
   617 
   599 // -----------------------------------------------------------------------------
   618 // -----------------------------------------------------------------------------
   600 //
   619 //
   601 // -----------------------------------------------------------------------------
   620 // -----------------------------------------------------------------------------
   737 //
   756 //
   738 // -----------------------------------------------------------------------------
   757 // -----------------------------------------------------------------------------
   739 //
   758 //
   740 TInt CMmListBoxItemDrawer::GetFloatingItemCount()
   759 TInt CMmListBoxItemDrawer::GetFloatingItemCount()
   741     {
   760     {
   742     for( TInt i = 0; i < iFloatingItems.Count(); i++ )
   761     for( TInt i( iFloatingItems.Count() - 1 ); i >= 0; i-- )
   743         {
   762         {
   744         TMmFloatingItem& current = GetFloatingItemAtIndex( i );
   763         TMmFloatingItem& current = GetFloatingItemAtIndex( i );
   745         if( current.GetDrawnItemIndex() == KErrNotFound )
   764         if( current.GetDrawnItemIndex() == KErrNotFound )
   746             {
   765             {
   747             RemoveFloatingItem( i );
   766             RemoveFloatingItem( i );
   933 // -----------------------------------------------------------------------------
   952 // -----------------------------------------------------------------------------
   934 //
   953 //
   935 // -----------------------------------------------------------------------------
   954 // -----------------------------------------------------------------------------
   936 //
   955 //
   937 void CMmListBoxItemDrawer::SetDraggedPointL( TPoint aPoint )
   956 void CMmListBoxItemDrawer::SetDraggedPointL( TPoint aPoint )
   938   {
   957     {
   939   TInt dragFloatingItem = GetFloatingItemIndex(EDrag);
   958     TInt dragFloatingItem = GetFloatingItemIndex( EDragStart );
   940   if (dragFloatingItem != KErrNotFound )
   959     if( KErrNotFound != dragFloatingItem )
   941     {
   960         {
   942     TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem );
   961         TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem );
   943     TMmFloatingItem floatingItem( item.GetDrawnItemIndex(),
   962         TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(),
   944         aPoint,	EDrag, MmEffects::KNoAnimationFramesCount, NULL );
       
   945     floatingItem.SetManualDelete( ETrue );
       
   946 
       
   947     TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(),
       
   948                 item.GetItemPosition(), EPostDragRefreshItem,
   963                 item.GetItemPosition(), EPostDragRefreshItem,
   949                 MmEffects::KNoAnimationFramesCount, iWidget->View() );
   964                 MmEffects::KNoAnimationFramesCount, iWidget->View() );
       
   965         if( postDragRefresh.GetItemPosition() != aPoint )
       
   966             {
       
   967             iFloatingItems.Append( postDragRefresh );
       
   968             }
       
   969         }
       
   970 
       
   971     if( dragFloatingItem == KErrNotFound
       
   972             && ( dragFloatingItem = GetFloatingItemIndex( EDrag ) )
       
   973                 != KErrNotFound )
       
   974         {
       
   975         TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem );
       
   976         TMmFloatingItem floatingItem( item.GetDrawnItemIndex(),
       
   977                 aPoint,	EDrag, MmEffects::KNoAnimationFramesCount, NULL );
       
   978         floatingItem.SetManualDelete( ETrue );
       
   979 
       
   980         TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(),
       
   981                 item.GetItemPosition(), EPostDragRefreshItem,
       
   982                 MmEffects::KNoAnimationFramesCount, iWidget->View() );
   950 
   983 
   951         iFloatingItems.Remove( dragFloatingItem );
   984         iFloatingItems.Remove( dragFloatingItem );
   952 
   985 
   953     if (postDragRefresh.GetItemPosition() != floatingItem.GetItemPosition())
   986         if (postDragRefresh.GetItemPosition() != floatingItem.GetItemPosition())
   954             {
   987             {
   955             iFloatingItems.Append( postDragRefresh );
   988             iFloatingItems.Append( postDragRefresh );
   956             }
   989             }
   957         iFloatingItems.Insert( floatingItem, 0 );
   990         iFloatingItems.Insert( floatingItem, 0 );
   958         }
   991         }
   966         TPoint aPoint )
   999         TPoint aPoint )
   967     {
  1000     {
   968     TInt dragFloatingItem = KErrNotFound;
  1001     TInt dragFloatingItem = KErrNotFound;
   969     do
  1002     do
   970         {
  1003         {
   971         dragFloatingItem = GetFloatingItemIndex( EDrag );
  1004         dragFloatingItem = GetFloatingItemIndex( EDragStart );
       
  1005         if( dragFloatingItem == KErrNotFound )
       
  1006             dragFloatingItem = GetFloatingItemIndex( EDrag );
   972         if( dragFloatingItem != KErrNotFound )
  1007         if( dragFloatingItem != KErrNotFound )
   973             {
  1008             {
   974         TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem );
  1009             TMmFloatingItem & item = GetFloatingItemAtIndex( dragFloatingItem );
   975 
  1010 
   976             TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(),
  1011             TMmFloatingItem postDragRefresh( item.GetDrawnItemIndex(),
   977                     item.GetItemPosition(), EPostDragRefreshItem,
  1012                     item.GetItemPosition(), EPostDragRefreshItem,
   978                     MmEffects::KNoAnimationFramesCount, iWidget->View() );
  1013                     MmEffects::KNoAnimationFramesCount, iWidget->View() );
   979 
  1014 
   980             if( postDragRefresh.GetItemPosition() != aPoint )
  1015             if( postDragRefresh.GetItemPosition() != aPoint )
   981                 {
  1016                 {
   982                 iFloatingItems.Append( postDragRefresh );
  1017                 iFloatingItems.Append( postDragRefresh );
   983                 }
  1018                 }
   984             }
  1019             if( item.GetFloatingItemType() == EDrag )
   985 
  1020                 RemoveFloatingItem( dragFloatingItem );
   986         RemoveFloatingItem( dragFloatingItem );
  1021             }
   987 
  1022         }
   988         }
  1023     while( GetFloatingItemIndex( EDrag ) != KErrNotFound );
   989     while( dragFloatingItem != KErrNotFound );
       
   990 
  1024 
   991     if( aDraggedItemIndex != KErrNotFound )
  1025     if( aDraggedItemIndex != KErrNotFound )
   992         {
  1026         {
   993         TMmFloatingItem floatingItem( aDraggedItemIndex, aPoint, EDrag,
  1027         TMmFloatingItem floatingItem( aDraggedItemIndex, aPoint, EDrag,
   994                 MmEffects::KNoAnimationFramesCount, iWidget->View() );
  1028                 MmEffects::KNoAnimationFramesCount, iWidget->View() );
   995         floatingItem.SetManualDelete( ETrue );
  1029         floatingItem.SetManualDelete( ETrue );
   996         AddFloatingItemL( floatingItem, 0 );
  1030         AddFloatingItemL( floatingItem, 0 );
       
  1031 
       
  1032         TMmFloatingItem postDragRefresh( aDraggedItemIndex,
       
  1033                 iWidget->View()->ItemPos( aDraggedItemIndex ), EPostDragRefreshItem,
       
  1034                 MmEffects::KNoAnimationFramesCount, iWidget->View() );
       
  1035         AddFloatingItemL( postDragRefresh );
   997 
  1036 
   998         ClearFlags( CListItemDrawer::EPressedDownState );
  1037         ClearFlags( CListItemDrawer::EPressedDownState );
   999         }
  1038         }
  1000 
  1039 
  1001     iAnimator->Trigger();
  1040     iAnimator->Trigger();
  1521     TInt index = GetFloatingItemIndex( EDrag );
  1560     TInt index = GetFloatingItemIndex( EDrag );
  1522     if( index == KErrNotFound )
  1561     if( index == KErrNotFound )
  1523         {
  1562         {
  1524         index = GetFloatingItemIndex( EDragTransition );
  1563         index = GetFloatingItemIndex( EDragTransition );
  1525         }
  1564         }
       
  1565     if( index == KErrNotFound )
       
  1566         {
       
  1567         index = GetFloatingItemIndex( EDragStart );
       
  1568         }
  1526 
  1569 
  1527     if( KErrNotFound != index )
  1570     if( KErrNotFound != index )
  1528         {
  1571         {
  1529         TMmFloatingItem& current = const_cast<CMmListBoxItemDrawer*>(this)->GetFloatingItemAtIndex( index );
  1572         TMmFloatingItem& current = const_cast<CMmListBoxItemDrawer*>(this)->GetFloatingItemAtIndex( index );
  1530         TInt drawnIndex = current.GetDrawnItemIndex();
  1573         TInt drawnIndex = current.GetDrawnItemIndex();
  1562     {
  1605     {
  1563     TBool highlightVisibility( EFalse );
  1606     TBool highlightVisibility( EFalse );
  1564     if( !iItemHasBackdrop && !iLeftOverAreaUnderAnimatedItem ) //never draw highlight when item has backdrop or when left over area under animated item
  1607     if( !iItemHasBackdrop && !iLeftOverAreaUnderAnimatedItem ) //never draw highlight when item has backdrop or when left over area under animated item
  1565         {
  1608         {
  1566         TBool currentlyDraggedItem =
  1609         TBool currentlyDraggedItem =
  1567                 ItemHasFloatingType( aItemIndex, EDrag ) ||
  1610                 ItemHasFloatingType( aItemIndex, EDrag )
  1568                 ItemHasFloatingType( aItemIndex, EDragTransition );
  1611                 || ItemHasFloatingType( aItemIndex, EDragTransition )
       
  1612                 || ItemHasFloatingType( aItemIndex, EDragStart );
  1569 
  1613 
  1570         if( ( STATIC_CAST(CMmWidgetContainer*,Widget()->Parent())->IsHighlightVisible()
  1614         if( ( STATIC_CAST(CMmWidgetContainer*,Widget()->Parent())->IsHighlightVisible()
  1571                 && aItemIsCurrent && aAllowHighlightForNonDraggedItem )
  1615                 && aItemIsCurrent && aAllowHighlightForNonDraggedItem )
  1572                 || currentlyDraggedItem )
  1616                 || currentlyDraggedItem )
  1573             {
  1617             {
  1583 //
  1627 //
  1584 TBool CMmListBoxItemDrawer::GetBackdropVisibility( TInt aItemIndex,
  1628 TBool CMmListBoxItemDrawer::GetBackdropVisibility( TInt aItemIndex,
  1585         TBool aItemIsCurrent ) const
  1629         TBool aItemIsCurrent ) const
  1586     {
  1630     {
  1587     TBool currentlyDraggedItem =
  1631     TBool currentlyDraggedItem =
  1588     ItemHasFloatingType( aItemIndex, EDrag ) ||
  1632             ItemHasFloatingType( aItemIndex, EDrag )
  1589     ItemHasFloatingType( aItemIndex, EDragTransition );
  1633             || ItemHasFloatingType( aItemIndex, EDragTransition )
       
  1634             || ItemHasFloatingType( aItemIndex, EDragStart );
  1590 
  1635 
  1591     return 	IsEditMode() /* draw the backdrop only in edit mode */
  1636     return 	IsEditMode() /* draw the backdrop only in edit mode */
  1592         && !currentlyDraggedItem /* backdrop is disabled for dragged items */
  1637         && !currentlyDraggedItem /* backdrop is disabled for dragged items */
  1593         && !iIsIndicatorItem /* in non-touch backdrop is not drawn, just "move indicators" */
  1638         && !iIsIndicatorItem /* in non-touch backdrop is not drawn, just "move indicators" */
  1594         && !iLeftOverAreaUnderAnimatedItem /* is the currently drawn item the area left over behind dragged item*/
  1639         && !iLeftOverAreaUnderAnimatedItem /* is the currently drawn item the area left over behind dragged item*/