idlehomescreen/xmluirendering/uiengine/src/xncontroladapterimpl.cpp
branchRCL_3
changeset 31 89165693e770
parent 26 1b758917cafc
equal deleted inserted replaced
28:d721605b30d0 31:89165693e770
    26 #include <AknsDrawUtils.h>
    26 #include <AknsDrawUtils.h>
    27 #include <aknconsts.h>
    27 #include <aknconsts.h>
    28 #include <AknUtils.h>
    28 #include <AknUtils.h>
    29 #include <AknsListBoxBackgroundControlContext.h>
    29 #include <AknsListBoxBackgroundControlContext.h>
    30 #include <gulicon.h>
    30 #include <gulicon.h>
       
    31 #include <aknpointereventsuppressor.h>
    31 #ifdef RD_TACTILE_FEEDBACK
    32 #ifdef RD_TACTILE_FEEDBACK
    32 #include <touchfeedback.h>
    33 #include <touchfeedback.h>
    33 #endif // RD_TACTILE_FEEDBACK
    34 #endif // RD_TACTILE_FEEDBACK
    34 
    35 
    35 // User includes
    36 // User includes
    60 #include "xnscrollablecontroladapter.h"
    61 #include "xnscrollablecontroladapter.h"
    61 #include "xnfocuscontrol.h"
    62 #include "xnfocuscontrol.h"
    62 #include "xneditmode.h"
    63 #include "xneditmode.h"
    63 
    64 
    64 _LIT8(KScrollableBoxNodeName, "scrollablebox");
    65 _LIT8(KScrollableBoxNodeName, "scrollablebox");
       
    66 _LIT8( KView, "view" );
    65 
    67 
    66 // Constants
    68 // Constants
    67 const TInt KSkinGfxInnerRectShrink = 5;
    69 const TInt KSkinGfxInnerRectShrink = 5;
    68 const TInt KFocusGrowValue = 3;
    70 const TInt KFocusGrowValue = 3;
    69 
    71 
    70 const TInt KLongTapStartShortDelay( 150000 ); // 0.15s for Sk
    72 const TInt KLongTapStartShortDelay( 150000 ); // 0.15s for Sk
    71 const TInt KLongTapStartLongDelay( 500000 ); // 0.5s
    73 const TInt KLongTapStartLongDelay( 500000 ); // 0.5s
    72 const TInt KLongTapTimeShortDelay( 600000 ); // 0.6s for SK
    74 const TInt KLongTapTimeShortDelay( 600000 ); // 0.6s for SK
    73 const TInt KLongTapTimeLongDelay( 1500000 ); // 1.5s
    75 const TInt KLongTapTimeLongDelay( 1500000 ); // 1.5s
    74 
    76 
    75 const TInt KDragThreshold = 20; // pixels
    77 const TInt KDragThreshold = 100; // pixels
       
    78 const TInt KMaxTapMove = 100; //100x100 pixels
    76 
    79 
    77 const TReal KEps( 3e-16 ); // proximite EPS value for double FP numbers
    80 const TReal KEps( 3e-16 ); // proximite EPS value for double FP numbers
    78 
    81 
    79 // LOCAL FUNCTION PROTOTYPES
    82 // LOCAL FUNCTION PROTOTYPES
    80 static TRgb ConvertHslToRgb( TInt aHue, TInt aSaturation, TInt aLightness );
    83 static TRgb ConvertHslToRgb( TInt aHue, TInt aSaturation, TInt aLightness );
  3587         iAnimation->Stop();
  3590         iAnimation->Stop();
  3588         delete iAnimation;
  3591         delete iAnimation;
  3589         }
  3592         }
  3590     
  3593     
  3591     delete iGestureFw;
  3594     delete iGestureFw;
       
  3595     delete iSuppressor;
  3592     }
  3596     }
  3593 
  3597 
  3594 // -----------------------------------------------------------------------------
  3598 // -----------------------------------------------------------------------------
  3595 // CXnControlAdapterImpl::CXnControlAdapterImpl
  3599 // CXnControlAdapterImpl::CXnControlAdapterImpl
  3596 // C++ default constructor. Must not leave.
  3600 // C++ default constructor. Must not leave.
  3881 // Handle pointer events
  3885 // Handle pointer events
  3882 // -----------------------------------------------------------------------------
  3886 // -----------------------------------------------------------------------------
  3883 //
  3887 //
  3884 TBool CXnControlAdapterImpl::HandlePointerEventL(
  3888 TBool CXnControlAdapterImpl::HandlePointerEventL(
  3885     const TPointerEvent& aPointerEvent )
  3889     const TPointerEvent& aPointerEvent )
  3886     {
  3890     {    
  3887     const TPointerEvent& event( aPointerEvent );
  3891     const TPointerEvent& event( aPointerEvent );
  3888     
  3892     
  3889     CXnNode* node( &iNode.Node() );
  3893     CXnNode* node( &iNode.Node() );
  3890     CXnUiEngine* engine( node->UiEngine() );
  3894     CXnUiEngine* engine( node->UiEngine() );
  3891     
  3895     
  3909         if ( !node )
  3913         if ( !node )
  3910             {
  3914             {
  3911             // No softkey node found, consume event
  3915             // No softkey node found, consume event
  3912             return ETrue;
  3916             return ETrue;
  3913             }
  3917             }
       
  3918         }
       
  3919     else if ( iSuppressor &&
       
  3920               iSuppressor->SuppressPointerEvent( aPointerEvent ) )
       
  3921         {
       
  3922         // if view does not handle swipe we have to pass event to children
       
  3923         return ( iGestureDestination == node );
  3914         }
  3924         }
  3915     
  3925     
  3916     CAknLongTapDetector* detector( iAdapter->LongTapDetector() );
  3926     CAknLongTapDetector* detector( iAdapter->LongTapDetector() );
  3917     
  3927     
  3918     if ( ( detector && ( !engine->IsPartialInputActive() || 
  3928     if ( ( detector && ( !engine->IsPartialInputActive() || 
  3985         }
  3995         }
  3986     else if ( event.iType == TPointerEvent::EDrag )
  3996     else if ( event.iType == TPointerEvent::EDrag )
  3987         {        
  3997         {        
  3988         if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) )
  3998         if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) )
  3989             {
  3999             {
  3990             if ( IsDragThresholdExceeded( event.iPosition ) ||
  4000             if ( IsDragThresholdExceeded( event.iPosition ) )
  3991                  !node->MarginRect().Contains( event.iPosition ) )
       
  3992                 {
  4001                 {
  3993                 // Remove focus
  4002                 // Remove focus
  3994                 node->UnsetStateL(
  4003                 node->UnsetStateL(
  3995                     XnPropertyNames::style::common::KFocus );
  4004                     XnPropertyNames::style::common::KFocus );
  3996                 }
  4005                 }
  4001         if ( !iLongtap )
  4010         if ( !iLongtap )
  4002             {
  4011             {
  4003             if ( menuBar ) 
  4012             if ( menuBar ) 
  4004                 {
  4013                 {
  4005                 node->SetStateL( XnPropertyNames::style::common::KActive );
  4014                 node->SetStateL( XnPropertyNames::style::common::KActive );
  4006                 }          
  4015                 }
  4007             else if ( ( node->MarginRect().Contains( event.iPosition ) &&
  4016             else if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) )
  4008                node->IsStateSet( XnPropertyNames::style::common::KFocus ) ) )
       
  4009                 {
  4017                 {
  4010 #ifdef RD_TACTILE_FEEDBACK            
  4018 #ifdef RD_TACTILE_FEEDBACK            
  4011                 MTouchFeedback* feedback( MTouchFeedback::Instance() );
  4019                 MTouchFeedback* feedback( MTouchFeedback::Instance() );
  4012                 
  4020                 
  4013                 if ( feedback )
  4021                 if ( feedback )
  5302 
  5310 
  5303     if ( CreateGestureHelperL( aNode.Node() ) )
  5311     if ( CreateGestureHelperL( aNode.Node() ) )
  5304         {
  5312         {
  5305         iGestureFw = CAknTouchGestureFw::NewL( *this, aAdapter );
  5313         iGestureFw = CAknTouchGestureFw::NewL( *this, aAdapter );
  5306         iGestureFw->SetGestureInterestL( EAknTouchGestureFwGroupFlick );
  5314         iGestureFw->SetGestureInterestL( EAknTouchGestureFwGroupFlick );
       
  5315         }
       
  5316     
       
  5317     if ( aNode.Type()->Type() == KView )
       
  5318         {
       
  5319         iSuppressor = CAknPointerEventSuppressor::NewL();
       
  5320         iSuppressor->SetMaxTapMove( TSize( KMaxTapMove, KMaxTapMove) );
       
  5321         iSuppressor->SetMaxTapDuration( KLongTapTimeLongDelay );
  5307         }
  5322         }
  5308     }
  5323     }
  5309 
  5324 
  5310 // -----------------------------------------------------------------------------
  5325 // -----------------------------------------------------------------------------
  5311 // CXnControlAdapterImpl::LoadBitmap
  5326 // CXnControlAdapterImpl::LoadBitmap