mulwidgets/mulcoverflowwidget/src/mulcoverflowao.cpp
branchRCL_3
changeset 26 0e9bb658ef58
parent 0 e83bab7cf002
equal deleted inserted replaced
25:4ea6f81c838a 26:0e9bb658ef58
       
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Active Object header for CoverFlow
       
    15 *
       
    16 */
       
    17 
       
    18 // Class Header
       
    19 #include "mulcoverflowao.h"
       
    20 
       
    21 // Alf Headers
       
    22 #include <math.h>
       
    23 
       
    24 // Local Header
       
    25 #include "mulcoverflowcontrol.h"
       
    26 #include "mulbaseelement.h"
       
    27 #include "mullog.h"
       
    28 
       
    29 namespace Alf
       
    30 	{
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // MulCoverFlowAo
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 MulCoverFlowAo::MulCoverFlowAo( MulCoverFlowControl& aControl ) : CTimer( EPriorityNormal ), mControl(aControl)							     								
       
    37 	{
       
    38 	MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowAo::MulCoverFlowAo"); 
       
    39 	ConstructL();
       
    40 	CActiveScheduler::Add(this);
       
    41 	}
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // ~MulCoverFlowAo
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 MulCoverFlowAo::~MulCoverFlowAo()
       
    48 	{
       
    49 	MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowAo::~MulCoverFlowAo"); 
       
    50 	StopTimer();	
       
    51 	}
       
    52 	
       
    53 // ---------------------------------------------------------------------------
       
    54 // StartMoving
       
    55 // ---------------------------------------------------------------------------
       
    56 //     
       
    57 void MulCoverFlowAo::StartMoving(TReal32 aSpeedPoint, int aCurrGestureDirection,bool aFastScrollForKey,int aAnimationTime)
       
    58     {
       
    59 	MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowAo::StartMoving"); 
       
    60 	int previosDir = mCurrGestureDirection;
       
    61 	mCurrGestureDirection = aCurrGestureDirection;
       
    62 
       
    63 	aSpeedPoint = aSpeedPoint < 0 ? aSpeedPoint * -1 : aSpeedPoint;
       
    64 	
       
    65 	// Fast scroll in key event ,
       
    66 	// Three steps are there Max(100),150,200(Min).	
       
    67 	if (aFastScrollForKey)
       
    68 		{
       
    69 		mTransitionTime = aAnimationTime;	
       
    70 		}
       
    71 	else
       
    72 		{
       
    73 		mTransitionTime = 200 *(1 + (1 - aSpeedPoint)*5);		
       
    74 		}
       
    75 		
       
    76 	if( !mStarted )
       
    77 		{
       
    78 		// Cancle any pending requests and start a new request
       
    79 	    // this is because the layout direction n speed should be changed according to the current swipe
       
    80 	    if( IsActive() )
       
    81 	    	{
       
    82 	    	MUL_LOG_INFO("MUL::MulCF::Cancel Previous Animation ");
       
    83 	    	Cancel();
       
    84 	    	}
       
    85 	    		
       
    86 	    MUL_LOG_INFO("MUL::MulCF::Start New Animation ");
       
    87 	    mStarted = true;
       
    88 		After(0);	
       
    89 		}
       
    90 	else
       
    91 		{
       
    92 		if (previosDir != mCurrGestureDirection)
       
    93 			{
       
    94 			mTransitionTime = 200;
       
    95 			Cancel();
       
    96 			After(0);	
       
    97 			}
       
    98 		else
       
    99 			{
       
   100 			}
       
   101 		}
       
   102 		
       
   103     }
       
   104 	
       
   105 // ---------------------------------------------------------------------------
       
   106 // StopMoving
       
   107 // ---------------------------------------------------------------------------
       
   108 //  
       
   109 void MulCoverFlowAo::StopMoving()
       
   110 	{
       
   111 	MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowAo::StopMoving"); 	
       
   112 	StopTimer();
       
   113 	mCurrGestureDirection = 0;
       
   114 	mTransitionTime = 0;
       
   115 	mWaitingTime = 0;
       
   116 	mStarted = false;
       
   117 	}
       
   118 	
       
   119 // ---------------------------------------------------------------------------
       
   120 // StopTimer
       
   121 // ---------------------------------------------------------------------------
       
   122 // 
       
   123 void MulCoverFlowAo::StopTimer()
       
   124 	{
       
   125 	MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowAo::StopTimer"); 	
       
   126 	if( IsActive() )
       
   127     	{
       
   128     	Cancel();
       
   129     	}
       
   130 	}
       
   131 // ---------------------------------------------------------------------------
       
   132 // RunL
       
   133 // ---------------------------------------------------------------------------
       
   134 // 	
       
   135 void MulCoverFlowAo::RunL()
       
   136 	{
       
   137 	MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowAo::RunL");	
       
   138 	// Check if the layout ahs moved by one complete visaul. 
       
   139 	// Then change the highlight and again start moving the layout.
       
   140 	// If it hasnot moved by complete visaul then allow the layout to move to new position but
       
   141 	// dont change the highlight
       
   142 	ChangeHighLight();	
       
   143 	After(fabs(mTransitionTime*600));
       
   144 	}
       
   145 	
       
   146 // ---------------------------------------------------------------------------
       
   147 // ChangeHighLight
       
   148 // ---------------------------------------------------------------------------
       
   149 // 	
       
   150 void MulCoverFlowAo::ChangeHighLight()
       
   151 	{
       
   152 	MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowAo::ChangeHighLight"); 	
       
   153 	// Inform widget/model that highlight has changed	
       
   154 	if(mCurrGestureDirection > 0 )
       
   155 		{
       
   156 		mControl.HandleNavigationEvent ( EEventScrollLeft );	
       
   157 		}
       
   158 	else if(mCurrGestureDirection < 0 )
       
   159 		{
       
   160 		mControl.HandleNavigationEvent ( EEventScrollRight );
       
   161 		}
       
   162 	else
       
   163 		{
       
   164 		// no need to change the highlight	
       
   165 		}
       
   166 	}
       
   167 
       
   168 // ---------------------------------------------------------------------------
       
   169 // FastScrollTransitionTime
       
   170 // ---------------------------------------------------------------------------
       
   171 // 	
       
   172 int MulCoverFlowAo::FastScrollTransitionTime()
       
   173 	{	
       
   174 	return mTransitionTime;
       
   175 	}
       
   176 			
       
   177 	} // End of namespace .
       
   178 
       
   179 //End of file
       
   180 
       
   181