photosgallery/viewframework/views/zoomview/src/glxzoomcontrol.cpp
branchRCL_3
changeset 12 ce1c7ad1f18b
parent 11 71da52165949
child 13 bcb43dc84c44
--- a/photosgallery/viewframework/views/zoomview/src/glxzoomcontrol.cpp	Fri Mar 12 15:42:44 2010 +0200
+++ b/photosgallery/viewframework/views/zoomview/src/glxzoomcontrol.cpp	Mon Mar 15 12:40:30 2010 +0200
@@ -58,7 +58,7 @@
 const TReal KGlxOpacityTransparent = 0.0;
 //zoom delay for animation while hdmi cable,
 //is connected and zoom is initiated
-const TInt KZoomDelay = 150000; 
+const TInt KHDMIZoomDelay = 250000; 
 //Zoom level for the animation , assuming the innitial level is 1.
 const TReal KGlxZoomLevel = 1.5;
 const TInt KGlxMinSmallImageZoomLevel =100;
@@ -277,11 +277,8 @@
     {
     TRACER("CGlxZoomControl::ActivateL()");
 
-    //To know if HDMi cable is connected.
     if ( !iZoomActive )
         {
-        //This Varaiable updates that we are in zoom state now.
-        iZoomActive = ETrue;
         //To Retrive the image details
         TMPXAttribute thumbNailAttribute(0,0);
 
@@ -291,10 +288,9 @@
                 ScreenSize(),aItem, idspace, this ));
         iImageVisual->SetImage(*iImageTexture);
         
-        
         if(iGlxTvOut->IsHDMIConnected()&& !aViewingMode )
             {
-            StartZoomAnimation();
+            StartZoomAnimation(aStartMode);
             }
         else
             {
@@ -347,25 +343,38 @@
                     }
                 }
             }
+        // Now the zoom activation process is complete.
+        // Now is when truly zoom is active. 
+        iZoomActive = ETrue;
         }
     }
 // ---------------------------------------------------------------------------
 // StartZoomAnimation
 // ---------------------------------------------------------------------------
 // 
-void CGlxZoomControl::StartZoomAnimation()
+void CGlxZoomControl::StartZoomAnimation(TZoomStartMode aStartMode)
     {
     TRACER("CGlxZoomControl::StartZoomAnimation()");
     iZoomIn = ETrue;
     //Set zoom visible but not enable the gesturehelper events    
-    iViewPort->SetOpacity(KGlxOpacityOpaque);  
+    iViewPort->SetOpacity(KGlxOpacityOpaque);    
     TAlfTimedValue timedvalue;
     //using KGlxOpacityOpaque for the value 1 , assuming the initial zoom level as 1.
     timedvalue.SetValueNow(KGlxOpacityOpaque); 
-    timedvalue.SetTarget(KGlxZoomLevel,KZoomDelay/1000);    
+    timedvalue.SetTarget(KGlxZoomLevel,KHDMIZoomDelay/1000);    
     iImageVisual->SetScale(timedvalue);
-    iTimer->Cancel();
-    iTimer->Start(KZoomDelay,KZoomDelay,TCallBack( TimeOut,this ));
+    
+    //If zoom is not done using pinch, zoom out with the rubber effect
+    //Else wait for the gesture helper event for zooming out.
+    if(aStartMode != EZoomStartPinch)
+        {
+        iTimer->Cancel();
+        iTimer->Start(KHDMIZoomDelay,KHDMIZoomDelay,TCallBack( TimeOut,this ));
+        }
+    else
+        {
+        iGestureHelper->AddObserver(this);
+        }
     }
 // ---------------------------------------------------------------------------
 // TimeOut
@@ -393,7 +402,7 @@
         iZoomIn = EFalse;
         TAlfTimedValue timedvalue;
         timedvalue.SetValueNow(KGlxZoomLevel);
-        timedvalue.SetTarget(KGlxOpacityOpaque,KZoomDelay/1000);
+        timedvalue.SetTarget(KGlxOpacityOpaque,KHDMIZoomDelay/1000);
         iImageVisual->SetScale(timedvalue);
         }
     else
@@ -590,6 +599,12 @@
     {
     TRACER("CGlxZoomControl::VisualLayoutUpdated ");
     // Callback comes to this function when there is a  resolution change
+    
+    if(iGlxTvOut->IsHDMIConnected())
+        {
+        return;
+        }
+    
     TRect rect;
     rect = AlfUtil::ScreenSize();
     if ( (rect.Width() != iScreenSize.iWidth) && ( rect.Height() != iScreenSize.iHeight) && (Activated()) )
@@ -809,6 +824,22 @@
 
 
 // -----------------------------------------------------------------------------
+// HandleHDMIGestureReleased
+// -----------------------------------------------------------------------------
+//
+void CGlxZoomControl::HandleHDMIGestureReleased()
+    {
+    TRACER("void CGlxZoomControl::HandlePinchReleased");
+    if ( iGlxTvOut->IsHDMIConnected() && iZoomActive)
+        {
+        //On HDMI pinch release, zoom out to fullscreen
+        GLX_LOG_INFO("_PHOTOS_LOG_: void CGlxZoomControl::HandlePinchReleased Start ZoomOut");
+        iTimer->Cancel();
+        iTimer->Start(KHDMIZoomDelay,KHDMIZoomDelay,TCallBack( TimeOut,this ));
+        }
+    }
+
+// -----------------------------------------------------------------------------
 // HandlePointerEventsL
 // -----------------------------------------------------------------------------
 //
@@ -830,21 +861,41 @@
     
     TGestureCode code = aEvent.Code(MGestureEvent::EAxisBoth); 
 	GLX_LOG_INFO1("_PHOTOS_LOG_: void CGlxZoomControl::HandleGestureL  Code : %d", code);
-    
-    // Todo: This switch should go into the event handler.  
+	
+	//In HDMI pinch mode we will handle only released gesture
+    //to zoom out the image to fullscreeen.
+	if( iGlxTvOut->IsHDMIConnected() )	    
+	    {        
+        if(code == EGestureReleased)
+            {
+            HandleHDMIGestureReleased();
+            }
+	    }
+	else
+	    {
+        // Todo: This switch should go into the event handler.  
         switch (code)
             {
             case EGestureDrag:
+            if (aEvent.Visual() == iImageVisual) 
+                {
                 iEventHandler->HandleDragEvent(aEvent);
+                }
                 break;
             case EGestureTap:
+            if (aEvent.Visual() == iImageVisual)
+                {
                 iEventHandler->HandleSingleTap(aEvent);
+                }
                 break;
             case EGesturePinch:
                 iEventHandler->HandlePinchEventL(aEvent);
                 break;
             case EGestureDoubleTap:
+            if (aEvent.Visual() == iImageVisual)
+                {
                 iEventHandler->HandleDoubleTap(aEvent);
+                }
                 break;
             case EGestureReleased:
                 iEventHandler->HandleGestureReleased(aEvent);
@@ -852,6 +903,7 @@
             default :
                 break;
             }
+	    }
     iEventHandler->SetPreviousEventCode(code);
     }