taskswitcher/taskswitcherui/taskswitcherapp/src/tsappview.cpp
branchRCL_3
changeset 20 899e4666ea9a
parent 19 79311d856354
child 23 7be2816dbabd
equal deleted inserted replaced
16:1526727a5b85 20:899e4666ea9a
   132     UpdatePopupRects();
   132     UpdatePopupRects();
   133     iBgContext = CAknsFrameBackgroundControlContext::NewL(
   133     iBgContext = CAknsFrameBackgroundControlContext::NewL(
   134                KAknsIIDQsnFrPopup,
   134                KAknsIIDQsnFrPopup,
   135                iBgContextOuterRect,
   135                iBgContextOuterRect,
   136                iBgContextInnerRect,
   136                iBgContextInnerRect,
   137                ETrue );
   137                EFalse );
   138     iBgContext->SetFrameRects(iBgContextOuterRect, iBgContextInnerRect);
   138     iBgContext->SetFrameRects(iBgContextOuterRect, iBgContextInnerRect);
   139     iBgContext->SetCenter( KAknsIIDQsnFrPopupCenter );
   139     iBgContext->SetCenter( KAknsIIDQsnFrPopupCenter );
   140 
   140 
   141     TSLOG4( TSLOG_INFO, "view rect = %d %d %d %d",
   141     TSLOG4( TSLOG_INFO, "view rect = %d %d %d %d",
   142         iViewRect.iTl.iX, iViewRect.iTl.iY,
   142         iViewRect.iTl.iX, iViewRect.iTl.iY,
   247     iFastSwapArea->SetRect( rects[1] ); // cannot be before iAppsHeading constructL
   247     iFastSwapArea->SetRect( rects[1] ); // cannot be before iAppsHeading constructL
   248     iAppsHeading->SetRect( rects[0] );
   248     iAppsHeading->SetRect( rects[0] );
   249     
   249     
   250     CleanupStack::PopAndDestroy( &rects );
   250     CleanupStack::PopAndDestroy( &rects );
   251     
   251     
   252     UpdateHeadingsL();
   252     UpdateHeadingsL(0);
   253     }
   253     }
   254 
   254 
   255 // -----------------------------------------------------------------------------
   255 // -----------------------------------------------------------------------------
   256 // CTsAppView::GetRects
   256 // CTsAppView::GetRects
   257 // -----------------------------------------------------------------------------
   257 // -----------------------------------------------------------------------------
   307     TSLOG_CONTEXT( CTsAppView::SizeChanged, TSLOG_LOCAL );
   307     TSLOG_CONTEXT( CTsAppView::SizeChanged, TSLOG_LOCAL );
   308     TSLOG_IN();
   308     TSLOG_IN();
   309     iViewRect = Rect();
   309     iViewRect = Rect();
   310     UpdatePopupRects();
   310     UpdatePopupRects();
   311     iBgContext->SetFrameRects(iBgContextOuterRect, iBgContextInnerRect);
   311     iBgContext->SetFrameRects(iBgContextOuterRect, iBgContextInnerRect);
       
   312     iBgContext->SetParentPos(PositionRelativeToScreen());
   312     if ( iFastSwapArea && iAppsHeading  )
   313     if ( iFastSwapArea && iAppsHeading  )
   313         {
   314         {
   314         RArray<TRect> rects;
   315         RArray<TRect> rects;
   315         // make sure that appending in GetRect cannot fail
   316         // make sure that appending in GetRect cannot fail
   316         if ( rects.Reserve( 2 ) == KErrNone )
   317         if ( rects.Reserve( 2 ) == KErrNone )
   454 void CTsAppView::HandleSwitchToForegroundEvent()
   455 void CTsAppView::HandleSwitchToForegroundEvent()
   455     {
   456     {
   456     TSLOG_CONTEXT( CTsAppView::HandleSwitchToForegroundEvent, TSLOG_LOCAL );
   457     TSLOG_CONTEXT( CTsAppView::HandleSwitchToForegroundEvent, TSLOG_LOCAL );
   457     TSLOG_IN();
   458     TSLOG_IN();
   458     
   459     
       
   460     // Forward event to interested controls
       
   461     iFastSwapArea->HandleSwitchToForegroundEvent();
       
   462     iFastSwapArea->UpdateComponentVisibility();
       
   463     
       
   464     // Check for layout updates
       
   465     CTsAppUi* appUi = static_cast<CTsAppUi*>(iCoeEnv->AppUi());
       
   466     if ( iViewRect != appUi->ApplicationRect() &&
       
   467          appUi->LayoutChangeAllowed() )
       
   468         {
       
   469         HandleDeviceStateChanged( EOrientation );
       
   470         }
       
   471     
   459     Window().Invalidate(Rect());
   472     Window().Invalidate(Rect());
   460     
   473     
   461     iEvtHandler->EnableEventHandling(ETrue);
   474     iEvtHandler->EnableEventHandling(ETrue);
   462     
   475     
   463     // Fade behind the pop-up
   476     // Fade behind the pop-up
   465 
   478 
   466     DrawDeferred(); // otherwise some parts may not be drawn properly
   479     DrawDeferred(); // otherwise some parts may not be drawn properly
   467 
   480 
   468     // Focus jumps back to fsw
   481     // Focus jumps back to fsw
   469     ChangeFocus( iFastSwapArea );
   482     ChangeFocus( iFastSwapArea );
   470 
       
   471     // Forward event to interested controls
       
   472     iFastSwapArea->HandleSwitchToForegroundEvent();
       
   473 
   483 
   474     // Start animation
   484     // Start animation
   475     CTsAppUi* appui =
   485     CTsAppUi* appui =
   476         static_cast<CTsAppUi*>( iEikonEnv->AppUi() );
   486         static_cast<CTsAppUi*>( iEikonEnv->AppUi() );
   477     if ( appui->EffectsEnabled() )
   487     if ( appui->EffectsEnabled() )
   602     {
   612     {
   603     if( TPointerEvent::EButton1Down == aPointerEvent.iType )
   613     if( TPointerEvent::EButton1Down == aPointerEvent.iType )
   604         {
   614         {
   605 		LaunchFeedback(ETouchFeedbackBasic, TTouchFeedbackType(
   615 		LaunchFeedback(ETouchFeedbackBasic, TTouchFeedbackType(
   606 				ETouchFeedbackVibra | ETouchFeedbackAudio), aPointerEvent);
   616 				ETouchFeedbackVibra | ETouchFeedbackAudio), aPointerEvent);
   607 		if ( !( iFastSwapArea->Rect().Contains(aPointerEvent.iParentPosition) ||
   617 
   608 		        iAppsHeading->Rect().Contains(aPointerEvent.iParentPosition)
   618 		if( !DragArea().Contains(aPointerEvent.iParentPosition))
   609 		       ) )
       
   610 		    {
   619 		    {
   611 		    //move task switcher to background
   620 		    //move task switcher to background
   612 		    iEvtHandler->EnableEventHandling(EFalse);
   621 		    iEvtHandler->EnableEventHandling(EFalse);
   613 		    iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit);
   622 		    iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit);
   614 		    }
   623 		    }
   618 
   627 
   619 // -----------------------------------------------------------------------------
   628 // -----------------------------------------------------------------------------
   620 // CTsAppView::DataChanged
   629 // CTsAppView::DataChanged
   621 // -----------------------------------------------------------------------------
   630 // -----------------------------------------------------------------------------
   622 //
   631 //
   623 void CTsAppView::DataChanged( CCoeControl* /*aWhere*/, TInt /*aNewCount*/ )
   632 void CTsAppView::DataChanged( CCoeControl* /*aWhere*/, TInt aNewCount )
   624     {
   633     {
   625     TRAP_IGNORE( UpdateHeadingsL() );
   634     TRAP_IGNORE( UpdateHeadingsL( aNewCount ) );
   626     }
   635     }
   627 
   636 
   628 // -----------------------------------------------------------------------------
   637 // -----------------------------------------------------------------------------
   629 // CTsAppView::UpdateHeadingsL
   638 // CTsAppView::UpdateHeadingsL
   630 // -----------------------------------------------------------------------------
   639 // -----------------------------------------------------------------------------
   631 //
   640 //
   632 void CTsAppView::UpdateHeadingsL()
   641 void CTsAppView::UpdateHeadingsL( TInt aNewCount )
   633     {
   642     {
   634 #ifndef TASKSWITCHER_USE_CUSTOM_LAYOUT
       
   635     HBufC* text = StringLoader::LoadLC(
   643     HBufC* text = StringLoader::LoadLC(
   636         R_TASK_SWITCHER_HEADING_APPLICATIONS );
   644         R_TASK_SWITCHER_HEADING_APPLICATIONS, aNewCount );
   637 #else
       
   638     _LIT( KTitle, "Task switcher" );
       
   639     HBufC* text = KTitle().AllocLC();
       
   640 #endif
       
   641     iAppsHeading->SetTextL( *text );
   645     iAppsHeading->SetTextL( *text );
   642     iAppsHeading->DrawDeferred();
   646     iAppsHeading->DrawDeferred();
   643     CleanupStack::PopAndDestroy( text );
   647     CleanupStack::PopAndDestroy( text );
   644 
       
   645     }
   648     }
   646 
   649 
   647 
   650 
   648 // -----------------------------------------------------------------------------
   651 // -----------------------------------------------------------------------------
   649 // CTsAppView::HandleAppKey
   652 // CTsAppView::HandleAppKey
   665     DrawNow();
   668     DrawNow();
   666     }
   669     }
   667 
   670 
   668 
   671 
   669 // -----------------------------------------------------------------------------
   672 // -----------------------------------------------------------------------------
       
   673 // CTsAppView::EnableDragEvents
       
   674 // -----------------------------------------------------------------------------
       
   675 //
       
   676 void CTsAppView::EnableDragEvents( TBool aEnable )
       
   677     {
       
   678     iEvtHandler->EnableDragEventHandling( aEnable );
       
   679     }
       
   680 
       
   681 
       
   682 // -----------------------------------------------------------------------------
   670 // CTsAppView::MoveOffset
   683 // CTsAppView::MoveOffset
   671 // -----------------------------------------------------------------------------
   684 // -----------------------------------------------------------------------------
   672 //
   685 //
   673 void CTsAppView::MoveOffset(const TPoint& aOffset, TBool aDrawNow)
   686 void CTsAppView::MoveOffset(const TPoint& aOffset, TBool aDrawNow)
   674     {
   687     {
   708 // CTsAppView::DragL()
   721 // CTsAppView::DragL()
   709 // -----------------------------------------------------------------------------
   722 // -----------------------------------------------------------------------------
   710 //
   723 //
   711 void CTsAppView::DragL(const MAknTouchGestureFwDragEvent& aEvent)
   724 void CTsAppView::DragL(const MAknTouchGestureFwDragEvent& aEvent)
   712     {
   725     {
   713 	if( aEvent.State() == EAknTouchGestureFwStop )
   726     if(DragArea().Contains(aEvent.StartPosition()))
   714 		{
       
   715 		LaunchFeedback(ETouchFeedbackBasic, TTouchFeedbackType(
       
   716 				ETouchFeedbackVibra | ETouchFeedbackAudio), TPointerEvent());
       
   717 		}
       
   718     if( iFastSwapArea->Rect().Contains(aEvent.StartPosition()) ||
       
   719 		iAppsHeading->Rect().Contains(aEvent.StartPosition()) )
       
   720         {
   727         {
   721 		iFastSwapArea->DragL(aEvent);
   728 		iFastSwapArea->DragL(aEvent);
   722         }
   729         }
   723     }
   730     }
   724 
   731 
   756 	    		aPointerEvent);
   763 	    		aPointerEvent);
   757 	    } 
   764 	    } 
   758 	}
   765 	}
   759 
   766 
   760 
   767 
       
   768 // -----------------------------------------------------------------------------
       
   769 // CTsAppView::AppCloseInProgress()
       
   770 // -----------------------------------------------------------------------------
       
   771 //
       
   772 TBool CTsAppView::AppCloseInProgress( TInt aWgId )
       
   773     {
       
   774     return iFastSwapArea->IsAppClosing(aWgId);
       
   775     }
       
   776 // -----------------------------------------------------------------------------
       
   777 // CTsAppView::DragArea
       
   778 // -----------------------------------------------------------------------------
       
   779 //
       
   780 TRect CTsAppView::DragArea()
       
   781 	{
       
   782 	TRect dragArea;
       
   783 	if (Layout_Meta_Data::IsLandscapeOrientation())
       
   784 		{
       
   785 		dragArea.SetRect(iAppsHeading->Rect().iTl.iX,
       
   786 				iAppsHeading->Rect().iTl.iY, iFastSwapArea->Rect().iBr.iX,
       
   787 				iFastSwapArea->Rect().iBr.iY);
       
   788 		}
       
   789 	else
       
   790 		{
       
   791 		dragArea.SetRect(Rect().iTl.iX, iAppsHeading->Rect().iTl.iY,
       
   792 				Rect().iBr.iX, iFastSwapArea->Rect().iBr.iY);
       
   793 		}
       
   794 	return dragArea;
       
   795 	}    
   761 
   796 
   762 
   797 
   763 // End of file
   798 // End of file