From: Umar Date: Thu, 26 Jan 2017 14:54:19 +0000 (+0000) Subject: Manual binding to add getter/setter APIs for Hover X-Git-Tag: dali_1.2.24~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=0c61136cd848c8541ae41e374588b42cbe11ac52 Manual binding to add getter/setter APIs for Hover Change-Id: I0bd5c96cae5f10078b580bcac1095899e1606f51 --- diff --git a/plugins/dali-swig/SWIG/dali-core.i b/plugins/dali-swig/SWIG/dali-core.i index 73ce8cc..48d8ff6 100755 --- a/plugins/dali-swig/SWIG/dali-core.i +++ b/plugins/dali-swig/SWIG/dali-core.i @@ -303,7 +303,7 @@ typedef std::pair< Dali::Radian, Dali::Radian > AngleThresholdPair; %template(LongPressGestureDetectedSignal) Dali::Signal; //%template(ActorTouchEventSignal) Dali::Signal; %template(ActorTouchDataSignal) Dali::Signal; -%template(ActorHoverEventSignal) Dali::Signal; +%template(ActorHoverSignal) Dali::Signal; %template(ActorWheelEventSignal) Dali::Signal; %template(ActorSignal) Dali::Signal; %template(KeyEventSignal) Dali::Signal; diff --git a/plugins/dali-swig/SWIG/dali-gc.i b/plugins/dali-swig/SWIG/dali-gc.i index a9566c8..2e86045 100644 --- a/plugins/dali-swig/SWIG/dali-gc.i +++ b/plugins/dali-swig/SWIG/dali-gc.i @@ -1207,8 +1207,6 @@ DALI_CREATE_CUSTOM_DISPOSE_DERIVED_FUNCTION( Dali, LongPressGestureDetector ); DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, KeyEvent ); DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, KeyEvent ); -DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, HoverEvent ); -DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, HoverEvent ); DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, TouchEvent ); DALI_CREATE_CUSTOM_DISPOSE_FUNCTION( Dali, TouchEvent ); DALI_CREATE_CUSTOM_DESTRUCTOR_FUNCTION( Dali, WheelEvent ); diff --git a/plugins/dali-swig/SWIG/dali.i b/plugins/dali-swig/SWIG/dali.i index 17a25e0..824ed85 100755 --- a/plugins/dali-swig/SWIG/dali.i +++ b/plugins/dali-swig/SWIG/dali.i @@ -286,6 +286,9 @@ using namespace Dali::Toolkit; %include dali-operator.i %include devel-properties.i +%include gestures/hover.i + + %include dali-core.i %include dali-adaptor.i %include dali-toolkit.i diff --git a/plugins/dali-swig/SWIG/events/control-event.i b/plugins/dali-swig/SWIG/events/control-event.i index 150be84..36704ca 100755 --- a/plugins/dali-swig/SWIG/events/control-event.i +++ b/plugins/dali-swig/SWIG/events/control-event.i @@ -191,10 +191,10 @@ * @brief Event arguments that passed via Hover signal * */ - public class HoverEventArgs : EventArgs + public class HoverArgs : EventArgs { private View _view; - private HoverEvent _hoverEvent; + private Hover _hover; /** * @brief View - is the view that is being hovered @@ -213,19 +213,19 @@ } /** - * @brief HoverEvent - contains touch points that represent the points + * @brief Hover - contains touch points that represent the points * that are currently being hovered or the points where a hover has stopped * */ - public HoverEvent HoverEvent + public Hover Hover { get { - return _hoverEvent; + return _hover; } set { - _hoverEvent = value; + _hover = value; } } } @@ -348,9 +348,9 @@ private TouchCallbackDelegate _viewTouchDataCallbackDelegate; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate bool HoverEventCallbackDelegate(IntPtr view, IntPtr hoverEvent); - private DaliEventHandlerWithReturnType _viewHoverEventHandler; - private HoverEventCallbackDelegate _viewHoverEventCallbackDelegate; + private delegate bool HoverCallbackDelegate(IntPtr view, IntPtr hover); + private DaliEventHandlerWithReturnType _viewHoverHandler; + private HoverCallbackDelegate _viewHoverCallbackDelegate; [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate bool WheelEventCallbackDelegate(IntPtr view, IntPtr wheelEvent); @@ -369,7 +369,7 @@ /** * @brief Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler - * (in the type of KeyInputFocusGainedEventHandler-DaliEventHandler) + * (in the type of KeyInputFocusGainedEventHandler-DaliEventHandler) * provided by the user. KeyInputFocusGained signal is emitted when the control gets Key Input Focus. */ public event DaliEventHandler KeyInputFocusGained @@ -628,22 +628,22 @@ /** * @brief Event for Hovered signal which can be used to subscribe/unsubscribe the event handler - * (in the type of HoverEventHandler-DaliEventHandlerWithReturnType) + * (in the type of HoverHandler-DaliEventHandlerWithReturnType) * provided by the user. Hovered signal is emitted when hover input is received. */ - public event DaliEventHandlerWithReturnType Hovered + public event DaliEventHandlerWithReturnType Hovered { add { lock(this) { // Restricted to only one listener - if (_viewHoverEventHandler == null) + if (_viewHoverHandler == null) { - _viewHoverEventHandler += value; + _viewHoverHandler += value; - _viewHoverEventCallbackDelegate = new HoverEventCallbackDelegate(OnHoverEvent); - this.HoveredSignal().Connect(_viewHoverEventCallbackDelegate); + _viewHoverCallbackDelegate = new HoverCallbackDelegate(OnHover); + this.HoveredSignal().Connect(_viewHoverCallbackDelegate); } } } @@ -652,29 +652,29 @@ { lock(this) { - if (_viewHoverEventHandler != null) + if (_viewHoverHandler != null) { - this.HoveredSignal().Disconnect(_viewHoverEventCallbackDelegate); + this.HoveredSignal().Disconnect(_viewHoverCallbackDelegate); } - _viewHoverEventHandler -= value; + _viewHoverHandler -= value; } } } // Callback for View Hover signal - private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent) + private bool OnHover(IntPtr view, IntPtr hover) { - HoverEventArgs e = new HoverEventArgs(); + HoverArgs e = new HoverArgs(); - // Populate all members of "e" (HoverEventArgs) with real data + // Populate all members of "e" (HoverArgs) with real data e.View = View.GetViewFromPtr(view); - e.HoverEvent = Dali.HoverEvent.GetHoverEventFromPtr(hoverEvent); + e.Hover = Dali.Hover.GetHoverFromPtr(hover); - if (_viewHoverEventHandler != null) + if (_viewHoverHandler != null) { //here we send all data to user event handlers - return _viewHoverEventHandler(this, e); + return _viewHoverHandler(this, e); } return false; diff --git a/plugins/dali-swig/SWIG/gestures/hover.i b/plugins/dali-swig/SWIG/gestures/hover.i new file mode 100644 index 0000000..6116efc --- /dev/null +++ b/plugins/dali-swig/SWIG/gestures/hover.i @@ -0,0 +1,62 @@ +%rename(Hover) Dali::HoverEvent; + +%csmethodmodifiers Dali::HoverEvent::points "private"; +%csmethodmodifiers Dali::HoverEvent::time "private"; + +%typemap(cscode) Dali::HoverEvent %{ + public static Hover GetHoverFromPtr(global::System.IntPtr cPtr) { + Hover ret = new Hover(cPtr, false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public uint GetTime() { + return time; + } + + public int GetDeviceId(uint point) { + if( point < points.Count ) + { + return points[(int)point].deviceId; + } + return -1; + } + + public PointStateType GetState(uint point) { + if( point < points.Count ) + { + return (Dali.PointStateType)(points[(int)point].state); + } + return PointStateType.FINISHED; + } + + public Actor GetHitActor(uint point) { + if( point < points.Count ) + { + return points[(int)point].hitActor; + } + else + { + // Return a native empty handle + Actor actor = new Actor(); + actor.Reset(); + return actor; + } + } + + public Vector2 GetLocalPosition(uint point) { + if( point < points.Count ) + { + return points[(int)point].local; + } + return new Vector2(0.0f, 0.0f); + } + + public Vector2 GetScreenPosition(uint point) { + if( point < points.Count ) + { + return points[(int)point].screen; + } + return new Vector2(0.0f, 0.0f); + } +%} \ No newline at end of file diff --git a/plugins/dali-swig/SWIG/signal-parameters.i b/plugins/dali-swig/SWIG/signal-parameters.i index 214abe4..ffb8ec7 100644 --- a/plugins/dali-swig/SWIG/signal-parameters.i +++ b/plugins/dali-swig/SWIG/signal-parameters.i @@ -56,7 +56,6 @@ DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, ResourceImage ); DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, Animation ); DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, TouchEvent ); DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, TouchData ); -DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, HoverEvent ); DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, WheelEvent ); DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, KeyEvent ); DALI_CREATE_C_PTR_TO_CSHARP_FUNCTION( Dali, LongPressGesture ); diff --git a/plugins/dali-swig/manual/csharp/CustomView.cs b/plugins/dali-swig/manual/csharp/CustomView.cs index f704885..020fad0 100644 --- a/plugins/dali-swig/manual/csharp/CustomView.cs +++ b/plugins/dali-swig/manual/csharp/CustomView.cs @@ -30,7 +30,7 @@ namespace Dali viewWrapperImpl.OnSizeSet = new ViewWrapperImpl.OnSizeSetDelegate(OnSizeSet); viewWrapperImpl.OnSizeAnimation = new ViewWrapperImpl.OnSizeAnimationDelegate(OnSizeAnimation); viewWrapperImpl.OnTouchEvent = new ViewWrapperImpl.OnTouchEventDelegate(OnTouchEvent); - viewWrapperImpl.OnHoverEvent = new ViewWrapperImpl.OnHoverEventDelegate(OnHoverEvent); + viewWrapperImpl.OnHover = new ViewWrapperImpl.OnHoverDelegate(OnHover); viewWrapperImpl.OnKeyEvent = new ViewWrapperImpl.OnKeyEventDelegate(OnKeyEvent); viewWrapperImpl.OnWheelEvent = new ViewWrapperImpl.OnWheelEventDelegate(OnWheelEvent); viewWrapperImpl.OnRelayout = new ViewWrapperImpl.OnRelayoutDelegate(OnRelayout); @@ -469,11 +469,11 @@ namespace Dali /** * @brief Called after a hover-event is received by the owning actor. * - * @param[in] event The hover event - * @return True if the event should be consumed. + * @param[in] hover The hover event + * @return True if the hover event should be consumed. * @note CustomViewBehaviour.REQUIRES_HOVER_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour). */ - public virtual bool OnHoverEvent(HoverEvent hoverEvent) + public virtual bool OnHover(Hover hover) { return false; // Do not consume } diff --git a/plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs b/plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs index 7605d4a..97e9cd3 100644 --- a/plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs +++ b/plugins/dali-swig/manual/csharp/ViewWrapperImpl.cs @@ -28,7 +28,7 @@ namespace Dali public delegate void OnSizeSetDelegate(Vector3 targetSize); public delegate void OnSizeAnimationDelegate(Animation animation, Vector3 targetSize); public delegate bool OnTouchEventDelegate(TouchEvent touchEvent); - public delegate bool OnHoverEventDelegate(HoverEvent hoverEvent); + public delegate bool OnHoverDelegate(Hover hover); public delegate bool OnKeyEventDelegate(KeyEvent keyEvent); public delegate bool OnWheelEventDelegate(WheelEvent wheelEvent); public delegate void OnRelayoutDelegate(Vector2 size, RelayoutContainer container); @@ -69,7 +69,7 @@ namespace Dali public OnSizeSetDelegate OnSizeSet; public OnSizeAnimationDelegate OnSizeAnimation; public OnTouchEventDelegate OnTouchEvent; - public OnHoverEventDelegate OnHoverEvent; + public OnHoverDelegate OnHover; public OnKeyEventDelegate OnKeyEvent; public OnWheelEventDelegate OnWheelEvent; public OnRelayoutDelegate OnRelayout; @@ -256,7 +256,7 @@ namespace Dali Delegate5 = new DelegateViewWrapperImpl_5(DirectorOnSizeSet); Delegate6 = new DelegateViewWrapperImpl_6(DirectorOnSizeAnimation); Delegate7 = new DelegateViewWrapperImpl_7(DirectorOnTouchEvent); - Delegate8 = new DelegateViewWrapperImpl_8(DirectorOnHoverEvent); + Delegate8 = new DelegateViewWrapperImpl_8(DirectorOnHover); Delegate9 = new DelegateViewWrapperImpl_9(DirectorOnKeyEvent); Delegate10 = new DelegateViewWrapperImpl_10(DirectorOnWheelEvent); Delegate11 = new DelegateViewWrapperImpl_11(DirectorOnRelayout); @@ -330,9 +330,9 @@ namespace Dali return OnTouchEvent(new TouchEvent(arg0, false)); } - private bool DirectorOnHoverEvent(global::System.IntPtr arg0) + private bool DirectorOnHover(global::System.IntPtr arg0) { - return OnHoverEvent(new HoverEvent(arg0, false)); + return OnHover(new Hover(arg0, false)); } private bool DirectorOnKeyEvent(global::System.IntPtr arg0)