photosgallery/viewframework/views/cloudview/src/glxcloudviewcontrol.cpp
changeset 2 7d9067c6fcb1
parent 0 4e91876724a2
child 9 6b87b143d312
equal deleted inserted replaced
1:9ba538e329bd 2:7d9067c6fcb1
    31 #include <alf/alfwidgetcontrol.h> // For CAlfWidgetControl
    31 #include <alf/alfwidgetcontrol.h> // For CAlfWidgetControl
    32 #include <alf/alfroster.h> // For CalfRoster
    32 #include <alf/alfroster.h> // For CalfRoster
    33 #include <alf/alfdisplay.h> // For CAlfDisplay
    33 #include <alf/alfdisplay.h> // For CAlfDisplay
    34 #include <alf/ialfscrollbarmodel.h> // For alfScrollbar model
    34 #include <alf/ialfscrollbarmodel.h> // For alfScrollbar model
    35 #include <aknlayoutscalable_uiaccel.cdl.h>
    35 #include <aknlayoutscalable_uiaccel.cdl.h>
    36 
    36 #include <aknphysics.h> // For Kinetic Scrolling
    37 #include <glxuiutility.h>
    37 #include <glxuiutility.h>
    38 #include <glxgeneraluiutilities.h>
    38 #include <glxgeneraluiutilities.h>
    39 #include <glxuistd.h>
    39 #include <glxuistd.h>
    40 
    40 
    41 //AlfT
    41 //AlfT
    63 const TInt KNumMinRowSpace = 2;
    63 const TInt KNumMinRowSpace = 2;
    64 const TInt KColSpace = 20;
    64 const TInt KColSpace = 20;
    65 const TInt KRightmargin = 20;
    65 const TInt KRightmargin = 20;
    66 const TInt KMinTagSize = 77;
    66 const TInt KMinTagSize = 77;
    67 const TInt KTagScreenHeight = 460;
    67 const TInt KTagScreenHeight = 460;
    68 const TInt KDragHoldTime = 500;
    68 const TReal KBoundaryMargin = 0.1; //10% = 10/100 = 0.1 
    69 
    69 const TInt KFastCloudMovement = 100; //Transition time to move cloud view
       
    70 const TInt KSlowCloudMovement = 1000; //Transition time to move cloud view
    70 
    71 
    71 // ---------------------------------------------------------------------------
    72 // ---------------------------------------------------------------------------
    72 // Two-phased constructor.
    73 // Two-phased constructor.
    73 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    74 // 
    75 // 
   140     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
   141     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
   141     iScreenHeight = rect.Height ();
   142     iScreenHeight = rect.Height ();
   142     iParentLayout = CAlfLayout::AddNewL(*this, aAnchorLayout);                    
   143     iParentLayout = CAlfLayout::AddNewL(*this, aAnchorLayout);                    
   143     iTagScreenWidth = rect.Width() - iScrollPaneHandle.iW - KRightmargin;
   144     iTagScreenWidth = rect.Width() - iScrollPaneHandle.iW - KRightmargin;
   144 
   145 
   145     if (GlxGeneralUiUtilities::IsLandscape())
   146     if(IsLandscape())
   146         {	
   147         {	
   147         iTagScreenHeight = rect.Height();	
   148         iTagScreenHeight = rect.Height();	
   148         }
   149         }
   149     else 
   150     else 
   150         {
   151         {
   192             UpdateRowDataL ();
   193             UpdateRowDataL ();
   193             }
   194             }
   194         }
   195         }
   195     //get touch feedback instance
   196     //get touch feedback instance
   196     iTouchFeedback = MTouchFeedback::Instance(); 
   197     iTouchFeedback = MTouchFeedback::Instance(); 
       
   198     iPhysics = CAknPhysics::NewL(*this, NULL);
       
   199     InitPhysicsL();
   197     }
   200     }
   198 
   201 
   199 
   202 
   200 // ---------------------------------------------------------------------------
   203 // ---------------------------------------------------------------------------
   201 //VisualLayoutUpdated()
   204 //VisualLayoutUpdated()
   204 void CGlxCloudViewControl::VisualLayoutUpdated(CAlfVisual &/* aVisual*/)
   207 void CGlxCloudViewControl::VisualLayoutUpdated(CAlfVisual &/* aVisual*/)
   205     {
   208     {
   206     TRACER("GLX_CLOUD::CGlxCloudViewControl::VisualLayoutUpdated");
   209     TRACER("GLX_CLOUD::CGlxCloudViewControl::VisualLayoutUpdated");
   207     TRect rect;
   210     TRect rect;
   208     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
   211     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
   209     if ( (rect.Width() != iTagScreenWidth) && ( rect.Height () != iScreenHeight))
   212     if ((rect.Width() != (iTagScreenWidth + iScrollPaneHandle.iW + KRightmargin)) || (rect.Height() != iScreenHeight))
   210         {
   213         {
   211         //set the new screen dimensions
   214         //set the new screen dimensions
   212         UpdateLayoutL();
   215         TRAP_IGNORE(UpdateLayoutL());
   213         }
   216         }
   214     }
   217     }
   215 
   218 
   216 // --------------------------------------------------------------------------- 
   219 // --------------------------------------------------------------------------- 
   217 // Destructor
   220 // Destructor
   235     if ( iUiUtility )
   238     if ( iUiUtility )
   236         {
   239         {
   237         iUiUtility->Close ();
   240         iUiUtility->Close ();
   238         }	
   241         }	
   239     delete iEmptyText;
   242     delete iEmptyText;
       
   243     delete iPhysics;
   240     }
   244     }
   241 
   245 
   242 // --------------------------------------------------------------------------- 
   246 // --------------------------------------------------------------------------- 
   243 // LayoutVisibleRows()
   247 // LayoutVisibleRows()
   244 // --------------------------------------------------------------------------- 
   248 // --------------------------------------------------------------------------- 
   406 
   410 
   407     iViewPortLayout->SetViewportSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
   411     iViewPortLayout->SetViewportSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
   408     iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
   412     iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
   409     iViewPortSize.iWidth = iTagScreenWidth;
   413     iViewPortSize.iWidth = iTagScreenWidth;
   410     iViewPortSize.iHeight = iTagScreenHeight;	
   414     iViewPortSize.iHeight = iTagScreenHeight;	
   411     iViewPortLayout->SetViewportPos(TAlfRealPoint(0, 0),1000);
   415     iViewPortLayout->SetViewportPos(TAlfRealPoint(0, 0), KSlowCloudMovement);
   412 
   416 
   413     iViewPortPosition.iX =0;
   417     iViewPortPosition.iX =0;
   414     iViewPortPosition.iY =0;
   418     iViewPortPosition.iY =0;
   415 
   419 
   416     iScrollEventData.mSpan = iViewPortVirtualSize.iHeight ;
   420     iScrollEventData.mSpan = iViewPortVirtualSize.iHeight ;
   473                 }
   477                 }
   474                 break;
   478                 break;
   475 
   479 
   476             case EKeyDownArrow:
   480             case EKeyDownArrow:
   477                 {              
   481                 {              
   478                 if(iCloudInfo.Count() >1 )
   482                 if (iCloudInfo.Count() > 1)
   479                     {
   483                     {
   480                     HandleKeyDownL ();
   484                     HandleKeyDownL ();
   481                     consumed = ETrue;
   485                     consumed = ETrue;
   482                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
   486                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
   483 
   487 
   592     if(aEvent.IsPointerEvent() )
   596     if(aEvent.IsPointerEvent() )
   593         {
   597         {
   594         //if its a pointer event
   598         //if its a pointer event
   595         consumed = HandlePointerEventL(aEvent);
   599         consumed = HandlePointerEventL(aEvent);
   596         }
   600         }
   597     else if( aEvent.IsCustomEvent() )
       
   598         {
       
   599         if(aEvent.CustomParameter() == ECustomEventFocusDragScroll)
       
   600             {
       
   601             //dragging down
       
   602             if( iIsDragging == 1 )
       
   603                 {
       
   604                 if(iFocusRowIndex!=iCloudInfo.Count()-1)
       
   605                     {
       
   606                     SetRelativeFocusL(iFocusRowIndex+1);
       
   607                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); 
       
   608                     // iScrollDirection = 0;               
       
   609                     MoveDownIfRequired();  
       
   610                     }
       
   611                 }
       
   612             //dragging up
       
   613             else if(iIsDragging == 2)
       
   614                 {
       
   615                 if(iFocusRowIndex!=0)
       
   616                     {
       
   617                     SetRelativeFocusL(iFocusRowIndex-1);
       
   618                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); 
       
   619                     // iScrollDirection = 0;               
       
   620                     MoveUpIfRequired();  
       
   621                     }
       
   622                 }
       
   623             }
       
   624         consumed = EFalse;
       
   625         }
       
   626     return consumed;
   601     return consumed;
   627     }
   602     }
   628 
   603 
   629 // --------------------------------------------------------------------------- 
   604 // --------------------------------------------------------------------------- 
   630 // HandleKeyUp()
   605 // HandleKeyUp()
   661     {
   636     {
   662     TRACER("GLX_CLOUD:: CGlxCloudViewControl::HandleKeyDownL");
   637     TRACER("GLX_CLOUD:: CGlxCloudViewControl::HandleKeyDownL");
   663 
   638 
   664     // If the last item is focused and if we are navigating downwards,then set the
   639     // If the last item is focused and if we are navigating downwards,then set the
   665     // focus to first element.
   640     // focus to first element.
   666     if( iFocusRowIndex == iCloudInfo.Count()-1 )
   641     if (iFocusRowIndex == iCloudInfo.Count() - 1)
   667         {   
   642         {
   668         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
   643         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, 0);
   669                 0); 
       
   670         }
   644         }
   671 
   645 
   672     //else set the focus to the item which is in the next row,that overlaps with midpoint of the 
   646     //else set the focus to the item which is in the next row,that overlaps with midpoint of the 
   673     //focused item.     
   647     //focused item.     
   674     else
   648     else
   816         //of items in array will remain same.
   790         //of items in array will remain same.
   817         FetchAttributeFromCacheL();
   791         FetchAttributeFromCacheL();
   818         UpdateRowDataL (); //updates the row data and reassigns font sizes and draw the layout on screen.
   792         UpdateRowDataL (); //updates the row data and reassigns font sizes and draw the layout on screen.
   819         }
   793         }
   820 
   794 
       
   795     InitPhysicsL();
   821     }
   796     }
   822 
   797 
   823 
   798 
   824 // ---------------------------------------------------------------------------
   799 // ---------------------------------------------------------------------------
   825 // HandleMediaL().
   800 // HandleMediaL().
   857         else
   832         else
   858             {
   833             {
   859             DisplayEmptyCloudViewL();
   834             DisplayEmptyCloudViewL();
   860             }
   835             }
   861         }
   836         }
       
   837     InitPhysicsL();
   862     }
   838     }
   863 
   839 
   864 // ---------------------------------------------------------------------------
   840 // ---------------------------------------------------------------------------
   865 // HandleItemModifiedL().
   841 // HandleItemModifiedL().
   866 // ---------------------------------------------------------------------------
   842 // ---------------------------------------------------------------------------
   908             {
   884             {
   909             iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
   885             iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
   910             }
   886             }
   911         //generate row structures and draw rows on screen
   887         //generate row structures and draw rows on screen
   912         UpdateRowDataL ();
   888         UpdateRowDataL ();
       
   889 
       
   890         InitPhysicsL();
   913         }
   891         }
   914     }
   892     }
   915 
   893 
   916 // ---------------------------------------------------------------------------
   894 // ---------------------------------------------------------------------------
   917 // HandleFocusChangedL().
   895 // HandleFocusChangedL().
  1334     //if its key event then it should be cyclic
  1312     //if its key event then it should be cyclic
  1335     else if( rownumber == (iCloudInfo.Count()-1))
  1313     else if( rownumber == (iCloudInfo.Count()-1))
  1336         {
  1314         {
  1337         iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
  1315         iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
  1338         }
  1316         }
  1339     iViewPortLayout->SetViewportPos (iViewPortPosition,1000); 
  1317     iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement);
  1340     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
  1318     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
  1341     Scroll();  
  1319     Scroll();  
  1342     //CalculateBubleMidPoint ();   
  1320     //CalculateBubleMidPoint ();   
  1343     }
  1321     }
  1344 
  1322 
  1369     //if its key event then it should be cyclic
  1347     //if its key event then it should be cyclic
  1370     else if (iMediaList.FocusIndex() == 0)
  1348     else if (iMediaList.FocusIndex() == 0)
  1371         {
  1349         {
  1372         iViewPortPosition.iY = 0;
  1350         iViewPortPosition.iY = 0;
  1373         }     
  1351         }     
  1374     iViewPortLayout->SetViewportPos (iViewPortPosition,1000); 
  1352     iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement);
  1375     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
  1353     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
  1376     if(iScrollBarWidget)
  1354     if(iScrollBarWidget)
  1377         {
  1355         {
  1378         Scroll();           
  1356         Scroll();           
  1379         }
  1357         }
  1432 TBool CGlxCloudViewControl::HandlePointerEventL( const TAlfEvent &aEvent )
  1410 TBool CGlxCloudViewControl::HandlePointerEventL( const TAlfEvent &aEvent )
  1433     {
  1411     {
  1434     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandlePointerEventL");
  1412     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandlePointerEventL");
  1435     CAlfVisual* tappedvisual = aEvent.Visual();	
  1413     CAlfVisual* tappedvisual = aEvent.Visual();	
  1436     TBool consumed = EFalse;
  1414     TBool consumed = EFalse;
       
  1415     
  1437     if(aEvent.PointerEvent().iType == TPointerEvent::EButton1Down)
  1416     if(aEvent.PointerEvent().iType == TPointerEvent::EButton1Down)
  1438         {	
  1417         {	
       
  1418         //reset variables & Physics simulator 
       
  1419         iPhysics->StopPhysics();
       
  1420         iPhysics->ResetFriction();
       
  1421         iDragging = EFalse;
       
  1422         iPhysicsStarted = EFalse;
       
  1423         iStartTime.HomeTime();
       
  1424         iViewDragged = EFalse;
       
  1425         Display()->Roster().SetPointerEventObservers(
       
  1426                 EAlfPointerEventReportDrag + EAlfPointerEventReportLongTap
       
  1427                         + EAlfPointerEventReportUnhandled, *this);
       
  1428         Display()->Roster().DisableLongTapEventsWhenDragging(*this);
       
  1429 
  1439         if(tappedvisual)
  1430         if(tappedvisual)
  1440             {
  1431             {
  1441             for(TInt index=0;index<iLayout->Count();index++)
  1432             for(TInt index=0;index<iLayout->Count();index++)
  1442                 {    	
  1433                 {    	
  1443                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
  1434                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
  1444                 //if the tapped visual is same as the visual in the layout then focus that visual
  1435                 //if the tapped visual is same as the visual in the layout then focus that visual
  1445                 if(layoutvisual == tappedvisual)
  1436                 if(layoutvisual == tappedvisual)
  1446                     {
  1437                     {
  1447                     TInt focus = iMediaList.FocusIndex();
  1438                     TInt focus = iMediaList.FocusIndex();
  1448                     //if the visual is already focused then for next tap open the next view
  1439                     if (index != focus)
  1449                     if( focus == index )
       
  1450                         {
  1440                         {
  1451                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
  1441                         iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
  1452                         iObserverEnterKeyEvent.HandleEnterKeyEventL( (TInt)EAknCmdOpen );		    			
  1442                         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index);
  1453                         consumed = ETrue;
  1443                         SetFocusColor();
  1454                         }
  1444                         }
  1455                     else if( index!= focus )
  1445                     consumed = ETrue;
       
  1446                     break;
       
  1447                     }
       
  1448                 }
       
  1449             }
       
  1450         }
       
  1451     else if (aEvent.PointerEvent().iType == TPointerEvent::EDrag)
       
  1452         {
       
  1453         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandlePointerEventL(EDrag) event");
       
  1454         iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
       
  1455 
       
  1456         consumed = HandleDragL(aEvent.PointerEvent());
       
  1457         }
       
  1458     else if (aEvent.PointerUp())
       
  1459         {
       
  1460         Display()->Roster().SetPointerEventObservers(0, *this);
       
  1461         consumed = ETrue;
       
  1462 
       
  1463         //Check if dragging actually happened using iViewDragged 
       
  1464         if (iDragging && iViewDragged)
       
  1465             {
       
  1466             iDragging = EFalse;
       
  1467             TPoint drag = iStart - aEvent.PointerEvent().iPosition;
       
  1468             iPhysics->StartPhysics(drag, iStartTime);
       
  1469             iPhysicsStarted = ETrue;
       
  1470             }
       
  1471         //If dragging not happened consider it as Tapped event
       
  1472         else if (tappedvisual && !iViewDragged)
       
  1473             {
       
  1474             for (TInt index = 0; index < iLayout->Count(); index++)
       
  1475                 {
       
  1476                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
       
  1477                 //if the tapped visual is same as the visual in the layout then focus that visual
       
  1478                 if (layoutvisual == tappedvisual)
       
  1479                     {
       
  1480                     TInt focus = iMediaList.FocusIndex();
       
  1481                     if (index != focus)
  1456                         {
  1482                         {
  1457                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
  1483                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
  1458                         TInt focusrowindex = iFocusRowIndex;
  1484                         TInt focusrowindex = iFocusRowIndex;
  1459                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
  1485                         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index);
  1460                                 index);
       
  1461                         SetFocusColor();
  1486                         SetFocusColor();
  1462                         iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
  1487                         iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
  1463                         if( iFocusRowIndex > focusrowindex)
  1488                         if( iFocusRowIndex > focusrowindex)
  1464                             {
  1489                             {
  1465                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
  1490                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
  1471                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup");
  1496                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup");
  1472                             iScrollDirection = 1;                
  1497                             iScrollDirection = 1;                
  1473                             MoveUpIfRequired();                 
  1498                             MoveUpIfRequired();                 
  1474                             }
  1499                             }
  1475                         }
  1500                         }
       
  1501 
       
  1502                     iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
       
  1503                     iObserverEnterKeyEvent.HandleEnterKeyEventL((TInt) EAknCmdOpen);
  1476                     consumed = ETrue;
  1504                     consumed = ETrue;
  1477                     Display()->Roster().SetPointerEventObservers( EAlfPointerEventReportDrag 
       
  1478                             + EAlfPointerEventReportLongTap 
       
  1479                             + EAlfPointerEventReportUnhandled, *this );
       
  1480                     Display()->Roster().DisableLongTapEventsWhenDragging(*this);
       
  1481                     break;
  1505                     break;
  1482                     }
  1506                     }
  1483                 }
  1507                 }
  1484             }
  1508             }
  1485         }			
  1509         iViewDragged = EFalse;
  1486 
       
  1487     else if (aEvent.PointerEvent().iType == TPointerEvent::EDrag)
       
  1488         {
       
  1489         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandlePointerEventL(EDrag) event");
       
  1490         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
       
  1491         consumed =  HandleDragL(aEvent.PointerEvent());
       
  1492         }
       
  1493     else if (aEvent.PointerUp())
       
  1494         {
       
  1495         
       
  1496         Env().CancelCustomCommands(this,ECustomEventFocusDragScroll);
       
  1497         Display()->Roster().SetPointerEventObservers(0, *this);
       
  1498         consumed =  ETrue;
       
  1499         }
  1510         }
  1500     return consumed;
  1511     return consumed;
  1501     }
  1512     }
  1502 
  1513 
  1503 // ---------------------------------------------------------------------------
  1514 // ---------------------------------------------------------------------------
  1504 // HandleDragL()
  1515 // HandleDragL()
  1505 // ---------------------------------------------------------------------------
  1516 // ---------------------------------------------------------------------------
  1506 //
  1517 //
  1507 TBool CGlxCloudViewControl::HandleDragL(const TPointerEvent& aPointerEvent)
  1518 TBool CGlxCloudViewControl::HandleDragL(const TPointerEvent& aPointerEvent)
  1508     {
  1519     {
  1509     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleDragL");
  1520     TBool consumed(EFalse);
  1510     TBool consumed = EFalse;
  1521     
  1511     TInt itemindex = GetAbsoluteIndex(aPointerEvent.iPosition);
  1522     // If Physics Emulation is going on, no need to entertain drag event
  1512     TInt focus = iMediaList.FocusIndex();
  1523     if (iPhysicsStarted)
  1513     TInt focusrowindex = iFocusRowIndex;
  1524         return consumed;
  1514 
  1525 
  1515     //if index is not NULL then focus the tag and move the viewport down if necessary
  1526     //Simply ignore the first drag event as there is huge difference between position 
  1516     if ( itemindex != KErrNotFound )
  1527     //coordinates in drag event and corordinates in normal pointer down / up events  
  1517         {
  1528     if (!iDragging)
  1518         if (focus != itemindex )
  1529         {
  1519             {
  1530         //Note the current position for future reference
  1520             iTouchFeedback->InstantFeedback( ETouchFeedbackSensitive );
  1531         iStart = aPointerEvent.iPosition;
  1521             iMediaList.SetFocusL (NGlxListDefs::EAbsolute,itemindex);			
  1532         iPrev = iStart; 
  1522             iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
  1533         iDragging = ETrue;
  1523             GLX_LOG_INFO1("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,focusrowindex = %d",iFocusRowIndex);
  1534         return consumed;
  1524             if( iFocusRowIndex > focusrowindex)
  1535         }
  1525                 {
  1536 
  1526                 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
  1537     TRect rect;
  1527                 iScrollDirection = 0;
  1538     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
  1528                 MoveDownIfRequired(); 				
  1539     TInt cntrlTopYLimit = rect.iTl.iY;
  1529                 }
  1540     TInt cntrlBottomYLimit = rect.iBr.iY;
  1530             else if( iFocusRowIndex < focusrowindex )
  1541     TInt delta = iPrev.iY - aPointerEvent.iPosition.iY;
  1531                 {
  1542 
  1532                 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup");
  1543     //Check for physics threshold, before regidterting drag corordinates
  1533                 iScrollDirection = 1;
  1544     TInt deltaAbs = delta < 0 ? -delta : delta;
  1534                 MoveUpIfRequired();					
  1545     TBool panning = deltaAbs >= iPhysics->DragThreshold();
  1535                 }			
  1546     if (panning)
  1536             }
  1547         {
  1537         consumed = ETrue;
  1548         TPoint deltaPt = iPrev - aPointerEvent.iPosition;
  1538         }
  1549         iPhysics->RegisterPanningPosition(deltaPt);
  1539 
  1550         iPrev = aPointerEvent.iPosition;
  1540     TRect screenstartrect;
  1551         iViewDragged = ETrue;
  1541     //the starting rect of the visible screen
  1552         }
  1542     screenstartrect.SetRect(0,0,iTagScreenWidth,2*KRowHeight);
  1553     consumed = ETrue;
  1543 
  1554 
  1544     TRect screenendrect;
  1555     //Calculate margin after which we might get pointer out of screen, and we might not 
  1545     //the end rect of the visible screen
  1556     //get further pointer events. Also This is currently only 10% of total delta we can find, 
  1546     screenendrect.SetRect(0,(iTagScreenHeight-(2*KRowHeight)),iTagScreenWidth,iTagScreenHeight);
  1557     //to get margin corresponding to movement of user flicking speed
  1547 
  1558     //This implies higher speed - higher margin
  1548     //dragging down
  1559     //Lower speed - 0 margin
  1549     if(screenendrect.Contains(aPointerEvent.iPosition))
  1560     TInt deltaMargin = deltaAbs * KBoundaryMargin;
  1550         {            
  1561 
  1551         iIsDragging = 1;            
  1562     //Code to predict future movement if same delta movement we might get in future
  1552         Env().Send(TAlfCustomEventCommand(ECustomEventFocusDragScroll,
  1563     //For flick event down - If the movement goes below screen, start physics
  1553                 this),KDragHoldTime);
  1564     //or For flick event up - If the movement goes above screen, start physics 
  1554         }
  1565     if (((delta < 0) && (aPointerEvent.iPosition.iY - delta >= cntrlBottomYLimit - deltaMargin))
  1555     //dragging up
  1566             || ((delta > 0) && (aPointerEvent.iPosition.iY - delta <= cntrlTopYLimit + deltaMargin)))
  1556     else if  (screenstartrect.Contains(aPointerEvent.iPosition))
  1567         {
  1557         {
  1568         iPhysicsStarted = ETrue;
  1558         iIsDragging = 2;             
  1569         }
  1559         Env().Send(TAlfCustomEventCommand(ECustomEventFocusDragScroll,
  1570 
  1560                 this),KDragHoldTime);
  1571     //If found that possibly in next move it might go out of bounds, start physics
  1561         }        
  1572     //emulation
       
  1573     if (iPhysicsStarted && iDragging)
       
  1574         {
       
  1575         TPoint drag = iStart - aPointerEvent.iPosition;
       
  1576         iPhysics->StartPhysics(drag, iStartTime);
       
  1577         iDragging = EFalse;
       
  1578         }
  1562 
  1579 
  1563     return consumed;
  1580     return consumed;
  1564     }
  1581     }
  1565 
  1582 
  1566 // ---------------------------------------------------------------------------
  1583 // ---------------------------------------------------------------------------
  1682                         {    
  1699                         {    
  1683                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollDown) event");
  1700                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollDown) event");
  1684                         TInt steps = TInt(aEvent.CustomEventData());
  1701                         TInt steps = TInt(aEvent.CustomEventData());
  1685                         UpdateScrollBar(steps,EFalse);                        
  1702                         UpdateScrollBar(steps,EFalse);                        
  1686                         Scroll();                       
  1703                         Scroll();                       
       
  1704                         iPhysics->StopPhysics();
       
  1705 
  1687                         status = EEventHandled; 
  1706                         status = EEventHandled; 
  1688                         }
  1707                         }
  1689                         break;                   
  1708                         break;                   
  1690                     case EEventScrollPageUp:
  1709                     case EEventScrollPageUp:
  1691                         { 
  1710                         { 
  1692                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageUp) event");                       
  1711                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageUp) event");                       
  1693                         UpdateScrollBar(-iScrollEventData.mViewLength); 
  1712                         UpdateScrollBar(-iScrollEventData.mViewLength); 
  1694                         Scroll();                        
  1713                         Scroll();                        
  1695                         status = EEventHandled;    		    	    
  1714                         iPhysics->StopPhysics();
       
  1715                         status = EEventHandled;
  1696                         }
  1716                         }
  1697                         break;
  1717                         break;
  1698                     case EEventScrollPageDown:
  1718                     case EEventScrollPageDown:
  1699                         {  
  1719                         {  
  1700                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageDown) event");                       
  1720                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageDown) event");                       
  1701                         UpdateScrollBar(iScrollEventData.mViewLength); 
  1721                         UpdateScrollBar(iScrollEventData.mViewLength); 
  1702                         Scroll();
  1722                         Scroll();
       
  1723                         iPhysics->StopPhysics();
  1703                         status = EEventHandled; 		    	    
  1724                         status = EEventHandled; 		    	    
  1704                         }
  1725                         }
  1705                         break;                    
  1726                         break;                    
  1706                     }//end switch
  1727                     }//end switch
  1707                 }
  1728                 }
  1753             baseelement->makeInterface (IAlfWidgetEventHandler::type()));
  1774             baseelement->makeInterface (IAlfWidgetEventHandler::type()));
  1754     //pass the custom event to scrollbar element so as to scroll to the required position
  1775     //pass the custom event to scrollbar element so as to scroll to the required position
  1755     iScrollbarElement->offerEvent(*(iScrollBarWidget->control()),customevent);
  1776     iScrollbarElement->offerEvent(*(iScrollBarWidget->control()),customevent);
  1756     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::Scroll(),position %d ",iScrollEventData.mViewStartPos);
  1777     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::Scroll(),position %d ",iScrollEventData.mViewStartPos);
  1757     iViewPortPosition.iY = iScrollEventData.mViewStartPos;
  1778     iViewPortPosition.iY = iScrollEventData.mViewStartPos;
  1758     iViewPortLayout->SetViewportPos (iViewPortPosition,1000);  
  1779     iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement);
  1759     }
  1780     }
  1760 
  1781 
  1761 // ---------------------------------------------------------------------------
  1782 // ---------------------------------------------------------------------------
  1762 // UpdateScrollBar()
  1783 // UpdateScrollBar()
  1763 // ---------------------------------------------------------------------------
  1784 // ---------------------------------------------------------------------------
  1818 //
  1839 //
  1819 void CGlxCloudViewControl::UpdateLayoutL() 
  1840 void CGlxCloudViewControl::UpdateLayoutL() 
  1820     {
  1841     {
  1821     TRect rect;
  1842     TRect rect;
  1822     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
  1843     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
  1823     if ( (rect.Width() != iTagScreenWidth) && ( rect.Height () != iScreenHeight))
  1844     if ((rect.Width() != (iTagScreenWidth + iScrollPaneHandle.iW + KRightmargin)) || (rect.Height() != iScreenHeight))
  1824         {
  1845         {
  1825         //set the new screen dimensions
  1846         //set the new screen dimensions
  1826         iScreenHeight=rect.Height();
  1847         iScreenHeight=rect.Height();
  1827        iTagScreenWidth = rect.Width()- iScrollPaneHandle.iW - KRightmargin;
  1848        iTagScreenWidth = rect.Width()- iScrollPaneHandle.iW - KRightmargin;
  1828         if (GlxGeneralUiUtilities::IsLandscape())
  1849         if(IsLandscape())
  1829             {   
  1850             {   
  1830             iTagScreenHeight = rect.Height();   
  1851             iTagScreenHeight = rect.Height();   
  1831             }
  1852             }
  1832         else 
  1853         else 
  1833             {
  1854             {
  1840             {
  1861             {
  1841             UpdateLayout();
  1862             UpdateLayout();
  1842             FetchAttributeFromCacheL();
  1863             FetchAttributeFromCacheL();
  1843             //generate row structures and draw rows on screen
  1864             //generate row structures and draw rows on screen
  1844             UpdateRowDataL ();                                    
  1865             UpdateRowDataL ();                                    
  1845             }
  1866 
  1846         }
  1867             InitPhysicsL();
  1847     }
  1868             }
       
  1869         }
       
  1870     }
       
  1871 
       
  1872 // ---------------------------------------------------------------------------
       
  1873 // InitPhysicsL() 
       
  1874 // ---------------------------------------------------------------------------
       
  1875 //
       
  1876 void CGlxCloudViewControl::InitPhysicsL()
       
  1877     {
       
  1878     //Update physics with new total layout, viewable size and our landscape mode 
       
  1879     iPhysics->InitPhysicsL(TSize(iViewPortVirtualSize.iWidth,
       
  1880             iViewPortVirtualSize.iHeight), TSize(iTagScreenWidth,
       
  1881             iTagScreenHeight), EFalse);
       
  1882 
       
  1883     //Note: Physics viewposition must always be mid of viewable screen size to get best result
       
  1884     //I learned the hard way
       
  1885     iViewPosition.SetXY(iTagScreenWidth / 2, iTagScreenHeight / 2);
       
  1886     }
       
  1887 
       
  1888 // ---------------------------------------------------------------------------
       
  1889 // ViewPositionChanged() 
       
  1890 // ---------------------------------------------------------------------------
       
  1891 //
       
  1892 void CGlxCloudViewControl::ViewPositionChanged(const TPoint& aNewPosition,
       
  1893         TBool aDrawNow, TUint /*aFlags*/)
       
  1894     {
       
  1895     iViewPosition = aNewPosition;
       
  1896     iViewPortPosition.iY = iViewPosition.iY - iTagScreenHeight / 2;
       
  1897     if (aDrawNow)
       
  1898         {
       
  1899         iViewPortLayout->SetViewportPos(iViewPortPosition, KFastCloudMovement);
  1848         
  1900         
       
  1901         iScrollEventData.mViewStartPos = iViewPortPosition.iY;
       
  1902         Scroll();
       
  1903         }
       
  1904     }
       
  1905 
       
  1906 // ---------------------------------------------------------------------------
       
  1907 // PhysicEmulationEnded() 
       
  1908 // ---------------------------------------------------------------------------
       
  1909 //
       
  1910 void CGlxCloudViewControl::PhysicEmulationEnded()
       
  1911     {
       
  1912     iPhysicsStarted = EFalse;
       
  1913     }
       
  1914 
       
  1915 // ---------------------------------------------------------------------------
       
  1916 // ViewPosition() 
       
  1917 // ---------------------------------------------------------------------------
       
  1918 //
       
  1919 TPoint CGlxCloudViewControl::ViewPosition() const
       
  1920     {
       
  1921     return iViewPosition;
       
  1922     }
       
  1923 
       
  1924 // ---------------------------------------------------------------------------
       
  1925 // IsLandscape() 
       
  1926 // ---------------------------------------------------------------------------
       
  1927 //
       
  1928 TBool CGlxCloudViewControl::IsLandscape()
       
  1929     {
       
  1930     TRect rect;
       
  1931     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, rect);
       
  1932     if(rect.Width() > rect.Height())
       
  1933         {
       
  1934         return ETrue;
       
  1935         }
       
  1936     else
       
  1937         {
       
  1938         return EFalse;
       
  1939         }
       
  1940     }
  1849 //End of file
  1941 //End of file