emailuis/uicomponents/src/fstreevisualizerbase.cpp
changeset 2 5253a20d2a1e
parent 1 12c456ceeff2
child 3 a4d6f1ea0416
equal deleted inserted replaced
1:12c456ceeff2 2:5253a20d2a1e
    10  * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11  *
    11  *
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  *  Description : Freestyle tree list visualizer implementation
    14  *  Description : Freestyle tree list visualizer implementation
    15  *  
    15  *
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 //////SYSTEM INCLUDES
    19 //////SYSTEM INCLUDES
    20 #include "emailtrace.h"
    20 #include "emailtrace.h"
   680     TRect itemRect;
   680     TRect itemRect;
   681     if (iWorld.GetItemRect(aItemId, itemRect) != KErrNotFound)
   681     if (iWorld.GetItemRect(aItemId, itemRect) != KErrNotFound)
   682         {
   682         {
   683         TInt top(itemRect.iTl.iY);
   683         TInt top(itemRect.iTl.iY);
   684         top -= aPosition.iY;
   684         top -= aPosition.iY;
   685         LimitTop(top);            
   685         LimitTop(top);
   686         if (aHint == EPositionAfterExpand)
   686         if (aHint == EPositionAfterExpand)
   687             {
   687             {
   688             const TInt error( iWorld.GetItemRectByIndex(
   688             const TInt error( iWorld.GetItemRectByIndex(
   689                     iWorld.IndexOfItem(aItemId) + 1, itemRect) );
   689                     iWorld.IndexOfItem(aItemId) + 1, itemRect) );
   690             if (!error)
   690             if (!error)
   691                 {
   691                 {
   692                 if (itemRect.iBr.iY - top > iSize.iHeight)
   692                 if (itemRect.iBr.iY - top > iSize.iHeight)
   693                     {
   693                     {
   694                     top += itemRect.iBr.iY - top - iSize.iHeight;
   694                     top += itemRect.iBr.iY - top - iSize.iHeight;
   695                     LimitTop(top);            
   695                     LimitTop(top);
   696                     }
   696                     }
   697                 }
   697                 }
   698             }
   698             }
   699         SetPositionL(TPoint(iPosition.iX, top), aInformUpdate);
   699         SetPositionL(TPoint(iPosition.iX, top), aInformUpdate);
   700         }
   700         }
  1408                     }
  1408                     }
  1409                 case EStdKeyLeftArrow:
  1409                 case EStdKeyLeftArrow:
  1410                     {
  1410                     {
  1411                     if (iVisualizerObserver)
  1411                     if (iVisualizerObserver)
  1412                         {
  1412                         {
  1413                         // <cmail> Touch
       
  1414                         iVisualizerObserver->TreeVisualizerEventL(
  1413                         iVisualizerObserver->TreeVisualizerEventL(
  1415                                 MFsTreeVisualizerObserver::EFsTreeKeyLeftArrow,
  1414                                 MFsTreeVisualizerObserver::EFsTreeKeyLeftArrow,
  1416                                 iFocusedItem);
  1415                                 iFocusedItem);
  1417                         // </cmail>
       
  1418                         }
  1416                         }
  1419                     eventHandled = ETrue;
  1417                     eventHandled = ETrue;
  1420                     break;
  1418                     break;
  1421                     }
  1419                     }
  1422                 case EStdKeyRightArrow:
  1420                 case EStdKeyRightArrow:
  1423                     {
  1421                     {
  1424                     if (iVisualizerObserver)
  1422                     if (iVisualizerObserver)
  1425                         {
  1423                         {
  1426                         // <cmail>
       
  1427                         iVisualizerObserver->TreeVisualizerEventL(
  1424                         iVisualizerObserver->TreeVisualizerEventL(
  1428                                 MFsTreeVisualizerObserver::EFsTreeKeyRightArrow,
  1425                                 MFsTreeVisualizerObserver::EFsTreeKeyRightArrow,
  1429                                 iFocusedItem);
  1426                                 iFocusedItem);
  1430                         // </cmail>
       
  1431                         }
  1427                         }
  1432                     eventHandled = ETrue;
  1428                     eventHandled = ETrue;
  1433                     break;
  1429                     break;
  1434                     }
  1430                     }
  1435                 case EStdKeyDevice3:
  1431                 case EStdKeyDevice3:
  1449                         {
  1445                         {
  1450                         if (iVisualizerObserver)
  1446                         if (iVisualizerObserver)
  1451                             {
  1447                             {
  1452                             if (iTreeData->ItemVisualizer(iFocusedItem)->Menu())
  1448                             if (iTreeData->ItemVisualizer(iFocusedItem)->Menu())
  1453                                 {
  1449                                 {
  1454                                 // <cmail> Touch
       
  1455                                 iVisualizerObserver->TreeVisualizerEventL(
  1450                                 iVisualizerObserver->TreeVisualizerEventL(
  1456                                         MFsTreeVisualizerObserver::EFsTreeItemWithMenuSelected,
  1451                                         MFsTreeVisualizerObserver::EFsTreeItemWithMenuSelected,
  1457                                         iFocusedItem);
  1452                                         iFocusedItem);
  1458                                 }
  1453                                 }
  1459                             else
  1454                             else
  1460                                 {
  1455                                 {
  1461                                 iVisualizerObserver->TreeVisualizerEventL(
  1456                                 iVisualizerObserver->TreeVisualizerEventL(
  1462                                         MFsTreeVisualizerObserver::EFsTreeItemSelected,
  1457                                         MFsTreeVisualizerObserver::EFsTreeItemSelected,
  1463                                         iFocusedItem);
  1458                                         iFocusedItem);
  1464                                 // </cmail>
       
  1465                                 }
  1459                                 }
  1466                             }
  1460                             }
  1467                         }
  1461                         }
  1468                     eventHandled = ETrue;
  1462                     eventHandled = ETrue;
  1469                     break;
  1463                     break;
  1530             MakeSelectorVisibleL( aShow );
  1524             MakeSelectorVisibleL( aShow );
  1531             UpdateItemL( iFocusedItem ); );
  1525             UpdateItemL( iFocusedItem ); );
  1532         }
  1526         }
  1533     }
  1527     }
  1534 
  1528 
  1535 // <cmail> "Base class modifications for using touch"
       
  1536 
       
  1537 // ---------------------------------------------------------------------------
  1529 // ---------------------------------------------------------------------------
  1538 // CFsTreeVisualizerBase::HandlePointerEventL
  1530 // CFsTreeVisualizerBase::HandlePointerEventL
  1539 //
       
  1540 // ---------------------------------------------------------------------------
  1531 // ---------------------------------------------------------------------------
  1541 //
  1532 //
  1542 TBool CFsTreeVisualizerBase::HandlePointerEventL(const TAlfEvent& aEvent)
  1533 TBool CFsTreeVisualizerBase::HandlePointerEventL(const TAlfEvent& aEvent)
  1543     {
  1534     {
  1544     TBool eventHandled(EFalse);
  1535     TBool eventHandled(EFalse);
  1545     if (iDragHandler && iOwnerControl->ControlGroup()->AcceptInput())
  1536     if (iDragHandler && iOwnerControl->ControlGroup()->AcceptInput())
  1546         {
  1537         {
  1547         TPointerEvent::TType type = aEvent.PointerEvent().iType;
  1538         TPointerEvent::TType type = aEvent.PointerEvent().iType;
  1548         const TInt id(EventItemId(aEvent));
  1539         const TInt id(EventItemId(aEvent));
  1549         INFO_1("visual: $%x", aEvent.Visual());
  1540         INFO_1("visual: $%x", aEvent.Visual());
  1550         if (KErrNotFound != id || type == TPointerEvent::EDrag || 
  1541         if (KErrNotFound != id || type == TPointerEvent::EDrag ||
  1551                 type  == TPointerEvent::EButtonRepeat || 
  1542                 type  == TPointerEvent::EButtonRepeat ||
  1552                 type  == TPointerEvent::EButton1Up)
  1543                 type  == TPointerEvent::EButton1Up)
  1553             {
  1544             {
  1554             switch (type)
  1545             switch (type)
  1555                 {
  1546                 {
  1556                 case TPointerEvent::EButton1Down:
  1547                 case TPointerEvent::EButton1Down:
  1702 
  1693 
  1703     visualizer = iTreeData->ItemVisualizer( iFocusedItem );
  1694     visualizer = iTreeData->ItemVisualizer( iFocusedItem );
  1704 
  1695 
  1705     if ( visualizer )
  1696     if ( visualizer )
  1706         {
  1697         {
  1707         TBool focused = IsFocusShown();    
  1698         TBool focused = IsFocusShown();
  1708         visualizer->UpdateL( iTreeData->ItemData( iFocusedItem ), focused,
  1699         visualizer->UpdateL( iTreeData->ItemData( iFocusedItem ), focused,
  1709                 iTreeData->Level( iFocusedItem ), iMarkIcon, iMenuIcon, 0 );
  1700                 iTreeData->Level( iFocusedItem ), iMarkIcon, iMenuIcon, 0 );
  1710         }
  1701         }
  1711 
  1702 
  1712     if ( iFocusedItem != KFsTreeNoneID )
  1703     if ( iFocusedItem != KFsTreeNoneID )
  1815             TFsTreeItemId itemId(iVisibleItems[i]);
  1806             TFsTreeItemId itemId(iVisibleItems[i]);
  1816             MFsTreeItemVisualizer* visualizer = iTreeData->ItemVisualizer(
  1807             MFsTreeItemVisualizer* visualizer = iTreeData->ItemVisualizer(
  1817                     itemId);
  1808                     itemId);
  1818 
  1809 
  1819             TBool itemFocused( EFalse );
  1810             TBool itemFocused( EFalse );
  1820             if( showFocus ) 
  1811             if( showFocus )
  1821                 {
  1812                 {
  1822                 itemFocused = IsItemFocused(itemId);
  1813                 itemFocused = IsItemFocused(itemId);
  1823                 }
  1814                 }
  1824             visualizer->UpdateL(iTreeData->ItemData(itemId), itemFocused,
  1815             visualizer->UpdateL(iTreeData->ItemData(itemId), itemFocused,
  1825                     iTreeData->Level(itemId), iMarkIcon, iMenuIcon,
  1816                     iTreeData->Level(itemId), iMarkIcon, iMenuIcon,
  2252     TRect rc;
  2243     TRect rc;
  2253     TUint index = iWorld.GetItemRect(aNodeId, rc);
  2244     TUint index = iWorld.GetItemRect(aNodeId, rc);
  2254     if (!nodeVisualizer->IsExpanded())
  2245     if (!nodeVisualizer->IsExpanded())
  2255         {
  2246         {
  2256         nodeVisualizer->SetExpanded(ETrue, &iTreeData->ItemData(aNodeId));
  2247         nodeVisualizer->SetExpanded(ETrue, &iTreeData->ItemData(aNodeId));
  2257         
  2248 
  2258         TFsTreeIterator treeIter = iTreeData->Iterator(aNodeId, aNodeId,
  2249         TFsTreeIterator treeIter = iTreeData->Iterator(aNodeId, aNodeId,
  2259                 KFsTreeIteratorSkipHiddenFlag);
  2250                 KFsTreeIteratorSkipHiddenFlag);
  2260         if (treeIter.HasNext())
  2251         if (treeIter.HasNext())
  2261             {
  2252             {
  2262             TPoint position;
  2253             TPoint position;
  2274                 MFsTreeItemVisualizer* itemviz =
  2265                 MFsTreeItemVisualizer* itemviz =
  2275                         iTreeData->ItemVisualizer(itemId);
  2266                         iTreeData->ItemVisualizer(itemId);
  2276                 ApplyListSpecificValuesToItem(itemviz);
  2267                 ApplyListSpecificValuesToItem(itemviz);
  2277                 size = itemviz->Size();
  2268                 size = itemviz->Size();
  2278                 iWorld.InsertL(itemId, size, index);
  2269                 iWorld.InsertL(itemId, size, index);
  2279                 } while (treeIter.HasNext()); 
  2270                 } while (treeIter.HasNext());
  2280             if (iFocusedItem != KFsTreeNoneID)
  2271             if (iFocusedItem != KFsTreeNoneID)
  2281                 {
  2272                 {
  2282                 iViewPort.ItemToPositionL(iFocusedItem, position, EFalse,
  2273                 iViewPort.ItemToPositionL(iFocusedItem, position, EFalse,
  2283                         TViewPort::EPositionAfterExpand);
  2274                         TViewPort::EPositionAfterExpand);
  2284                 }
  2275                 }
  2340 void CFsTreeVisualizerBase::ExpandAllL()
  2331 void CFsTreeVisualizerBase::ExpandAllL()
  2341     {
  2332     {
  2342     FUNC_LOG;
  2333     FUNC_LOG;
  2343     iWorld.BeginUpdate();
  2334     iWorld.BeginUpdate();
  2344     TPoint position;
  2335     TPoint position;
  2345     if (iFocusedItem != KFsTreeNoneID)
  2336 
       
  2337     if( iFocusedItem != KFsTreeNoneID )
  2346         {
  2338         {
  2347         position = iViewPort.ItemRect(iFocusedItem).iTl;
  2339         position = iViewPort.ItemRect(iFocusedItem).iTl;
  2348         }
  2340         }
  2349     iWorld.RemoveAllL();
  2341     iWorld.RemoveAllL();
  2350     TFsTreeIterator treeIter = iTreeData->Iterator(KFsTreeRootID,
  2342     TFsTreeIterator treeIter = iTreeData->Iterator(
  2351             KFsTreeRootID);
  2343         KFsTreeRootID, KFsTreeRootID );
  2352     TFsTreeItemId itemId = KFsTreeNoneID;
  2344     TFsTreeItemId itemId = KFsTreeNoneID;
  2353     TSize size;
  2345     TSize size;
  2354     while (treeIter.HasNext())
  2346     while( treeIter.HasNext() )
  2355         {
  2347         {
  2356         itemId = treeIter.Next();
  2348         itemId = treeIter.Next();
  2357         if (itemId != KFsTreeNoneID)
  2349         if( itemId != KFsTreeNoneID )
  2358             {
  2350             {
  2359             if (iTreeData->IsNode(itemId))
  2351             if( iTreeData->IsNode( itemId ) )
  2360                 {
  2352                 {
  2361                 MFsTreeNodeVisualizer* nodeviz = iTreeData->NodeVisualizer(
  2353                 MFsTreeNodeVisualizer* nodeviz = iTreeData->NodeVisualizer(
  2362                         itemId);
  2354                         itemId);
  2363                 nodeviz->SetExpanded(ETrue, &iTreeData->ItemData(itemId));
  2355                 nodeviz->SetExpanded( ETrue, &iTreeData->ItemData( itemId ) );
  2364                 size = nodeviz->Size();
  2356                 size = nodeviz->Size();
  2365                 }
  2357                 }
  2366             else
  2358             else
  2367                 {
  2359                 {
  2368                 MFsTreeItemVisualizer* itemviz = iTreeData->ItemVisualizer(
  2360                 MFsTreeItemVisualizer* itemviz =
  2369                         itemId);
  2361                     iTreeData->ItemVisualizer( itemId );
  2370                 size = itemviz->Size();
  2362                 size = itemviz->Size();
  2371                 }
  2363                 }
  2372             iWorld.AppendL(itemId, size);
  2364             iWorld.AppendL( itemId, size );
  2373             }
  2365             }
  2374         }
  2366         }
  2375     if (iFocusedItem != KFsTreeNoneID)
  2367 
       
  2368     if( iFocusedItem != KFsTreeNoneID )
  2376         {
  2369         {
  2377         iViewPort.ItemToPositionL(iFocusedItem, position, EFalse,
  2370         iViewPort.ItemToPositionL(iFocusedItem, position, EFalse,
  2378                 TViewPort::EPositionAfterExpand);
  2371                 TViewPort::EPositionAfterExpand );
  2379         }
  2372         }
  2380     iWorld.EndUpdateL();
  2373     iWorld.EndUpdateL();
  2381     // <cmail>
  2374 
  2382     if ( iVisualizerObserver )
  2375     if ( iVisualizerObserver )
  2383         {
  2376         {
  2384         iVisualizerObserver->TreeVisualizerEventL(
  2377         iVisualizerObserver->TreeVisualizerEventL(
  2385                 MFsTreeVisualizerObserver::EFsTreeListExpandedAll );
  2378                 MFsTreeVisualizerObserver::EFsTreeListExpandedAll );
  2386         }
  2379         }
  2387     // </cmail>
       
  2388     }
  2380     }
  2389 
  2381 
  2390 // ---------------------------------------------------------------------------
  2382 // ---------------------------------------------------------------------------
  2391 // Collapse all nodes in the tree.
  2383 // Collapse all nodes in the tree.
  2392 // ---------------------------------------------------------------------------
  2384 // ---------------------------------------------------------------------------
  2394 void CFsTreeVisualizerBase::CollapseAllL()
  2386 void CFsTreeVisualizerBase::CollapseAllL()
  2395     {
  2387     {
  2396     FUNC_LOG;
  2388     FUNC_LOG;
  2397     iWorld.BeginUpdate();
  2389     iWorld.BeginUpdate();
  2398     TPoint position;
  2390     TPoint position;
  2399     if (iFocusedItem != KFsTreeNoneID)
  2391 
  2400         {
  2392     if( iFocusedItem != KFsTreeNoneID )
  2401         position = iViewPort.ItemRect(iFocusedItem).iTl;
  2393         {
       
  2394         position = iViewPort.ItemRect( iFocusedItem ).iTl;
  2402         }
  2395         }
  2403     iWorld.RemoveAllL();
  2396     iWorld.RemoveAllL();
  2404     if (iTreeData->Count() > 0)
  2397     if( iTreeData->Count() > 0 )
  2405         {
  2398         {
  2406         TUint childcount = iTreeData->CountChildren(KFsTreeRootID);
  2399         const TUint childcount = iTreeData->CountChildren( KFsTreeRootID );
  2407         for (TUint i = 0; i < childcount; ++i)
  2400         for( TUint i( 0 ); i < childcount; ++i )
  2408             {
  2401             {
  2409             TFsTreeItemId itemId = iTreeData->Child(KFsTreeRootID, i);
  2402             TFsTreeItemId itemId = iTreeData->Child( KFsTreeRootID, i );
  2410             TSize itemSize;
  2403             TSize itemSize;
  2411             if (iTreeData->IsNode(itemId))
  2404             if( iTreeData->IsNode( itemId ) )
  2412                 {
  2405                 {
  2413                 MFsTreeNodeVisualizer* nodeVis(iTreeData->NodeVisualizer(
  2406                 MFsTreeNodeVisualizer* nodeVis =
  2414                         itemId));
  2407                     iTreeData->NodeVisualizer( itemId );
  2415                 nodeVis->SetExpanded(EFalse, &iTreeData->ItemData(itemId));
  2408                 nodeVis->SetExpanded( EFalse, &iTreeData->ItemData( itemId ) );
  2416                 itemSize = nodeVis->Size();
  2409                 itemSize = nodeVis->Size();
  2417                 }
  2410                 }
  2418             else
  2411             else
  2419                 {
  2412                 {
  2420                 itemSize = iTreeData->ItemVisualizer(itemId)->Size();
  2413                 itemSize = iTreeData->ItemVisualizer( itemId )->Size();
  2421                 }
  2414                 }
  2422             iWorld.AppendL(itemId, itemSize);
  2415             iWorld.AppendL(itemId, itemSize);
  2423             }
  2416             }
  2424         }
  2417         }
  2425     if (iFocusedItem != KFsTreeNoneID)
  2418 
  2426         {
  2419     if( iFocusedItem != KFsTreeNoneID )
  2427         iViewPort.ItemToPositionL(iFocusedItem, position, EFalse);
  2420         {
  2428         }
  2421         // If item, which was selected, wasn't node, then make its parent node
       
  2422         // focused, if it doesn't have parent node or its parent is not a node
       
  2423         // then leave focus as it was.
       
  2424         if( !iTreeData->IsNode( iFocusedItem ) )
       
  2425             {
       
  2426             TFsTreeItemId parentId = iTreeData->Parent( iFocusedItem );
       
  2427             if( iTreeData->IsNode( parentId ) )
       
  2428                 {
       
  2429                 SetFocusedItemL( parentId );
       
  2430                 position = iViewPort.ItemRect( iFocusedItem ).iTl;
       
  2431                 }
       
  2432             }
       
  2433         iViewPort.ItemToPositionL( iFocusedItem, position, EFalse );
       
  2434         }
       
  2435 
  2429     iWorld.EndUpdateL();
  2436     iWorld.EndUpdateL();
  2430     // <cmail>
  2437 
  2431     if ( iVisualizerObserver )
  2438     if ( iVisualizerObserver )
  2432         {
  2439         {
  2433         iVisualizerObserver->TreeVisualizerEventL(
  2440         iVisualizerObserver->TreeVisualizerEventL(
  2434                 MFsTreeVisualizerObserver::EFsTreeListCollapsedAll );
  2441                 MFsTreeVisualizerObserver::EFsTreeListCollapsedAll );
  2435         }
  2442         }
  2436     // </cmail>
       
  2437     }
  2443     }
  2438 
  2444 
  2439 // ---------------------------------------------------------------------------
  2445 // ---------------------------------------------------------------------------
  2440 //
  2446 //
  2441 //
  2447 //
  2569             iOwnerControl->Env());
  2575             iOwnerControl->Env());
  2570     backgroundBrush->SetLayer(EAlfBrushLayerBackground);
  2576     backgroundBrush->SetLayer(EAlfBrushLayerBackground);
  2571     backgroundBrush->SetColor(aColor);
  2577     backgroundBrush->SetColor(aColor);
  2572 
  2578 
  2573     iWatermarkLayout->Brushes()->AppendL(backgroundBrush, EAlfHasOwnership);
  2579     iWatermarkLayout->Brushes()->AppendL(backgroundBrush, EAlfHasOwnership);
  2574         }    
  2580         }
  2575     }
  2581     }
  2576 
  2582 
  2577 // ---------------------------------------------------------------------------
  2583 // ---------------------------------------------------------------------------
  2578 // Sets a given brush as a list background.
  2584 // Sets a given brush as a list background.
  2579 // ---------------------------------------------------------------------------
  2585 // ---------------------------------------------------------------------------
  3596     if (iFocusedItem != KFsTreeNoneID)
  3602     if (iFocusedItem != KFsTreeNoneID)
  3597         {
  3603         {
  3598         keepFocusedItemInView = iViewPort.ItemRect(iFocusedItem).Height() > 0;
  3604         keepFocusedItemInView = iViewPort.ItemRect(iFocusedItem).Height() > 0;
  3599         }
  3605         }
  3600     iViewPort.SetSizeL(listPane.Size());
  3606     iViewPort.SetSizeL(listPane.Size());
  3601     iWorld.Recalculate(*iTreeData);   
  3607     iWorld.Recalculate(*iTreeData);
  3602     if (keepFocusedItemInView)
  3608     if (keepFocusedItemInView)
  3603         {
  3609         {
  3604         iViewPort.ScrollItemToViewL(iFocusedItem, EFalse);
  3610         iViewPort.ScrollItemToViewL(iFocusedItem, EFalse);
  3605         }
  3611         }
  3606     else
  3612     else
  3631 // ---------------------------------------------------------------------------
  3637 // ---------------------------------------------------------------------------
  3632 //
  3638 //
  3633 void CFsTreeVisualizerBase::UpdateScrollBarL(const TInt /*aTimeout*/)
  3639 void CFsTreeVisualizerBase::UpdateScrollBarL(const TInt /*aTimeout*/)
  3634     {
  3640     {
  3635     FUNC_LOG;
  3641     FUNC_LOG;
  3636     
  3642 
  3637     TRect mainPaneRect;
  3643     TRect mainPaneRect;
  3638     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
  3644     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
  3639     TRect listRect(iRootLayout->DisplayRectTarget());
  3645     TRect listRect(iRootLayout->DisplayRectTarget());
  3640     listRect.Move(mainPaneRect.iTl);
  3646     listRect.Move(mainPaneRect.iTl);
  3641     TRect scrollPane, listPane;
  3647     TRect scrollPane, listPane;
  4042                     iTreeData->ItemVisualizer( iFocusedItem );
  4048                     iTreeData->ItemVisualizer( iFocusedItem );
  4043             MFsTreeItemData* data = &iTreeData->ItemData( iFocusedItem );
  4049             MFsTreeItemData* data = &iTreeData->ItemData( iFocusedItem );
  4044 
  4050 
  4045             iListLayout->SetFlag( EAlfVisualFlagFreezeLayout );
  4051             iListLayout->SetFlag( EAlfVisualFlagFreezeLayout );
  4046             iListItemBackgroundLayout->SetFlag( EAlfVisualFlagFreezeLayout );
  4052             iListItemBackgroundLayout->SetFlag( EAlfVisualFlagFreezeLayout );
  4047             
  4053 
  4048             iSelectorVisual = CAlfImageVisual::AddNewL(*iOwnerControl, iSelectorLayout);
  4054             iSelectorVisual = CAlfImageVisual::AddNewL(*iOwnerControl, iSelectorLayout);
  4049             opacity.SetValueNow(0.0f);
  4055             opacity.SetValueNow(0.0f);
  4050             iSelectorVisual->SetOpacity(opacity);
  4056             iSelectorVisual->SetOpacity(opacity);
  4051             iSelectorVisual->SetScaleMode( CAlfImageVisual::EScaleFit);
  4057             iSelectorVisual->SetScaleMode( CAlfImageVisual::EScaleFit);
  4052             iSelectorVisual->EnableBrushesL();
  4058             iSelectorVisual->EnableBrushesL();
  4053 
  4059 
  4054             // Set the selector visual size and pos.
  4060             // Set the selector visual size and pos.
  4055             iSelectorVisual->SetFlags(EAlfVisualFlagManualLayout | 
  4061             iSelectorVisual->SetFlags(EAlfVisualFlagManualLayout |
  4056                     EAlfVisualFlagIgnorePointer);           
  4062                     EAlfVisualFlagIgnorePointer);
  4057             
  4063 
  4058             TRect itemRect(iViewPort.ItemRect(iFocusedItem));
  4064             TRect itemRect(iViewPort.ItemRect(iFocusedItem));
  4059             itemRect.SetWidth(iListLayout->Size().iX.Target() - 2 * iListLayout->PaddingInPixels().iTl.iX);
  4065             itemRect.SetWidth(iListLayout->Size().iX.Target() - 2 * iListLayout->PaddingInPixels().iTl.iX);
  4060             if ( itemRect.Height() )
  4066             if ( itemRect.Height() )
  4061                 {
  4067                 {
  4062                 iSelectorVisual->SetPos(itemRect.iTl);
  4068                 iSelectorVisual->SetPos(itemRect.iTl);
  4877             tpItemSize.SetTarget(TAlfRealPoint(listInnerWidth, size.iHeight),
  4883             tpItemSize.SetTarget(TAlfRealPoint(listInnerWidth, size.iHeight),
  4878                     0);
  4884                     0);
  4879             CAlfLayout& visualizerLayout(visualizer->Layout());
  4885             CAlfLayout& visualizerLayout(visualizer->Layout());
  4880             visualizerLayout.SetSize(tpItemSize);
  4886             visualizerLayout.SetSize(tpItemSize);
  4881             visualizerLayout.PropertySetIntegerL(KPropertyItemId(), itemId);
  4887             visualizerLayout.PropertySetIntegerL(KPropertyItemId(), itemId);
  4882             visualizer->UpdateL(iTreeData->ItemData(itemId), 
  4888             visualizer->UpdateL(iTreeData->ItemData(itemId),
  4883                     IsItemFocused(itemId) && IsFocusShown(),
  4889                     IsItemFocused(itemId) && IsFocusShown(),
  4884                     iTreeData->Level(itemId), iMarkIcon, iMenuIcon,
  4890                     iTreeData->Level(itemId), iMarkIcon, iMenuIcon,
  4885                     0);
  4891                     0);
  4886             visualizerLayout.Brushes()->AppendL(iBorderBrush,
  4892             visualizerLayout.Brushes()->AppendL(iBorderBrush,
  4887                     EAlfDoesNotHaveOwnership);
  4893                     EAlfDoesNotHaveOwnership);
  4934     FUNC_LOG;
  4940     FUNC_LOG;
  4935     TTime startTime( aStartTime );
  4941     TTime startTime( aStartTime );
  4936     TTime now;
  4942     TTime now;
  4937     now.HomeTime();
  4943     now.HomeTime();
  4938     TInt moveTime( now.MicroSecondsFrom( aStartTime ).Int64() );
  4944     TInt moveTime( now.MicroSecondsFrom( aStartTime ).Int64() );
  4939     if (moveTime > KFlickMaxDuration) 
  4945     if (moveTime > KFlickMaxDuration)
  4940         {
  4946         {
  4941         startTime = now - TTimeIntervalMicroSeconds( KFlickMaxDuration - 1 );
  4947         startTime = now - TTimeIntervalMicroSeconds( KFlickMaxDuration - 1 );
  4942         aDrag.iY = aDrag.iY * KFlickMaxDuration / moveTime;
  4948         aDrag.iY = aDrag.iY * KFlickMaxDuration / moveTime;
  4943         }
  4949         }
  4944     iPhysics->StartPhysics(aDrag, startTime);
  4950     iPhysics->StartPhysics(aDrag, startTime);
  5005 // Wrapper for SetFocusedItemAndSendEventL to trap the error and return it
  5011 // Wrapper for SetFocusedItemAndSendEventL to trap the error and return it
  5006 // instead of leaving.
  5012 // instead of leaving.
  5007 // ---------------------------------------------------------------------------
  5013 // ---------------------------------------------------------------------------
  5008 //
  5014 //
  5009 TInt CFsTreeVisualizerBase::SetFocusedItemAndSendEvent(
  5015 TInt CFsTreeVisualizerBase::SetFocusedItemAndSendEvent(
  5010     const TFsTreeItemId aItemId, TPointerEventType aEventType )
  5016     const TFsTreeItemId aItemId, TPointerEventType aEventType, const TPoint& aPoint )
  5011     {
  5017     {
  5012     FUNC_LOG;
  5018     FUNC_LOG;
  5013     TRAPD(error, SetFocusedItemAndSendEventL( aItemId, aEventType ) );
  5019     TRAPD(error, SetFocusedItemAndSendEventL( aItemId, aEventType, aPoint ) );
  5014     return error;
  5020     return error;
  5015     }
  5021     }
  5016 
  5022 
  5017 // ---------------------------------------------------------------------------
  5023 // ---------------------------------------------------------------------------
  5018 // Sets the specified item as focused and sends event about touch focusing if
  5024 // Sets the specified item as focused and sends event about touch focusing if
  5019 // the same item is already focused, action event will be sent instead.
  5025 // the same item is already focused, action event will be sent instead.
  5020 // ---------------------------------------------------------------------------
  5026 // ---------------------------------------------------------------------------
  5021 //
  5027 //
  5022 void CFsTreeVisualizerBase::SetFocusedItemAndSendEventL(
  5028 void CFsTreeVisualizerBase::SetFocusedItemAndSendEventL(
  5023         const TFsTreeItemId aItemId, TPointerEventType aEventType )
  5029         const TFsTreeItemId aItemId, TPointerEventType aEventType, const TPoint& aPoint )
  5024     {
  5030     {
  5025     FUNC_LOG;
  5031     FUNC_LOG;
  5026 
  5032 
  5027     // Handles all other than pointer up events.
  5033     // Handles all other than pointer up events.
  5028     // Focus is drawn when:
  5034     // Focus is drawn when:
  5034             ( ( aEventType == EPointerDown ) && IsFocusShown() ) ) )
  5040             ( ( aEventType == EPointerDown ) && IsFocusShown() ) ) )
  5035         {
  5041         {
  5036         SetFocusedItemL( aItemId );
  5042         SetFocusedItemL( aItemId );
  5037         iVisualizerObserver->TreeVisualizerEventL(
  5043         iVisualizerObserver->TreeVisualizerEventL(
  5038             MFsTreeVisualizerObserver::EFsTreeItemTouchFocused,
  5044             MFsTreeVisualizerObserver::EFsTreeItemTouchFocused,
  5039             FocusedItem() );
  5045             FocusedItem(), aPoint );
  5040 
  5046 
  5041         // If DirectTouchMode (actions happens in pointer down events)
  5047         // If DirectTouchMode (actions happens in pointer down events)
  5042         if( iFlags.IsSet( EDirectTouchMode ) && aEventType == EPointerDown )
  5048         if( iFlags.IsSet( EDirectTouchMode ) && aEventType == EPointerDown )
  5043             {
  5049             {
  5044             iTouchPressed = EFalse;
  5050             iTouchPressed = EFalse;
  5045             iVisualizerObserver->TreeVisualizerEventL(
  5051             iVisualizerObserver->TreeVisualizerEventL(
  5046                 MFsTreeVisualizerObserver::EFsTreeItemTouchAction,
  5052                 MFsTreeVisualizerObserver::EFsTreeItemTouchAction,
  5047                 aItemId );
  5053                 aItemId, aPoint );
  5048             }
  5054             }
  5049         }
  5055         }
  5050     else if( aEventType == ELongTap )
  5056     else if( aEventType == ELongTap )
  5051         {
  5057         {
       
  5058         // HandlePointerEventL do not get pointer up event after long tap event
       
  5059         // so <code>iTouchPressed</code> flag needs to be reset here.
       
  5060         iTouchPressed = EFalse;
  5052 		iVisualizerObserver->TreeVisualizerEventL(
  5061 		iVisualizerObserver->TreeVisualizerEventL(
  5053 				MFsTreeVisualizerObserver::EFsTreeItemTouchLongTap,
  5062 				MFsTreeVisualizerObserver::EFsTreeItemTouchLongTap,
  5054   			    aItemId );
  5063   			    aItemId, aPoint );
  5055         }
  5064         }
  5056     else if( aEventType == EPointerUp )
  5065     else if( aEventType == EPointerUp )
  5057         {
  5066         {
  5058         iVisualizerObserver->TreeVisualizerEventL(
  5067         iVisualizerObserver->TreeVisualizerEventL(
  5059             MFsTreeVisualizerObserver::EFsTreeItemTouchAction, aItemId );
  5068             MFsTreeVisualizerObserver::EFsTreeItemTouchAction, aItemId, aPoint );
  5060         }
  5069         }
  5061     }
  5070     }
  5062 
  5071 
  5063 // CFsTreeVisualizerBase::CDragHandler
  5072 // CFsTreeVisualizerBase::CDragHandler
  5064 
  5073 
  5104 
  5113 
  5105 // ---------------------------------------------------------------------------
  5114 // ---------------------------------------------------------------------------
  5106 //
  5115 //
  5107 // ---------------------------------------------------------------------------
  5116 // ---------------------------------------------------------------------------
  5108 //
  5117 //
  5109 CFsTreeVisualizerBase::CDragHandler::TDragDirection 
  5118 CFsTreeVisualizerBase::CDragHandler::TDragDirection
  5110     CFsTreeVisualizerBase::CDragHandler::DragDirection( 
  5119     CFsTreeVisualizerBase::CDragHandler::DragDirection(
  5111         const TPoint& aCurrent, const TPoint aPrevious ) const
  5120         const TPoint& aCurrent, const TPoint aPrevious ) const
  5112     {
  5121     {
  5113     FUNC_LOG;
  5122     FUNC_LOG;
  5114     if (aCurrent.iY > aPrevious.iY) 
  5123     if (aCurrent.iY > aPrevious.iY)
  5115         {
  5124         {
  5116         return EDraggingDown;
  5125         return EDraggingDown;
  5117         }
  5126         }
  5118     else if (aCurrent.iY < aPrevious.iY)
  5127     else if (aCurrent.iY < aPrevious.iY)
  5119         {
  5128         {
  5120         return EDraggingUp;
  5129         return EDraggingUp;
  5121         }
  5130         }
  5122     else 
  5131     else
  5123         {
  5132         {
  5124         return iDragDirection;
  5133         return iDragDirection;
  5125         }
  5134         }
  5126     }
  5135     }
  5127 
  5136 
  5138     iPosition = aEvent.iParentPosition;
  5147     iPosition = aEvent.iParentPosition;
  5139     iLastPointerPosition = aEvent.iParentPosition;
  5148     iLastPointerPosition = aEvent.iParentPosition;
  5140     iStartTime.HomeTime();
  5149     iStartTime.HomeTime();
  5141     iFlags.Set( EPointerDownReceived );
  5150     iFlags.Set( EPointerDownReceived );
  5142 
  5151 
  5143     iTree.SetFocusedItemAndSendEvent( iItemId, EPointerDown );
  5152     iTree.SetFocusedItemAndSendEvent( iItemId, EPointerDown, iPosition );
  5144     }
  5153     }
  5145 
  5154 
  5146 // ---------------------------------------------------------------------------
  5155 // ---------------------------------------------------------------------------
  5147 //
  5156 //
  5148 // ---------------------------------------------------------------------------
  5157 // ---------------------------------------------------------------------------
  5149 //
  5158 //
  5150 void CFsTreeVisualizerBase::CDragHandler::PointerRepeat(
  5159 void CFsTreeVisualizerBase::CDragHandler::PointerRepeat(
  5151         const TPointerEvent& /*aEvent*/ )
  5160         const TPointerEvent& aEvent )
  5152     {
  5161     {
  5153     if( iItemId != KFsTreeNoneID && !IsFlicking() )
  5162     if( iItemId != KFsTreeNoneID && !IsFlicking() )
  5154         {
  5163         {
  5155         iFlags.Set( EWasRepeat );
  5164         iFlags.Set( EWasRepeat );
  5156         iTree.SetFocusedItemAndSendEvent( iItemId, ELongTap );
  5165         iTree.SetFocusedItemAndSendEvent( iItemId, ELongTap, aEvent.iParentPosition );
  5157         }
  5166         }
  5158     }
  5167     }
  5159 
  5168 
  5160 // ---------------------------------------------------------------------------
  5169 // ---------------------------------------------------------------------------
  5161 //
  5170 //
  5169     if( iTree.IsKineticScrollingDisabled() )
  5178     if( iTree.IsKineticScrollingDisabled() )
  5170         {
  5179         {
  5171         if( ( aItemId != KFsTreeNoneID ) &&
  5180         if( ( aItemId != KFsTreeNoneID ) &&
  5172             ( iTree.FocusedItem() == aItemId  ) )
  5181             ( iTree.FocusedItem() == aItemId  ) )
  5173             {
  5182             {
  5174             iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp );
  5183             iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp, aEvent.iParentPosition );
  5175             }
  5184             }
  5176         }
  5185         }
  5177     else if ( IsFlicking() )
  5186     else if ( IsFlicking() )
  5178         {
  5187         {
  5179         TPoint drag(iPosition - aEvent.iParentPosition);
  5188         TPoint drag(iPosition - aEvent.iParentPosition);
  5180         iTree.StartPhysics( drag, iStartTime );
  5189         iTree.StartPhysics( drag, iStartTime );
  5181         }
  5190         }
  5182     else if( !iFlags.IsSet( EWasRepeat ) && iItemId != KFsTreeNoneID )
  5191     else if( !iFlags.IsSet( EWasRepeat ) && iItemId != KFsTreeNoneID )
  5183         {
  5192         {
  5184         iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp );
  5193         iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp, aEvent.iParentPosition );
  5185         }
  5194         }
  5186     iLastPointerPosition = iPosition = TPoint();
  5195     iLastPointerPosition = iPosition = TPoint();
  5187     iFlags.Clear( EPointerDownReceived );
  5196     iFlags.Clear( EPointerDownReceived );
  5188     iDragDirection = EDraggingNone;
  5197     iDragDirection = EDraggingNone;
  5189     }
  5198     }
  5226             {
  5235             {
  5227             iTree.SetPanningPosition(TPoint(0, iLastPointerPosition.iY
  5236             iTree.SetPanningPosition(TPoint(0, iLastPointerPosition.iY
  5228                     - aEvent.iPosition.iY));
  5237                     - aEvent.iPosition.iY));
  5229             }
  5238             }
  5230         TDragDirection dragDirection(DragDirection(aEvent.iPosition, iLastPointerPosition));
  5239         TDragDirection dragDirection(DragDirection(aEvent.iPosition, iLastPointerPosition));
  5231         const TBool dragDirectionChanged( 
  5240         const TBool dragDirectionChanged(
  5232                 (dragDirection == EDraggingUp && iDragDirection == EDraggingDown ) ||
  5241                 (dragDirection == EDraggingUp && iDragDirection == EDraggingDown ) ||
  5233                 (dragDirection == EDraggingDown && iDragDirection == EDraggingUp ) );
  5242                 (dragDirection == EDraggingDown && iDragDirection == EDraggingUp ) );
  5234         if (dragDirectionChanged)
  5243         if (dragDirectionChanged)
  5235             {
  5244             {
  5236             iPosition = aEvent.iPosition;
  5245             iPosition = aEvent.iPosition;
  5292 TInt CFsTreeVisualizerBase::CDragHandler::HighlightTimerCallback( TAny* aPtr )
  5301 TInt CFsTreeVisualizerBase::CDragHandler::HighlightTimerCallback( TAny* aPtr )
  5293     {
  5302     {
  5294     FUNC_LOG;
  5303     FUNC_LOG;
  5295     CDragHandler* self = reinterpret_cast<CDragHandler*>( aPtr );
  5304     CDragHandler* self = reinterpret_cast<CDragHandler*>( aPtr );
  5296     self->iHighlightTimer->Cancel();
  5305     self->iHighlightTimer->Cancel();
  5297     return self->iTree.SetFocusedItemAndSendEvent( self->iItemId, ELongTap );
  5306     return self->iTree.SetFocusedItemAndSendEvent( self->iItemId, ELongTap, self->iPosition );
  5298     }
  5307     }
  5299 
  5308 
  5300 // ---------------------------------------------------------------------------
  5309 // ---------------------------------------------------------------------------
  5301 // CFsTreeVisualizerBase::IsFocusShown
  5310 // CFsTreeVisualizerBase::IsFocusShown
  5302 // ---------------------------------------------------------------------------
  5311 // ---------------------------------------------------------------------------
  5303 //
  5312 //
  5304 TBool CFsTreeVisualizerBase::IsFocusShown()
  5313 TBool CFsTreeVisualizerBase::IsFocusShown()
  5305     {
  5314     {
  5306     if( iTouchPressed || iFocusVisible ) 
  5315     if( iTouchPressed || iFocusVisible )
  5307         {
  5316         {
  5308         return ETrue;
  5317         return ETrue;
  5309         }
  5318         }
  5310 
  5319 
  5311     return EFalse;
  5320     return EFalse;