taskswitcher/taskswitcherui/taskswitcherapp/src/tsappview.cpp
branchRCL_3
changeset 20 899e4666ea9a
parent 19 79311d856354
child 23 7be2816dbabd
--- a/taskswitcher/taskswitcherui/taskswitcherapp/src/tsappview.cpp	Fri Mar 26 15:15:17 2010 +0200
+++ b/taskswitcher/taskswitcherui/taskswitcherapp/src/tsappview.cpp	Wed May 12 13:12:59 2010 +0300
@@ -134,7 +134,7 @@
                KAknsIIDQsnFrPopup,
                iBgContextOuterRect,
                iBgContextInnerRect,
-               ETrue );
+               EFalse );
     iBgContext->SetFrameRects(iBgContextOuterRect, iBgContextInnerRect);
     iBgContext->SetCenter( KAknsIIDQsnFrPopupCenter );
 
@@ -249,7 +249,7 @@
     
     CleanupStack::PopAndDestroy( &rects );
     
-    UpdateHeadingsL();
+    UpdateHeadingsL(0);
     }
 
 // -----------------------------------------------------------------------------
@@ -309,6 +309,7 @@
     iViewRect = Rect();
     UpdatePopupRects();
     iBgContext->SetFrameRects(iBgContextOuterRect, iBgContextInnerRect);
+    iBgContext->SetParentPos(PositionRelativeToScreen());
     if ( iFastSwapArea && iAppsHeading  )
         {
         RArray<TRect> rects;
@@ -456,6 +457,18 @@
     TSLOG_CONTEXT( CTsAppView::HandleSwitchToForegroundEvent, TSLOG_LOCAL );
     TSLOG_IN();
     
+    // Forward event to interested controls
+    iFastSwapArea->HandleSwitchToForegroundEvent();
+    iFastSwapArea->UpdateComponentVisibility();
+    
+    // Check for layout updates
+    CTsAppUi* appUi = static_cast<CTsAppUi*>(iCoeEnv->AppUi());
+    if ( iViewRect != appUi->ApplicationRect() &&
+         appUi->LayoutChangeAllowed() )
+        {
+        HandleDeviceStateChanged( EOrientation );
+        }
+    
     Window().Invalidate(Rect());
     
     iEvtHandler->EnableEventHandling(ETrue);
@@ -468,9 +481,6 @@
     // Focus jumps back to fsw
     ChangeFocus( iFastSwapArea );
 
-    // Forward event to interested controls
-    iFastSwapArea->HandleSwitchToForegroundEvent();
-
     // Start animation
     CTsAppUi* appui =
         static_cast<CTsAppUi*>( iEikonEnv->AppUi() );
@@ -604,9 +614,8 @@
         {
 		LaunchFeedback(ETouchFeedbackBasic, TTouchFeedbackType(
 				ETouchFeedbackVibra | ETouchFeedbackAudio), aPointerEvent);
-		if ( !( iFastSwapArea->Rect().Contains(aPointerEvent.iParentPosition) ||
-		        iAppsHeading->Rect().Contains(aPointerEvent.iParentPosition)
-		       ) )
+
+		if( !DragArea().Contains(aPointerEvent.iParentPosition))
 		    {
 		    //move task switcher to background
 		    iEvtHandler->EnableEventHandling(EFalse);
@@ -620,28 +629,22 @@
 // CTsAppView::DataChanged
 // -----------------------------------------------------------------------------
 //
-void CTsAppView::DataChanged( CCoeControl* /*aWhere*/, TInt /*aNewCount*/ )
+void CTsAppView::DataChanged( CCoeControl* /*aWhere*/, TInt aNewCount )
     {
-    TRAP_IGNORE( UpdateHeadingsL() );
+    TRAP_IGNORE( UpdateHeadingsL( aNewCount ) );
     }
 
 // -----------------------------------------------------------------------------
 // CTsAppView::UpdateHeadingsL
 // -----------------------------------------------------------------------------
 //
-void CTsAppView::UpdateHeadingsL()
+void CTsAppView::UpdateHeadingsL( TInt aNewCount )
     {
-#ifndef TASKSWITCHER_USE_CUSTOM_LAYOUT
     HBufC* text = StringLoader::LoadLC(
-        R_TASK_SWITCHER_HEADING_APPLICATIONS );
-#else
-    _LIT( KTitle, "Task switcher" );
-    HBufC* text = KTitle().AllocLC();
-#endif
+        R_TASK_SWITCHER_HEADING_APPLICATIONS, aNewCount );
     iAppsHeading->SetTextL( *text );
     iAppsHeading->DrawDeferred();
     CleanupStack::PopAndDestroy( text );
-
     }
 
 
@@ -667,6 +670,16 @@
 
 
 // -----------------------------------------------------------------------------
+// CTsAppView::EnableDragEvents
+// -----------------------------------------------------------------------------
+//
+void CTsAppView::EnableDragEvents( TBool aEnable )
+    {
+    iEvtHandler->EnableDragEventHandling( aEnable );
+    }
+
+
+// -----------------------------------------------------------------------------
 // CTsAppView::MoveOffset
 // -----------------------------------------------------------------------------
 //
@@ -710,13 +723,7 @@
 //
 void CTsAppView::DragL(const MAknTouchGestureFwDragEvent& aEvent)
     {
-	if( aEvent.State() == EAknTouchGestureFwStop )
-		{
-		LaunchFeedback(ETouchFeedbackBasic, TTouchFeedbackType(
-				ETouchFeedbackVibra | ETouchFeedbackAudio), TPointerEvent());
-		}
-    if( iFastSwapArea->Rect().Contains(aEvent.StartPosition()) ||
-		iAppsHeading->Rect().Contains(aEvent.StartPosition()) )
+    if(DragArea().Contains(aEvent.StartPosition()))
         {
 		iFastSwapArea->DragL(aEvent);
         }
@@ -758,6 +765,34 @@
 	}
 
 
+// -----------------------------------------------------------------------------
+// CTsAppView::AppCloseInProgress()
+// -----------------------------------------------------------------------------
+//
+TBool CTsAppView::AppCloseInProgress( TInt aWgId )
+    {
+    return iFastSwapArea->IsAppClosing(aWgId);
+    }
+// -----------------------------------------------------------------------------
+// CTsAppView::DragArea
+// -----------------------------------------------------------------------------
+//
+TRect CTsAppView::DragArea()
+	{
+	TRect dragArea;
+	if (Layout_Meta_Data::IsLandscapeOrientation())
+		{
+		dragArea.SetRect(iAppsHeading->Rect().iTl.iX,
+				iAppsHeading->Rect().iTl.iY, iFastSwapArea->Rect().iBr.iX,
+				iFastSwapArea->Rect().iBr.iY);
+		}
+	else
+		{
+		dragArea.SetRect(Rect().iTl.iX, iAppsHeading->Rect().iTl.iY,
+				Rect().iBr.iX, iFastSwapArea->Rect().iBr.iY);
+		}
+	return dragArea;
+	}    
 
 
 // End of file