uifw/AvKon/src/aknlongtapanimation.cpp
branchRCL_3
changeset 55 aecbbf00d063
parent 29 a8834a2e9a96
child 56 d48ab3b357f1
equal deleted inserted replaced
51:fcdfafb36fe7 55:aecbbf00d063
    22 #include <apgwgnam.h>
    22 #include <apgwgnam.h>
    23 #include <aknlayoutscalable_avkon.cdl.h>
    23 #include <aknlayoutscalable_avkon.cdl.h>
    24 
    24 
    25 #include <AknTasHook.h> // for testability hooks
    25 #include <AknTasHook.h> // for testability hooks
    26 #include <touchfeedback.h>
    26 #include <touchfeedback.h>
       
    27 const TInt KStartIntensity = 1;
       
    28 const TInt KEndIntensity = 100;
    27 #include "aknlongtapanimation.h"
    29 #include "aknlongtapanimation.h"
    28 
    30 
    29 enum TInternalFlags
    31 enum TInternalFlags
    30 	{
    32 	{
    31 	EAnimationStarted			     =	0x0001,
    33 	EAnimationStarted			     =	0x0001,
    37 /**  window group's priority */
    39 /**  window group's priority */
    38 const TInt KAknLongTapWindowPosition = 11; // window group's priority
    40 const TInt KAknLongTapWindowPosition = 11; // window group's priority
    39 
    41 
    40 /** Window`s Position when hiding the animation which  does not own Window Group */
    42 /** Window`s Position when hiding the animation which  does not own Window Group */
    41 const TInt KAknAnimationNotOwnWindowGroupWindowPosition = -10; // never at front  
    43 const TInt KAknAnimationNotOwnWindowGroupWindowPosition = -10; // never at front  
    42 
       
    43 /** animation's position offset */
       
    44 const TInt KVerticalOffset = -75;
       
    45 
    44 
    46 /**  window group's name */
    45 /**  window group's name */
    47 _LIT( KAknLongTapWgName, "LongTapAnim" ); // window groups name
    46 _LIT( KAknLongTapWgName, "LongTapAnim" ); // window groups name
    48 
    47 
    49 
    48 
   164     layoutRect.LayoutRect( layoutRect.Rect(),
   163     layoutRect.LayoutRect( layoutRect.Rect(),
   165         AknLayoutScalable_Avkon::cursor_press_pane_g1() );
   164         AknLayoutScalable_Avkon::cursor_press_pane_g1() );
   166     
   165     
   167     SetRect( TRect( TPoint(aX, aY), layoutRect.Rect().Size() ));
   166     SetRect( TRect( TPoint(aX, aY), layoutRect.Rect().Size() ));
   168     
   167     
   169     // position window
   168     // Position window so that it will be directly on top of
       
   169     // the location that was clicked.
   170     TPoint point( aX - Rect().Width() / 2, aY - Rect().Height() / 2 );
   170     TPoint point( aX - Rect().Width() / 2, aY - Rect().Height() / 2 );
   171     point.iY += KVerticalOffset;
       
   172     point.iY = Max( 0, point.iY );
       
   173     
       
   174     Window().SetPosition( point );
   171     Window().SetPosition( point );
   175 
   172 
   176     iAnim->SetSize( layoutRect.Rect().Size() );
   173     iAnim->SetSize( layoutRect.Rect().Size() );
   177     
   174     
   178     iAnim->SetPosition( Rect().iTl );
   175     iAnim->SetPosition( Rect().iTl );
   191     ActivateL();
   188     ActivateL();
   192 
   189 
   193     MTouchFeedback* feedback = MTouchFeedback::Instance();
   190     MTouchFeedback* feedback = MTouchFeedback::Instance();
   194     if ( feedback )
   191     if ( feedback )
   195         {
   192         {
   196         feedback->InstantFeedback( 
   193         CBitmapAnimClientData* animData = iAnim->BitmapAnimData();	
   197                 this, ETouchFeedbackLongTap,
   194 		TInt interval = animData->FrameIntervalInMilliSeconds()
   198                 ETouchFeedbackVibra, TPointerEvent() );
   195 		             * KConversionFromMillisecondsToMicroseconds;
       
   196         TInt frameCount = animData->FrameArray().Count();
       
   197 
       
   198         // timeout should be greater than normal animation time 
       
   199         // so that timeout does not interfere into normal operation
       
   200         TInt timeout = interval * (frameCount+1); 
       
   201         feedback->StartFeedback( this, ETouchContinuousSmooth, NULL, KStartIntensity, timeout );
   199         }
   202         }
   200 	StartAnimation();
   203 	StartAnimation();
   201     }
   204     }
   202 
   205 
   203 
   206 
   388 	iExtension->iIndex++;
   391 	iExtension->iIndex++;
   389 	if (iExtension->iIndex == frameCount)
   392 	if (iExtension->iIndex == frameCount)
   390 	{
   393 	{
   391 		iExtension->iIndex = frameCount - 1;
   394 		iExtension->iIndex = frameCount - 1;
   392 	}
   395 	}
       
   396     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   397     if ( feedback )
       
   398         {
       
   399         // intensity should go from 0 to 100
       
   400         TInt intensity = KEndIntensity
       
   401                        * (iExtension->iIndex+1) / frameCount;
       
   402         feedback->ModifyFeedback( this, intensity );
       
   403         }
   393 	DrawNow();
   404 	DrawNow();
   394 	}
   405 	}
   395 
   406 
   396 
   407 
   397 // ---------------------------------------------------------
   408 // ---------------------------------------------------------