photosgallery/viewframework/views/zoomview/src/glxzoomcontrol.cpp
branchRCL_3
changeset 12 ce1c7ad1f18b
parent 11 71da52165949
child 13 bcb43dc84c44
equal deleted inserted replaced
11:71da52165949 12:ce1c7ad1f18b
    56 const TReal KGlxOpacityOpaque = 1.0;
    56 const TReal KGlxOpacityOpaque = 1.0;
    57 const TInt KGlxMaxExifSize = 0x10000;   
    57 const TInt KGlxMaxExifSize = 0x10000;   
    58 const TReal KGlxOpacityTransparent = 0.0;
    58 const TReal KGlxOpacityTransparent = 0.0;
    59 //zoom delay for animation while hdmi cable,
    59 //zoom delay for animation while hdmi cable,
    60 //is connected and zoom is initiated
    60 //is connected and zoom is initiated
    61 const TInt KZoomDelay = 150000; 
    61 const TInt KHDMIZoomDelay = 250000; 
    62 //Zoom level for the animation , assuming the innitial level is 1.
    62 //Zoom level for the animation , assuming the innitial level is 1.
    63 const TReal KGlxZoomLevel = 1.5;
    63 const TReal KGlxZoomLevel = 1.5;
    64 const TInt KGlxMinSmallImageZoomLevel =100;
    64 const TInt KGlxMinSmallImageZoomLevel =100;
    65 
    65 
    66 const TInt KGlxDecodingThreshold = 3000000; // pixels
    66 const TInt KGlxDecodingThreshold = 3000000; // pixels
   275 EXPORT_C void CGlxZoomControl::ActivateL(TInt aInitialZoomRatio, TZoomStartMode aStartMode, 
   275 EXPORT_C void CGlxZoomControl::ActivateL(TInt aInitialZoomRatio, TZoomStartMode aStartMode, 
   276         TInt aFocusIndex, TGlxMedia& aItem, TPoint* aZoomFocus,TBool aViewingMode)
   276         TInt aFocusIndex, TGlxMedia& aItem, TPoint* aZoomFocus,TBool aViewingMode)
   277     {
   277     {
   278     TRACER("CGlxZoomControl::ActivateL()");
   278     TRACER("CGlxZoomControl::ActivateL()");
   279 
   279 
   280     //To know if HDMi cable is connected.
       
   281     if ( !iZoomActive )
   280     if ( !iZoomActive )
   282         {
   281         {
   283         //This Varaiable updates that we are in zoom state now.
       
   284         iZoomActive = ETrue;
       
   285         //To Retrive the image details
   282         //To Retrive the image details
   286         TMPXAttribute thumbNailAttribute(0,0);
   283         TMPXAttribute thumbNailAttribute(0,0);
   287 
   284 
   288         TGlxIdSpaceId idspace = iMediaList.IdSpaceId( aFocusIndex );
   285         TGlxIdSpaceId idspace = iMediaList.IdSpaceId( aFocusIndex );
   289         //Get the texture Created in fullscreen View.
   286         //Get the texture Created in fullscreen View.
   290         iImageTexture = &(iTextureMgr->CreateNewTextureForMediaL(
   287         iImageTexture = &(iTextureMgr->CreateNewTextureForMediaL(
   291                 ScreenSize(),aItem, idspace, this ));
   288                 ScreenSize(),aItem, idspace, this ));
   292         iImageVisual->SetImage(*iImageTexture);
   289         iImageVisual->SetImage(*iImageTexture);
   293         
   290         
   294         
       
   295         if(iGlxTvOut->IsHDMIConnected()&& !aViewingMode )
   291         if(iGlxTvOut->IsHDMIConnected()&& !aViewingMode )
   296             {
   292             {
   297             StartZoomAnimation();
   293             StartZoomAnimation(aStartMode);
   298             }
   294             }
   299         else
   295         else
   300             {
   296             {
   301             ShowZoom(ETrue);
   297             ShowZoom(ETrue);
   302             iZoomSliderWidget.AddEventHandler(*this);
   298             iZoomSliderWidget.AddEventHandler(*this);
   345                     {
   341                     {
   346                     cba->ActivateL();
   342                     cba->ActivateL();
   347                     }
   343                     }
   348                 }
   344                 }
   349             }
   345             }
       
   346         // Now the zoom activation process is complete.
       
   347         // Now is when truly zoom is active. 
       
   348         iZoomActive = ETrue;
   350         }
   349         }
   351     }
   350     }
   352 // ---------------------------------------------------------------------------
   351 // ---------------------------------------------------------------------------
   353 // StartZoomAnimation
   352 // StartZoomAnimation
   354 // ---------------------------------------------------------------------------
   353 // ---------------------------------------------------------------------------
   355 // 
   354 // 
   356 void CGlxZoomControl::StartZoomAnimation()
   355 void CGlxZoomControl::StartZoomAnimation(TZoomStartMode aStartMode)
   357     {
   356     {
   358     TRACER("CGlxZoomControl::StartZoomAnimation()");
   357     TRACER("CGlxZoomControl::StartZoomAnimation()");
   359     iZoomIn = ETrue;
   358     iZoomIn = ETrue;
   360     //Set zoom visible but not enable the gesturehelper events    
   359     //Set zoom visible but not enable the gesturehelper events    
   361     iViewPort->SetOpacity(KGlxOpacityOpaque);  
   360     iViewPort->SetOpacity(KGlxOpacityOpaque);    
   362     TAlfTimedValue timedvalue;
   361     TAlfTimedValue timedvalue;
   363     //using KGlxOpacityOpaque for the value 1 , assuming the initial zoom level as 1.
   362     //using KGlxOpacityOpaque for the value 1 , assuming the initial zoom level as 1.
   364     timedvalue.SetValueNow(KGlxOpacityOpaque); 
   363     timedvalue.SetValueNow(KGlxOpacityOpaque); 
   365     timedvalue.SetTarget(KGlxZoomLevel,KZoomDelay/1000);    
   364     timedvalue.SetTarget(KGlxZoomLevel,KHDMIZoomDelay/1000);    
   366     iImageVisual->SetScale(timedvalue);
   365     iImageVisual->SetScale(timedvalue);
   367     iTimer->Cancel();
   366     
   368     iTimer->Start(KZoomDelay,KZoomDelay,TCallBack( TimeOut,this ));
   367     //If zoom is not done using pinch, zoom out with the rubber effect
       
   368     //Else wait for the gesture helper event for zooming out.
       
   369     if(aStartMode != EZoomStartPinch)
       
   370         {
       
   371         iTimer->Cancel();
       
   372         iTimer->Start(KHDMIZoomDelay,KHDMIZoomDelay,TCallBack( TimeOut,this ));
       
   373         }
       
   374     else
       
   375         {
       
   376         iGestureHelper->AddObserver(this);
       
   377         }
   369     }
   378     }
   370 // ---------------------------------------------------------------------------
   379 // ---------------------------------------------------------------------------
   371 // TimeOut
   380 // TimeOut
   372 // ---------------------------------------------------------------------------
   381 // ---------------------------------------------------------------------------
   373 //  
   382 //  
   391     if(iZoomIn)
   400     if(iZoomIn)
   392         {
   401         {
   393         iZoomIn = EFalse;
   402         iZoomIn = EFalse;
   394         TAlfTimedValue timedvalue;
   403         TAlfTimedValue timedvalue;
   395         timedvalue.SetValueNow(KGlxZoomLevel);
   404         timedvalue.SetValueNow(KGlxZoomLevel);
   396         timedvalue.SetTarget(KGlxOpacityOpaque,KZoomDelay/1000);
   405         timedvalue.SetTarget(KGlxOpacityOpaque,KHDMIZoomDelay/1000);
   397         iImageVisual->SetScale(timedvalue);
   406         iImageVisual->SetScale(timedvalue);
   398         }
   407         }
   399     else
   408     else
   400         {
   409         {
   401         if(iTimer->IsActive())
   410         if(iTimer->IsActive())
   588 //
   597 //
   589 void CGlxZoomControl::VisualLayoutUpdated(CAlfVisual& aVisual)
   598 void CGlxZoomControl::VisualLayoutUpdated(CAlfVisual& aVisual)
   590     {
   599     {
   591     TRACER("CGlxZoomControl::VisualLayoutUpdated ");
   600     TRACER("CGlxZoomControl::VisualLayoutUpdated ");
   592     // Callback comes to this function when there is a  resolution change
   601     // Callback comes to this function when there is a  resolution change
       
   602     
       
   603     if(iGlxTvOut->IsHDMIConnected())
       
   604         {
       
   605         return;
       
   606         }
       
   607     
   593     TRect rect;
   608     TRect rect;
   594     rect = AlfUtil::ScreenSize();
   609     rect = AlfUtil::ScreenSize();
   595     if ( (rect.Width() != iScreenSize.iWidth) && ( rect.Height() != iScreenSize.iHeight) && (Activated()) )
   610     if ( (rect.Width() != iScreenSize.iWidth) && ( rect.Height() != iScreenSize.iHeight) && (Activated()) )
   596         {
   611         {
   597         //notify slider about Orientation Change
   612         //notify slider about Orientation Change
   807     iCommandHandler.HandleCommandL(aCommandId, this);
   822     iCommandHandler.HandleCommandL(aCommandId, this);
   808     }
   823     }
   809 
   824 
   810 
   825 
   811 // -----------------------------------------------------------------------------
   826 // -----------------------------------------------------------------------------
       
   827 // HandleHDMIGestureReleased
       
   828 // -----------------------------------------------------------------------------
       
   829 //
       
   830 void CGlxZoomControl::HandleHDMIGestureReleased()
       
   831     {
       
   832     TRACER("void CGlxZoomControl::HandlePinchReleased");
       
   833     if ( iGlxTvOut->IsHDMIConnected() && iZoomActive)
       
   834         {
       
   835         //On HDMI pinch release, zoom out to fullscreen
       
   836         GLX_LOG_INFO("_PHOTOS_LOG_: void CGlxZoomControl::HandlePinchReleased Start ZoomOut");
       
   837         iTimer->Cancel();
       
   838         iTimer->Start(KHDMIZoomDelay,KHDMIZoomDelay,TCallBack( TimeOut,this ));
       
   839         }
       
   840     }
       
   841 
       
   842 // -----------------------------------------------------------------------------
   812 // HandlePointerEventsL
   843 // HandlePointerEventsL
   813 // -----------------------------------------------------------------------------
   844 // -----------------------------------------------------------------------------
   814 //
   845 //
   815 TBool CGlxZoomControl::HandlePointerEventsL(const TAlfEvent &aEvent)
   846 TBool CGlxZoomControl::HandlePointerEventsL(const TAlfEvent &aEvent)
   816     {
   847     {
   828     {
   859     {
   829     TRACER("void CGlxZoomControl::HandleGestureL");
   860     TRACER("void CGlxZoomControl::HandleGestureL");
   830     
   861     
   831     TGestureCode code = aEvent.Code(MGestureEvent::EAxisBoth); 
   862     TGestureCode code = aEvent.Code(MGestureEvent::EAxisBoth); 
   832 	GLX_LOG_INFO1("_PHOTOS_LOG_: void CGlxZoomControl::HandleGestureL  Code : %d", code);
   863 	GLX_LOG_INFO1("_PHOTOS_LOG_: void CGlxZoomControl::HandleGestureL  Code : %d", code);
   833     
   864 	
   834     // Todo: This switch should go into the event handler.  
   865 	//In HDMI pinch mode we will handle only released gesture
       
   866     //to zoom out the image to fullscreeen.
       
   867 	if( iGlxTvOut->IsHDMIConnected() )	    
       
   868 	    {        
       
   869         if(code == EGestureReleased)
       
   870             {
       
   871             HandleHDMIGestureReleased();
       
   872             }
       
   873 	    }
       
   874 	else
       
   875 	    {
       
   876         // Todo: This switch should go into the event handler.  
   835         switch (code)
   877         switch (code)
   836             {
   878             {
   837             case EGestureDrag:
   879             case EGestureDrag:
       
   880             if (aEvent.Visual() == iImageVisual) 
       
   881                 {
   838                 iEventHandler->HandleDragEvent(aEvent);
   882                 iEventHandler->HandleDragEvent(aEvent);
       
   883                 }
   839                 break;
   884                 break;
   840             case EGestureTap:
   885             case EGestureTap:
       
   886             if (aEvent.Visual() == iImageVisual)
       
   887                 {
   841                 iEventHandler->HandleSingleTap(aEvent);
   888                 iEventHandler->HandleSingleTap(aEvent);
       
   889                 }
   842                 break;
   890                 break;
   843             case EGesturePinch:
   891             case EGesturePinch:
   844                 iEventHandler->HandlePinchEventL(aEvent);
   892                 iEventHandler->HandlePinchEventL(aEvent);
   845                 break;
   893                 break;
   846             case EGestureDoubleTap:
   894             case EGestureDoubleTap:
       
   895             if (aEvent.Visual() == iImageVisual)
       
   896                 {
   847                 iEventHandler->HandleDoubleTap(aEvent);
   897                 iEventHandler->HandleDoubleTap(aEvent);
       
   898                 }
   848                 break;
   899                 break;
   849             case EGestureReleased:
   900             case EGestureReleased:
   850                 iEventHandler->HandleGestureReleased(aEvent);
   901                 iEventHandler->HandleGestureReleased(aEvent);
   851                 break;
   902                 break;
   852             default :
   903             default :
   853                 break;
   904                 break;
   854             }
   905             }
       
   906 	    }
   855     iEventHandler->SetPreviousEventCode(code);
   907     iEventHandler->SetPreviousEventCode(code);
   856     }
   908     }
   857 
   909 
   858 // -----------------------------------------------------------------------------
   910 // -----------------------------------------------------------------------------
   859 // GetInitialZoomLevel
   911 // GetInitialZoomLevel