photosgallery/viewframework/views/cloudview/src/glxcloudviewcontrol.cpp
branchRCL_3
changeset 9 6b87b143d312
parent 2 7d9067c6fcb1
child 14 ce1c7ad1f18b
equal deleted inserted replaced
5:f7f0874bfe7d 9:6b87b143d312
    14 * Description:    Cloud View control class 
    14 * Description:    Cloud View control class 
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 
       
    20 
       
    21 // INCLUDE FILES
    19 // INCLUDE FILES
    22 #include "glxcloudviewcontrol.h" //class header
    20 #include "glxcloudviewcontrol.h" //class header
    23 //AlfT headers
    21 //AlfT headers
    24 
    22 
    25 #include <alf/alfanchorlayout.h> // For CAlfAnchorLayout 
    23 #include <alf/alfanchorlayout.h> // For CAlfAnchorLayout 
    31 #include <alf/alfwidgetcontrol.h> // For CAlfWidgetControl
    29 #include <alf/alfwidgetcontrol.h> // For CAlfWidgetControl
    32 #include <alf/alfroster.h> // For CalfRoster
    30 #include <alf/alfroster.h> // For CalfRoster
    33 #include <alf/alfdisplay.h> // For CAlfDisplay
    31 #include <alf/alfdisplay.h> // For CAlfDisplay
    34 #include <alf/ialfscrollbarmodel.h> // For alfScrollbar model
    32 #include <alf/ialfscrollbarmodel.h> // For alfScrollbar model
    35 #include <aknlayoutscalable_uiaccel.cdl.h>
    33 #include <aknlayoutscalable_uiaccel.cdl.h>
       
    34 #include <alf/alfcontrolgroup.h>
       
    35 #include <alf/alfutil.h>
    36 #include <aknphysics.h> // For Kinetic Scrolling
    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 
    47 #include "glxcontainerinfobubble.h" //intelligent class for data of infobubble
    47 #include "glxcontainerinfobubble.h" //intelligent class for data of infobubble
    48 #include "glxcloudview.hrh"
    48 #include "glxcloudview.hrh"
    49 #include "mglxcloudviewmskobserver.h" // For Msk Observer
    49 #include "mglxcloudviewmskobserver.h" // For Msk Observer
    50 #include "mglxenterkeyeventobserver.h" // For enterkey observer
    50 #include "mglxenterkeyeventobserver.h" // For enterkey observer
    51 #include "mglxcloudviewlayoutobserver.h"
    51 #include "mglxcloudviewlayoutobserver.h"
       
    52 #include "glxtagscontextmenucontrol.h"
    52 
    53 
    53 //Constants
    54 //Constants
    54 const TInt KPrimaryFontSize = 21;
    55 const TInt KPrimaryFontSize = 21;
    55 //Font sizes
    56 //Font sizes
    56 const TInt KFontSmallest = 28;
    57 const TInt KFontSmallest = 28;
    66 const TInt KMinTagSize = 77;
    67 const TInt KMinTagSize = 77;
    67 const TInt KTagScreenHeight = 460;
    68 const TInt KTagScreenHeight = 460;
    68 const TReal KBoundaryMargin = 0.1; //10% = 10/100 = 0.1 
    69 const TReal KBoundaryMargin = 0.1; //10% = 10/100 = 0.1 
    69 const TInt KFastCloudMovement = 100; //Transition time to move cloud view
    70 const TInt KFastCloudMovement = 100; //Transition time to move cloud view
    70 const TInt KSlowCloudMovement = 1000; //Transition time to move cloud view
    71 const TInt KSlowCloudMovement = 1000; //Transition time to move cloud view
       
    72 const TInt KLongPressTimer = 1500000; //1.5 seconds
    71 
    73 
    72 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    73 // Two-phased constructor.
    75 // Two-phased constructor.
    74 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    75 // 
    77 // 
    76 CGlxCloudViewControl *CGlxCloudViewControl::NewL(CAlfDisplay& aDisplay,
    78 CGlxCloudViewControl *CGlxCloudViewControl::NewL(CAlfDisplay& aDisplay,
    77         CAlfEnv &aEnv, MGlxMediaList& aMediaList, const TDesC& aEmptyText,
    79         CAlfEnv &aEnv, MGlxMediaList& aMediaList, const TDesC& aEmptyText,
    78         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
    80         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
    79         ,CAlfAnchorLayout *aAnchorLayout,MGlxCloudViewLayoutObserver& aLayoutObserver)
    81         ,CAlfAnchorLayout *aAnchorLayout,
       
    82         MGlxCloudViewLayoutObserver& aLayoutObserver
       
    83         ,MGlxItemMenuObserver& aItemMenuObserver)
    80     {
    84     {
    81     TRACER("GLX_CLOUD::CGlxCloudViewControl::NewL");
    85     TRACER("GLX_CLOUD::CGlxCloudViewControl::NewL");
    82     CGlxCloudViewControl *self = CGlxCloudViewControl::NewLC (aDisplay, aEnv,
    86     CGlxCloudViewControl *self = CGlxCloudViewControl::NewLC (aDisplay, aEnv,
    83             aMediaList, aEmptyText,aObserver,aObserverEnterKeyEvent,aAnchorLayout,aLayoutObserver);
    87             aMediaList, aEmptyText,aObserver,aObserverEnterKeyEvent,aAnchorLayout,aLayoutObserver,aItemMenuObserver);
    84     CleanupStack::Pop (self);
    88     CleanupStack::Pop (self);
    85     return self;
    89     return self;
    86     }
    90     }
    87 
    91 
    88 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    94 // ---------------------------------------------------------------------------
    91 // 
    95 // 
    92 CGlxCloudViewControl *CGlxCloudViewControl::NewLC(CAlfDisplay& aDisplay,
    96 CGlxCloudViewControl *CGlxCloudViewControl::NewLC(CAlfDisplay& aDisplay,
    93         CAlfEnv &aEnv, MGlxMediaList& aMediaList, const TDesC& aEmptyText,
    97         CAlfEnv &aEnv, MGlxMediaList& aMediaList, const TDesC& aEmptyText,
    94         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
    98         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
    95         ,CAlfAnchorLayout *aAnchorLayout,MGlxCloudViewLayoutObserver& aLayoutObserver)
    99         ,CAlfAnchorLayout *aAnchorLayout,MGlxCloudViewLayoutObserver& aLayoutObserver
       
   100         ,MGlxItemMenuObserver& aItemMenuObserver)
    96     {
   101     {
    97     TRACER("GLX_CLOUD::CGlxCloudViewControl::NewLC");
   102     TRACER("GLX_CLOUD::CGlxCloudViewControl::NewLC");
    98     CGlxCloudViewControl *self = new(ELeave)CGlxCloudViewControl(aEnv,aMediaList,aObserver
   103     CGlxCloudViewControl *self = new(ELeave)CGlxCloudViewControl(aEnv,aMediaList,aObserver
    99             ,aObserverEnterKeyEvent,aLayoutObserver);
   104             ,aObserverEnterKeyEvent,aLayoutObserver);
   100     CleanupStack::PushL (self);
   105     CleanupStack::PushL (self);
   101     self->ConstructL (aEmptyText,aDisplay,aAnchorLayout);
   106     self->ConstructL (aEmptyText,aDisplay,aAnchorLayout,aItemMenuObserver);
   102     return self;
   107     return self;
   103     }
   108     }
   104 
   109 
   105 // ---------------------------------------------------------------------------
   110 // ---------------------------------------------------------------------------
   106 // Default C++ Constructor
   111 // Default C++ Constructor
   124 // ---------------------------------------------------------------------------
   129 // ---------------------------------------------------------------------------
   125 //ConstructL()
   130 //ConstructL()
   126 // ---------------------------------------------------------------------------
   131 // ---------------------------------------------------------------------------
   127 //
   132 //
   128 void CGlxCloudViewControl::ConstructL(const TDesC& aEmptyText,CAlfDisplay& aDisplay
   133 void CGlxCloudViewControl::ConstructL(const TDesC& aEmptyText,CAlfDisplay& aDisplay
   129         ,CAlfAnchorLayout *aAnchorLayout)
   134         ,CAlfAnchorLayout *aAnchorLayout,MGlxItemMenuObserver& aItemMenuObserver)
   130     {
   135     {
   131     TRACER("GLX_CLOUD::CGlxCloudViewControl::ConstructL");
   136     TRACER("GLX_CLOUD::CGlxCloudViewControl::ConstructL");
   132     iUiUtility = CGlxUiUtility::UtilityL ();
   137     iUiUtility = CGlxUiUtility::UtilityL ();
   133     CAlfControl::ConstructL(iEnv);
   138     CAlfControl::ConstructL(iEnv);
   134     BindDisplay (aDisplay);
   139     BindDisplay (aDisplay);
   135     //Initializing data for cloud view display 
   140     //Initializing data for cloud view display 
   136     iFocusRowIndex = 0; //initially focus row will be zero
   141     iFocusRowIndex = 0; //initially focus row will be zero
   137 
   142 
   138     iEmptyText = aEmptyText.AllocL();
   143     iEmptyText = aEmptyText.AllocL();
   139 
   144 
       
   145     iTimer = CGlxBubbleTimer::NewL (this);
       
   146     
       
   147     CAlfControlGroup* ctrlGroup = iUiUtility->Env()->FindControlGroup(0);
       
   148     //Creating Grid control for floating menu bar 
       
   149     iTagsContextMenuControl = CGlxTagsContextMenuControl::NewL(aItemMenuObserver);
       
   150     if(ctrlGroup)
       
   151         {
       
   152         ctrlGroup->AppendL(iTagsContextMenuControl);
       
   153         }
       
   154     
   140     TRect rect;
   155     TRect rect;
   141     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
   156     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
   142     iScreenHeight = rect.Height ();
   157     iScreenHeight = rect.Height ();
   143     iParentLayout = CAlfLayout::AddNewL(*this, aAnchorLayout);                    
   158     iParentLayout = CAlfLayout::AddNewL(*this, aAnchorLayout);                    
   144     iTagScreenWidth = rect.Width() - iScrollPaneHandle.iW - KRightmargin;
   159     iTagScreenWidth = rect.Width() - iScrollPaneHandle.iW - KRightmargin;
   238     if ( iUiUtility )
   253     if ( iUiUtility )
   239         {
   254         {
   240         iUiUtility->Close ();
   255         iUiUtility->Close ();
   241         }	
   256         }	
   242     delete iEmptyText;
   257     delete iEmptyText;
       
   258 
       
   259     if ( iTimer)
       
   260         {
       
   261         iTimer->Cancel ();//cancels any outstanding requests
       
   262         delete iTimer;
       
   263         }
   243     delete iPhysics;
   264     delete iPhysics;
   244     }
   265     }
   245 
   266 
   246 // --------------------------------------------------------------------------- 
   267 // --------------------------------------------------------------------------- 
   247 // LayoutVisibleRows()
   268 // LayoutVisibleRows()
  1424         iViewDragged = EFalse;
  1445         iViewDragged = EFalse;
  1425         Display()->Roster().SetPointerEventObservers(
  1446         Display()->Roster().SetPointerEventObservers(
  1426                 EAlfPointerEventReportDrag + EAlfPointerEventReportLongTap
  1447                 EAlfPointerEventReportDrag + EAlfPointerEventReportLongTap
  1427                         + EAlfPointerEventReportUnhandled, *this);
  1448                         + EAlfPointerEventReportUnhandled, *this);
  1428         Display()->Roster().DisableLongTapEventsWhenDragging(*this);
  1449         Display()->Roster().DisableLongTapEventsWhenDragging(*this);
       
  1450         
       
  1451         //If the grid is already shown , disable it
       
  1452         iTagsContextMenuControl->ShowItemMenu(EFalse);
  1429 
  1453 
  1430         if(tappedvisual)
  1454         if(tappedvisual)
  1431             {
  1455             {
  1432             for(TInt index=0;index<iLayout->Count();index++)
  1456             for(TInt index=0;index<iLayout->Count();index++)
  1433                 {    	
  1457                 {    	
  1434                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
  1458                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
  1435                 //if the tapped visual is same as the visual in the layout then focus that visual
  1459                 //if the tapped visual is same as the visual in the layout then focus that visual
  1436                 if(layoutvisual == tappedvisual)
  1460                 if(layoutvisual == tappedvisual)
  1437                     {
  1461                     {
  1438                     TInt focus = iMediaList.FocusIndex();
  1462                     iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
  1439                     if (index != focus)
  1463                     iMediaList.SetFocusL (NGlxListDefs::EAbsolute, index);
  1440                         {
  1464 
  1441                         iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
  1465                     //Start the timer to interpret longpress events
  1442                         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index);
  1466                     iTimerComplete = EFalse;
  1443                         SetFocusColor();
  1467                     iTimer->Cancel ();//cancels any outstanding requests
  1444                         }
  1468                     iTimer->SetDelay (KLongPressTimer);
       
  1469                     
  1445                     consumed = ETrue;
  1470                     consumed = ETrue;
  1446                     break;
  1471                     break;
  1447                     }
  1472                     }
  1448                 }
  1473                 }
  1449             }
  1474             }
  1450         }
  1475         }
  1451     else if (aEvent.PointerEvent().iType == TPointerEvent::EDrag)
  1476     else if (aEvent.PointerEvent().iType == TPointerEvent::EDrag)
  1452         {
  1477         {
  1453         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandlePointerEventL(EDrag) event");
  1478         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandlePointerEventL(EDrag) event");
       
  1479         
  1454         iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
  1480         iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
  1455 
  1481 
  1456         consumed = HandleDragL(aEvent.PointerEvent());
  1482         consumed = HandleDragL(aEvent.PointerEvent());
  1457         }
  1483         }
  1458     else if (aEvent.PointerUp())
  1484     else if (aEvent.PointerUp())
  1459         {
  1485         {
  1460         Display()->Roster().SetPointerEventObservers(0, *this);
  1486         Display()->Roster().SetPointerEventObservers(0, *this);
  1461         consumed = ETrue;
  1487         consumed = ETrue;
       
  1488         
       
  1489         //If the long press timer is completed , and if upevent is received.. ignore it
       
  1490         if(iTimerComplete)
       
  1491             {
       
  1492             consumed =  ETrue;
       
  1493             }
  1462 
  1494 
  1463         //Check if dragging actually happened using iViewDragged 
  1495         //Check if dragging actually happened using iViewDragged 
  1464         if (iDragging && iViewDragged)
  1496         if (iDragging && iViewDragged)
  1465             {
  1497             {
  1466             iDragging = EFalse;
  1498             iDragging = EFalse;
  1467             TPoint drag = iStart - aEvent.PointerEvent().iPosition;
  1499             TPoint drag = iStart - aEvent.PointerEvent().iPosition;
  1468             iPhysics->StartPhysics(drag, iStartTime);
  1500             iPhysics->StartPhysics(drag, iStartTime);
  1469             iPhysicsStarted = ETrue;
  1501             iPhysicsStarted = ETrue;
       
  1502             
       
  1503             iTimer->Cancel ();//cancels any outstanding requests
  1470             }
  1504             }
  1471         //If dragging not happened consider it as Tapped event
  1505         //If dragging not happened consider it as Tapped event
  1472         else if (tappedvisual && !iViewDragged)
  1506         //When it recognises the long press event ,  and if up event is received..Ignore it 
  1473             {
  1507         else if (tappedvisual && !iViewDragged && !iTimerComplete)
  1474             for (TInt index = 0; index < iLayout->Count(); index++)
  1508             {
       
  1509            for (TInt index = 0; index < iLayout->Count(); index++)
  1475                 {
  1510                 {
  1476                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
  1511                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
  1477                 //if the tapped visual is same as the visual in the layout then focus that visual
  1512                 //if the tapped visual is same as the visual in the layout then focus that visual
  1478                 if (layoutvisual == tappedvisual)
  1513                 if (layoutvisual == tappedvisual)
  1479                     {
  1514                     {
  1483                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
  1518                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
  1484                         TInt focusrowindex = iFocusRowIndex;
  1519                         TInt focusrowindex = iFocusRowIndex;
  1485                         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index);
  1520                         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index);
  1486                         SetFocusColor();
  1521                         SetFocusColor();
  1487                         iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
  1522                         iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
  1523                         
  1488                         if( iFocusRowIndex > focusrowindex)
  1524                         if( iFocusRowIndex > focusrowindex)
  1489                             {
  1525                             {
  1490                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
  1526                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
  1491                             iScrollDirection = 0;               
  1527                             iScrollDirection = 0;               
  1492                             MoveDownIfRequired();               
  1528                             MoveDownIfRequired();               
  1679     {
  1715     {
  1680     TRACER("GLX_CLOUD::CGlxCloudViewControl::offerEvent");  
  1716     TRACER("GLX_CLOUD::CGlxCloudViewControl::offerEvent");  
  1681     AlfEventStatus status = EEventNotHandled;  
  1717     AlfEventStatus status = EEventNotHandled;  
  1682     if(aEvent.IsCustomEvent() && accept(aControl, aEvent))
  1718     if(aEvent.IsCustomEvent() && accept(aControl, aEvent))
  1683         {
  1719         {
  1684         if ((iScrollBarWidget!=NULL))
  1720         if ( iScrollBarWidget )
  1685             {    		
  1721             {    		
  1686             if (aEvent.IsCustomEvent())
  1722             if (aEvent.IsCustomEvent())
  1687                 {
  1723                 {
  1688                 switch(aEvent.CustomParameter())
  1724                 switch(aEvent.CustomParameter())
  1689                     {
  1725                     {
  1936     else
  1972     else
  1937         {
  1973         {
  1938         return EFalse;
  1974         return EFalse;
  1939         }
  1975         }
  1940     }
  1976     }
       
  1977 // ---------------------------------------------------------------------------
       
  1978 // TimerComplete()
       
  1979 // ---------------------------------------------------------------------------
       
  1980 //
       
  1981 void CGlxCloudViewControl::TimerComplete()
       
  1982     {
       
  1983     iTimerComplete = ETrue;
       
  1984     iTagsContextMenuControl->ShowItemMenu(EFalse);
       
  1985 
       
  1986     CAlfVisual& visual = iLayout->Visual( iMediaList.FocusIndex() );
       
  1987     TRect focussedItemRect = visual.DisplayRect();
       
  1988     TPoint midpoint;
       
  1989     midpoint.iX=focussedItemRect.iTl.iX +
       
  1990             ((focussedItemRect.iBr.iX - focussedItemRect.iTl.iX )/2);
       
  1991     midpoint.iY=focussedItemRect.iTl.iY+
       
  1992                     ((focussedItemRect.iBr.iY - focussedItemRect.iTl.iY )/2); 
       
  1993     
       
  1994     TRect rect;
       
  1995     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
  1996     
       
  1997     if(!iPhysicsStarted)//only if physics hasnt started
       
  1998         {
       
  1999         iTagsContextMenuControl->SetViewableRect(rect);
       
  2000         iTagsContextMenuControl->ShowItemMenu(ETrue);
       
  2001         iTagsContextMenuControl->SetDisplay(midpoint);
       
  2002         }
       
  2003    }
       
  2004 // ---------------------------------------------------------------------------
       
  2005 // ShowContextItemMenu()
       
  2006 // ---------------------------------------------------------------------------
       
  2007 //
       
  2008 void CGlxCloudViewControl::ShowContextItemMenu(TBool aShow)
       
  2009     {
       
  2010     iTagsContextMenuControl->ShowItemMenu(aShow);
       
  2011     }
       
  2012 
  1941 //End of file
  2013 //End of file