51 #include "xndomnode.h" |
51 #include "xndomnode.h" |
52 #include "xnproperty.h" |
52 #include "xnproperty.h" |
53 #include "xndomlist.h" |
53 #include "xndomlist.h" |
54 #include "xnodt.h" |
54 #include "xnodt.h" |
55 #include "xnresource.h" |
55 #include "xnresource.h" |
56 #include "xnhittest.h" |
|
57 #include "xnplugindata.h" |
56 #include "xnplugindata.h" |
58 #include "xnnode.h" |
57 #include "xnnode.h" |
59 #include "xnpanic.h" |
58 #include "xnpanic.h" |
60 #include "xnviewdata.h" |
59 #include "xnviewdata.h" |
61 #include "xnscrollablecontroladapter.h" |
60 #include "xnscrollablecontroladapter.h" |
62 #include "xnfocuscontrol.h" |
61 #include "xnfocuscontrol.h" |
63 #include "xneditmode.h" |
62 #include "xneditmode.h" |
64 |
63 |
65 _LIT8(KScrollableBoxNodeName, "scrollablebox"); |
64 _LIT8(KScrollableBoxNodeName, "scrollablebox"); |
66 |
|
67 using namespace XnGestureHelper; |
|
68 #include "xngesture.h" |
|
69 |
65 |
70 // Constants |
66 // Constants |
71 const TInt KSkinGfxInnerRectShrink = 5; |
67 const TInt KSkinGfxInnerRectShrink = 5; |
72 const TInt KFocusGrowValue = 3; |
68 const TInt KFocusGrowValue = 3; |
73 |
69 |
74 const TInt KLongTapStartShortDelay( 150000 ); // 0.15s for Sk |
70 const TInt KLongTapStartShortDelay( 150000 ); // 0.15s for Sk |
75 const TInt KLongTapStartLongDelay( 500000 ); // 0.5s |
71 const TInt KLongTapStartLongDelay( 500000 ); // 0.5s |
76 const TInt KLongTapTimeShortDelay( 600000 ); // 0.6s for SK |
72 const TInt KLongTapTimeShortDelay( 600000 ); // 0.6s for SK |
77 const TInt KLongTapTimeLongDelay( 1500000 ); // 1.5s |
73 const TInt KLongTapTimeLongDelay( 1500000 ); // 1.5s |
|
74 |
|
75 const TInt KDragThreshold = 20; // pixels |
78 |
76 |
79 // LOCAL FUNCTION PROTOTYPES |
77 // LOCAL FUNCTION PROTOTYPES |
80 static TRgb ConvertHslToRgb( TInt aHue, TInt aSaturation, TInt aLightness ); |
78 static TRgb ConvertHslToRgb( TInt aHue, TInt aSaturation, TInt aLightness ); |
81 static void ConvertRgbToHsl( TRgb aRGB, TUint& aHue, TUint& aSaturation, |
79 static void ConvertRgbToHsl( TRgb aRGB, TUint& aHue, TUint& aSaturation, |
82 TUint& aLightness ); |
80 TUint& aLightness ); |
3354 CleanupStack::Pop( aTrgBitmap ); |
3352 CleanupStack::Pop( aTrgBitmap ); |
3355 } |
3353 } |
3356 |
3354 |
3357 // ----------------------------------------------------------------------------- |
3355 // ----------------------------------------------------------------------------- |
3358 // SoftkeyNode |
3356 // SoftkeyNode |
3359 // Gets the node of softkey according to index |
|
3360 // ----------------------------------------------------------------------------- |
|
3361 // |
|
3362 static CXnNode* SoftkeyNodeL( CXnNode* aMenuBarNode, const TDesC8& aSoftkey ) |
|
3363 { |
|
3364 if ( aMenuBarNode ) |
|
3365 { |
|
3366 XnMenuInterface::MXnMenuInterface* menuIf( NULL ); |
|
3367 XnComponentInterface::MakeInterfaceL( menuIf, aMenuBarNode->AppIfL() ); |
|
3368 CXnNodePluginIf* skNode( NULL ); |
|
3369 if ( menuIf ) |
|
3370 { |
|
3371 if ( aSoftkey == XnPropertyNames::softkey::type::KLeft ) |
|
3372 { |
|
3373 skNode = menuIf->SoftKeyL( |
|
3374 XnMenuInterface::MXnMenuInterface::ELeft ); |
|
3375 } |
|
3376 else if ( aSoftkey == XnPropertyNames::softkey::type::KMiddle ) |
|
3377 { |
|
3378 skNode = menuIf->SoftKeyL( |
|
3379 XnMenuInterface::MXnMenuInterface::ECenter ); |
|
3380 } |
|
3381 else if ( aSoftkey == XnPropertyNames::softkey::type::KRight ) |
|
3382 { |
|
3383 skNode = menuIf->SoftKeyL( |
|
3384 XnMenuInterface::MXnMenuInterface::ERight ); |
|
3385 } |
|
3386 } |
|
3387 if ( skNode ) |
|
3388 { |
|
3389 return &skNode->Node(); |
|
3390 } |
|
3391 } |
|
3392 return NULL; |
|
3393 } |
|
3394 |
|
3395 // ----------------------------------------------------------------------------- |
|
3396 // SoftkeyNode |
|
3397 // Gets the node of softkey according to pointer location |
3357 // Gets the node of softkey according to pointer location |
3398 // ----------------------------------------------------------------------------- |
3358 // ----------------------------------------------------------------------------- |
3399 // |
3359 // |
3400 static CXnNode* SoftkeyNode( CXnNode* aMenuBarNode, const TPoint aPosition ) |
3360 static CXnNode* SoftkeyNode( CXnNode* aMenuBarNode, const TPoint aPosition ) |
3401 { |
3361 { |
5863 CleanupStack::Pop( newBitmap ); |
5806 CleanupStack::Pop( newBitmap ); |
5864 return newBitmap; |
5807 return newBitmap; |
5865 } |
5808 } |
5866 |
5809 |
5867 // ----------------------------------------------------------------------------- |
5810 // ----------------------------------------------------------------------------- |
5868 // PassEventToGestureHelperL |
5811 // InitializeGestureL |
5869 // Forwards event to gesturehelper |
5812 // Sets up gesture |
5870 // ----------------------------------------------------------------------------- |
5813 // ----------------------------------------------------------------------------- |
5871 // |
5814 // |
5872 TBool CXnControlAdapterImpl::PassEventToGestureHelperL( |
5815 void CXnControlAdapterImpl::InitializeGestureL( |
5873 const TPointerEvent& aPointerEvent ) |
5816 const TPointerEvent& aPointerEvent ) |
5874 { |
5817 { |
5875 TBool ret( EFalse ); |
5818 if ( !iGestureFw || aPointerEvent.iType != TPointerEvent::EButton1Down ) |
|
5819 { |
|
5820 return; |
|
5821 } |
5876 |
5822 |
5877 CXnNode* node( &iNode.Node() ); |
5823 CXnUiEngine* engine( iNode.Node().UiEngine() ); |
5878 CXnUiEngine* engine( node->UiEngine() ); |
5824 // Set default destination |
5879 |
5825 iGestureDestination = &iNode.Node(); |
5880 if ( iGestureHelper && iGestureHelper->Owner() == node ) |
5826 |
5881 { |
5827 RPointerArray< CXnPluginData >& plugins( |
5882 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
5828 engine->ViewManager()->ActiveViewData().PluginData() ); |
5883 { |
5829 |
5884 // Set default destination |
5830 for ( TInt i = 0; i < plugins.Count(); i++ ) |
5885 iGestureHelper->SetDestination( iGestureHelper->Owner() ); |
5831 { |
|
5832 CXnPluginData* plugin( plugins[i] ); |
|
5833 |
|
5834 if ( plugin->Occupied() ) |
|
5835 { |
|
5836 CXnNode* widget( plugin->Node()->LayoutNode() ); |
5886 |
5837 |
5887 RPointerArray< CXnPluginData >& plugins( |
5838 if ( widget->MarginRect().Contains( aPointerEvent.iPosition ) ) |
5888 engine->ViewManager()->ActiveViewData().PluginData() ); |
5839 { |
5889 |
5840 // Resolve swipe destination |
5890 for ( TInt i = 0; i < plugins.Count(); i++ ) |
5841 CXnProperty* prop( widget->GetPropertyL( |
5891 { |
5842 XnPropertyNames::common::KSwipeDestination ) ); |
5892 CXnPluginData* plugin( plugins[i] ); |
5843 |
5893 |
5844 if ( prop ) |
5894 if ( plugin->Occupied() ) |
|
5895 { |
5845 { |
5896 CXnNode* widget( plugin->Node()->LayoutNode() ); |
5846 const TDesC8& value( prop->StringValue() ); |
5897 |
5847 |
5898 if ( widget->MarginRect().Contains( aPointerEvent.iPosition ) ) |
5848 if( value == XnPropertyNames::KWidget ) |
5899 { |
5849 { |
5900 // Resolve swipe destination |
5850 // Set widget as destination |
5901 CXnProperty* prop( widget->GetPropertyL( |
5851 iGestureDestination = widget; |
5902 XnPropertyNames::common::KSwipeDestination ) ); |
5852 } |
5903 |
5853 else if( value == XnPropertyNames::KNone ) |
5904 if ( prop ) |
5854 { |
5905 { |
5855 // Set no destination |
5906 const TDesC8& value( prop->StringValue() ); |
5856 iGestureDestination = NULL; |
5907 |
|
5908 if( value == XnPropertyNames::KWidget ) |
|
5909 { |
|
5910 // Set widget as destination |
|
5911 iGestureHelper->SetDestination( widget ); |
|
5912 } |
|
5913 else if( value == XnPropertyNames::KNone ) |
|
5914 { |
|
5915 // Set no destination |
|
5916 iGestureHelper->SetDestination( NULL ); |
|
5917 } |
|
5918 } |
|
5919 |
|
5920 break; |
|
5921 } |
5857 } |
5922 } |
5858 } |
|
5859 break; |
5923 } |
5860 } |
5924 } |
5861 } |
5925 |
5862 } |
5926 TXnGestureCode result( iGestureHelper->HandlePointerEventL( aPointerEvent ) ); |
5863 } |
|
5864 |
|
5865 // ----------------------------------------------------------------------------- |
|
5866 // ----------------------------------------------------------------------------- |
|
5867 // |
|
5868 void CXnControlAdapterImpl::RemoveChildAdapters() |
|
5869 { |
|
5870 iChildren.Reset(); |
|
5871 } |
|
5872 |
|
5873 // ----------------------------------------------------------------------------- |
|
5874 // ----------------------------------------------------------------------------- |
|
5875 // |
|
5876 RPointerArray< CXnControlAdapter >& CXnControlAdapterImpl::ChildAdapters() |
|
5877 { |
|
5878 return iChildren; |
|
5879 } |
|
5880 |
|
5881 // ----------------------------------------------------------------------------- |
|
5882 // ----------------------------------------------------------------------------- |
|
5883 // |
|
5884 RFs& CXnControlAdapterImpl::FsSession() |
|
5885 { |
|
5886 return iAdapter->ControlEnv()->FsSession(); |
|
5887 } |
|
5888 |
|
5889 // ----------------------------------------------------------------------------- |
|
5890 // ----------------------------------------------------------------------------- |
|
5891 // |
|
5892 void CXnControlAdapterImpl::HandleTouchGestureL( MAknTouchGestureFwEvent& aEvent ) |
|
5893 { |
|
5894 if ( aEvent.Group() == EAknTouchGestureFwGroupFlick ) |
|
5895 { |
|
5896 TAknTouchGestureFwType type = aEvent.Type(); |
5927 |
5897 |
5928 const TDesC8* swipe( NULL ); |
5898 const TDesC8* swipe( NULL ); |
5929 |
5899 |
5930 if ( result == EGestureSwipeLeft ) |
5900 if ( type == EAknTouchGestureFwFlickLeft ) |
5931 { |
5901 { |
5932 swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KLeft; |
5902 swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KLeft; |
5933 } |
5903 } |
5934 else if ( result == EGestureSwipeRight ) |
5904 else if ( type == EAknTouchGestureFwFlickRight ) |
5935 { |
5905 { |
5936 swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KRight; |
5906 swipe = &XnPropertyNames::action::trigger::name::swipe::direction::KRight; |
5937 } |
5907 } |
5938 |
5908 |
5939 if ( swipe ) |
5909 if ( swipe && iGestureDestination ) |
5940 { |
5910 { |
5941 CXnNode* destination( iGestureHelper->Destination() ); |
5911 CXnUiEngine* engine = iNode.Node().UiEngine(); |
|
5912 if ( iGestureDestination == &iNode.Node() ) |
|
5913 { |
|
5914 CancelFocusRefusalL( *engine ); |
|
5915 } |
5942 |
5916 |
5943 if ( destination ) |
5917 // Remove focus |
5944 { |
5918 engine->AppUiAdapter().HideFocus(); |
5945 if ( destination == iGestureHelper->Owner() ) |
5919 |
5946 { |
5920 CXnNode* trigger( BuildSwipeTriggerNodeLC( *engine, *swipe ) ); |
5947 CancelFocusRefusalL( *engine ); |
5921 iGestureDestination->ReportXuikonEventL( *trigger ); |
5948 } |
5922 CleanupStack::PopAndDestroy( trigger ); |
5949 |
5923 |
5950 // Remove focus |
5924 CXnAppUiAdapter& appui( engine->AppUiAdapter() ); |
5951 engine->AppUiAdapter().HideFocus(); |
5925 CXnViewData& data( appui.ViewManager().ActiveViewData() ); |
5952 |
5926 |
5953 CXnNode* trigger( BuildSwipeTriggerNodeLC( *engine, *swipe ) ); |
5927 CXnViewControlAdapter* control = |
5954 destination->ReportXuikonEventL( *trigger ); |
5928 static_cast< CXnViewControlAdapter* >( data.ViewNode()->Control() ); |
5955 CleanupStack::PopAndDestroy( trigger ); |
5929 |
5956 |
5930 control->ResetGrabbing(); |
5957 // If needed we can call here for example HandleSwipeL() |
5931 } |
5958 |
5932 } |
5959 // Consume this event |
|
5960 ret = ETrue; |
|
5961 } |
|
5962 } |
|
5963 } |
|
5964 |
|
5965 return ret; |
|
5966 } |
|
5967 |
|
5968 // ----------------------------------------------------------------------------- |
|
5969 // ----------------------------------------------------------------------------- |
|
5970 // |
|
5971 void CXnControlAdapterImpl::RemoveChildAdapters() |
|
5972 { |
|
5973 iChildren.Reset(); |
|
5974 } |
|
5975 |
|
5976 // ----------------------------------------------------------------------------- |
|
5977 // ----------------------------------------------------------------------------- |
|
5978 // |
|
5979 RPointerArray< CXnControlAdapter >& CXnControlAdapterImpl::ChildAdapters() |
|
5980 { |
|
5981 return iChildren; |
|
5982 } |
|
5983 |
|
5984 // ----------------------------------------------------------------------------- |
|
5985 // ----------------------------------------------------------------------------- |
|
5986 // |
|
5987 RFs& CXnControlAdapterImpl::FsSession() |
|
5988 { |
|
5989 return iAdapter->ControlEnv()->FsSession(); |
|
5990 } |
5933 } |
5991 |
5934 |
5992 |
5935 |
5993 // ============================= TIconProvider =============================== |
5936 // ============================= TIconProvider =============================== |
5994 |
5937 |