photosgallery/viewframework/views/cloudview/src/glxcloudviewcontrol.cpp
branchRCL_3
changeset 26 5b3385a43d68
child 27 34937ec34dac
equal deleted inserted replaced
25:8e5f6eea9c9f 26:5b3385a43d68
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Cloud View control class 
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "glxcloudviewcontrol.h" //class header
       
    21 //AlfT headers
       
    22 
       
    23 #include <alf/alfanchorlayout.h> // For CAlfAnchorLayout 
       
    24 #include <alf/alfviewportlayout.h> // For CAlfViewPortLayout
       
    25 #include <touchfeedback.h>  // For MTouchFeedback
       
    26 #include <alf/alftextstyle.h>  // For CAlfTextStyle
       
    27 #include <alf/alftextvisual.h> // For CAlfTextVisual
       
    28 #include <alf/alftransformation.h>
       
    29 #include <alf/alfwidgetcontrol.h> // For CAlfWidgetControl
       
    30 #include <alf/alfroster.h> // For CalfRoster
       
    31 #include <alf/alfdisplay.h> // For CAlfDisplay
       
    32 #include <alf/ialfscrollbarmodel.h> // For alfScrollbar model
       
    33 #include <aknlayoutscalable_uiaccel.cdl.h>
       
    34 #include <alf/alfcontrolgroup.h>
       
    35 #include <alf/alfutil.h>
       
    36 #include <aknphysics.h> // For Kinetic Scrolling
       
    37 #include <glxuiutility.h>
       
    38 #include <glxgeneraluiutilities.h>
       
    39 #include <glxuistd.h>
       
    40 
       
    41 //AlfT
       
    42 #include <glxlog.h>			// For Logs
       
    43 #include <glxtracer.h>			// For Logs
       
    44 #include <glxattributecontext.h> //attribute context
       
    45 #include <mglxmedialist.h> //for medialist
       
    46 
       
    47 #include "glxcloudview.hrh"
       
    48 #include "mglxcloudviewmskobserver.h" // For Msk Observer
       
    49 #include "mglxenterkeyeventobserver.h" // For enterkey observer
       
    50 #include "mglxcloudviewlayoutobserver.h"
       
    51 #include "glxtagscontextmenucontrol.h"
       
    52 
       
    53 //Constants
       
    54 const TInt KPrimaryFontSize = 21;
       
    55 //Font sizes
       
    56 const TInt KFontSmallest = 28;
       
    57 const TInt KFontSmaller = 32;
       
    58 const TInt KFontMedium = 36;
       
    59 const TInt KFontLarger = 40;
       
    60 const TInt KFontLargest = 44;
       
    61 const TInt KRowHeight = 72;
       
    62 const TInt KLeftMargin = 10;
       
    63 const TInt KNumMinRowSpace = 2;
       
    64 const TInt KColSpace = 30;
       
    65 const TInt KRightmargin = 10;//Aligning Right margin
       
    66 const TInt KMinTagSize = 77;
       
    67 const TInt KTagScreenHeight = 460;
       
    68 const TReal KBoundaryMargin = 0.1; //10% = 10/100 = 0.1 
       
    69 const TInt KFastCloudMovement = 100; //Transition time to move cloud view
       
    70 const TInt KSlowCloudMovement = 1000; //Transition time to move cloud view
       
    71 const TInt KLongPressTimer = 700000;//700 ms to synchonize with gridview context menu timings
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // Two-phased constructor.
       
    75 // ---------------------------------------------------------------------------
       
    76 // 
       
    77 CGlxCloudViewControl *CGlxCloudViewControl::NewL(CAlfDisplay& aDisplay,
       
    78         CAlfEnv &aEnv, MGlxMediaList& aMediaList, const TDesC& aEmptyText,
       
    79         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
       
    80         ,CAlfAnchorLayout *aAnchorLayout,
       
    81         MGlxCloudViewLayoutObserver& aLayoutObserver
       
    82         ,MGlxItemMenuObserver& aItemMenuObserver)
       
    83     {
       
    84     TRACER("GLX_CLOUD::CGlxCloudViewControl::NewL");
       
    85     CGlxCloudViewControl *self = CGlxCloudViewControl::NewLC (aDisplay, aEnv,
       
    86             aMediaList, aEmptyText,aObserver,aObserverEnterKeyEvent,aAnchorLayout,aLayoutObserver,aItemMenuObserver);
       
    87     CleanupStack::Pop (self);
       
    88     return self;
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // Two-phased constructor.
       
    93 // ---------------------------------------------------------------------------
       
    94 // 
       
    95 CGlxCloudViewControl *CGlxCloudViewControl::NewLC(CAlfDisplay& aDisplay,
       
    96         CAlfEnv &aEnv, MGlxMediaList& aMediaList, const TDesC& aEmptyText,
       
    97         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
       
    98         ,CAlfAnchorLayout *aAnchorLayout,MGlxCloudViewLayoutObserver& aLayoutObserver
       
    99         ,MGlxItemMenuObserver& aItemMenuObserver)
       
   100     {
       
   101     TRACER("GLX_CLOUD::CGlxCloudViewControl::NewLC");
       
   102     CGlxCloudViewControl *self = new(ELeave)CGlxCloudViewControl(aEnv,aMediaList,aObserver
       
   103             ,aObserverEnterKeyEvent,aLayoutObserver);
       
   104     CleanupStack::PushL (self);
       
   105     self->ConstructL (aEmptyText,aDisplay,aAnchorLayout,aItemMenuObserver);
       
   106     return self;
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // Default C++ Constructor
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 
       
   114 CGlxCloudViewControl::CGlxCloudViewControl(CAlfEnv &aEnv, MGlxMediaList& aMediaList,
       
   115         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
       
   116         ,MGlxCloudViewLayoutObserver& aLayoutObserver):
       
   117         iEnv(aEnv),  iMediaList(aMediaList), iObserver(aObserver)
       
   118         ,iObserverEnterKeyEvent(aObserverEnterKeyEvent),iLayoutObserver(aLayoutObserver)
       
   119         {
       
   120         TRACER("GLX_CLOUD::CGlxCloudViewControl::CGlxCloudViewControl");
       
   121         //added for scrollbar widget implementation
       
   122         iScrollEventData.mChangedMask = 0;
       
   123         iScrollEventData.mViewStartPos = 0;
       
   124         iScrollEventData.mSpan = 0;
       
   125         iScrollEventData.mViewLength = 0;    
       
   126         }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 //ConstructL()
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 void CGlxCloudViewControl::ConstructL(const TDesC& aEmptyText,CAlfDisplay& aDisplay
       
   133         ,CAlfAnchorLayout *aAnchorLayout,MGlxItemMenuObserver& aItemMenuObserver)
       
   134     {
       
   135     TRACER("GLX_CLOUD::CGlxCloudViewControl::ConstructL");
       
   136     iUiUtility = CGlxUiUtility::UtilityL ();
       
   137     CAlfControl::ConstructL(iEnv);
       
   138     BindDisplay (aDisplay);
       
   139     //Initializing data for cloud view display 
       
   140     iFocusRowIndex = 0; //initially focus row will be zero
       
   141 
       
   142     iEmptyText = aEmptyText.AllocL();
       
   143 
       
   144     iTimer = CGlxBubbleTimer::NewL (this);
       
   145     
       
   146     CAlfControlGroup* ctrlGroup = iUiUtility->Env()->FindControlGroup(0);
       
   147     //Creating Grid control for floating menu bar 
       
   148     iTagsContextMenuControl = CGlxTagsContextMenuControl::NewL(aItemMenuObserver);
       
   149     if(ctrlGroup)
       
   150         {
       
   151         ctrlGroup->AppendL(iTagsContextMenuControl);
       
   152         }
       
   153     
       
   154     TRect rect;
       
   155     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
       
   156     iScreenHeight = rect.Height ();
       
   157     iParentLayout = CAlfLayout::AddNewL(*this, aAnchorLayout);                    
       
   158     iTagScreenWidth = rect.Width() - KRightmargin;
       
   159 
       
   160     if(IsLandscape())
       
   161         {	
       
   162         iTagScreenHeight = rect.Height();	
       
   163         }
       
   164     else 
       
   165         {
       
   166 
       
   167         iTagScreenHeight = KTagScreenHeight;
       
   168         }                                  
       
   169 
       
   170     iViewPortLayout = CAlfViewportLayout::AddNewL(*this, iParentLayout);      
       
   171     iLayout=CAlfAnchorLayout::AddNewL (*this,iViewPortLayout);
       
   172     iLayout->SetFlags ( EAlfVisualFlagLayoutUpdateNotification); //to get screen change notification
       
   173 
       
   174     iViewPortLayout->SetClipping(ETrue); 
       
   175 
       
   176     // Set the attribute context
       
   177     iAttributeContext = CGlxDefaultAttributeContext::NewL ();
       
   178     iAttributeContext->AddAttributeL (KMPXMediaGeneralTitle);
       
   179     iAttributeContext->AddAttributeL (KMPXMediaGeneralCount);
       
   180     iAttributeContext->SetRangeOffsets( 0, KMaxTInt / 2 );
       
   181     iMediaList.AddContextL ( iAttributeContext, KGlxFetchContextPriorityCloudView ); //highest one to use 0 or 1
       
   182     iMediaList.AddMediaListObserverL ( this); //make this control as medialist observer
       
   183 
       
   184     TInt listCount = iMediaList.Count();
       
   185     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::ConstructL MedialistCount  %d ",
       
   186             listCount);
       
   187     
       
   188     //Display Empty Cloud View if no tags exists and if the navigation is backwards
       
   189     //Since in backward navigation the callback HandlePopulatedL() does not come
       
   190     if ( listCount ==0 && (iUiUtility->ViewNavigationDirection ()== EGlxNavigationBackwards) ) 
       
   191         {
       
   192         DisplayEmptyCloudViewL();
       
   193         }
       
   194     else	//Setting focus on the 1 st Media List item
       
   195         {
       
   196         //get the attributes from Cache
       
   197         FetchAttributeFromCacheL();
       
   198 
       
   199         if ( iLabels.Count ()==listCount && iAttributeContext->RequestCountL (&iMediaList)==0)
       
   200             {
       
   201             //if we navigate in forward direction, first item should be highlighted.if we are navigating in
       
   202             // backwards direction, index is not necessarily zero, it will be restored.
       
   203             if ( iUiUtility->ViewNavigationDirection ()== EGlxNavigationForwards && iMediaList.Count ())
       
   204                 {
       
   205                 iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
       
   206                 }
       
   207             UpdateRowDataL ();
       
   208             }
       
   209         }
       
   210     //get touch feedback instance
       
   211     iTouchFeedback = MTouchFeedback::Instance(); 
       
   212     iPhysics = CAknPhysics::NewL(*this, NULL);
       
   213     InitPhysicsL();
       
   214     }
       
   215 
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 //VisualLayoutUpdated()
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 void CGlxCloudViewControl::VisualLayoutUpdated(CAlfVisual &/* aVisual*/)
       
   222     {
       
   223     TRACER("GLX_CLOUD::CGlxCloudViewControl::VisualLayoutUpdated");
       
   224 	
       
   225 	//If the grid is already shown , disable it
       
   226     if(iTagsContextMenuControl->ItemMenuVisibility())
       
   227        {
       
   228        iTagsContextMenuControl->ShowItemMenuL(EFalse);
       
   229        }
       
   230     TRect rect;
       
   231     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
       
   232     if ((rect.Width() != (iTagScreenWidth + KRightmargin)) || (rect.Height() != iScreenHeight))
       
   233         {
       
   234         //set the new screen dimensions
       
   235         TRAP_IGNORE(UpdateLayoutL());
       
   236         }
       
   237     }
       
   238 
       
   239 // --------------------------------------------------------------------------- 
       
   240 // Destructor
       
   241 // --------------------------------------------------------------------------- 
       
   242 //
       
   243 CGlxCloudViewControl::~CGlxCloudViewControl()
       
   244 
       
   245     {
       
   246     TRACER("GLX_CLOUD::CGlxCloudViewControl::~CGlxCloudViewControl");
       
   247     iCloudInfo.Close ();
       
   248     iLabels.Close();
       
   249     iMediaList.RemoveContext (iAttributeContext);
       
   250     iMediaList.RemoveMediaListObserver (this);
       
   251     delete iAttributeContext;
       
   252 
       
   253     if ( iUiUtility )
       
   254         {
       
   255         iUiUtility->Close ();
       
   256         }	
       
   257     delete iEmptyText;
       
   258 
       
   259     if ( iTimer)
       
   260         {
       
   261         iTimer->Cancel ();//cancels any outstanding requests
       
   262         delete iTimer;
       
   263         }
       
   264     delete iPhysics;
       
   265     }
       
   266 
       
   267 // --------------------------------------------------------------------------- 
       
   268 // LayoutVisibleRows()
       
   269 // --------------------------------------------------------------------------- 
       
   270 //
       
   271 TInt CGlxCloudViewControl::LayoutVisibleRows(TPoint aStartPoint,TInt aRowStartIndex
       
   272         , TInt aRowEndIndex)
       
   273     {
       
   274     TRACER("CGlxCloudViewControl::LayoutVisibleRows");
       
   275     TSize vsize;
       
   276     TPoint tl, br;
       
   277     tl = aStartPoint;
       
   278     br.iX = 0;
       
   279     br.iY = tl.iY + KRowHeight;
       
   280     const TInt KMaxScreenWidth = iTagScreenWidth - iScrollPaneHandle.iW;
       
   281     //drawing in reverse for arabic hebrew support
       
   282     if ( GlxGeneralUiUtilities::LayoutIsMirrored ())
       
   283         {
       
   284 		GLX_LOG_INFO("Mirrorred Layout");
       
   285 		//In Mirrored layout, 'BottomRight' considers scrollpane width for each row
       
   286         br.iX =  aStartPoint.iX  - iScrollPaneHandle.iW;
       
   287         //Set the positions of tags in a row.
       
   288         for (TInt j = aRowStartIndex; j <= aRowEndIndex; j++)
       
   289             {
       
   290             vsize = iLabels[j]->TextExtents();
       
   291             if ( vsize.iWidth < KMinTagSize )
       
   292                 {
       
   293                 vsize.iWidth = KMinTagSize;
       
   294                 }
       
   295             //If the size of the tag is more than the screen size then wrap it
       
   296             if (vsize.iWidth > KMaxScreenWidth)
       
   297                 {
       
   298                 TAlfRealSize tagSize( KMaxScreenWidth, br.iY );
       
   299                 iLabels[j]->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
       
   300                 tl.iX -= aStartPoint.iX;
       
   301                 tl.iY = aStartPoint.iY;
       
   302                 br.iX = tagSize.iWidth;              
       
   303                 }
       
   304             else
       
   305                 {
       
   306 				tl.iX = br.iX - vsize.iWidth;
       
   307                 }
       
   308             
       
   309             //Set the anchor points for the tags 	            	        
       
   310             iLayout->SetAnchor (EAlfAnchorTopLeft, iLayoutIndex,
       
   311                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   312                     EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
   313                     TAlfTimedPoint (tl.iX, tl.iY));
       
   314             iLayout->SetAnchor (EAlfAnchorBottomRight, iLayoutIndex,
       
   315                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   316                     EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
   317                     TAlfTimedPoint (br.iX, br.iY));
       
   318             //Bottom-Right corner for next tag in same row
       
   319             br.iX -= (vsize.iWidth + KColSpace); 
       
   320             iLayoutIndex += 1;
       
   321             }
       
   322         }
       
   323     else
       
   324         {
       
   325 		GLX_LOG_INFO("NOT Mirrorred Layout");
       
   326         for (TInt j = aRowStartIndex; j <= aRowEndIndex; j++)
       
   327             {
       
   328             vsize = iLabels[j]->TextExtents();
       
   329             if( vsize.iWidth < KMinTagSize )
       
   330                 {
       
   331                 vsize.iWidth = KMinTagSize;
       
   332                 }
       
   333             if (vsize.iWidth > KMaxScreenWidth)
       
   334                 {
       
   335                 TAlfRealSize tagSize( KMaxScreenWidth, br.iY );
       
   336                 iLabels[j]->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
       
   337                 tl.iX = aStartPoint.iX;
       
   338                 tl.iY = aStartPoint.iY;
       
   339                 br.iX = tagSize.iWidth;
       
   340                 }
       
   341             else
       
   342                 {
       
   343                 br.iX = tl.iX + vsize.iWidth;
       
   344                 }
       
   345             
       
   346             iLayout->SetAnchor (EAlfAnchorTopLeft, iLayoutIndex,
       
   347                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   348                     EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
   349                     TAlfTimedPoint (tl.iX, tl.iY));
       
   350             iLayout->SetAnchor (EAlfAnchorBottomRight, iLayoutIndex,
       
   351                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   352                     EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
   353                     TAlfTimedPoint (br.iX, br.iY));
       
   354             //Top-Left Corner for next tag in same row
       
   355             tl.iX += (vsize.iWidth + KColSpace);
       
   356             iLayoutIndex += 1;
       
   357             }
       
   358         }
       
   359     return 0;
       
   360     }
       
   361 
       
   362 // --------------------------------------------------------------------------- 
       
   363 // LayoutVisibleArea()
       
   364 // 
       
   365 // ---------------------------------------------------------------------------
       
   366 void CGlxCloudViewControl::LayoutVisibleArea()
       
   367     {
       
   368 	TRACER("CGlxCloudViewControl::LayoutVisibleArea");
       
   369     //screen height for boundary check:how many rows fit in.
       
   370     //find out how many rows can fit in.
       
   371     //add upper and lower margin spacing 5 pixels
       
   372 
       
   373     //draw the row on screens
       
   374     TPoint startpoint;
       
   375     // arabic hebrew change
       
   376     //If the layout is arabic hebrew then start positioning of tags from end
       
   377     if ( GlxGeneralUiUtilities::LayoutIsMirrored ())
       
   378         {
       
   379         startpoint.iX = iTagScreenWidth - KRightmargin;        
       
   380         }
       
   381     //else start from beginning
       
   382     else
       
   383         {
       
   384         startpoint.iX = KLeftMargin;
       
   385         }
       
   386         startpoint.iY = KNumMinRowSpace;
       
   387     
       
   388     //associate the active visuals with anchor layout
       
   389     GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Layout reset");
       
   390     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea layout Count after reset  %d ", iLayout->Count ());
       
   391     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea iCloudInfo[0].iStartIndex  %d ", iCloudInfo[0].iStartIndex);
       
   392     TInt endindex = iCloudInfo.Count()-1;
       
   393 
       
   394     for (TInt j = iCloudInfo[0].iStartIndex; j <=iCloudInfo[endindex].iEndIndex; j++)
       
   395         {
       
   396         GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::::FindEndRowIndex Entering layout append");
       
   397 
       
   398         TAlfTimedValue opacity;
       
   399         opacity.SetValueNow(1.0); // immediate change
       
   400         iLabels[j]->SetOpacity(opacity);
       
   401         }
       
   402 
       
   403     GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Exiting layout append");
       
   404     iLayoutIndex = 0;
       
   405     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea layout Count realloc  %d ", iLayout->Count ());
       
   406     for (TInt j = 0; j <= iEndRowIndex; j++)
       
   407         {
       
   408         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Drawing row started  %d ", j);
       
   409         LayoutVisibleRows (startpoint,iCloudInfo[j].iStartIndex, 
       
   410                 iCloudInfo[j].iEndIndex);
       
   411         startpoint.iY += KRowHeight + KNumMinRowSpace;		
       
   412         }
       
   413     TInt totalHeight = 0;
       
   414     for (TInt j = 0; j <= iCloudInfo.Count()-1; j++)
       
   415         {
       
   416         totalHeight+=KRowHeight;
       
   417         totalHeight+=KNumMinRowSpace;
       
   418         }
       
   419 
       
   420     //Set the virtual size of viewport to the total size of anchor.	
       
   421     if( totalHeight > iTagScreenHeight )
       
   422         {
       
   423         iViewPortLayout->SetVirtualSize(TAlfRealSize(iTagScreenWidth,totalHeight ),0); 
       
   424         iViewPortVirtualSize.iHeight = totalHeight;
       
   425         }
       
   426     else
       
   427         {
       
   428         iViewPortLayout->SetVirtualSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight ),0);
       
   429         iViewPortVirtualSize.iHeight = iTagScreenHeight;
       
   430         }    
       
   431     iViewPortVirtualSize.iWidth = iTagScreenWidth;
       
   432 
       
   433     iViewPortLayout->SetViewportSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
       
   434     iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
       
   435     iViewPortSize.iWidth = iTagScreenWidth;
       
   436     iViewPortSize.iHeight = iTagScreenHeight;	
       
   437     iViewPortLayout->SetViewportPos(TAlfRealPoint(0, 0), KSlowCloudMovement);
       
   438 
       
   439     iViewPortPosition.iX =0;
       
   440     iViewPortPosition.iY =0;
       
   441 
       
   442     iScrollEventData.mSpan = iViewPortVirtualSize.iHeight ;
       
   443     iScrollEventData.mViewLength = iViewPortSize.iHeight;
       
   444     if(iScrollBarWidget)
       
   445         {
       
   446         ((IAlfScrollBarModel *)(iScrollBarWidget->model()))->changeData(iScrollEventData.mSpan,
       
   447                 iScrollEventData.mViewLength,
       
   448                 0);
       
   449         DisplayScrollBar();
       
   450         }   	
       
   451 
       
   452     iLayout->UpdateChildrenLayout (); //update layout
       
   453 
       
   454     HandleLayoutFocusChange ();
       
   455     
       
   456     MoveDownIfRequired();
       
   457     }
       
   458 
       
   459 // --------------------------------------------------------------------------- 
       
   460 // OfferEventL()
       
   461 // --------------------------------------------------------------------------- 
       
   462 //
       
   463 TBool CGlxCloudViewControl::OfferEventL(const TAlfEvent &aEvent)
       
   464     {   TRACER("GLX_CLOUD:: CGlxCloudViewControl::OfferEventL");
       
   465 
       
   466     //check if key inputs needs handling
       
   467     TBool consumed = EFalse;
       
   468     if ( ( iLabels.Count () == 0 ) ) 
       
   469         {
       
   470         GLX_LOG_INFO( "GLX_CLOUD ::CGlxCloudViewControl::offerkeyeventL no key press returning  ");
       
   471         return EFalse; //return as no futher processing is required
       
   472         }
       
   473 
       
   474     if ( aEvent.IsKeyEvent ()&& aEvent.Code() == EEventKey )
       
   475         {
       
   476         switch (aEvent.KeyEvent().iCode)            
       
   477             {	
       
   478             //@ EABI-7R7FRU Fute failure: Tag views enter key has no functionality.
       
   479             case EKeyEnter :
       
   480             case EKeyDevice3:
       
   481                 {
       
   482                 iObserverEnterKeyEvent.HandleEnterKeyEventL( (TInt)EAknCmdOpen );
       
   483                 consumed= ETrue;
       
   484                 }
       
   485                 break;
       
   486             case EKeyUpArrow:
       
   487                 {             
       
   488                 if(iCloudInfo.Count() >1 )
       
   489                     {
       
   490                     HandleKeyUpL ();
       
   491                     consumed = ETrue;
       
   492                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); 
       
   493 
       
   494                     MoveUpIfRequired();                   
       
   495                     }
       
   496                 }
       
   497                 break;
       
   498 
       
   499             case EKeyDownArrow:
       
   500                 {              
       
   501                 if (iCloudInfo.Count() > 1)
       
   502                     {
       
   503                     HandleKeyDownL ();
       
   504                     consumed = ETrue;
       
   505                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
   506 
       
   507                     MoveDownIfRequired();                                 
       
   508                     }                  
       
   509                 }
       
   510                 break;
       
   511 
       
   512             case EKeyLeftArrow:
       
   513             case EKeyPrevious:
       
   514                 {
       
   515                 // arabic hebrew change
       
   516                 if ( GlxGeneralUiUtilities::LayoutIsMirrored () )
       
   517                     {
       
   518                     if ( iMediaList.FocusIndex() == iMediaList.Count() - 1 )
       
   519                         {
       
   520                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
       
   521                         }
       
   522                     else
       
   523                         {
       
   524                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   525                                 iMediaList.FocusIndex ()+ 1);
       
   526                         }
       
   527                     iScrollDirection = 0;
       
   528                     }
       
   529                 else
       
   530                     {
       
   531                     if ( iMediaList.FocusIndex ()== 0 )
       
   532                         {
       
   533                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   534                                 iMediaList.Count() - 1 );
       
   535                         }
       
   536                     else
       
   537                         {
       
   538                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   539                                 iMediaList.FocusIndex ()- 1);
       
   540                         }
       
   541                     iScrollDirection = 1;
       
   542                     }
       
   543                 consumed = ETrue;
       
   544                 TInt focusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
   545                 if(iFocusRowIndex != focusRowIndex)
       
   546                     {
       
   547                     iFocusRowIndex = focusRowIndex; 
       
   548                     if( iScrollDirection == 0 )
       
   549                         {                      
       
   550                         MoveDownIfRequired();
       
   551                         }
       
   552                     else
       
   553                         {
       
   554                         MoveUpIfRequired();
       
   555                         }
       
   556                     }                
       
   557                 }
       
   558 
       
   559                 break;
       
   560 
       
   561             case EKeyRightArrow:
       
   562             case EKeyNext:
       
   563                 {               
       
   564                 // arabic hebrew change
       
   565                 if ( GlxGeneralUiUtilities::LayoutIsMirrored () )
       
   566                     {
       
   567                     if ( iMediaList.FocusIndex ()== 0 )
       
   568                         {
       
   569                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   570                                 iMediaList.Count() - 1 );
       
   571                         }
       
   572                     else
       
   573                         {
       
   574                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   575                                 iMediaList.FocusIndex ()- 1);
       
   576                         }
       
   577                     iScrollDirection = 1;
       
   578                     }
       
   579                 else
       
   580                     {
       
   581                     if ( iMediaList.FocusIndex ()== iMediaList.Count() - 1 )
       
   582                         {
       
   583                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
       
   584                         }
       
   585                     else
       
   586                         {
       
   587                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   588                                 iMediaList.FocusIndex ()+ 1);
       
   589                         }
       
   590                     iScrollDirection = 0;
       
   591                     }
       
   592                 TInt focusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
   593 
       
   594                 if( iFocusRowIndex != focusRowIndex )
       
   595                     {
       
   596                     iFocusRowIndex = focusRowIndex;  
       
   597                     if( iScrollDirection == 1 )
       
   598                         {                           
       
   599                         MoveUpIfRequired();                               
       
   600                         }
       
   601                     else
       
   602                         {                           
       
   603                         MoveDownIfRequired();                               
       
   604                         }
       
   605                     }
       
   606                 }
       
   607                 consumed = ETrue;
       
   608                 break;
       
   609 
       
   610             default:
       
   611                 break;
       
   612             }
       
   613         }
       
   614 
       
   615     if(aEvent.IsPointerEvent() )
       
   616         {
       
   617         //if its a pointer event
       
   618         consumed = HandlePointerEventL(aEvent);
       
   619         }
       
   620     return consumed;
       
   621     }
       
   622 
       
   623 // --------------------------------------------------------------------------- 
       
   624 // HandleKeyUp()
       
   625 // --------------------------------------------------------------------------- 
       
   626 //
       
   627 void CGlxCloudViewControl::HandleKeyUpL()
       
   628     {
       
   629     TRACER("GLX_CLOUD:: CGlxCloudViewControl::HandleKeyUpL");
       
   630 
       
   631     //If the first item is focused and if we are navigating upwards,then set the focus to last element.
       
   632     if( iFocusRowIndex ==  0 )
       
   633         {               
       
   634         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   635                 iMediaList.Count() - 1);
       
   636         }
       
   637 
       
   638     //else set the focus to the item which is in the previous row,that overlaps with midpoint of the 
       
   639     //focused item.
       
   640     else
       
   641         { 
       
   642         TInt prevrownum = iFocusRowIndex - 1;
       
   643         SetRelativeFocusL(prevrownum);		
       
   644         }
       
   645 
       
   646     iScrollDirection = 1;
       
   647     }
       
   648 
       
   649 // --------------------------------------------------------------------------- 
       
   650 // HandleKeyDown()
       
   651 // --------------------------------------------------------------------------- 
       
   652 //
       
   653 void CGlxCloudViewControl::HandleKeyDownL()
       
   654     {
       
   655     TRACER("GLX_CLOUD:: CGlxCloudViewControl::HandleKeyDownL");
       
   656 
       
   657     // If the last item is focused and if we are navigating downwards,then set the
       
   658     // focus to first element.
       
   659     if (iFocusRowIndex == iCloudInfo.Count() - 1)
       
   660         {
       
   661         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, 0);
       
   662         }
       
   663 
       
   664     //else set the focus to the item which is in the next row,that overlaps with midpoint of the 
       
   665     //focused item.     
       
   666     else
       
   667         { 
       
   668         TInt nextrownum = iFocusRowIndex + 1;            
       
   669         SetRelativeFocusL(nextrownum);	       
       
   670         }
       
   671 
       
   672     iScrollDirection = 0;
       
   673     }
       
   674 
       
   675 // --------------------------------------------------------------------------- 
       
   676 // HandleLayoutFocusChange()
       
   677 // --------------------------------------------------------------------------- 
       
   678 //
       
   679 void CGlxCloudViewControl::HandleLayoutFocusChange()
       
   680     {
       
   681     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleLayoutFocusChange");
       
   682 
       
   683     if ( iLabels.Count()-1 >= iMediaList.FocusIndex())
       
   684         {
       
   685         //to highlight focused element 
       
   686         SetFocusColor(); 
       
   687         }
       
   688     }
       
   689 
       
   690 // --------------------------------------------------------------------------- 
       
   691 // FocusUpdate()
       
   692 // --------------------------------------------------------------------------- 
       
   693 //
       
   694 void CGlxCloudViewControl::FocusUpdate()
       
   695     {
       
   696     TRACER("GLX_CLOUD::CGlxCloudViewControl::FocusUpdate");
       
   697     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::FocusUpdate HighLighted RowNum  %d ",iFocusRowIndex);
       
   698     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::FocusUpdate End RowNumn %d ",iCloudInfo.Count()-1);
       
   699     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
   700     iEndRowIndex = iCloudInfo.Count()-1;
       
   701     LayoutVisibleArea();
       
   702     }
       
   703 
       
   704 // --------------------------------------------------------------------------- 
       
   705 // ResetLayout()
       
   706 // --------------------------------------------------------------------------- 
       
   707 //
       
   708 void CGlxCloudViewControl::UpdateLayout()
       
   709     {
       
   710     TRACER("GLX_CLOUD::CGlxCloudViewControl::UpdateLayout()");
       
   711     iCloudInfo.Close (); //row information is reset
       
   712     for(TInt i = 0;i<iLabels.Count();i++)
       
   713         {
       
   714         iLabels[i]->RemoveAndDestroyAllD(); // removes from control
       
   715         iLabels[i] = NULL;
       
   716         }        
       
   717     iLabels.Reset();
       
   718     }
       
   719 
       
   720 // --------------------------------------------------------------------------- 
       
   721 // GetRownum()
       
   722 // --------------------------------------------------------------------------- 
       
   723 //
       
   724 TInt CGlxCloudViewControl::RowNumber(TInt aItemIndex) const
       
   725 	{
       
   726 	TRACER("GLX_CLOUD::CGlxCloudViewControl::GetRownum");
       
   727 	//Get the rownumber of the given item index.
       
   728 	TInt i;
       
   729 	for (i = 0; i < iCloudInfo.Count(); i++)
       
   730 		{
       
   731 		if ((aItemIndex >= iCloudInfo[i].iStartIndex) && (aItemIndex
       
   732 				<= iCloudInfo[i].iEndIndex))
       
   733 			break;
       
   734 		}
       
   735 	return i;
       
   736 	}
       
   737 
       
   738 // --------------------------------------------------------------------------- 
       
   739 // FetchAttributeFromCacheL()
       
   740 // --------------------------------------------------------------------------- 
       
   741 //
       
   742 void CGlxCloudViewControl::FetchAttributeFromCacheL()
       
   743     {
       
   744     TRACER("GLX_CLOUD::CGlxCloudViewControl::FetchAttributeFromCacheL");
       
   745     GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::FetchAttributeFromCache MediaList already filled" );
       
   746     iLayoutObserver.HandleLayoutChanged();
       
   747     if ( iLabels.Count ()==0)
       
   748         {
       
   749         for (TInt i=0; i<iMediaList.Count();i++)
       
   750             {
       
   751             CAlfTextVisual *tempVisual= NULL;
       
   752             tempVisual = CAlfTextVisual::AddNewL (*this,iLayout);
       
   753             iLabels.InsertL (tempVisual, i); //appending the visual text   /
       
   754             TAlfTimedValue opacity;
       
   755             opacity.SetValueNow(0.0);
       
   756             iLabels[i]->SetOpacity(opacity);
       
   757             }
       
   758         }
       
   759 
       
   760     for (TInt i=0; i<iMediaList.Count(); i++)
       
   761         {
       
   762         GLX_LOG_INFO1("GLX_CLOUD::Fetching title for item %d", i );
       
   763         // get the media item
       
   764         TGlxMedia item = iMediaList.Item( i );
       
   765         // get the title and set it to the text visual
       
   766         iLabels[i]->SetTextL( item.Title() );
       
   767         }
       
   768     }
       
   769 
       
   770 //medialist Observers
       
   771 
       
   772 // ---------------------------------------------------------------------------
       
   773 // HandleItemAddedL().
       
   774 // ---------------------------------------------------------------------------
       
   775 //
       
   776 void CGlxCloudViewControl::HandleItemAddedL(TInt aStartIndex, TInt aEndIndex,
       
   777         MGlxMediaList* aList)
       
   778     {
       
   779     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL");
       
   780     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL start index  %d ", aStartIndex);
       
   781     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL end index  %d ", aEndIndex);
       
   782     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL  media list count  %d ", aList->Count());
       
   783     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL  attribute request count %d ", iAttributeContext->RequestCountL(aList));
       
   784 
       
   785     if ( iEmptyString )
       
   786         {
       
   787         // remove the empty string so it does not fool around in animations
       
   788         iEmptyString->RemoveAndDestroyAllD(); // removes from control
       
   789         iEmptyString = NULL;
       
   790         }
       
   791     //The new item has been added and it is required to cleanup the visuals and info bubble
       
   792     //for the existing tags(if any).	
       
   793     //when a filter is applied attribute request count is zero but medialist count in non zero
       
   794     if (iAttributeContext->RequestCountL(aList) == 0 )
       
   795         {
       
   796         //reset the layout and get the items from cache
       
   797         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.
       
   798         iCloudInfo.Close (); //row information is reset
       
   799         //get the new array contents from cache.no need to reset the array as the number
       
   800         //of items in array will remain same.
       
   801         FetchAttributeFromCacheL();
       
   802         UpdateRowDataL (); //updates the row data and reassigns font sizes and draw the layout on screen.
       
   803         }
       
   804 
       
   805     InitPhysicsL();
       
   806     }
       
   807 
       
   808 // ---------------------------------------------------------------------------
       
   809 // HandleMediaL().
       
   810 // ---------------------------------------------------------------------------
       
   811 //
       
   812 void CGlxCloudViewControl::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/)
       
   813     {
       
   814     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleMediaL");
       
   815     }
       
   816 
       
   817 // ---------------------------------------------------------------------------
       
   818 // HandleItemRemovedL().
       
   819 // ---------------------------------------------------------------------------
       
   820 //
       
   821 void CGlxCloudViewControl::HandleItemRemovedL(TInt aStartIndex, TInt aEndIndex,
       
   822         MGlxMediaList* aList)
       
   823     {
       
   824     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleItemRemovedL");
       
   825     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemRemovedL Start RowNum  %d ", aStartIndex);
       
   826     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemRemovedL iCloudCount  %d ", aEndIndex);
       
   827     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemRemovedL  media list count  %d ", aList->Count());
       
   828 
       
   829     //when a filter is applied attribute request count is zero but medialist count in non zero
       
   830     if (iAttributeContext->RequestCountL(aList) == 0 )
       
   831         {
       
   832         //reset the layout and get the items from cache
       
   833         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.       
       
   834         if( aList->Count() > 0 )
       
   835             {
       
   836             //get the new array contents from cache.no need to reset the array as the number
       
   837             //of items in array will remain same.
       
   838             FetchAttributeFromCacheL();
       
   839             UpdateRowDataL (); //updates the row data and reassigns font sizes and draw the layout on screen.
       
   840             }
       
   841         else
       
   842             {
       
   843             DisplayEmptyCloudViewL();
       
   844             }
       
   845         }
       
   846     InitPhysicsL();
       
   847     }
       
   848 
       
   849 // ---------------------------------------------------------------------------
       
   850 // HandleItemModifiedL().
       
   851 // ---------------------------------------------------------------------------
       
   852 //
       
   853 void CGlxCloudViewControl::HandleItemModifiedL(
       
   854         const RArray<TInt>& /*aItemIndexes*/, MGlxMediaList* /*aList*/)
       
   855     {
       
   856     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleItemModifiedL");
       
   857     }
       
   858 
       
   859 // ---------------------------------------------------------------------------
       
   860 // HandleAttributesAvailableL().
       
   861 // ---------------------------------------------------------------------------
       
   862 //
       
   863 void CGlxCloudViewControl::HandleAttributesAvailableL(TInt aItemIndex,
       
   864         const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList)
       
   865     {
       
   866     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleAttributesAvailableL");
       
   867     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleAttributesAvailableL  iLabels.Count()  %d ",iLabels.Count());
       
   868     TInt attCount = aAttributes.Count ();
       
   869     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleAttributesAvailableL  count: %d ",attCount);
       
   870     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleAttributesAvailableL  Item Index: %d ", aItemIndex);
       
   871 
       
   872     TBool relevantAttribute = EFalse;
       
   873     for ( TInt i = 0 ; i < attCount ; i++ )
       
   874         {
       
   875         if ( ( aAttributes[i] == KMPXMediaGeneralTitle ) 
       
   876                 || ( aAttributes[i] == KMPXMediaGeneralCount ) )
       
   877             {
       
   878             relevantAttribute = ETrue;
       
   879             }
       
   880         }
       
   881     //if the title array has been loaded completely and request count for attribute context becomes 
       
   882     //zero update the row data and arrange layout
       
   883     if ( ( iAttributeContext->RequestCountL(aList) ==0 ) 
       
   884             && ( aList->Count() != 0) && relevantAttribute )
       
   885         {
       
   886         //get the new array contents from cache.no need to reset the array as the number
       
   887         //of items in array will remain same.
       
   888         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.        
       
   889         FetchAttributeFromCacheL();
       
   890         //if we navigate in forward direction, first item should be highlighted.if we are navigating in
       
   891         // backwards direction, index is not necessarily zero, it will be restored.
       
   892         if ( iUiUtility->ViewNavigationDirection ()== EGlxNavigationForwards && iMediaList.Count ())
       
   893             {
       
   894             iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
       
   895             }
       
   896         //generate row structures and draw rows on screen
       
   897         UpdateRowDataL ();
       
   898 
       
   899         InitPhysicsL();
       
   900         }
       
   901     }
       
   902 
       
   903 // ---------------------------------------------------------------------------
       
   904 // HandleFocusChangedL().
       
   905 // ---------------------------------------------------------------------------
       
   906 //
       
   907 void CGlxCloudViewControl::HandleFocusChangedL(
       
   908         NGlxListDefs::TFocusChangeType /*aType*/, TInt aNewIndex,
       
   909         TInt aOldIndex, MGlxMediaList* /*aList*/)
       
   910     {
       
   911     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleFocusChangedL");
       
   912     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleFocusChangedL aNewIndex %d ", aNewIndex);
       
   913     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleFocusChangedL aOldIndex %d ",aOldIndex);
       
   914     if ( (aOldIndex >= 0) && (iLabels.Count()-1 >= aOldIndex) )
       
   915         {      		  
       
   916         //Reset the focused color
       
   917         iLabels[aOldIndex]->SetColor (KAknsIIDQsnTextColors,
       
   918                 EAknsCIQsnTextColorsCG6);
       
   919         HandleLayoutFocusChange ();
       
   920         }
       
   921     }
       
   922 
       
   923 // ---------------------------------------------------------------------------
       
   924 // HandleItemSelectedL().
       
   925 // ---------------------------------------------------------------------------
       
   926 //
       
   927 void CGlxCloudViewControl::HandleItemSelectedL(TInt /*aIndex*/,
       
   928         TBool /*aSelected*/, MGlxMediaList* /*aList*/)
       
   929     {
       
   930     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleItemSelectedL");
       
   931     }
       
   932 
       
   933 // ---------------------------------------------------------------------------
       
   934 // HandleMessageL().
       
   935 // ---------------------------------------------------------------------------
       
   936 //
       
   937 void CGlxCloudViewControl::HandleMessageL(const CMPXMessage& /*aMessage*/,
       
   938         MGlxMediaList* /*aList*/)
       
   939     {
       
   940     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleMessageL");
       
   941     }
       
   942 
       
   943 // ---------------------------------------------------------------------------
       
   944 // HandlePopulatedL().
       
   945 // ---------------------------------------------------------------------------
       
   946 //
       
   947 void CGlxCloudViewControl::HandlePopulatedL(MGlxMediaList* /*aList*/)
       
   948     {
       
   949     //Display the Empty clould view only when we get this call back.
       
   950     // At this stage the medialist will be populated.    
       
   951     if(iMediaList.Count()<=0)
       
   952         {
       
   953         DisplayEmptyCloudViewL();
       
   954         }
       
   955     }
       
   956 
       
   957 // ---------------------------------------------------------------------------
       
   958 //UpdateRowDataL()
       
   959 // ---------------------------------------------------------------------------
       
   960 //
       
   961 void CGlxCloudViewControl::UpdateRowDataL()
       
   962     {
       
   963     TRACER("GLX_CLOUD::CGlxCloudViewControl::UpdateRowData()");
       
   964 
       
   965     TInt rowStartingTagIndex = 0;
       
   966     TInt lastRowStartTagIndex = 0;
       
   967     TInt currentTagIndex = 0;
       
   968     TSize currentTagSize(0, 0);
       
   969     TGlxCloudInfo cloudInfo;
       
   970     TInt rowHeight = 0;
       
   971     TInt rowWidth = 0;
       
   972     TInt itemUsageCount = 0;
       
   973     const TInt KLabelsCount = iLabels.Count();
       
   974     iScrollPaneHandle = AknLayoutScalable_UiAccel::aa_scroll_pane(0).LayoutLine();
       
   975     const TInt KMaxScreenWidth = iTagScreenWidth - KRightmargin - iScrollPaneHandle.iW;
       
   976 
       
   977     iCloudInfo.Close (); //delete existing structures for orintation change
       
   978 
       
   979 
       
   980     //Setting the Font Styles based on association counts
       
   981     //Finding the maximum value of image association
       
   982     //Determining the Font(Style) for each visual
       
   983     TInt maxCount = MaxUsageCount (); //Maximum Association count 
       
   984     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  mediaCount %d ", maxCount);
       
   985     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iLabels.Count()  %d ",iLabels.Count());
       
   986     if ( 0 == maxCount )
       
   987         {
       
   988         return; //do not proceed if max count is zero
       
   989         }
       
   990 
       
   991     for (TInt i = 0; i < KLabelsCount; i++)
       
   992         {
       
   993         TInt percent( 0 );
       
   994         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  Item Counter value  %d ",i);
       
   995         itemUsageCount = UsageCount(i);
       
   996         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  Usage Count  %d ", itemUsageCount);
       
   997         percent = ((itemUsageCount * 99)/ maxCount);
       
   998         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iLabels.Count()  %d ",iLabels.Count());
       
   999 
       
  1000         // percent is between 0 and 99 so divide it by 20 to make it 0, 1, 2, 3 or 4
       
  1001         // as there is 5 different font sizes
       
  1002         SetPropertiesL( i, TInt( percent / 20 ) );
       
  1003         }
       
  1004 
       
  1005     while ( currentTagIndex < KLabelsCount )
       
  1006         {
       
  1007         //Determining text size of visual.
       
  1008         currentTagSize = iLabels[currentTagIndex]->TextExtents();
       
  1009         if( currentTagSize .iWidth < KMinTagSize )
       
  1010             {
       
  1011             currentTagSize.iWidth = KMinTagSize;
       
  1012             }
       
  1013         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  currentTagSize.iHeight %d ", currentTagSize.iHeight);
       
  1014 
       
  1015         // The current row's height will always be the largest height of all the tags in that row
       
  1016         if ( currentTagSize.iHeight > rowHeight )
       
  1017             {
       
  1018             rowHeight = currentTagSize.iHeight;
       
  1019             }
       
  1020 
       
  1021         // Current row width will be progressively incremented to fit as many tags as possible
       
  1022         rowWidth += currentTagSize.iWidth + KColSpace;
       
  1023         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData   currentTagSize.iWidth %d ", currentTagSize.iWidth);
       
  1024         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  rowWidth %d ", rowWidth);
       
  1025 
       
  1026         // If the tag size crosses the Screen Size, Then wrap it.
       
  1027         if ( currentTagSize.iWidth > KMaxScreenWidth )
       
  1028             {
       
  1029             lastRowStartTagIndex = ((rowStartingTagIndex == currentTagIndex)?rowStartingTagIndex : currentTagIndex-1);
       
  1030             AppendToCloudArrayL( cloudInfo,/* rowHeight,*/  rowStartingTagIndex, lastRowStartTagIndex );
       
  1031             // Reset row height and row width for the next line
       
  1032             rowHeight = 0;
       
  1033             rowWidth = 0;
       
  1034             if (lastRowStartTagIndex != currentTagIndex-1 )
       
  1035                 {
       
  1036                 currentTagIndex++; 
       
  1037                 }
       
  1038             rowStartingTagIndex = currentTagIndex;
       
  1039             lastRowStartTagIndex++;
       
  1040             }
       
  1041 
       
  1042         // If the current row's width is overflowing the screen width
       
  1043         // then we must fit the current visual into the next row.
       
  1044         // Do that check now and adjust accordingly.
       
  1045         // Fix for EAHN-7BZD78 is to exclude the gap value between the row's tags from the logic
       
  1046         else if ( rowWidth - KColSpace > KMaxScreenWidth )
       
  1047             {
       
  1048             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::UpdateRowData Row added");
       
  1049             lastRowStartTagIndex = currentTagIndex - 1;
       
  1050             AppendToCloudArrayL( cloudInfo,rowStartingTagIndex, lastRowStartTagIndex );
       
  1051             lastRowStartTagIndex++;
       
  1052             // Reset row height and row width for the next line
       
  1053             rowHeight = 0;
       
  1054             rowWidth = 0;
       
  1055             rowStartingTagIndex = currentTagIndex;
       
  1056             GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iCloudInfo.count  %d ", iCloudInfo.Count());
       
  1057             } 
       
  1058 
       
  1059         // need to work with next tag only if current tag has been taken care of
       
  1060         if ( rowWidth )
       
  1061             {
       
  1062             currentTagIndex++; 
       
  1063             }
       
  1064 
       
  1065         } // while ( currentTagIndex < KLabelsCount )
       
  1066 
       
  1067     if( lastRowStartTagIndex < KLabelsCount)
       
  1068         {
       
  1069         AppendToCloudArrayL( cloudInfo,lastRowStartTagIndex, KLabelsCount - 1 );
       
  1070         }
       
  1071 
       
  1072     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iCloudInfo.count loop exit  %d ", iCloudInfo.Count());
       
  1073     FocusUpdate (); //Start screen drawing 
       
  1074 
       
  1075     iEndRowIndex = iCloudInfo.Count()-1;
       
  1076     }
       
  1077 
       
  1078 // ---------------------------------------------------------------------------
       
  1079 // SetProperties
       
  1080 // ---------------------------------------------------------------------------
       
  1081 //
       
  1082 void CGlxCloudViewControl::SetPropertiesL(TInt aIndex, TInt aScale)
       
  1083     {
       
  1084     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetProperties()");
       
  1085     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::SetProperties layout Count after reset  %d ", iLayout->Count());
       
  1086     //Retrieving theme color
       
  1087 
       
  1088     TAlfTimedValue scale(0);
       
  1089     TRAP_IGNORE(iLabels[aIndex]->EnableTransformationL());   
       
  1090     TAlfTimedValue opacity;
       
  1091     opacity.SetStyle (EAlfTimedValueStyleLinear);
       
  1092     opacity.SetValueNow(0.0);
       
  1093     iLabels[aIndex]->SetOpacity(opacity);
       
  1094     iLabels[aIndex]->SetAlign (EAlfAlignHLocale, EAlfAlignVBottom); //setting allignment
       
  1095     iLabels[aIndex]->SetColor (KAknsIIDQsnTextColors,EAknsCIQsnTextColorsCG6);
       
  1096     //custom style cod
       
  1097     TInt typefaceSecondaryStyleId = CGlxCloudViewControl::Env().TextStyleManager().CreatePlatformTextStyleL(
       
  1098             EAknLogicalFontSecondaryFont,EAlfTextStyleNormal);
       
  1099     TInt typefacePrimaryStyleId = CGlxCloudViewControl::Env().TextStyleManager().CreatePlatformTextStyleL(
       
  1100             EAknLogicalFontPrimaryFont,EAlfTextStyleNormal);
       
  1101     CAlfTextStyle* stylePrimary = CGlxCloudViewControl::Env().TextStyleManager().TextStyle(
       
  1102             typefacePrimaryStyleId);
       
  1103     CAlfTextStyle* styleSecondary = CGlxCloudViewControl::Env().TextStyleManager().TextStyle(
       
  1104             typefaceSecondaryStyleId);
       
  1105     switch (aScale)
       
  1106         {
       
  1107         case 0:
       
  1108             {
       
  1109             styleSecondary->SetTextSizeInPixels (KFontSmallest, 0);
       
  1110             iLabels[aIndex]->SetTextStyle (typefaceSecondaryStyleId);
       
  1111             TAlfTimedValue opacity;
       
  1112             opacity.SetValueNow(0.0);
       
  1113             iLabels[aIndex]->SetOpacity(opacity);
       
  1114             scale.SetTarget(1, 1000);
       
  1115             break;
       
  1116             }
       
  1117         case 1:
       
  1118             {
       
  1119             styleSecondary->SetTextSizeInPixels (KFontSmaller, 0);
       
  1120             iLabels[aIndex]->SetTextStyle (typefaceSecondaryStyleId);
       
  1121             scale.SetTarget(1, 1200);
       
  1122             TAlfTimedValue opacity;
       
  1123             opacity.SetValueNow(0.0);
       
  1124             iLabels[aIndex]->SetOpacity(opacity);
       
  1125             break;
       
  1126             }
       
  1127         case 2:
       
  1128             {
       
  1129             stylePrimary->SetTextSizeInPixels (KFontMedium, 0);
       
  1130             iLabels[aIndex]->SetTextStyle (typefacePrimaryStyleId);
       
  1131             scale.SetTarget(1, 1500);
       
  1132             TAlfTimedValue opacity;
       
  1133             opacity.SetValueNow(0.0);
       
  1134             iLabels[aIndex]->SetOpacity(opacity);
       
  1135             break;
       
  1136             }
       
  1137         case 3:
       
  1138             {
       
  1139             stylePrimary->SetTextSizeInPixels (KFontLarger, 0);
       
  1140             iLabels[aIndex]->SetTextStyle (typefacePrimaryStyleId);
       
  1141             scale.SetTarget(1, 1800);
       
  1142             TAlfTimedValue opacity;
       
  1143             opacity.SetValueNow(0.0);
       
  1144             iLabels[aIndex]->SetOpacity(opacity);
       
  1145             break;
       
  1146             }
       
  1147         case 4:
       
  1148             {
       
  1149             stylePrimary->SetTextSizeInPixels (KFontLargest, 0);
       
  1150             iLabels[aIndex]->SetTextStyle (typefacePrimaryStyleId);
       
  1151             scale.SetTarget(1, 2200);
       
  1152             TAlfTimedValue opacity;
       
  1153             opacity.SetValueNow(0.0);
       
  1154             iLabels[aIndex]->SetOpacity(opacity);
       
  1155             break;
       
  1156             }
       
  1157         }
       
  1158 
       
  1159     iLabels[aIndex]->Transformation().Scale (scale, scale);
       
  1160     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::SetProperties layout Count after reset  %d ", iLayout->Count());
       
  1161     }
       
  1162 
       
  1163 // ---------------------------------------------------------------------------
       
  1164 // DisplayEmptyCloudView
       
  1165 // ---------------------------------------------------------------------------
       
  1166 // 
       
  1167 void CGlxCloudViewControl::DisplayEmptyCloudViewL()
       
  1168     {
       
  1169     TRACER("GLX_CLOUD::CGlxCloudViewControl::DisplayEmptyCloudView");
       
  1170     if( !iEmptyString )
       
  1171         {
       
  1172         iEmptyString = CAlfTextVisual::AddNewL ( *this, iViewPortLayout );
       
  1173         iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
       
  1174         iLayout->UpdateChildrenLayout (); //update layout
       
  1175         }
       
  1176     //Setting text color to default theme text color.
       
  1177     iEmptyString->SetColor(KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
       
  1178     iEmptyString->SetTextStyle(iUiUtility->TextStyleIdL(EAknLogicalFontPrimaryFont
       
  1179             ,KPrimaryFontSize));
       
  1180     iEmptyString->SetWrapping( CAlfTextVisual::ELineWrapBreak );
       
  1181     iEmptyString->SetTextL (iEmptyText->Des());
       
  1182     // no shadow wanted for the text
       
  1183     iEmptyString->EnableShadow( EFalse );
       
  1184 
       
  1185     //disable msk
       
  1186     iLayoutObserver.HandleLayoutChanged();
       
  1187     iScrollEventData.mSpan = 0;
       
  1188     iScrollEventData.mViewLength = 0;
       
  1189     DisplayScrollBar();
       
  1190     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::DisplayEmptyCloudView layout Count after reset  %d ", iLayout->Count());
       
  1191     }
       
  1192 
       
  1193 // ---------------------------------------------------------------------------
       
  1194 // MaxUsageCount()
       
  1195 // ---------------------------------------------------------------------------
       
  1196 //
       
  1197 TInt CGlxCloudViewControl::MaxUsageCount()
       
  1198     {
       
  1199     TRACER("GLX_CLOUD::CGlxCloudViewControl::GetMaxusageCount");
       
  1200     TInt maxValue=0;
       
  1201     const TInt mediaListSize = iMediaList.Count();
       
  1202     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::GetMaxusageCount MediaList Count %d ",iMediaList.Count());
       
  1203     for (TInt k=0; k < mediaListSize; k++)
       
  1204         {
       
  1205         TInt count = UsageCount (k);
       
  1206         if ( count > maxValue)
       
  1207             {
       
  1208             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::GetMaxusageCount  in the loop");
       
  1209             maxValue=count;
       
  1210             }
       
  1211         }
       
  1212     return maxValue;
       
  1213     }
       
  1214 
       
  1215 // ---------------------------------------------------------------------------
       
  1216 // UsageCount()
       
  1217 // ---------------------------------------------------------------------------
       
  1218 //
       
  1219 TInt CGlxCloudViewControl::UsageCount(TInt aIndex)
       
  1220     {
       
  1221     TRACER("GLX_CLOUD::CGlxCloudViewControl::UsageCount");
       
  1222     GLX_LOG_INFO1("GLX_CLOUD :: CGlxCloudViewControl::UsageCount Item index: %d ", aIndex);
       
  1223     TMPXAttribute attrCount(KMPXMediaGeneralCount); // get the attrCount
       
  1224     TInt usageCount =0;
       
  1225     const CGlxMedia* media = iMediaList.Item(aIndex).Properties ();
       
  1226     if ( media)
       
  1227         {
       
  1228         if ( media->IsSupported (attrCount))
       
  1229             {
       
  1230             usageCount = media->ValueTObject<TInt> (attrCount);
       
  1231             GLX_LOG_INFO1("GLX_CLOUD :: CGlxCloudViewControl::UsageCount Count: %d ", usageCount);
       
  1232             }
       
  1233         }
       
  1234     return usageCount;
       
  1235     }
       
  1236 
       
  1237 // ---------------------------------------------------------------------------
       
  1238 // SetFocusColor()
       
  1239 // ---------------------------------------------------------------------------
       
  1240 //
       
  1241 void CGlxCloudViewControl::AppendToCloudArrayL( 
       
  1242         TGlxCloudInfo& aCloudInfo,const TInt& aStartIndex, const TInt& aEndIndex )
       
  1243     {
       
  1244     TRACER("GLX_CLOUD::CGlxCloudViewControl::AppendToCloudArrayL");
       
  1245     aCloudInfo.iStartIndex = aStartIndex;
       
  1246     aCloudInfo.iEndIndex = aEndIndex; 
       
  1247     iCloudInfo.AppendL( aCloudInfo );
       
  1248     }
       
  1249 
       
  1250 // ---------------------------------------------------------------------------
       
  1251 // SetFocusColor()
       
  1252 // ---------------------------------------------------------------------------
       
  1253 //
       
  1254 void  CGlxCloudViewControl::SetFocusColor()
       
  1255     {
       
  1256     iLabels[iMediaList.FocusIndex()]->SetColor (KAknsIIDQsnHighlightColors ,EAknsCIQsnHighlightColorsCG3); 
       
  1257     }
       
  1258 
       
  1259 // ---------------------------------------------------------------------------
       
  1260 // SetBubleMidPoint()
       
  1261 // ---------------------------------------------------------------------------
       
  1262 //
       
  1263 void  CGlxCloudViewControl::SetBubleMidPoint(TPoint& aMidPoint)
       
  1264     {
       
  1265     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetBubleMidPoint");
       
  1266     //Substract the viewport position so as to set the buble at the right position on the screen     
       
  1267     aMidPoint.iX-=iViewPortPosition.iX;
       
  1268     aMidPoint.iY-=iViewPortPosition.iY;
       
  1269     }
       
  1270 
       
  1271 // ---------------------------------------------------------------------------
       
  1272 // MoveUpIfRequired()
       
  1273 // ---------------------------------------------------------------------------
       
  1274 //
       
  1275 void CGlxCloudViewControl::MoveUpIfRequired()
       
  1276     {
       
  1277     TRACER("GLX_CLOUD::CGlxCloudViewControl::MoveUpIfRequired");
       
  1278     //get the focused item's position
       
  1279     TPoint point;
       
  1280     iLayout->ChildPos(iMediaList.FocusIndex(),point);
       
  1281     TSize size;
       
  1282     iLayout->ChildSize(iMediaList.FocusIndex(),size);
       
  1283     TInt focus = iMediaList.FocusIndex();
       
  1284     TInt rownumber = RowNumber(focus);
       
  1285     //if the focused item is not visible then move the viewport
       
  1286     if(point.iY < iViewPortPosition.iY)         
       
  1287         { 
       
  1288         //set the new position of viewport
       
  1289         TInt offeset = iViewPortPosition.iY - point.iY;
       
  1290         iViewPortPosition.iY-=offeset;
       
  1291         if( (iViewPortPosition.iY < 0) )
       
  1292             {
       
  1293             iViewPortPosition.iY = 0;
       
  1294             }   
       
  1295         }    
       
  1296     //if its key event then it should be cyclic
       
  1297     else if( rownumber == (iCloudInfo.Count()-1))
       
  1298         {
       
  1299         iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
       
  1300         }
       
  1301     iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement);
       
  1302     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
       
  1303     Scroll();  
       
  1304     }
       
  1305 
       
  1306 // ---------------------------------------------------------------------------
       
  1307 // MoveDownIfRequired()
       
  1308 // ---------------------------------------------------------------------------
       
  1309 //
       
  1310 void CGlxCloudViewControl::MoveDownIfRequired()
       
  1311     {
       
  1312     TRACER("GLX_CLOUD::CGlxCloudViewControl::MoveDownIfRequired");  
       
  1313     //get the focused item's position
       
  1314     TPoint point;
       
  1315     iLayout->ChildPos(iMediaList.FocusIndex(),point);
       
  1316     TSize size;
       
  1317     iLayout->ChildSize(iMediaList.FocusIndex(),size);
       
  1318     //if the focused visual is not visible then move the viewport 
       
  1319     if(point.iY+size.iHeight > iViewPortPosition.iY+iViewPortSize.iHeight )
       
  1320         { 
       
  1321         //set the new position of viewport
       
  1322         TInt offeset = (point.iY+size.iHeight) - (iViewPortPosition.iY+iViewPortSize.iHeight);
       
  1323         iViewPortPosition.iY+=offeset;
       
  1324         if( (iViewPortPosition.iY > iViewPortVirtualSize.iHeight) )
       
  1325             {
       
  1326             iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
       
  1327             } 
       
  1328         }
       
  1329     //if its key event then it should be cyclic
       
  1330     else if (iMediaList.FocusIndex() == 0)
       
  1331         {
       
  1332         iViewPortPosition.iY = 0;
       
  1333         }     
       
  1334     iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement);
       
  1335     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
       
  1336     if(iScrollBarWidget)
       
  1337         {
       
  1338         Scroll();           
       
  1339         }
       
  1340     }     
       
  1341 
       
  1342 // ---------------------------------------------------------------------------
       
  1343 // MoveDownIfRequired()
       
  1344 // ---------------------------------------------------------------------------
       
  1345 //
       
  1346 void CGlxCloudViewControl::CalculateBubleMidPoint()
       
  1347     { 
       
  1348     TRACER("GLX_CLOUD::CGlxCloudViewControl::CalculateBubleMidPoint");
       
  1349     TPoint midpoint;
       
  1350     TAlfRealRect focussedItemRect;
       
  1351     TRect mainPaneRect;
       
  1352     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, mainPaneRect);
       
  1353 
       
  1354     CAlfVisual& visual = iLayout->Visual( iMediaList.FocusIndex() );
       
  1355     focussedItemRect = visual.DisplayRect();
       
  1356 
       
  1357     if( GlxGeneralUiUtilities::LayoutIsMirrored () )
       
  1358         {  
       
  1359         midpoint.iX = focussedItemRect.iBr.iX +
       
  1360         ((focussedItemRect.iTl.iX - focussedItemRect.iBr.iX )/2);
       
  1361         }
       
  1362 
       
  1363     else 
       
  1364         {
       
  1365         midpoint.iX=focussedItemRect.iTl.iX +
       
  1366         ((focussedItemRect.iBr.iX - focussedItemRect.iTl.iX )/2);
       
  1367         }
       
  1368 
       
  1369     midpoint.iY=focussedItemRect.iTl.iY+
       
  1370                 ((focussedItemRect.iBr.iY - focussedItemRect.iTl.iY )/2); 
       
  1371     TPoint anchorRect;
       
  1372 
       
  1373     //Get the position of anchor layout
       
  1374     iViewPortLayout->ChildPos (0, anchorRect);
       
  1375 
       
  1376     //Add the differance to the midpoint
       
  1377     midpoint.iX+=anchorRect.iX;
       
  1378     midpoint.iY+=anchorRect.iY; 
       
  1379 
       
  1380     //Substract from the viewport position the viewport position    
       
  1381     SetBubleMidPoint(midpoint);   
       
  1382     } 
       
  1383 
       
  1384 // ---------------------------------------------------------------------------
       
  1385 // HandlePointerEventL()
       
  1386 // ---------------------------------------------------------------------------
       
  1387 //  
       
  1388 TBool CGlxCloudViewControl::HandlePointerEventL( const TAlfEvent &aEvent )
       
  1389     {
       
  1390     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandlePointerEventL");
       
  1391     CAlfVisual* tappedvisual = aEvent.Visual();	
       
  1392     TBool consumed = EFalse;
       
  1393 
       
  1394     if(aEvent.PointerEvent().iType == TPointerEvent::EButton1Down)
       
  1395         {	
       
  1396         iDownEventReceived = ETrue;
       
  1397         //reset variables & Physics simulator 
       
  1398         iPhysics->StopPhysics();
       
  1399         iPhysics->ResetFriction();
       
  1400         iDragging = EFalse;
       
  1401         iPhysicsStarted = EFalse;
       
  1402         iStartTime.HomeTime();
       
  1403         iViewDragged = EFalse;
       
  1404         Display()->Roster().SetPointerEventObservers(
       
  1405                 EAlfPointerEventReportDrag + EAlfPointerEventReportLongTap
       
  1406                         + EAlfPointerEventReportUnhandled, *this);
       
  1407         Display()->Roster().DisableLongTapEventsWhenDragging(*this);
       
  1408         
       
  1409         //If the grid is already shown , disable it
       
  1410         if(iTagsContextMenuControl->ItemMenuVisibility())
       
  1411            {
       
  1412            iTagsContextMenuControl->ShowItemMenuL(EFalse);
       
  1413            return ETrue;
       
  1414            }
       
  1415         if(tappedvisual)
       
  1416             {
       
  1417             for(TInt index=0;index<iLayout->Count();index++)
       
  1418                 {    	
       
  1419                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
       
  1420                 //if the tapped visual is same as the visual in the layout then focus that visual
       
  1421                 if(layoutvisual == tappedvisual)
       
  1422                     {
       
  1423                     iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
       
  1424                     iMediaList.SetFocusL (NGlxListDefs::EAbsolute, index);
       
  1425 
       
  1426                     //Start the timer to interpret longpress events
       
  1427                     iTimerComplete = EFalse;
       
  1428                     iTimer->Cancel ();//cancels any outstanding requests
       
  1429                     iTimer->SetDelay (KLongPressTimer);
       
  1430                     
       
  1431                     consumed = ETrue;
       
  1432                     break;
       
  1433                     }
       
  1434                 }
       
  1435             }
       
  1436         }
       
  1437     else if (iDownEventReceived && aEvent.PointerEvent().iType == TPointerEvent::EDrag)
       
  1438         {
       
  1439         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandlePointerEventL(EDrag) event");
       
  1440 
       
  1441         iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
       
  1442 
       
  1443         consumed = HandleDragL(aEvent.PointerEvent());
       
  1444         }
       
  1445     else if (iDownEventReceived && aEvent.PointerUp())
       
  1446         {
       
  1447         iDownEventReceived = EFalse;
       
  1448         Display()->Roster().SetPointerEventObservers(0, *this);
       
  1449         consumed = ETrue;
       
  1450         
       
  1451         //If the long press timer is completed , and if upevent is received.. ignore it
       
  1452         if(iTimerComplete)
       
  1453             {
       
  1454             consumed =  ETrue;
       
  1455             }
       
  1456 
       
  1457         //Check if dragging actually happened using iViewDragged 
       
  1458         if (iDragging && iViewDragged)
       
  1459             {
       
  1460 			iTimer->Cancel ();//cancels any outstanding requests
       
  1461 						
       
  1462             iDragging = EFalse;
       
  1463             TPoint drag = iStart - aEvent.PointerEvent().iPosition;
       
  1464             iPhysics->StartPhysics(drag, iStartTime);
       
  1465             iPhysicsStarted = ETrue;
       
  1466             }
       
  1467         //If dragging not happened consider it as Tapped event
       
  1468         //When it recognises the long press event ,  and if up event is received..Ignore it 
       
  1469         else if (tappedvisual && !iViewDragged && !iTimerComplete)
       
  1470             {
       
  1471            for (TInt index = 0; index < iLayout->Count(); index++)
       
  1472                 {
       
  1473                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
       
  1474                 //if the tapped visual is same as the visual in the layout then focus that visual
       
  1475                 if (layoutvisual == tappedvisual)
       
  1476                     {
       
  1477                     TInt focus = iMediaList.FocusIndex();
       
  1478                     if (index != focus)
       
  1479                         {
       
  1480                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
       
  1481                         TInt focusrowindex = iFocusRowIndex;
       
  1482                         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index);
       
  1483                         SetFocusColor();
       
  1484                         iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
  1485                         
       
  1486                         if( iFocusRowIndex > focusrowindex)
       
  1487                             {
       
  1488                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
       
  1489                             iScrollDirection = 0;               
       
  1490                             MoveDownIfRequired();               
       
  1491                             }
       
  1492                         else if( iFocusRowIndex < focusrowindex )
       
  1493                             {
       
  1494                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup");
       
  1495                             iScrollDirection = 1;                
       
  1496                             MoveUpIfRequired();                 
       
  1497                             }
       
  1498                         }
       
  1499 
       
  1500                     iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
       
  1501                     iObserverEnterKeyEvent.HandleEnterKeyEventL((TInt) EAknCmdOpen);
       
  1502                     consumed = ETrue;
       
  1503                     break;
       
  1504                     }
       
  1505                 }
       
  1506             }
       
  1507         iViewDragged = EFalse;
       
  1508         }
       
  1509     return consumed;
       
  1510     }
       
  1511 
       
  1512 // ---------------------------------------------------------------------------
       
  1513 // HandleDragL()
       
  1514 // ---------------------------------------------------------------------------
       
  1515 //
       
  1516 TBool CGlxCloudViewControl::HandleDragL(const TPointerEvent& aPointerEvent)
       
  1517     {
       
  1518     TBool consumed(EFalse);
       
  1519     
       
  1520     // If Physics Emulation is going on, no need to entertain drag event
       
  1521     if (iPhysicsStarted)
       
  1522         return consumed;
       
  1523 
       
  1524     //Simply ignore the first drag event as there is huge difference between position 
       
  1525     //coordinates in drag event and corordinates in normal pointer down / up events  
       
  1526     if (!iDragging)
       
  1527         {
       
  1528         //Note the current position for future reference
       
  1529         iStart = aPointerEvent.iPosition;
       
  1530         iPrev = iStart; 
       
  1531         iDragging = ETrue;
       
  1532         return consumed;
       
  1533         }
       
  1534 
       
  1535     TRect rect;
       
  1536     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
  1537     TInt cntrlTopYLimit = rect.iTl.iY;
       
  1538     TInt cntrlBottomYLimit = rect.iBr.iY;
       
  1539     TInt delta = iPrev.iY - aPointerEvent.iPosition.iY;
       
  1540 
       
  1541     //Check for physics threshold, before regidterting drag corordinates
       
  1542     TInt deltaAbs = delta < 0 ? -delta : delta;
       
  1543     TBool panning = deltaAbs >= iPhysics->DragThreshold();
       
  1544     if (panning)
       
  1545         {
       
  1546         TPoint deltaPt = iPrev - aPointerEvent.iPosition;
       
  1547         iPhysics->RegisterPanningPosition(deltaPt);
       
  1548         iPrev = aPointerEvent.iPosition;
       
  1549         iViewDragged = ETrue;
       
  1550         }
       
  1551     consumed = ETrue;
       
  1552 
       
  1553     //Calculate margin after which we might get pointer out of screen, and we might not 
       
  1554     //get further pointer events. Also This is currently only 10% of total delta we can find, 
       
  1555     //to get margin corresponding to movement of user flicking speed
       
  1556     //This implies higher speed - higher margin
       
  1557     //Lower speed - 0 margin
       
  1558     TInt deltaMargin = deltaAbs * KBoundaryMargin;
       
  1559 
       
  1560     //Code to predict future movement if same delta movement we might get in future
       
  1561     //For flick event down - If the movement goes below screen, start physics
       
  1562     //or For flick event up - If the movement goes above screen, start physics 
       
  1563     if (((delta < 0) && (aPointerEvent.iPosition.iY - delta >= cntrlBottomYLimit - deltaMargin))
       
  1564             || ((delta > 0) && (aPointerEvent.iPosition.iY - delta <= cntrlTopYLimit + deltaMargin)))
       
  1565         {
       
  1566         iPhysicsStarted = ETrue;
       
  1567         }
       
  1568 
       
  1569     //If found that possibly in next move it might go out of bounds, start physics
       
  1570     //emulation
       
  1571     if (iPhysicsStarted && iDragging)
       
  1572         {
       
  1573         iTimer->Cancel();
       
  1574         TPoint drag = iStart - aPointerEvent.iPosition;
       
  1575         iPhysics->StartPhysics(drag, iStartTime);
       
  1576         iDragging = EFalse;
       
  1577         }
       
  1578 
       
  1579     return consumed;
       
  1580     }
       
  1581 
       
  1582 // ---------------------------------------------------------------------------
       
  1583 // GetAbsoluteIndex()
       
  1584 // ---------------------------------------------------------------------------
       
  1585 //
       
  1586 TInt CGlxCloudViewControl::GetAbsoluteIndex(const TPoint& aPosition)
       
  1587     {
       
  1588     TRACER("GLX_CLOUD::CGlxCloudViewControl::GetAbsoluteIndex");
       
  1589     //find out the visual on which the drag event has occured
       
  1590     for(TInt j = 0; j < iLayout->Count(); j++)
       
  1591         {
       
  1592         CAlfVisual* visual = &(iLayout->Visual(j));
       
  1593         TRect visualrect = visual->DisplayRect();
       
  1594         TInt focusindex = iMediaList.FocusIndex();
       
  1595         if(visualrect.Contains(aPosition) && (focusindex != j))      
       
  1596             {
       
  1597             return j;
       
  1598             }
       
  1599         }
       
  1600     return KErrNotFound;	         
       
  1601     }
       
  1602 
       
  1603 // ---------------------------------------------------------------------------
       
  1604 // SetRelativeFocusL()
       
  1605 // ---------------------------------------------------------------------------
       
  1606 //
       
  1607 void CGlxCloudViewControl::SetRelativeFocusL(TInt aRowNumber)
       
  1608     {
       
  1609     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetRelativeFocusL");
       
  1610     TInt focus = iMediaList.FocusIndex ();
       
  1611     //get the co-ordinates of the focused tag
       
  1612     TInt x = iLayout->Visual(focus).DisplayRect().Center().iX;
       
  1613     TInt y = iLayout->Visual(focus).DisplayRect().Center().iY;
       
  1614     TPoint midpoint(x, y);
       
  1615 
       
  1616     //find the tag below\above that overlaps with the focused tag
       
  1617     for(TInt index = iCloudInfo[aRowNumber].iStartIndex; 
       
  1618         index <= iCloudInfo[aRowNumber].iEndIndex; index++)
       
  1619         {	    
       
  1620         CAlfVisual* visual = &(iLayout->Visual(index));				
       
  1621         TRect visualrect = visual->DisplayRect();
       
  1622         if ( (visualrect.iTl.iX <= midpoint.iX) && (midpoint.iX <= visualrect.iBr.iX))
       
  1623             {            
       
  1624             iMediaList.SetFocusL (NGlxListDefs::EAbsolute,index);
       
  1625             break;
       
  1626             } 
       
  1627         }
       
  1628 
       
  1629     // if no element is found that overlaps with midpoint of the 
       
  1630     //focused item,then focus the last element of the next row.
       
  1631     if(focus == iMediaList.FocusIndex ())	
       
  1632         {        
       
  1633         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
  1634                 iCloudInfo[aRowNumber].iEndIndex);
       
  1635         } 	 	
       
  1636     }
       
  1637 
       
  1638 // ---------------------------------------------------------------------------
       
  1639 // setActiveStates()
       
  1640 // ---------------------------------------------------------------------------
       
  1641 //
       
  1642 void CGlxCloudViewControl::setActiveStates( unsigned int /*aStates*/ )
       
  1643     {
       
  1644     }
       
  1645 
       
  1646 // ---------------------------------------------------------------------------
       
  1647 // makeInterface()
       
  1648 // ---------------------------------------------------------------------------
       
  1649 //
       
  1650 IAlfInterfaceBase* CGlxCloudViewControl::makeInterface ( const IfId& /*aType*/ )
       
  1651     {
       
  1652     return NULL;
       
  1653     }
       
  1654 
       
  1655 // ---------------------------------------------------------------------------
       
  1656 // eventHandlerType()
       
  1657 // ---------------------------------------------------------------------------
       
  1658 //
       
  1659 IAlfWidgetEventHandler::AlfEventHandlerType CGlxCloudViewControl::eventHandlerType()
       
  1660     {
       
  1661     return IAlfWidgetEventHandler::ELogicalEventHandler;
       
  1662     }  
       
  1663 
       
  1664 // ---------------------------------------------------------------------------
       
  1665 // eventExecutionPhase()
       
  1666 // ---------------------------------------------------------------------------
       
  1667 //
       
  1668 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase CGlxCloudViewControl::eventExecutionPhase()
       
  1669     {
       
  1670     return IAlfWidgetEventHandler::ETunnellingPhaseEventHandler;
       
  1671     }
       
  1672 
       
  1673 // ---------------------------------------------------------------------------
       
  1674 // offerEvent()
       
  1675 // ---------------------------------------------------------------------------
       
  1676 //
       
  1677 AlfEventStatus CGlxCloudViewControl::offerEvent(CAlfWidgetControl& aControl,
       
  1678         const TAlfEvent& aEvent)
       
  1679     {
       
  1680     TRACER("GLX_CLOUD::CGlxCloudViewControl::offerEvent");  
       
  1681     AlfEventStatus status = EEventNotHandled;  
       
  1682     if(aEvent.IsCustomEvent() && accept(aControl, aEvent))
       
  1683         {
       
  1684         if ( iScrollBarWidget )
       
  1685             {    		
       
  1686             if (aEvent.IsCustomEvent())
       
  1687                 {
       
  1688                 switch(aEvent.CustomParameter())
       
  1689                     {
       
  1690                     case KAlfActionIdDeviceLayoutChanged:
       
  1691                         {
       
  1692                         iLayoutObserver.HandleLayoutChanged();
       
  1693                         TRAP_IGNORE(UpdateLayoutL());
       
  1694                         }
       
  1695                          return EEventNotHandled;
       
  1696 
       
  1697                     case EEventDragVertical:
       
  1698                         {    
       
  1699                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollDown) event");
       
  1700                         TInt steps = TInt(aEvent.CustomEventData());
       
  1701                         UpdateScrollBar(steps,EFalse);                        
       
  1702                         Scroll();                       
       
  1703                         iPhysics->StopPhysics();
       
  1704 
       
  1705                         status = EEventHandled; 
       
  1706                         }
       
  1707                         break;                   
       
  1708                     case EEventScrollPageUp:
       
  1709                         { 
       
  1710                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageUp) event");                       
       
  1711                         UpdateScrollBar(-iScrollEventData.mViewLength); 
       
  1712                         Scroll();                        
       
  1713                         iPhysics->StopPhysics();
       
  1714                         status = EEventHandled;
       
  1715                         }
       
  1716                         break;
       
  1717                     case EEventScrollPageDown:
       
  1718                         {  
       
  1719                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageDown) event");                       
       
  1720                         UpdateScrollBar(iScrollEventData.mViewLength); 
       
  1721                         Scroll();
       
  1722                         iPhysics->StopPhysics();
       
  1723                         status = EEventHandled; 		    	    
       
  1724                         }
       
  1725                         break;                    
       
  1726                     }//end switch
       
  1727                 }
       
  1728             }
       
  1729         }
       
  1730     return status;
       
  1731     }
       
  1732 
       
  1733 // ---------------------------------------------------------------------------
       
  1734 // accept()
       
  1735 // ---------------------------------------------------------------------------
       
  1736 //   
       
  1737 bool CGlxCloudViewControl::accept(CAlfWidgetControl& /*aControl*/,
       
  1738         const TAlfEvent& aEvent) const
       
  1739     {
       
  1740     TRACER("GLX_CLOUD::CGlxCloudViewControl::accept");
       
  1741     if(	aEvent.CustomParameter() == EEventScrollPageUp 	||
       
  1742         aEvent.CustomParameter() == EEventScrollPageDown ||
       
  1743         aEvent.CustomParameter() == EEventDragVertical ||
       
  1744         aEvent.CustomParameter() == KAlfActionIdDeviceLayoutChanged )
       
  1745         {
       
  1746         return true;
       
  1747         }
       
  1748     return false;
       
  1749     }
       
  1750 
       
  1751 // ---------------------------------------------------------------------------
       
  1752 // attachScrollBar()
       
  1753 // ---------------------------------------------------------------------------
       
  1754 //	
       
  1755 void CGlxCloudViewControl::InitializeScrollBar(IAlfScrollBarWidget* aScrollBarWidget)
       
  1756     {
       
  1757     TRACER("GLX_CLOUD::CGlxCloudViewControl::InitializeScrollBar");
       
  1758     iScrollBarWidget = aScrollBarWidget;
       
  1759     ((IAlfScrollBarModel *) (iScrollBarWidget->model()))->initializeData(
       
  1760             iScrollEventData.mSpan, iScrollEventData.mViewLength, 0);
       
  1761     DisplayScrollBar();
       
  1762     }
       
  1763 
       
  1764 // ---------------------------------------------------------------------------
       
  1765 // Scroll()
       
  1766 // ---------------------------------------------------------------------------
       
  1767 //
       
  1768 void CGlxCloudViewControl::Scroll()
       
  1769     {
       
  1770     TRACER("GLX_CLOUD::CGlxCloudViewControl::Scroll()");
       
  1771     TAlfEvent customevent(EEventScrollBarModelChanged,(TInt)&iScrollEventData);
       
  1772     IAlfElement* baseelement = iScrollBarWidget->control()->findElement ("BaseElement");
       
  1773     iScrollbarElement=static_cast<IAlfWidgetEventHandler*> (
       
  1774             baseelement->makeInterface (IAlfWidgetEventHandler::type()));
       
  1775     //pass the custom event to scrollbar element so as to scroll to the required position
       
  1776     iScrollbarElement->offerEvent(*(iScrollBarWidget->control()),customevent);
       
  1777     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::Scroll(),position %d ",iScrollEventData.mViewStartPos);
       
  1778     iViewPortPosition.iY = iScrollEventData.mViewStartPos;
       
  1779     iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement);
       
  1780     }
       
  1781 
       
  1782 // ---------------------------------------------------------------------------
       
  1783 // UpdateScrollBar()
       
  1784 // ---------------------------------------------------------------------------
       
  1785 //
       
  1786 void CGlxCloudViewControl::UpdateScrollBar(TInt aNumberOfSteps, TBool aDiff)
       
  1787     {
       
  1788     TRACER("GLX_CLOUD::CGlxCloudViewControl::UpdateScrollBar()");
       
  1789     TInt viewLength = ((IAlfScrollBarModel *)(iScrollBarWidget->model()))->getViewLength();
       
  1790     TInt viewStartPos=((IAlfScrollBarModel *)(iScrollBarWidget->model()))->getViewStartPosition();
       
  1791     TInt totalLength=((IAlfScrollBarModel *)(iScrollBarWidget->model()))->getTotalLength();
       
  1792 
       
  1793     TInt newViewStartPos=viewStartPos;
       
  1794     if(aDiff)
       
  1795         {
       
  1796         aNumberOfSteps+=viewStartPos;
       
  1797         }
       
  1798     if( (aNumberOfSteps <= (totalLength-viewLength))&&(aNumberOfSteps>=0) )
       
  1799         {
       
  1800         newViewStartPos=aNumberOfSteps;
       
  1801         }
       
  1802     else if( aNumberOfSteps > (totalLength-viewLength) )
       
  1803         {
       
  1804         newViewStartPos=totalLength-viewLength;
       
  1805         }
       
  1806     else if ( aNumberOfSteps < 0 )
       
  1807         {
       
  1808         newViewStartPos=0;
       
  1809         }
       
  1810     iScrollEventData.mViewStartPos = newViewStartPos;
       
  1811     }
       
  1812 
       
  1813 // ---------------------------------------------------------------------------
       
  1814 // DisplayScrollBar()
       
  1815 // ---------------------------------------------------------------------------
       
  1816 //
       
  1817 void CGlxCloudViewControl::DisplayScrollBar() 
       
  1818     {
       
  1819     if (iScrollBarWidget)
       
  1820         {
       
  1821         IAlfElement* vertBaseElement =(iScrollBarWidget->control()->findElement ("BaseElement"));
       
  1822         IAlfScrollBarDefaultBaseElement* scrollbarbaselement=static_cast<IAlfScrollBarDefaultBaseElement*> (
       
  1823             vertBaseElement->makeInterface (IAlfScrollBarDefaultBaseElement::type() ) );
       
  1824 
       
  1825         // To set the scrollbar visibility, it's enough to set the opacity 
       
  1826         // of baselayout. No need to set the opacity of thumb separately. 
       
  1827         if (iScrollEventData.mSpan)
       
  1828             {
       
  1829             //make scroll bar visible
       
  1830             scrollbarbaselement->setOpacity(1.0);
       
  1831             }
       
  1832         else
       
  1833             {
       
  1834             //make scroll bar invisible
       
  1835             scrollbarbaselement->setOpacity(0.0);
       
  1836             }
       
  1837         }
       
  1838     }
       
  1839 
       
  1840 // ---------------------------------------------------------------------------
       
  1841 // UpdateLayoutL() 
       
  1842 // ---------------------------------------------------------------------------
       
  1843 //
       
  1844 void CGlxCloudViewControl::UpdateLayoutL() 
       
  1845     {
       
  1846     TRect rect;
       
  1847     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
       
  1848     if ((rect.Width() != (iTagScreenWidth + KRightmargin)) || (rect.Height() != iScreenHeight))
       
  1849         {
       
  1850 		//set the new screen dimensions
       
  1851 		iScreenHeight = rect.Height();
       
  1852 		iTagScreenWidth = rect.Width() - KRightmargin;
       
  1853 		if (IsLandscape())
       
  1854 			{
       
  1855 			iTagScreenHeight = rect.Height();
       
  1856 			}
       
  1857 		else
       
  1858 			{
       
  1859 			iTagScreenHeight = KTagScreenHeight;
       
  1860 			}
       
  1861 
       
  1862 		iViewPortLayout->SetSize(
       
  1863 				TAlfRealSize(iTagScreenWidth, iTagScreenHeight), 0);
       
  1864 		//delete all layout associations
       
  1865 		if (iCloudInfo.Count() != 0)//check for the empty cloud view
       
  1866 			{
       
  1867 			UpdateLayout();
       
  1868 			FetchAttributeFromCacheL();
       
  1869 			//generate row structures and draw rows on screen
       
  1870 			UpdateRowDataL();
       
  1871 
       
  1872 			InitPhysicsL();
       
  1873 			}
       
  1874 		}
       
  1875     }
       
  1876 
       
  1877 // ---------------------------------------------------------------------------
       
  1878 // InitPhysicsL() 
       
  1879 // ---------------------------------------------------------------------------
       
  1880 //
       
  1881 void CGlxCloudViewControl::InitPhysicsL()
       
  1882     {
       
  1883     //Update physics with new total layout, viewable size and our landscape mode 
       
  1884     iPhysics->InitPhysicsL(TSize(iViewPortVirtualSize.iWidth,
       
  1885             iViewPortVirtualSize.iHeight), TSize(iTagScreenWidth,
       
  1886             iTagScreenHeight), EFalse);
       
  1887 
       
  1888     //Note: Physics viewposition must always be mid of viewable screen size to get best result
       
  1889     //I learned the hard way
       
  1890     iViewPosition.SetXY(iTagScreenWidth / 2, iTagScreenHeight / 2);
       
  1891     }
       
  1892 
       
  1893 // ---------------------------------------------------------------------------
       
  1894 // ViewPositionChanged() 
       
  1895 // ---------------------------------------------------------------------------
       
  1896 //
       
  1897 void CGlxCloudViewControl::ViewPositionChanged(const TPoint& aNewPosition,
       
  1898         TBool aDrawNow, TUint /*aFlags*/)
       
  1899     {
       
  1900     iViewPosition = aNewPosition;
       
  1901     iViewPortPosition.iY = iViewPosition.iY - iTagScreenHeight / 2;
       
  1902     if (aDrawNow)
       
  1903         {
       
  1904         iViewPortLayout->SetViewportPos(iViewPortPosition, KFastCloudMovement);
       
  1905         
       
  1906         iScrollEventData.mViewStartPos = iViewPortPosition.iY;
       
  1907         Scroll();
       
  1908         }
       
  1909     }
       
  1910 
       
  1911 // ---------------------------------------------------------------------------
       
  1912 // PhysicEmulationEnded() 
       
  1913 // ---------------------------------------------------------------------------
       
  1914 //
       
  1915 void CGlxCloudViewControl::PhysicEmulationEnded()
       
  1916     {
       
  1917     iPhysicsStarted = EFalse;
       
  1918     }
       
  1919 
       
  1920 // ---------------------------------------------------------------------------
       
  1921 // ViewPosition() 
       
  1922 // ---------------------------------------------------------------------------
       
  1923 //
       
  1924 TPoint CGlxCloudViewControl::ViewPosition() const
       
  1925     {
       
  1926     return iViewPosition;
       
  1927     }
       
  1928 
       
  1929 // ---------------------------------------------------------------------------
       
  1930 // IsLandscape() 
       
  1931 // ---------------------------------------------------------------------------
       
  1932 //
       
  1933 TBool CGlxCloudViewControl::IsLandscape()
       
  1934     {
       
  1935     TRect rect;
       
  1936     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, rect);
       
  1937     if(rect.Width() > rect.Height())
       
  1938         {
       
  1939         return ETrue;
       
  1940         }
       
  1941     else
       
  1942         {
       
  1943         return EFalse;
       
  1944         }
       
  1945     }
       
  1946 
       
  1947 // ---------------------------------------------------------------------------
       
  1948 // TimerCompleteL()
       
  1949 // ---------------------------------------------------------------------------
       
  1950 //
       
  1951 void CGlxCloudViewControl::TimerCompleteL()
       
  1952     {
       
  1953     iTimerComplete = ETrue;
       
  1954     iTagsContextMenuControl->ShowItemMenuL(EFalse);
       
  1955 
       
  1956     CAlfVisual& visual = iLayout->Visual( iMediaList.FocusIndex() );
       
  1957     TRect focussedItemRect = visual.DisplayRect();
       
  1958     TPoint midpoint;
       
  1959     midpoint.iX=focussedItemRect.iTl.iX +
       
  1960             ((focussedItemRect.iBr.iX - focussedItemRect.iTl.iX )/2);
       
  1961     midpoint.iY=focussedItemRect.iTl.iY+
       
  1962                     ((focussedItemRect.iBr.iY - focussedItemRect.iTl.iY )/2); 
       
  1963     
       
  1964     TRect rect;
       
  1965     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
  1966     
       
  1967     if(!iPhysicsStarted)//only if physics hasnt started
       
  1968         {
       
  1969         iTagsContextMenuControl->SetViewableRect(rect);
       
  1970         iTagsContextMenuControl->ShowItemMenuL(ETrue);
       
  1971         iTagsContextMenuControl->SetDisplay(midpoint);
       
  1972         }
       
  1973    }
       
  1974 
       
  1975 // ---------------------------------------------------------------------------
       
  1976 // ShowContextItemMenuL()
       
  1977 // ---------------------------------------------------------------------------
       
  1978 //
       
  1979 void CGlxCloudViewControl::ShowContextItemMenuL(TBool aShow)
       
  1980     {
       
  1981     iTagsContextMenuControl->ShowItemMenuL(aShow);
       
  1982     if(!aShow)
       
  1983         {
       
  1984         iViewPortLayout->UpdateChildrenLayout(0);
       
  1985         }
       
  1986     }
       
  1987 
       
  1988 //End of file