photosgallery/viewframework/views/cloudview/src/glxcloudviewcontrol.cpp
branchRCL_3
changeset 64 34937ec34dac
parent 60 5b3385a43d68
child 75 01504893d9cb
equal deleted inserted replaced
60:5b3385a43d68 64:34937ec34dac
   196         //get the attributes from Cache
   196         //get the attributes from Cache
   197         FetchAttributeFromCacheL();
   197         FetchAttributeFromCacheL();
   198 
   198 
   199         if ( iLabels.Count ()==listCount && iAttributeContext->RequestCountL (&iMediaList)==0)
   199         if ( iLabels.Count ()==listCount && iAttributeContext->RequestCountL (&iMediaList)==0)
   200             {
   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 ())
   201             if ( iUiUtility->ViewNavigationDirection ()== EGlxNavigationForwards && iMediaList.Count ())
   204                 {
   202                 {
   205                 iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
   203                 iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
   206                 }
   204                 }
   207             UpdateRowDataL ();
   205             UpdateRowDataL ();
   209         }
   207         }
   210     //get touch feedback instance
   208     //get touch feedback instance
   211     iTouchFeedback = MTouchFeedback::Instance(); 
   209     iTouchFeedback = MTouchFeedback::Instance(); 
   212     iPhysics = CAknPhysics::NewL(*this, NULL);
   210     iPhysics = CAknPhysics::NewL(*this, NULL);
   213     InitPhysicsL();
   211     InitPhysicsL();
       
   212     iShowFocus = EFalse;
   214     }
   213     }
   215 
   214 
   216 
   215 
   217 // ---------------------------------------------------------------------------
   216 // ---------------------------------------------------------------------------
   218 //VisualLayoutUpdated()
   217 //VisualLayoutUpdated()
   239 // --------------------------------------------------------------------------- 
   238 // --------------------------------------------------------------------------- 
   240 // Destructor
   239 // Destructor
   241 // --------------------------------------------------------------------------- 
   240 // --------------------------------------------------------------------------- 
   242 //
   241 //
   243 CGlxCloudViewControl::~CGlxCloudViewControl()
   242 CGlxCloudViewControl::~CGlxCloudViewControl()
   244 
       
   245     {
   243     {
   246     TRACER("GLX_CLOUD::CGlxCloudViewControl::~CGlxCloudViewControl");
   244     TRACER("GLX_CLOUD::CGlxCloudViewControl::~CGlxCloudViewControl");
   247     iCloudInfo.Close ();
   245     iCloudInfo.Close ();
   248     iLabels.Close();
   246     iLabels.Close();
   249     iMediaList.RemoveContext (iAttributeContext);
   247     iMediaList.RemoveContext (iAttributeContext);
   401         }
   399         }
   402 
   400 
   403     GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Exiting layout append");
   401     GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Exiting layout append");
   404     iLayoutIndex = 0;
   402     iLayoutIndex = 0;
   405     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea layout Count realloc  %d ", iLayout->Count ());
   403     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea layout Count realloc  %d ", iLayout->Count ());
   406     for (TInt j = 0; j <= iEndRowIndex; j++)
   404     TInt totalHeight = 0;
       
   405     for (TInt j = 0; j <= iCloudInfo.Count() - 1; j++)
   407         {
   406         {
   408         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Drawing row started  %d ", j);
   407         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Drawing row started  %d ", j);
   409         LayoutVisibleRows (startpoint,iCloudInfo[j].iStartIndex, 
   408         LayoutVisibleRows (startpoint,iCloudInfo[j].iStartIndex, 
   410                 iCloudInfo[j].iEndIndex);
   409                 iCloudInfo[j].iEndIndex);
   411         startpoint.iY += KRowHeight + KNumMinRowSpace;		
   410         startpoint.iY += KRowHeight + KNumMinRowSpace;		
   412         }
   411 
   413     TInt totalHeight = 0;
       
   414     for (TInt j = 0; j <= iCloudInfo.Count()-1; j++)
       
   415         {
       
   416         totalHeight+=KRowHeight;
   412         totalHeight+=KRowHeight;
   417         totalHeight+=KNumMinRowSpace;
   413         totalHeight+=KNumMinRowSpace;
   418         }
   414         }
   419 
   415 
   420     //Set the virtual size of viewport to the total size of anchor.	
   416     //Set the virtual size of viewport to the total size of anchor.	
   459 // --------------------------------------------------------------------------- 
   455 // --------------------------------------------------------------------------- 
   460 // OfferEventL()
   456 // OfferEventL()
   461 // --------------------------------------------------------------------------- 
   457 // --------------------------------------------------------------------------- 
   462 //
   458 //
   463 TBool CGlxCloudViewControl::OfferEventL(const TAlfEvent &aEvent)
   459 TBool CGlxCloudViewControl::OfferEventL(const TAlfEvent &aEvent)
   464     {   TRACER("GLX_CLOUD:: CGlxCloudViewControl::OfferEventL");
   460     {
       
   461     TRACER("GLX_CLOUD:: CGlxCloudViewControl::OfferEventL");
   465 
   462 
   466     //check if key inputs needs handling
   463     //check if key inputs needs handling
   467     TBool consumed = EFalse;
   464     TBool consumed = EFalse;
   468     if ( ( iLabels.Count () == 0 ) ) 
   465     if (iLabels.Count() == 0)
   469         {
   466         {
   470         GLX_LOG_INFO( "GLX_CLOUD ::CGlxCloudViewControl::offerkeyeventL no key press returning  ");
   467         GLX_LOG_INFO( "GLX_CLOUD ::CGlxCloudViewControl::offerkeyeventL no key press returning  ");
   471         return EFalse; //return as no futher processing is required
   468         return EFalse; //return as no futher processing is required
   472         }
   469         }
   473 
   470 
       
   471     if (aEvent.IsKeyEvent() && iTagsContextMenuControl->ItemMenuVisibility())
       
   472         {
       
   473         // Hide the context menu, if visible
       
   474         ShowContextItemMenuL(EFalse);
       
   475         }
       
   476 
   474     if ( aEvent.IsKeyEvent ()&& aEvent.Code() == EEventKey )
   477     if ( aEvent.IsKeyEvent ()&& aEvent.Code() == EEventKey )
   475         {
   478         {
   476         switch (aEvent.KeyEvent().iCode)            
   479         switch (aEvent.KeyEvent().iCode)            
   477             {	
   480             {	
   478             //@ EABI-7R7FRU Fute failure: Tag views enter key has no functionality.
       
   479             case EKeyEnter :
   481             case EKeyEnter :
   480             case EKeyDevice3:
   482             case EKeyDevice3:
   481                 {
   483                 {
   482                 iObserverEnterKeyEvent.HandleEnterKeyEventL( (TInt)EAknCmdOpen );
   484                 if (iShowFocus)
   483                 consumed= ETrue;
   485                     {
       
   486                     iShowFocus = EFalse;
       
   487                     iObserverEnterKeyEvent.HandleEnterKeyEventL(
       
   488                             (TInt) EAknCmdOpen);
       
   489                     }
       
   490                 else
       
   491                     {
       
   492                     SetFocusToFirstVisibleItemL();
       
   493                     }
       
   494                 consumed = ETrue;
   484                 }
   495                 }
   485                 break;
   496                 break;
   486             case EKeyUpArrow:
   497             case EKeyUpArrow:
   487                 {             
   498                 {
   488                 if(iCloudInfo.Count() >1 )
   499                 if (iShowFocus)
   489                     {
   500                     {
   490                     HandleKeyUpL ();
   501                     HandleKeyUpL();
   491                     consumed = ETrue;
   502                     iFocusRowIndex = RowNumber(iMediaList.FocusIndex());
   492                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); 
   503 
   493 
   504                     MoveUpIfRequired();
   494                     MoveUpIfRequired();                   
       
   495                     }
   505                     }
       
   506                 else
       
   507                     {
       
   508                     SetFocusToFirstVisibleItemL();
       
   509                     }
       
   510                 consumed = ETrue;
   496                 }
   511                 }
   497                 break;
   512                 break;
   498 
   513 
   499             case EKeyDownArrow:
   514             case EKeyDownArrow:
   500                 {              
   515                 {
   501                 if (iCloudInfo.Count() > 1)
   516                 if (iShowFocus)
   502                     {
   517                     {
   503                     HandleKeyDownL ();
   518                     HandleKeyDownL();
   504                     consumed = ETrue;
   519                     iFocusRowIndex = RowNumber(iMediaList.FocusIndex());
   505                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
   520 
   506 
   521                     MoveDownIfRequired();
   507                     MoveDownIfRequired();                                 
   522                     }
   508                     }                  
   523                 else
       
   524                     {
       
   525                     SetFocusToFirstVisibleItemL();
       
   526                     }
       
   527                 consumed = ETrue;
   509                 }
   528                 }
   510                 break;
   529                 break;
   511 
   530 
   512             case EKeyLeftArrow:
   531             case EKeyLeftArrow:
   513             case EKeyPrevious:
   532             case EKeyPrevious:
   514                 {
   533                 {
   515                 // arabic hebrew change
   534                 if (iShowFocus)
   516                 if ( GlxGeneralUiUtilities::LayoutIsMirrored () )
       
   517                     {
   535                     {
   518                     if ( iMediaList.FocusIndex() == iMediaList.Count() - 1 )
   536                     // arabic hebrew change
       
   537                     if (GlxGeneralUiUtilities::LayoutIsMirrored())
   519                         {
   538                         {
   520                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
   539                         if (iMediaList.FocusIndex() == iMediaList.Count() - 1)
       
   540                             {
       
   541                             iMediaList.SetFocusL(NGlxListDefs::EAbsolute, 0);
       
   542                             }
       
   543                         else
       
   544                             {
       
   545                             iMediaList.SetFocusL(NGlxListDefs::EAbsolute,
       
   546                                     iMediaList.FocusIndex() + 1);
       
   547                             }
       
   548                         iScrollDirection = 0;
   521                         }
   549                         }
   522                     else
   550                     else
   523                         {
   551                         {
   524                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
   552                         if (iMediaList.FocusIndex() == 0)
   525                                 iMediaList.FocusIndex ()+ 1);
   553                             {
       
   554                             iMediaList.SetFocusL(NGlxListDefs::EAbsolute,
       
   555                                     iMediaList.Count() - 1);
       
   556                             }
       
   557                         else
       
   558                             {
       
   559                             iMediaList.SetFocusL(NGlxListDefs::EAbsolute,
       
   560                                     iMediaList.FocusIndex() - 1);
       
   561                             }
       
   562                         iScrollDirection = 1;
   526                         }
   563                         }
   527                     iScrollDirection = 0;
   564                     TInt focusRowIndex = RowNumber(iMediaList.FocusIndex());
       
   565                     if (iFocusRowIndex != focusRowIndex)
       
   566                         {
       
   567                         iFocusRowIndex = focusRowIndex;
       
   568                         if (iScrollDirection == 0)
       
   569                             {
       
   570                             MoveDownIfRequired();
       
   571                             }
       
   572                         else
       
   573                             {
       
   574                             MoveUpIfRequired();
       
   575                             }
       
   576                         }
   528                     }
   577                     }
   529                 else
   578                 else
   530                     {
   579                     {
   531                     if ( iMediaList.FocusIndex ()== 0 )
   580                     SetFocusToFirstVisibleItemL();
       
   581                     }
       
   582                 consumed = ETrue;
       
   583                 }
       
   584                 break;
       
   585 
       
   586             case EKeyRightArrow:
       
   587             case EKeyNext:
       
   588                 {
       
   589                 if (iShowFocus)
       
   590                     {
       
   591                     // arabic hebrew change
       
   592                     if (GlxGeneralUiUtilities::LayoutIsMirrored())
   532                         {
   593                         {
   533                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
   594                         if (iMediaList.FocusIndex() == 0)
   534                                 iMediaList.Count() - 1 );
   595                             {
       
   596                             iMediaList.SetFocusL(NGlxListDefs::EAbsolute,
       
   597                                     iMediaList.Count() - 1);
       
   598                             }
       
   599                         else
       
   600                             {
       
   601                             iMediaList.SetFocusL(NGlxListDefs::EAbsolute,
       
   602                                     iMediaList.FocusIndex() - 1);
       
   603                             }
       
   604                         iScrollDirection = 1;
   535                         }
   605                         }
   536                     else
   606                     else
   537                         {
   607                         {
   538                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
   608                         if (iMediaList.FocusIndex() == iMediaList.Count() - 1)
   539                                 iMediaList.FocusIndex ()- 1);
   609                             {
       
   610                             iMediaList.SetFocusL(NGlxListDefs::EAbsolute, 0);
       
   611                             }
       
   612                         else
       
   613                             {
       
   614                             iMediaList.SetFocusL(NGlxListDefs::EAbsolute,
       
   615                                     iMediaList.FocusIndex() + 1);
       
   616                             }
       
   617                         iScrollDirection = 0;
   540                         }
   618                         }
   541                     iScrollDirection = 1;
   619                     TInt focusRowIndex = RowNumber(iMediaList.FocusIndex());
   542                     }
   620 
   543                 consumed = ETrue;
   621                     if (iFocusRowIndex != focusRowIndex)
   544                 TInt focusRowIndex = RowNumber (iMediaList.FocusIndex ());
   622                         {
   545                 if(iFocusRowIndex != focusRowIndex)
   623                         iFocusRowIndex = focusRowIndex;
   546                     {
   624                         if (iScrollDirection == 1)
   547                     iFocusRowIndex = focusRowIndex; 
   625                             {
   548                     if( iScrollDirection == 0 )
   626                             MoveUpIfRequired();
   549                         {                      
   627                             }
   550                         MoveDownIfRequired();
   628                         else
       
   629                             {
       
   630                             MoveDownIfRequired();
       
   631                             }
   551                         }
   632                         }
   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                     }
   633                     }
   579                 else
   634                 else
   580                     {
   635                     {
   581                     if ( iMediaList.FocusIndex ()== iMediaList.Count() - 1 )
   636                     SetFocusToFirstVisibleItemL();
   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                     }
   637                     }
   592                 TInt focusRowIndex = RowNumber (iMediaList.FocusIndex ());
   638                 consumed = ETrue;
   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                 }
   639                 }
   607                 consumed = ETrue;
       
   608                 break;
   640                 break;
   609 
   641 
   610             default:
   642             default:
   611                 break;
   643                 break;
   612             }
   644             }
   678 //
   710 //
   679 void CGlxCloudViewControl::HandleLayoutFocusChange()
   711 void CGlxCloudViewControl::HandleLayoutFocusChange()
   680     {
   712     {
   681     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleLayoutFocusChange");
   713     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleLayoutFocusChange");
   682 
   714 
   683     if ( iLabels.Count()-1 >= iMediaList.FocusIndex())
   715     if ((iShowFocus || !iUiUtility->IsPenSupported()) && (iLabels.Count() - 1
       
   716             >= iMediaList.FocusIndex()))
   684         {
   717         {
   685         //to highlight focused element 
   718         //to highlight focused element 
   686         SetFocusColor(); 
   719         SetFocusColor(); 
   687         }
   720         }
   688     }
   721     }
   692 // --------------------------------------------------------------------------- 
   725 // --------------------------------------------------------------------------- 
   693 //
   726 //
   694 void CGlxCloudViewControl::FocusUpdate()
   727 void CGlxCloudViewControl::FocusUpdate()
   695     {
   728     {
   696     TRACER("GLX_CLOUD::CGlxCloudViewControl::FocusUpdate");
   729     TRACER("GLX_CLOUD::CGlxCloudViewControl::FocusUpdate");
   697     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::FocusUpdate HighLighted RowNum  %d ",iFocusRowIndex);
   730     iFocusRowIndex = RowNumber(iMediaList.FocusIndex());
   698     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::FocusUpdate End RowNumn %d ",iCloudInfo.Count()-1);
   731     GLX_LOG_INFO1("GLX_CLOUD::FocusUpdate iFocusRowIndex=%d", 
   699     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
   732             iFocusRowIndex);
   700     iEndRowIndex = iCloudInfo.Count()-1;
       
   701     LayoutVisibleArea();
   733     LayoutVisibleArea();
   702     }
   734     }
   703 
   735 
   704 // --------------------------------------------------------------------------- 
   736 // --------------------------------------------------------------------------- 
   705 // ResetLayout()
   737 // ResetLayout()
   794     if (iAttributeContext->RequestCountL(aList) == 0 )
   826     if (iAttributeContext->RequestCountL(aList) == 0 )
   795         {
   827         {
   796         //reset the layout and get the items from cache
   828         //reset the layout and get the items from cache
   797         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.
   829         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.
   798         iCloudInfo.Close (); //row information is reset
   830         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         }
   831         }
   804 
   832 
   805     InitPhysicsL();
   833     InitPhysicsL();
   806     }
   834     }
   807 
   835 
   885         {
   913         {
   886         //get the new array contents from cache.no need to reset the array as the number
   914         //get the new array contents from cache.no need to reset the array as the number
   887         //of items in array will remain same.
   915         //of items in array will remain same.
   888         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.        
   916         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.        
   889         FetchAttributeFromCacheL();
   917         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 ())
   918         if ( iUiUtility->ViewNavigationDirection ()== EGlxNavigationForwards && iMediaList.Count ())
   893             {
   919             {
   894             iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
   920             iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
   895             }
   921             }
   896         //generate row structures and draw rows on screen
   922         //generate row structures and draw rows on screen
  1069         AppendToCloudArrayL( cloudInfo,lastRowStartTagIndex, KLabelsCount - 1 );
  1095         AppendToCloudArrayL( cloudInfo,lastRowStartTagIndex, KLabelsCount - 1 );
  1070         }
  1096         }
  1071 
  1097 
  1072     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iCloudInfo.count loop exit  %d ", iCloudInfo.Count());
  1098     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iCloudInfo.count loop exit  %d ", iCloudInfo.Count());
  1073     FocusUpdate (); //Start screen drawing 
  1099     FocusUpdate (); //Start screen drawing 
  1074 
       
  1075     iEndRowIndex = iCloudInfo.Count()-1;
       
  1076     }
  1100     }
  1077 
  1101 
  1078 // ---------------------------------------------------------------------------
  1102 // ---------------------------------------------------------------------------
  1079 // SetProperties
  1103 // SetProperties
  1080 // ---------------------------------------------------------------------------
  1104 // ---------------------------------------------------------------------------
  1233         }
  1257         }
  1234     return usageCount;
  1258     return usageCount;
  1235     }
  1259     }
  1236 
  1260 
  1237 // ---------------------------------------------------------------------------
  1261 // ---------------------------------------------------------------------------
  1238 // SetFocusColor()
  1262 // AppendToCloudArrayL()
  1239 // ---------------------------------------------------------------------------
  1263 // ---------------------------------------------------------------------------
  1240 //
  1264 //
  1241 void CGlxCloudViewControl::AppendToCloudArrayL( 
  1265 void CGlxCloudViewControl::AppendToCloudArrayL(TGlxCloudInfo& aCloudInfo,
  1242         TGlxCloudInfo& aCloudInfo,const TInt& aStartIndex, const TInt& aEndIndex )
  1266         const TInt& aStartIndex, const TInt& aEndIndex)
  1243     {
  1267     {
  1244     TRACER("GLX_CLOUD::CGlxCloudViewControl::AppendToCloudArrayL");
  1268     TRACER("GLX_CLOUD::CGlxCloudViewControl::AppendToCloudArrayL");
  1245     aCloudInfo.iStartIndex = aStartIndex;
  1269     aCloudInfo.iStartIndex = aStartIndex;
  1246     aCloudInfo.iEndIndex = aEndIndex; 
  1270     aCloudInfo.iEndIndex = aEndIndex; 
  1247     iCloudInfo.AppendL( aCloudInfo );
  1271     iCloudInfo.AppendL( aCloudInfo );
  1249 
  1273 
  1250 // ---------------------------------------------------------------------------
  1274 // ---------------------------------------------------------------------------
  1251 // SetFocusColor()
  1275 // SetFocusColor()
  1252 // ---------------------------------------------------------------------------
  1276 // ---------------------------------------------------------------------------
  1253 //
  1277 //
  1254 void  CGlxCloudViewControl::SetFocusColor()
  1278 void CGlxCloudViewControl::SetFocusColor()
  1255     {
  1279     {
  1256     iLabels[iMediaList.FocusIndex()]->SetColor (KAknsIIDQsnHighlightColors ,EAknsCIQsnHighlightColorsCG3); 
  1280     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetFocusColor");
  1257     }
  1281     if (iMediaList.Count())
  1258 
  1282         {
  1259 // ---------------------------------------------------------------------------
  1283         iLabels[iMediaList.FocusIndex()]->SetColor(
  1260 // SetBubleMidPoint()
  1284                 KAknsIIDQsnHighlightColors, EAknsCIQsnHighlightColorsCG3);
  1261 // ---------------------------------------------------------------------------
  1285         }
  1262 //
  1286     }
  1263 void  CGlxCloudViewControl::SetBubleMidPoint(TPoint& aMidPoint)
  1287 
  1264     {
  1288 // ---------------------------------------------------------------------------
  1265     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetBubleMidPoint");
  1289 // ResetFocusColor()
  1266     //Substract the viewport position so as to set the buble at the right position on the screen     
  1290 // ---------------------------------------------------------------------------
  1267     aMidPoint.iX-=iViewPortPosition.iX;
  1291 //
  1268     aMidPoint.iY-=iViewPortPosition.iY;
  1292 void CGlxCloudViewControl::ResetFocusColor()
       
  1293     {
       
  1294     TRACER("GLX_CLOUD::CGlxCloudViewControl::ResetFocusColor");
       
  1295     if (iMediaList.Count())
       
  1296         {
       
  1297         iLabels[iMediaList.FocusIndex()]->SetColor(KAknsIIDQsnTextColors,
       
  1298                 EAknsCIQsnTextColorsCG6);
       
  1299         }
  1269     }
  1300     }
  1270 
  1301 
  1271 // ---------------------------------------------------------------------------
  1302 // ---------------------------------------------------------------------------
  1272 // MoveUpIfRequired()
  1303 // MoveUpIfRequired()
  1273 // ---------------------------------------------------------------------------
  1304 // ---------------------------------------------------------------------------
  1274 //
  1305 //
  1275 void CGlxCloudViewControl::MoveUpIfRequired()
  1306 void CGlxCloudViewControl::MoveUpIfRequired()
  1276     {
  1307     {
  1277     TRACER("GLX_CLOUD::CGlxCloudViewControl::MoveUpIfRequired");
  1308     TRACER("GLX_CLOUD::CGlxCloudViewControl::MoveUpIfRequired");
       
  1309     TInt focusIndex = iMediaList.FocusIndex();
       
  1310 
  1278     //get the focused item's position
  1311     //get the focused item's position
  1279     TPoint point;
  1312     TPoint point;
  1280     iLayout->ChildPos(iMediaList.FocusIndex(),point);
  1313     iLayout->ChildPos(focusIndex,point);
  1281     TSize size;
  1314     TSize size;
  1282     iLayout->ChildSize(iMediaList.FocusIndex(),size);
  1315     iLayout->ChildSize(focusIndex,size);
  1283     TInt focus = iMediaList.FocusIndex();
  1316 
  1284     TInt rownumber = RowNumber(focus);
  1317     TInt rownumber = RowNumber(focusIndex);
  1285     //if the focused item is not visible then move the viewport
  1318     //if the focused item is not visible then move the viewport
  1286     if(point.iY < iViewPortPosition.iY)         
  1319     if(point.iY < iViewPortPosition.iY)         
  1287         { 
  1320         { 
  1288         //set the new position of viewport
  1321         //set the new position of viewport
  1289         TInt offeset = iViewPortPosition.iY - point.iY;
  1322         TInt offset = iViewPortPosition.iY - point.iY;
  1290         iViewPortPosition.iY-=offeset;
  1323         iViewPortPosition.iY-=offset;
  1291         if( (iViewPortPosition.iY < 0) )
  1324         if( (iViewPortPosition.iY < 0) )
  1292             {
  1325             {
  1293             iViewPortPosition.iY = 0;
  1326             iViewPortPosition.iY = 0;
  1294             }   
  1327             }   
  1295         }    
  1328         }    
  1307 // MoveDownIfRequired()
  1340 // MoveDownIfRequired()
  1308 // ---------------------------------------------------------------------------
  1341 // ---------------------------------------------------------------------------
  1309 //
  1342 //
  1310 void CGlxCloudViewControl::MoveDownIfRequired()
  1343 void CGlxCloudViewControl::MoveDownIfRequired()
  1311     {
  1344     {
  1312     TRACER("GLX_CLOUD::CGlxCloudViewControl::MoveDownIfRequired");  
  1345     TRACER("GLX_CLOUD::CGlxCloudViewControl::MoveDownIfRequired");
       
  1346     TInt focusIndex = iMediaList.FocusIndex();
       
  1347 
  1313     //get the focused item's position
  1348     //get the focused item's position
  1314     TPoint point;
  1349     TPoint point;
  1315     iLayout->ChildPos(iMediaList.FocusIndex(),point);
  1350     iLayout->ChildPos(focusIndex, point);
  1316     TSize size;
  1351     TSize size;
  1317     iLayout->ChildSize(iMediaList.FocusIndex(),size);
  1352     iLayout->ChildSize(focusIndex, size);
  1318     //if the focused visual is not visible then move the viewport 
  1353 
  1319     if(point.iY+size.iHeight > iViewPortPosition.iY+iViewPortSize.iHeight )
  1354     //Reset viewport position for cases:
  1320         { 
  1355     //case 1)Focus index is first item
  1321         //set the new position of viewport
  1356     if (focusIndex == 0)
  1322         TInt offeset = (point.iY+size.iHeight) - (iViewPortPosition.iY+iViewPortSize.iHeight);
  1357         {
  1323         iViewPortPosition.iY+=offeset;
  1358 		iViewPortPosition.iY = 0;
  1324         if( (iViewPortPosition.iY > iViewPortVirtualSize.iHeight) )
  1359 		}
  1325             {
  1360     //case 2)Focused item is in last screen
  1326             iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
  1361     else if( point.iY > (iViewPortVirtualSize.iHeight - iViewPortSize.iHeight))
  1327             } 
  1362         {
  1328         }
  1363         iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
  1329     //if its key event then it should be cyclic
  1364         }
  1330     else if (iMediaList.FocusIndex() == 0)
  1365     else
  1331         {
  1366         {
  1332         iViewPortPosition.iY = 0;
  1367         iViewPortPosition.iY = point.iY + KNumMinRowSpace;
  1333         }     
  1368         }
       
  1369 
       
  1370     //Validate the viewport position
       
  1371     if ((iViewPortPosition.iY > iViewPortVirtualSize.iHeight))
       
  1372         {
       
  1373 		iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
       
  1374         }
       
  1375 
       
  1376     GLX_LOG_INFO1("GLX_CLOUD::MoveDownIfRequired() iViewPortPosition.iY:%d",
       
  1377             iViewPortPosition.iY);
  1334     iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement);
  1378     iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement);
  1335     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
  1379     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
  1336     if(iScrollBarWidget)
  1380     if(iScrollBarWidget)
  1337         {
  1381         {
  1338         Scroll();           
  1382         Scroll();
  1339         }
  1383         }
  1340     }     
  1384     }
  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 
  1385 
  1384 // ---------------------------------------------------------------------------
  1386 // ---------------------------------------------------------------------------
  1385 // HandlePointerEventL()
  1387 // HandlePointerEventL()
  1386 // ---------------------------------------------------------------------------
  1388 // ---------------------------------------------------------------------------
  1387 //  
  1389 //
  1388 TBool CGlxCloudViewControl::HandlePointerEventL( const TAlfEvent &aEvent )
  1390 TBool CGlxCloudViewControl::HandlePointerEventL( const TAlfEvent &aEvent )
  1389     {
  1391     {
  1390     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandlePointerEventL");
  1392     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandlePointerEventL");
  1391     CAlfVisual* tappedvisual = aEvent.Visual();	
  1393     CAlfVisual* tappedvisual = aEvent.Visual();	
  1392     TBool consumed = EFalse;
  1394     TBool consumed = EFalse;
  1420                 //if the tapped visual is same as the visual in the layout then focus that visual
  1422                 //if the tapped visual is same as the visual in the layout then focus that visual
  1421                 if(layoutvisual == tappedvisual)
  1423                 if(layoutvisual == tappedvisual)
  1422                     {
  1424                     {
  1423                     iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
  1425                     iTouchFeedback->InstantFeedback(ETouchFeedbackBasic);
  1424                     iMediaList.SetFocusL (NGlxListDefs::EAbsolute, index);
  1426                     iMediaList.SetFocusL (NGlxListDefs::EAbsolute, index);
       
  1427                     iShowFocus = ETrue;
       
  1428                     HandleLayoutFocusChange();
  1425 
  1429 
  1426                     //Start the timer to interpret longpress events
  1430                     //Start the timer to interpret longpress events
  1427                     iTimerComplete = EFalse;
  1431                     iTimerComplete = EFalse;
  1428                     iTimer->Cancel ();//cancels any outstanding requests
  1432                     iTimer->Cancel ();//cancels any outstanding requests
  1429                     iTimer->SetDelay (KLongPressTimer);
  1433                     iTimer->SetDelay (KLongPressTimer);
  1442 
  1446 
  1443         consumed = HandleDragL(aEvent.PointerEvent());
  1447         consumed = HandleDragL(aEvent.PointerEvent());
  1444         }
  1448         }
  1445     else if (iDownEventReceived && aEvent.PointerUp())
  1449     else if (iDownEventReceived && aEvent.PointerUp())
  1446         {
  1450         {
       
  1451         if (!iTagsContextMenuControl->ItemMenuVisibility())
       
  1452             {
       
  1453             iShowFocus = EFalse;
       
  1454             ResetFocusColor();
       
  1455             }
       
  1456 
  1447         iDownEventReceived = EFalse;
  1457         iDownEventReceived = EFalse;
  1448         Display()->Roster().SetPointerEventObservers(0, *this);
  1458         Display()->Roster().SetPointerEventObservers(0, *this);
  1449         consumed = ETrue;
  1459         consumed = ETrue;
  1450         
  1460         
  1451         //If the long press timer is completed , and if upevent is received.. ignore it
  1461         //If the long press timer is completed , and if upevent is received.. ignore it
  1475                 if (layoutvisual == tappedvisual)
  1485                 if (layoutvisual == tappedvisual)
  1476                     {
  1486                     {
  1477                     TInt focus = iMediaList.FocusIndex();
  1487                     TInt focus = iMediaList.FocusIndex();
  1478                     if (index != focus)
  1488                     if (index != focus)
  1479                         {
  1489                         {
  1480                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
       
  1481                         TInt focusrowindex = iFocusRowIndex;
  1490                         TInt focusrowindex = iFocusRowIndex;
  1482                         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index);
  1491                         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index);
  1483                         SetFocusColor();
       
  1484                         iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
  1492                         iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
  1485                         
  1493                         
  1486                         if( iFocusRowIndex > focusrowindex)
  1494                         if( iFocusRowIndex > focusrowindex)
  1487                             {
  1495                             {
  1488                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
  1496                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
  1747         }
  1755         }
  1748     return false;
  1756     return false;
  1749     }
  1757     }
  1750 
  1758 
  1751 // ---------------------------------------------------------------------------
  1759 // ---------------------------------------------------------------------------
  1752 // attachScrollBar()
  1760 // InitializeScrollBar()
  1753 // ---------------------------------------------------------------------------
  1761 // ---------------------------------------------------------------------------
  1754 //	
  1762 //
  1755 void CGlxCloudViewControl::InitializeScrollBar(IAlfScrollBarWidget* aScrollBarWidget)
  1763 void CGlxCloudViewControl::InitializeScrollBar(
       
  1764         IAlfScrollBarWidget* aScrollBarWidget)
  1756     {
  1765     {
  1757     TRACER("GLX_CLOUD::CGlxCloudViewControl::InitializeScrollBar");
  1766     TRACER("GLX_CLOUD::CGlxCloudViewControl::InitializeScrollBar");
  1758     iScrollBarWidget = aScrollBarWidget;
  1767     iScrollBarWidget = aScrollBarWidget;
  1759     ((IAlfScrollBarModel *) (iScrollBarWidget->model()))->initializeData(
  1768     ((IAlfScrollBarModel *) (iScrollBarWidget->model()))->initializeData(
  1760             iScrollEventData.mSpan, iScrollEventData.mViewLength, 0);
  1769             iScrollEventData.mSpan, iScrollEventData.mViewLength, 0);
       
  1770     Scroll();
  1761     DisplayScrollBar();
  1771     DisplayScrollBar();
  1762     }
  1772     }
  1763 
  1773 
  1764 // ---------------------------------------------------------------------------
  1774 // ---------------------------------------------------------------------------
  1765 // Scroll()
  1775 // Scroll()
  1812 
  1822 
  1813 // ---------------------------------------------------------------------------
  1823 // ---------------------------------------------------------------------------
  1814 // DisplayScrollBar()
  1824 // DisplayScrollBar()
  1815 // ---------------------------------------------------------------------------
  1825 // ---------------------------------------------------------------------------
  1816 //
  1826 //
  1817 void CGlxCloudViewControl::DisplayScrollBar() 
  1827 void CGlxCloudViewControl::DisplayScrollBar()
  1818     {
  1828     {
       
  1829     TRACER("GLX_CLOUD::CGlxCloudViewControl::DisplayScrollBar()");
  1819     if (iScrollBarWidget)
  1830     if (iScrollBarWidget)
  1820         {
  1831         {
  1821         IAlfElement* vertBaseElement =(iScrollBarWidget->control()->findElement ("BaseElement"));
  1832         IAlfElement* vertBaseElement =(iScrollBarWidget->control()->findElement ("BaseElement"));
  1822         IAlfScrollBarDefaultBaseElement* scrollbarbaselement=static_cast<IAlfScrollBarDefaultBaseElement*> (
  1833         IAlfScrollBarDefaultBaseElement* scrollbarbaselement=static_cast<IAlfScrollBarDefaultBaseElement*> (
  1823             vertBaseElement->makeInterface (IAlfScrollBarDefaultBaseElement::type() ) );
  1834             vertBaseElement->makeInterface (IAlfScrollBarDefaultBaseElement::type() ) );
  1824 
  1835 
  1825         // To set the scrollbar visibility, it's enough to set the opacity 
  1836         TInt totalHeight = 0;
  1826         // of baselayout. No need to set the opacity of thumb separately. 
  1837         for (TInt index = 0; index <= iCloudInfo.Count() - 1; index++)
  1827         if (iScrollEventData.mSpan)
  1838             {
       
  1839             totalHeight += KRowHeight;
       
  1840             totalHeight += KNumMinRowSpace;
       
  1841             }
       
  1842 
       
  1843         // To set the scrollbar visibility, it's enough to set the opacity
       
  1844         // of baselayout. No need to set the opacity of thumb separately.
       
  1845         // Set the scrollbar visibility only
       
  1846         // when visuals height exceeds the screen height
       
  1847         if (iScrollEventData.mSpan && totalHeight > iTagScreenHeight)
  1828             {
  1848             {
  1829             //make scroll bar visible
  1849             //make scroll bar visible
       
  1850             GLX_LOG_INFO("GLX_CLOUD: Make scrollbar visible!");
  1830             scrollbarbaselement->setOpacity(1.0);
  1851             scrollbarbaselement->setOpacity(1.0);
  1831             }
  1852             }
  1832         else
  1853         else
  1833             {
  1854             {
  1834             //make scroll bar invisible
  1855             //make scroll bar invisible
  1962                     ((focussedItemRect.iBr.iY - focussedItemRect.iTl.iY )/2); 
  1983                     ((focussedItemRect.iBr.iY - focussedItemRect.iTl.iY )/2); 
  1963     
  1984     
  1964     TRect rect;
  1985     TRect rect;
  1965     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
  1986     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
  1966     
  1987     
  1967     if(!iPhysicsStarted)//only if physics hasnt started
  1988     //only if not dragged and physics hasnt started
       
  1989     if (!iPhysicsStarted && !iViewDragged)
  1968         {
  1990         {
  1969         iTagsContextMenuControl->SetViewableRect(rect);
  1991         iTagsContextMenuControl->SetViewableRect(rect);
  1970         iTagsContextMenuControl->ShowItemMenuL(ETrue);
  1992         iTagsContextMenuControl->ShowItemMenuL(ETrue);
  1971         iTagsContextMenuControl->SetDisplay(midpoint);
  1993         iTagsContextMenuControl->SetDisplay(midpoint);
  1972         }
  1994         }
  1976 // ShowContextItemMenuL()
  1998 // ShowContextItemMenuL()
  1977 // ---------------------------------------------------------------------------
  1999 // ---------------------------------------------------------------------------
  1978 //
  2000 //
  1979 void CGlxCloudViewControl::ShowContextItemMenuL(TBool aShow)
  2001 void CGlxCloudViewControl::ShowContextItemMenuL(TBool aShow)
  1980     {
  2002     {
       
  2003     TRACER("GLX_CLOUD::ShowContextItemMenuL");
       
  2004     GLX_LOG_INFO1("GLX_CLOUD::ShowContextItemMenuL() aShow=%d", aShow);
  1981     iTagsContextMenuControl->ShowItemMenuL(aShow);
  2005     iTagsContextMenuControl->ShowItemMenuL(aShow);
  1982     if(!aShow)
  2006     if(!aShow)
  1983         {
  2007         {
  1984         iViewPortLayout->UpdateChildrenLayout(0);
  2008         iViewPortLayout->UpdateChildrenLayout(0);
       
  2009         iShowFocus = EFalse;
       
  2010         ResetFocusColor();
       
  2011         }
       
  2012     }
       
  2013 
       
  2014 // ---------------------------------------------------------------------------
       
  2015 // SetFocusToFirstVisibleItemL()
       
  2016 // ---------------------------------------------------------------------------
       
  2017 //
       
  2018 void CGlxCloudViewControl::SetFocusToFirstVisibleItemL()
       
  2019     {
       
  2020     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetFocusToFirstVisibleItemL()");
       
  2021     iShowFocus = ETrue;
       
  2022 
       
  2023     TInt visIndex = GetAbsoluteIndex(TPoint(KLeftMargin + KLeftMargin,
       
  2024             KColSpace));
       
  2025     GLX_LOG_INFO1("GLX_CLOUD::SetFocusToFirstVisibleItemL() visIndex=%d", visIndex);
       
  2026 
       
  2027     if (visIndex != KErrNotFound)
       
  2028         {
       
  2029         iMediaList.SetFocusL(NGlxListDefs::EAbsolute, visIndex);
       
  2030 
       
  2031         MoveUpIfRequired();
       
  2032         }
       
  2033     else
       
  2034         {
       
  2035         HandleLayoutFocusChange();
  1985         }
  2036         }
  1986     }
  2037     }
  1987 
  2038 
  1988 //End of file
  2039 //End of file