From: dongsug song Date: Tue, 25 Oct 2016 13:38:21 +0000 (-0700) Subject: Merge "Move Event Handlers to View class" into devel/master X-Git-Tag: dali_1.2.12~9 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=2c223add632be0638418928056d5ac1421c47eb6;hp=e67c9d8f760dd679fcc2e1b265cdd6d42cc86759 Merge "Move Event Handlers to View class" into devel/master --- diff --git a/plugins/dali-swig/SWIG/events/actor-event.i b/plugins/dali-swig/SWIG/events/actor-event.i index 7eca466..c1f7095 100644 --- a/plugins/dali-swig/SWIG/events/actor-event.i +++ b/plugins/dali-swig/SWIG/events/actor-event.i @@ -26,555 +26,6 @@ %define ACTOR_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName) %typemap(cscode) NameSpace::ClassName %{ - - /** - * @brief Event arguments that passed via Touch signal - * - */ - public class TouchEventArgs : EventArgs - { - private Actor _actor; - private TouchData _touchData; - - /** - * @brief Actor - is the actor that is being touched - * - */ - public Actor Actor - { - get - { - return _actor; - } - set - { - _actor = value; - } - } - - /** - * @brief TouchData - contains the information of touch points - * - */ - public TouchData TouchData - { - get - { - return _touchData; - } - set - { - _touchData = value; - } - } - } - - /** - * @brief Event arguments that passed via Hover signal - * - */ - public class HoverEventArgs : EventArgs - { - private Actor _actor; - private HoverEvent _hoverEvent; - - /** - * @brief Actor - is the actor that is being hovered - * - */ - public Actor Actor - { - get - { - return _actor; - } - set - { - _actor = value; - } - } - - /** - * @brief HoverEvent - contains touch points that represent the points - * that are currently being hovered or the points where a hover has stopped - * - */ - public HoverEvent HoverEvent - { - get - { - return _hoverEvent; - } - set - { - _hoverEvent = value; - } - } - } - - /** - * @brief Event arguments that passed via Wheel signal - * - */ - public class WheelEventArgs : EventArgs - { - private Actor _actor; - private WheelEvent _wheelEvent; - - /** - * @brief Actor - is the actor that is being wheeled - * - */ - public Actor Actor - { - get - { - return _actor; - } - set - { - _actor = value; - } - } - - /** - * @brief WheelEvent - store a wheel rolling type : MOUSE_WHEEL or CUSTOM_WHEEL - * - */ - public WheelEvent WheelEvent - { - get - { - return _wheelEvent; - } - set - { - _wheelEvent = value; - } - } - } - - /** - * @brief Event arguments that passed via OnStage signal - * - */ - public class OnStageEventArgs : EventArgs - { - private Actor _actor; - - /** - * @brief Actor - is the actor that is being connected to the stage - * - */ - public Actor Actor - { - get - { - return _actor; - } - set - { - _actor = value; - } - } - } - - /** - * @brief Event arguments that passed via OffStage signal - * - */ - public class OffStageEventArgs : EventArgs - { - private Actor _actor; - - /** - * @brief Actor - is the actor that is being disconnected from the stage - * - */ - public Actor Actor - { - get - { - return _actor; - } - set - { - _actor = value; - } - } - } - - /** - * @brief Event arguments that passed via OnRelayout signal - * - */ - public class OnRelayoutEventArgs : EventArgs - { - private Actor _actor; - - /** - * @brief Actor - is the actor that is being resized upon relayout - * - */ - public Actor Actor - { - get - { - return _actor; - } - set - { - _actor = value; - } - } - } - - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate bool TouchCallbackDelegate(IntPtr actor, IntPtr touchData); - private DaliEventHandlerWithReturnType _actorTouchDataEventHandler; - private TouchCallbackDelegate _actorTouchDataCallbackDelegate; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate bool HoverEventCallbackDelegate(IntPtr actor, IntPtr hoverEvent); - private DaliEventHandlerWithReturnType _actorHoverEventHandler; - private HoverEventCallbackDelegate _actorHoverEventCallbackDelegate; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate bool WheelEventCallbackDelegate(IntPtr actor, IntPtr wheelEvent); - private DaliEventHandlerWithReturnType _actorWheelEventHandler; - private WheelEventCallbackDelegate _actorWheelEventCallbackDelegate; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void OnStageEventCallbackDelegate(IntPtr actor); - private DaliEventHandler _actorOnStageEventHandler; - private OnStageEventCallbackDelegate _actorOnStageEventCallbackDelegate; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void OffStageEventCallbackDelegate(IntPtr actor); - private DaliEventHandler _actorOffStageEventHandler; - private OffStageEventCallbackDelegate _actorOffStageEventCallbackDelegate; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void OnRelayoutEventCallbackDelegate(IntPtr actor); - private DaliEventHandler _actorOnRelayoutEventHandler; - private OnRelayoutEventCallbackDelegate _actorOnRelayoutEventCallbackDelegate; - - /** - * @brief Event for Touched signal which can be used to subscribe/unsubscribe the event handler - * (in the type of TouchEventHandler-DaliEventHandlerWithReturnType) - * provided by the user. Touched signal is emitted when touch input is received. - */ - public event DaliEventHandlerWithReturnType Touched - { - add - { - lock(this) - { - // Restricted to only one listener - if (_actorTouchDataEventHandler == null) - { - _actorTouchDataEventHandler += value; - - _actorTouchDataCallbackDelegate = new TouchCallbackDelegate(OnTouch); - this.TouchSignal().Connect(_actorTouchDataCallbackDelegate); - } - } - } - - remove - { - lock(this) - { - if (_actorTouchDataEventHandler != null) - { - this.TouchSignal().Disconnect(_actorTouchDataCallbackDelegate); - } - - _actorTouchDataEventHandler -= value; - } - } - } - - // Callback for Actor TouchSignal - private bool OnTouch(IntPtr actor, IntPtr touchData) - { - TouchEventArgs e = new TouchEventArgs(); - - // Populate all members of "e" (TouchEventArgs) with real data - e.Actor = Actor.GetActorFromPtr(actor); - e.TouchData = Dali.TouchData.GetTouchDataFromPtr(touchData); - - if (_actorTouchDataEventHandler != null) - { - //here we send all data to user event handlers - return _actorTouchDataEventHandler(this, e); - } - - return false; - } - - /** - * @brief Event for Hovered signal which can be used to subscribe/unsubscribe the event handler - * (in the type of HoverEventHandler-DaliEventHandlerWithReturnType) - * provided by the user. Hovered signal is emitted when hover input is received. - */ - public event DaliEventHandlerWithReturnType Hovered - { - add - { - lock(this) - { - // Restricted to only one listener - if (_actorHoverEventHandler == null) - { - _actorHoverEventHandler += value; - - _actorHoverEventCallbackDelegate = new HoverEventCallbackDelegate(OnHoverEvent); - this.HoveredSignal().Connect(_actorHoverEventCallbackDelegate); - } - } - } - - remove - { - lock(this) - { - if (_actorHoverEventHandler != null) - { - this.HoveredSignal().Disconnect(_actorHoverEventCallbackDelegate); - } - - _actorHoverEventHandler -= value; - } - } - } - - // Callback for Actor Hover signal - private bool OnHoverEvent(IntPtr actor, IntPtr hoverEvent) - { - HoverEventArgs e = new HoverEventArgs(); - - // Populate all members of "e" (HoverEventArgs) with real data - e.Actor = Actor.GetActorFromPtr(actor); - e.HoverEvent = Dali.HoverEvent.GetHoverEventFromPtr(hoverEvent); - - if (_actorHoverEventHandler != null) - { - //here we send all data to user event handlers - return _actorHoverEventHandler(this, e); - } - - return false; - } - - /** - * @brief Event for WheelMoved signal which can be used to subscribe/unsubscribe the event handler - * (in the type of WheelEventHandler-DaliEventHandlerWithReturnType) - * provided by the user. WheelMoved signal is emitted when wheel event is received. - */ - public event DaliEventHandlerWithReturnType WheelMoved - { - add - { - lock(this) - { - // Restricted to only one listener - if (_actorWheelEventHandler == null) - { - _actorWheelEventHandler += value; - - _actorWheelEventCallbackDelegate = new WheelEventCallbackDelegate(OnWheelEvent); - this.WheelEventSignal().Connect(_actorWheelEventCallbackDelegate); - } - } - } - - remove - { - lock(this) - { - if (_actorWheelEventHandler != null) - { - this.WheelEventSignal().Disconnect(_actorWheelEventCallbackDelegate); - } - - _actorWheelEventHandler -= value; - } - } - } - - // Callback for Actor Wheel signal - private bool OnWheelEvent(IntPtr actor, IntPtr wheelEvent) - { - WheelEventArgs e = new WheelEventArgs(); - - // Populate all members of "e" (WheelEventArgs) with real data - e.Actor = Actor.GetActorFromPtr(actor); - e.WheelEvent = Dali.WheelEvent.GetWheelEventFromPtr(wheelEvent); - - if (_actorWheelEventHandler != null) - { - //here we send all data to user event handlers - return _actorWheelEventHandler(this, e); - } - - return false; - } - - /** - * @brief Event for OnStage signal which can be used to subscribe/unsubscribe the event handler - * (in the type of OnStageEventHandler) provided by the user. - * OnStage signal is emitted after the actor has been connected to the stage. - */ - public event DaliEventHandler OnStageEvent - { - add - { - lock(this) - { - // Restricted to only one listener - if (_actorOnStageEventHandler == null) - { - _actorOnStageEventHandler += value; - - _actorOnStageEventCallbackDelegate = new OnStageEventCallbackDelegate(OnStage); - this.OnStageSignal().Connect(_actorOnStageEventCallbackDelegate); - } - } - } - - remove - { - lock(this) - { - if (_actorOnStageEventHandler != null) - { - this.OnStageSignal().Disconnect(_actorOnStageEventCallbackDelegate); - } - - _actorOnStageEventHandler -= value; - } - } - } - - // Callback for Actor OnStage signal - private void OnStage(IntPtr data) - { - OnStageEventArgs e = new OnStageEventArgs(); - - // Populate all members of "e" (OnStageEventArgs) with real data - e.Actor = Actor.GetActorFromPtr(data); - - if (_actorOnStageEventHandler != null) - { - //here we send all data to user event handlers - _actorOnStageEventHandler(this, e); - } - } - - /** - * @brief Event for OffStage signal which can be used to subscribe/unsubscribe the event handler - * (in the type of OffStageEventHandler) provided by the user. - * OffStage signal is emitted after the actor has been disconnected from the stage. - */ - public event DaliEventHandler OffStageEvent - { - add - { - lock(this) - { - // Restricted to only one listener - if (_actorOffStageEventHandler == null) - { - _actorOffStageEventHandler += value; - - _actorOffStageEventCallbackDelegate = new OffStageEventCallbackDelegate(OffStage); - this.OnStageSignal().Connect(_actorOffStageEventCallbackDelegate); - } - } - } - - remove - { - lock(this) - { - if (_actorOffStageEventHandler != null) - { - this.OnStageSignal().Disconnect(_actorOffStageEventCallbackDelegate); - } - - _actorOffStageEventHandler -= value; - } - } - } - - // Callback for Actor OffStage signal - private void OffStage(IntPtr data) - { - OffStageEventArgs e = new OffStageEventArgs(); - - // Populate all members of "e" (OffStageEventArgs) with real data - e.Actor = Actor.GetActorFromPtr(data); - - if (_actorOffStageEventHandler != null) - { - //here we send all data to user event handlers - _actorOffStageEventHandler(this, e); - } - } - - /** - * @brief Event for OnRelayout signal which can be used to subscribe/unsubscribe the event handler - * (in the type of OnRelayoutEventHandler) provided by the user. - * OnRelayout signal is emitted after the size has been set on the actor during relayout. - */ - public event DaliEventHandler OnRelayoutEvent - { - add - { - lock(this) - { - // Restricted to only one listener - if (_actorOnRelayoutEventHandler == null) - { - _actorOnRelayoutEventHandler += value; - - _actorOnRelayoutEventCallbackDelegate = new OnRelayoutEventCallbackDelegate(OnRelayout); - this.OnRelayoutSignal().Connect(_actorOnRelayoutEventCallbackDelegate); - } - } - } - - remove - { - lock(this) - { - if (_actorOnRelayoutEventHandler != null) - { - this.OnRelayoutSignal().Disconnect(_actorOnRelayoutEventCallbackDelegate); - } - - _actorOnRelayoutEventHandler -= value; - } - } - } - - // Callback for Actor OnRelayout signal - private void OnRelayout(IntPtr data) - { - OnRelayoutEventArgs e = new OnRelayoutEventArgs(); - - // Populate all members of "e" (OnRelayoutEventArgs) with real data - e.Actor = Actor.GetActorFromPtr(data); - - if (_actorOnRelayoutEventHandler != null) - { - //here we send all data to user event handlers - _actorOnRelayoutEventHandler(this, e); - } - } - public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) { ClassName ret = new ClassName(cPtr, false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -595,7 +46,7 @@ } } - public bool Vibility + public bool Visibility { get { diff --git a/plugins/dali-swig/SWIG/events/control-event.i b/plugins/dali-swig/SWIG/events/control-event.i index 9f7d02f..489af5a 100644 --- a/plugins/dali-swig/SWIG/events/control-event.i +++ b/plugins/dali-swig/SWIG/events/control-event.i @@ -16,297 +16,845 @@ */ %define CONTROL_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName) -%typemap(csimports) NameSpace::ClassName %{ -using System; -using System.Runtime.InteropServices; + %typemap(csimports) NameSpace::ClassName %{ + using System; + using System.Runtime.InteropServices; -%} + %} -%enddef + %enddef %define CONTROL_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName) -%typemap(cscode) NameSpace::ClassName %{ + %typemap(cscode) NameSpace::ClassName %{ -/** - * @brief Event arguments that passed via KeyInputFocusGained signal - * - */ -public class KeyInputFocusGainedEventArgs : EventArgs -{ - private View _view; - - /** - * @brief View - is the view that gets Key Input Focus + /** + * @brief Event arguments that passed via KeyInputFocusGained signal * */ - public View View - { - get + public class KeyInputFocusGainedEventArgs : EventArgs + { + private View _view; + + /** + * @brief View - is the view that gets Key Input Focus + * + */ + public View View { - return _view; + get + { + return _view; + } + set + { + _view = value; + } } - set + } + + /** + * @brief Event arguments that passed via KeyInputFocusLost signal + * + */ + public class KeyInputFocusLostEventArgs : EventArgs + { + private View _view; + + /** + * @brief View - is the view that loses Key Input Focus + * + */ + public View View { - _view = value; + get + { + return _view; + } + set + { + _view = value; + } } - } -} - -/** - * @brief Event arguments that passed via KeyInputFocusLost signal - * - */ -public class KeyInputFocusLostEventArgs : EventArgs -{ - private View _view; + } - /** - * @brief View - is the view that loses Key Input Focus + /** + * @brief Event arguments that passed via KeyEvent signal * */ - public View View - { - get + public class KeyEventArgs : EventArgs + { + private View _view; + private KeyEvent _keyEvent; + + /** + * @brief View - is the view that recieves the keyevent. + * + */ + public View View { - return _view; + get + { + return _view; + } + set + { + _view = value; + } } - set + + /** + * @brief KeyEvent - is the keyevent sent to the View. + * + */ + public KeyEvent KeyEvent { - _view = value; + get + { + return _keyEvent; + } + set + { + _keyEvent = value; + } + } + } + + /** + * @brief Event arguments that passed via OnRelayout signal + * + */ + public class OnRelayoutEventArgs : EventArgs + { + private View _view; + + /** + * @brief View - is the view that is being resized upon relayout + * + */ + public View View + { + get + { + return _view; + } + set + { + _view = value; + } + } + } + + + /** + * @brief Event arguments that passed via Touch signal + * + */ + public class TouchEventArgs : EventArgs + { + private View _view; + private TouchData _touchData; + + /** + * @brief View - is the view that is being touched + * + */ + public View View + { + get + { + return _view; + } + set + { + _view = value; + } } - } -} -/** - * @brief Event arguments that passed via KeyEvent signal - * - */ -public class KeyEventArgs : EventArgs -{ - private View _view; - private KeyEvent _keyEvent; + /** + * @brief TouchData - contains the information of touch points + * + */ + public TouchData TouchData + { + get + { + return _touchData; + } + set + { + _touchData = value; + } + } + } + + /** + * @brief Event arguments that passed via Hover signal + * + */ + public class HoverEventArgs : EventArgs + { + private View _view; + private HoverEvent _hoverEvent; + + /** + * @brief View - is the view that is being hovered + * + */ + public View View + { + get + { + return _view; + } + set + { + _view = value; + } + } - /** - * @brief View - is the view that recieves the keyevent. - * + /** + * @brief HoverEvent - contains touch points that represent the points + * that are currently being hovered or the points where a hover has stopped + * + */ + public HoverEvent HoverEvent + { + get + { + return _hoverEvent; + } + set + { + _hoverEvent = value; + } + } + } + + /** + * @brief Event arguments that passed via Wheel signal + * + */ + public class WheelEventArgs : EventArgs + { + private View _view; + private WheelEvent _wheelEvent; + + /** + * @brief View - is the view that is being wheeled + * + */ + public View View + { + get + { + return _view; + } + set + { + _view = value; + } + } + + /** + * @brief WheelEvent - store a wheel rolling type : MOUSE_WHEEL or CUSTOM_WHEEL + * + */ + public WheelEvent WheelEvent + { + get + { + return _wheelEvent; + } + set + { + _wheelEvent = value; + } + } + } + + /** + * @brief Event arguments that passed via OnStage signal + * + */ + public class OnStageEventArgs : EventArgs + { + private View _view; + + /** + * @brief View - is the view that is being connected to the stage + * + */ + public View View + { + get + { + return _view; + } + set + { + _view = value; + } + } + } + + /** + * @brief Event arguments that passed via OffStage signal + * + */ + public class OffStageEventArgs : EventArgs + { + private View _view; + + /** + * @brief View - is the view that is being disconnected from the stage + * + */ + public View View + { + get + { + return _view; + } + set + { + _view = value; + } + } + } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void KeyInputFocusGainedCallbackDelegate(IntPtr control); + private DaliEventHandler _KeyInputFocusGainedEventHandler; + private KeyInputFocusGainedCallbackDelegate _KeyInputFocusGainedCallbackDelegate; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void KeyInputFocusLostCallbackDelegate(IntPtr control); + private DaliEventHandler _KeyInputFocusLostEventHandler; + private KeyInputFocusLostCallbackDelegate _KeyInputFocusLostCallbackDelegate; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool KeyCallbackDelegate(IntPtr control, IntPtr keyEvent); + private DaliEventHandlerWithReturnType _KeyEventHandler; + private KeyCallbackDelegate _KeyCallbackDelegate; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void OnRelayoutEventCallbackDelegate(IntPtr control); + private DaliEventHandler _viewOnRelayoutEventHandler; + private OnRelayoutEventCallbackDelegate _viewOnRelayoutEventCallbackDelegate; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool TouchCallbackDelegate(IntPtr view, IntPtr touchData); + private DaliEventHandlerWithReturnType _viewTouchDataEventHandler; + private TouchCallbackDelegate _viewTouchDataCallbackDelegate; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool HoverEventCallbackDelegate(IntPtr view, IntPtr hoverEvent); + private DaliEventHandlerWithReturnType _viewHoverEventHandler; + private HoverEventCallbackDelegate _viewHoverEventCallbackDelegate; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate bool WheelEventCallbackDelegate(IntPtr view, IntPtr wheelEvent); + private DaliEventHandlerWithReturnType _viewWheelEventHandler; + private WheelEventCallbackDelegate _viewWheelEventCallbackDelegate; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void OnStageEventCallbackDelegate(IntPtr control); + private DaliEventHandler _viewOnStageEventHandler; + private OnStageEventCallbackDelegate _viewOnStageEventCallbackDelegate; + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void OffStageEventCallbackDelegate(IntPtr control); + private DaliEventHandler _viewOffStageEventHandler; + private OffStageEventCallbackDelegate _viewOffStageEventCallbackDelegate; + + /** + * @brief Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler + * (in the type of KeyInputFocusGainedEventHandler-DaliEventHandler) + * provided by the user. KeyInputFocusGained signal is emitted when the control gets Key Input Focus. */ - public View View - { - get + public event DaliEventHandler KeyInputFocusGained + { + add + { + lock(this) + { + // Restricted to only one listener + if (_KeyInputFocusGainedEventHandler == null) + { + _KeyInputFocusGainedEventHandler += value; + Console.WriteLine("View Keyevent EVENT Locked...."); + _KeyInputFocusGainedCallbackDelegate = new KeyInputFocusGainedCallbackDelegate(OnKeyInputFocusGained); + this.KeyInputFocusGainedSignal().Connect(_KeyInputFocusGainedCallbackDelegate); + } + } + } + + remove { - return _view; + lock(this) + { + if (_KeyInputFocusGainedEventHandler != null) + { + this.KeyInputFocusGainedSignal().Disconnect(_KeyInputFocusGainedCallbackDelegate); + } + + _KeyInputFocusGainedEventHandler -= value; + } } - set + } + + private void OnKeyInputFocusGained(IntPtr view) + { + KeyInputFocusGainedEventArgs e = new KeyInputFocusGainedEventArgs(); + Console.WriteLine("View Keyevent ...."); + // Populate all members of "e" (KeyInputFocusGainedEventArgs) with real data + e.View = Dali.View.GetViewFromPtr(view); + + if (_KeyInputFocusGainedEventHandler != null) { - _view = value; + //here we send all data to user event handlers + _KeyInputFocusGainedEventHandler(this, e); } - } - /** - * @brief KeyEvent - is the keyevent sent to the View. - * + } + + /** + * @brief Event for KeyInputFocusLost signal which can be used to subscribe/unsubscribe the event handler + * (in the type of KeyInputFocusLostEventHandler-DaliEventHandler) + * provided by the user. KeyInputFocusLost signal is emitted when the control loses Key Input Focus. */ - public KeyEvent KeyEvent - { - get + public event DaliEventHandler KeyInputFocusLost + { + add { - return _keyEvent; + lock(this) + { + // Restricted to only one listener + if (_KeyInputFocusLostEventHandler == null) + { + _KeyInputFocusLostEventHandler += value; + + _KeyInputFocusLostCallbackDelegate = new KeyInputFocusLostCallbackDelegate(OnKeyInputFocusLost); + this.KeyInputFocusLostSignal().Connect(_KeyInputFocusLostCallbackDelegate); + } + } } - set + + remove { - _keyEvent = value; + lock(this) + { + if (_KeyInputFocusLostEventHandler != null) + { + this.KeyInputFocusLostSignal().Disconnect(_KeyInputFocusLostCallbackDelegate); + } + + _KeyInputFocusLostEventHandler -= value; + } + } + } + + private void OnKeyInputFocusLost(IntPtr view) + { + KeyInputFocusLostEventArgs e = new KeyInputFocusLostEventArgs(); + + // Populate all members of "e" (KeyInputFocusLostEventArgs) with real data + e.View = Dali.View.GetViewFromPtr(view); + + if (_KeyInputFocusLostEventHandler != null) + { + //here we send all data to user event handlers + _KeyInputFocusLostEventHandler(this, e); + } + } + + /** + * @brief Event for KeyPressed signal which can be used to subscribe/unsubscribe the event handler + * (in the type of KeyEventEventHandler-DaliEventHandlerWithReturnType) + * provided by the user. KeyPressed signal is emitted when key event is received. + */ + public event DaliEventHandlerWithReturnType KeyPressed + { + add + { + lock(this) + { + // Restricted to only one listener + if (_KeyEventHandler == null) + { + _KeyEventHandler += value; + + _KeyCallbackDelegate = new KeyCallbackDelegate(OnKeyEvent); + this.KeyEventSignal().Connect(_KeyCallbackDelegate); + } + } } - } -} - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void KeyInputFocusGainedCallbackDelegate(IntPtr control); - private DaliEventHandler _KeyInputFocusGainedEventHandler; - private KeyInputFocusGainedCallbackDelegate _KeyInputFocusGainedCallbackDelegate; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void KeyInputFocusLostCallbackDelegate(IntPtr control); - private DaliEventHandler _KeyInputFocusLostEventHandler; - private KeyInputFocusLostCallbackDelegate _KeyInputFocusLostCallbackDelegate; - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate bool KeyCallbackDelegate(IntPtr control, IntPtr keyEvent); - private DaliEventHandlerWithReturnType _KeyEventHandler; - private KeyCallbackDelegate _KeyCallbackDelegate; - - /** - * @brief Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler - * (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 - { - add - { + remove + { lock(this) { - // Restricted to only one listener - if (_KeyInputFocusGainedEventHandler == null) - { - _KeyInputFocusGainedEventHandler += value; + if (_KeyEventHandler != null) + { + this.KeyEventSignal().Disconnect(_KeyCallbackDelegate); + } + + _KeyEventHandler -= value; + } + } + } + + private bool OnKeyEvent(IntPtr view, IntPtr keyEvent) + { + KeyEventArgs e = new KeyEventArgs(); + + // Populate all members of "e" (KeyEventArgs) with real data + e.View = Dali.View.GetViewFromPtr(view); + e.KeyEvent = Dali.KeyEvent.GetKeyEventFromPtr(keyEvent); - _KeyInputFocusGainedCallbackDelegate = new KeyInputFocusGainedCallbackDelegate(OnKeyInputFocusGained); - this.KeyInputFocusGainedSignal().Connect(_KeyInputFocusGainedCallbackDelegate); - } + if (_KeyEventHandler != null) + { + //here we send all data to user event handlers + return _KeyEventHandler(this, e); + } + return false; + + } + + /** + * @brief Event for OnRelayout signal which can be used to subscribe/unsubscribe the event handler + * (in the type of OnRelayoutEventHandler) provided by the user. + * OnRelayout signal is emitted after the size has been set on the view during relayout. + */ + public event DaliEventHandler OnRelayoutEvent + { + add + { + lock(this) + { + // Restricted to only one listener + if (_viewOnRelayoutEventHandler == null) + { + _viewOnRelayoutEventHandler += value; + Console.WriteLine("View OnRelayoutEventArgs Locked...."); + _viewOnRelayoutEventCallbackDelegate = new OnRelayoutEventCallbackDelegate(OnRelayout); + this.OnRelayoutSignal().Connect(_viewOnRelayoutEventCallbackDelegate); + } } - } + } - remove - { + remove + { lock(this) { - if (_KeyInputFocusGainedEventHandler != null) - { - this.KeyInputFocusGainedSignal().Disconnect(_KeyInputFocusGainedCallbackDelegate); - } + if (_viewOnRelayoutEventHandler != null) + { + this.OnRelayoutSignal().Disconnect(_viewOnRelayoutEventCallbackDelegate); + } - _KeyInputFocusGainedEventHandler -= value; + _viewOnRelayoutEventHandler -= value; } - } - } + } + } + + // Callback for View OnRelayout signal + private void OnRelayout(IntPtr data) + { + OnRelayoutEventArgs e = new OnRelayoutEventArgs(); + Console.WriteLine("View OnRelayoutEventArgs...."); + // Populate all members of "e" (OnRelayoutEventArgs) with real data + e.View = View.GetViewFromPtr(data); - private void OnKeyInputFocusGained(IntPtr view) - { - KeyInputFocusGainedEventArgs e = new KeyInputFocusGainedEventArgs(); + if (_viewOnRelayoutEventHandler != null) + { + //here we send all data to user event handlers + _viewOnRelayoutEventHandler(this, e); + } + } + + /** + * @brief Event for Touched signal which can be used to subscribe/unsubscribe the event handler + * (in the type of TouchEventHandler-DaliEventHandlerWithReturnType) + * provided by the user. Touched signal is emitted when touch input is received. + */ + public event DaliEventHandlerWithReturnType Touched + { + add + { + lock(this) + { + // Restricted to only one listener + if (_viewTouchDataEventHandler == null) + { + _viewTouchDataEventHandler += value; + Console.WriteLine("View Touch EVENT LOCKED...."); + _viewTouchDataCallbackDelegate = new TouchCallbackDelegate(OnTouch); + this.TouchSignal().Connect(_viewTouchDataCallbackDelegate); + } + } + } - // Populate all members of "e" (KeyInputFocusGainedEventArgs) with real data - e.View = Dali.View.GetViewFromPtr(view); + remove + { + lock(this) + { + if (_viewTouchDataEventHandler != null) + { + this.TouchSignal().Disconnect(_viewTouchDataCallbackDelegate); + } - if (_KeyInputFocusGainedEventHandler != null) - { - //here we send all data to user event handlers - _KeyInputFocusGainedEventHandler(this, e); - } + _viewTouchDataEventHandler -= value; + } + } + } + + // Callback for View TouchSignal + private bool OnTouch(IntPtr view, IntPtr touchData) + { + TouchEventArgs e = new TouchEventArgs(); + Console.WriteLine("View Touch EVENT...."); + // Populate all members of "e" (TouchEventArgs) with real data + e.View = View.GetViewFromPtr(view); + e.TouchData = Dali.TouchData.GetTouchDataFromPtr(touchData); + + if (_viewTouchDataEventHandler != null) + { + //here we send all data to user event handlers + return _viewTouchDataEventHandler(this, e); + } - } + return false; + } + + /** + * @brief Event for Hovered signal which can be used to subscribe/unsubscribe the event handler + * (in the type of HoverEventHandler-DaliEventHandlerWithReturnType) + * provided by the user. Hovered signal is emitted when hover input is received. + */ + public event DaliEventHandlerWithReturnType Hovered + { + add + { + lock(this) + { + // Restricted to only one listener + if (_viewHoverEventHandler == null) + { + _viewHoverEventHandler += value; + + _viewHoverEventCallbackDelegate = new HoverEventCallbackDelegate(OnHoverEvent); + this.HoveredSignal().Connect(_viewHoverEventCallbackDelegate); + } + } + } - /** - * @brief Event for KeyInputFocusLost signal which can be used to subscribe/unsubscribe the event handler - * (in the type of KeyInputFocusLostEventHandler-DaliEventHandler) - * provided by the user. KeyInputFocusLost signal is emitted when the control loses Key Input Focus. - */ - public event DaliEventHandler KeyInputFocusLost - { - add - { + remove + { lock(this) { - // Restricted to only one listener - if (_KeyInputFocusLostEventHandler == null) - { - _KeyInputFocusLostEventHandler += value; + if (_viewHoverEventHandler != null) + { + this.HoveredSignal().Disconnect(_viewHoverEventCallbackDelegate); + } - _KeyInputFocusLostCallbackDelegate = new KeyInputFocusLostCallbackDelegate(OnKeyInputFocusLost); - this.KeyInputFocusLostSignal().Connect(_KeyInputFocusLostCallbackDelegate); - } + _viewHoverEventHandler -= value; } - } + } + } + + // Callback for View Hover signal + private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent) + { + HoverEventArgs e = new HoverEventArgs(); + + // Populate all members of "e" (HoverEventArgs) with real data + e.View = View.GetViewFromPtr(view); + e.HoverEvent = Dali.HoverEvent.GetHoverEventFromPtr(hoverEvent); + + if (_viewHoverEventHandler != null) + { + //here we send all data to user event handlers + return _viewHoverEventHandler(this, e); + } - remove - { + return false; + } + + /** + * @brief Event for WheelMoved signal which can be used to subscribe/unsubscribe the event handler + * (in the type of WheelEventHandler-DaliEventHandlerWithReturnType) + * provided by the user. WheelMoved signal is emitted when wheel event is received. + */ + public event DaliEventHandlerWithReturnType WheelMoved + { + add + { lock(this) { - if (_KeyInputFocusLostEventHandler != null) - { - this.KeyInputFocusLostSignal().Disconnect(_KeyInputFocusLostCallbackDelegate); - } - - _KeyInputFocusLostEventHandler -= value; - } - } - } - - private void OnKeyInputFocusLost(IntPtr view) - { - KeyInputFocusLostEventArgs e = new KeyInputFocusLostEventArgs(); - - // Populate all members of "e" (KeyInputFocusLostEventArgs) with real data - e.View = Dali.View.GetViewFromPtr(view); - - if (_KeyInputFocusLostEventHandler != null) - { - //here we send all data to user event handlers - _KeyInputFocusLostEventHandler(this, e); - } - } - - /** - * @brief Event for KeyPressed signal which can be used to subscribe/unsubscribe the event handler - * (in the type of KeyEventEventHandler-DaliEventHandlerWithReturnType) - * provided by the user. KeyPressed signal is emitted when key event is received. - */ - public event DaliEventHandlerWithReturnType KeyPressed - { - add - { + // Restricted to only one listener + if (_viewWheelEventHandler == null) + { + _viewWheelEventHandler += value; + Console.WriteLine("View Wheel EVENT LOCKED...."); + _viewWheelEventCallbackDelegate = new WheelEventCallbackDelegate(OnWheelEvent); + this.WheelEventSignal().Connect(_viewWheelEventCallbackDelegate); + } + } + } + + remove + { lock(this) { - // Restricted to only one listener - if (_KeyEventHandler == null) - { - _KeyEventHandler += value; + if (_viewWheelEventHandler != null) + { + this.WheelEventSignal().Disconnect(_viewWheelEventCallbackDelegate); + } + + _viewWheelEventHandler -= value; + } + } + } + + // Callback for View Wheel signal + private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent) + { + WheelEventArgs e = new WheelEventArgs(); + Console.WriteLine("View Wheel EVENT ...."); + // Populate all members of "e" (WheelEventArgs) with real data + e.View = View.GetViewFromPtr(view); + e.WheelEvent = Dali.WheelEvent.GetWheelEventFromPtr(wheelEvent); + + if (_viewWheelEventHandler != null) + { + //here we send all data to user event handlers + return _viewWheelEventHandler(this, e); + } - _KeyCallbackDelegate = new KeyCallbackDelegate(OnKeyEvent); - this.KeyEventSignal().Connect(_KeyCallbackDelegate); - } + return false; + } + + /** + * @brief Event for OnStage signal which can be used to subscribe/unsubscribe the event handler + * (in the type of OnStageEventHandler) provided by the user. + * OnStage signal is emitted after the view has been connected to the stage. + */ + public event DaliEventHandler OnStageEvent + { + add + { + lock(this) + { + // Restricted to only one listener + if (_viewOnStageEventHandler == null) + { + _viewOnStageEventHandler += value; + + _viewOnStageEventCallbackDelegate = new OnStageEventCallbackDelegate(OnStage); + this.OnStageSignal().Connect(_viewOnStageEventCallbackDelegate); + } } - } + } - remove - { + remove + { lock(this) { - if (_KeyEventHandler != null) - { - this.KeyEventSignal().Disconnect(_KeyCallbackDelegate); - } + if (_viewOnStageEventHandler != null) + { + this.OnStageSignal().Disconnect(_viewOnStageEventCallbackDelegate); + } + + _viewOnStageEventHandler -= value; + } + } + } + + // Callback for View OnStage signal + private void OnStage(IntPtr data) + { + OnStageEventArgs e = new OnStageEventArgs(); - _KeyEventHandler -= value; + // Populate all members of "e" (OnStageEventArgs) with real data + e.View = View.GetViewFromPtr(data); + + if (_viewOnStageEventHandler != null) + { + //here we send all data to user event handlers + _viewOnStageEventHandler(this, e); + } + } + + /** + * @brief Event for OffStage signal which can be used to subscribe/unsubscribe the event handler + * (in the type of OffStageEventHandler) provided by the user. + * OffStage signal is emitted after the view has been disconnected from the stage. + */ + public event DaliEventHandler OffStageEvent + { + add + { + lock(this) + { + // Restricted to only one listener + if (_viewOffStageEventHandler == null) + { + _viewOffStageEventHandler += value; + + _viewOffStageEventCallbackDelegate = new OffStageEventCallbackDelegate(OffStage); + this.OnStageSignal().Connect(_viewOffStageEventCallbackDelegate); + } } - } - } + } + + remove + { + lock(this) + { + if (_viewOffStageEventHandler != null) + { + this.OnStageSignal().Disconnect(_viewOffStageEventCallbackDelegate); + } - private bool OnKeyEvent(IntPtr view, IntPtr keyEvent) - { - KeyEventArgs e = new KeyEventArgs(); + _viewOffStageEventHandler -= value; + } + } + } - // Populate all members of "e" (KeyEventArgs) with real data - e.View = Dali.View.GetViewFromPtr(view); - e.KeyEvent = Dali.KeyEvent.GetKeyEventFromPtr(keyEvent); + // Callback for View OffStage signal + private void OffStage(IntPtr data) + { + OffStageEventArgs e = new OffStageEventArgs(); - if (_KeyEventHandler != null) - { - //here we send all data to user event handlers - return _KeyEventHandler(this, e); - } - return false; + // Populate all members of "e" (OffStageEventArgs) with real data + e.View = View.GetViewFromPtr(data); - } + if (_viewOffStageEventHandler != null) + { + //here we send all data to user event handlers + _viewOffStageEventHandler(this, e); + } + } - public static View GetViewFromPtr(global::System.IntPtr cPtr) { - View ret = new View(cPtr, false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } + public static View GetViewFromPtr(global::System.IntPtr cPtr) { + View ret = new View(cPtr, false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } -%} + %} -%enddef + %enddef %define DALI_CONTROL_EVENTHANDLER_PARAM( NameSpace, ClassName) CONTROL_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName); CONTROL_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName); -%enddef + %enddef -namespace Dali + namespace Dali { DALI_CONTROL_EVENTHANDLER_PARAM( Dali::Toolkit, Control); } diff --git a/plugins/dali-swig/examples/scroll-view.cs b/plugins/dali-swig/examples/scroll-view.cs index 9710c0e..93554fc 100644 --- a/plugins/dali-swig/examples/scroll-view.cs +++ b/plugins/dali-swig/examples/scroll-view.cs @@ -21,125 +21,184 @@ using Dali; namespace MyCSharpExample { - class Example - { - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - delegate void CallbackDelegate(IntPtr data); + class Example + { + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void CallbackDelegate(IntPtr data); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - delegate void ActorCallbackDelegate(IntPtr data); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + delegate void ActorCallbackDelegate(IntPtr data); - private Dali.Application _application; - private ScrollView _scrollView; - private ScrollBar _scrollBar; + private Dali.Application _application; + private ScrollView _scrollView; + private ScrollBar _scrollBar; + private Animation _animation; + private TextLabel _text; - public Example(Dali.Application application) - { - _application = application; - _application.Initialized += Initialize; - } + public Example(Dali.Application application) + { + _application = application; + _application.Initialized += Initialize; + } - public void Initialize(object source, AUIApplicationInitEventArgs e) - { - CreateScrollView(); - } + public void Initialize(object source, AUIApplicationInitEventArgs e) + { + CreateScrollView(); + } - private void CreateScrollView() + private void CreateScrollView() + { + Stage stage = Stage.GetCurrent(); + stage.BackgroundColor = NDalic.WHITE; + + // Create a scroll view + _scrollView = new ScrollView(); + Vector2 stageSize = stage.Size; + _scrollView.Size = new Vector3(stageSize.x, stageSize.y, 0.0f); + _scrollView.ParentOrigin = NDalic.ParentOriginCenter; + _scrollView.AnchorPoint = NDalic.AnchorPointCenter; + stage.Add(_scrollView); + + // Add actors to a scroll view with 3 pages + int pageRows = 1; + int pageColumns = 3; + for(int pageRow = 0; pageRow < pageRows; pageRow++) + { + for(int pageColumn = 0; pageColumn < pageColumns; pageColumn++) { - Stage stage = Stage.GetCurrent(); - stage.BackgroundColor = NDalic.WHITE; - - // Create a scroll view - _scrollView = new ScrollView(); - Vector2 stageSize = stage.Size; - _scrollView.Size = new Vector3(stageSize.x, stageSize.y, 0.0f); - _scrollView.ParentOrigin = NDalic.ParentOriginCenter; - _scrollView.AnchorPoint = NDalic.AnchorPointCenter; - stage.Add(_scrollView); - - // Add actors to a scroll view with 3 pages - int pageRows = 1; - int pageColumns = 3; - for(int pageRow = 0; pageRow < pageRows; pageRow++) + View pageActor = new View(); + pageActor.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.ALL_DIMENSIONS); + pageActor.ParentOrigin = NDalic.ParentOriginCenter; + pageActor.AnchorPoint = NDalic.AnchorPointCenter; + pageActor.Position = new Vector3(pageColumn * stageSize.x, pageRow * stageSize.y, 0.0f); + + // Add images in a 3x4 grid layout for each page + int imageRows = 4; + int imageColumns = 3; + float margin = 10.0f; + Vector3 imageSize = new Vector3((stageSize.x / imageColumns) - margin, (stageSize.y / imageRows) - margin, 0.0f); + + for(int row = 0; row < imageRows; row++) + { + for(int column = 0; column < imageColumns;column++) { - for(int pageColumn = 0; pageColumn < pageColumns; pageColumn++) - { - View pageActor = new View(); - pageActor.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.ALL_DIMENSIONS); - pageActor.ParentOrigin = NDalic.ParentOriginCenter; - pageActor.AnchorPoint = NDalic.AnchorPointCenter; - pageActor.Position = new Vector3(pageColumn * stageSize.x, pageRow * stageSize.y, 0.0f); - - // Add images in a 3x4 grid layout for each page - int imageRows = 4; - int imageColumns = 3; - float margin = 10.0f; - Vector3 imageSize = new Vector3((stageSize.x / imageColumns) - margin, (stageSize.y / imageRows) - margin, 0.0f); - - for(int row = 0; row < imageRows; row++) - { - for(int column = 0; column < imageColumns;column++) - { - int imageId = (row * imageColumns + column) % 2 + 1; - ImageView imageView = new ImageView("images/image-" + imageId + ".jpg"); - imageView.ParentOrigin = NDalic.ParentOriginCenter; - imageView.AnchorPoint = NDalic.AnchorPointCenter; - imageView.Size = imageSize; - imageView.Position = new Vector3( margin * 0.5f + (imageSize.x + margin) * column - stageSize.x * 0.5f + imageSize.x * 0.5f, - margin * 0.5f + (imageSize.y + margin) * row - stageSize.y * 0.5f + imageSize.y * 0.5f, 0.0f ); - pageActor.Add(imageView); - } - } - - _scrollView.Add(pageActor); - } + int imageId = (row * imageColumns + column) % 2 + 1; + ImageView imageView = new ImageView("images/image-" + imageId + ".jpg"); + imageView.ParentOrigin = NDalic.ParentOriginCenter; + imageView.AnchorPoint = NDalic.AnchorPointCenter; + imageView.Size = imageSize; + imageView.Position = new Vector3( margin * 0.5f + (imageSize.x + margin) * column - stageSize.x * 0.5f + imageSize.x * 0.5f, + margin * 0.5f + (imageSize.y + margin) * row - stageSize.y * 0.5f + imageSize.y * 0.5f, 0.0f ); + pageActor.Add(imageView); } + } - _scrollView.SetAxisAutoLock(true); - - // Set scroll view to have 3 pages in X axis and allow page snapping, - // and also disable scrolling in Y axis. - RulerPtr scrollRulerX = new RulerPtr(new FixedRuler(stageSize.width)); - RulerPtr scrollRulerY = new RulerPtr(new DefaultRuler()); - scrollRulerX.SetDomain(new RulerDomain(0.0f, stageSize.width * pageColumns, true)); - scrollRulerY.Disable(); - _scrollView.SetRulerX(scrollRulerX); - _scrollView.SetRulerY(scrollRulerY); - - // Create a horizontal scroll bar in the bottom of scroll view (which is optional) - _scrollBar = new ScrollBar(); - _scrollBar.ParentOrigin = NDalic.ParentOriginBottomLeft; - _scrollBar.AnchorPoint = NDalic.AnchorPointTopLeft; - _scrollBar.SetResizePolicy(ResizePolicyType.FIT_TO_CHILDREN, DimensionType.WIDTH); - _scrollBar.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.HEIGHT); - _scrollBar.Orientation = new Quaternion( new Radian( new Degree( 270.0f ) ), Vector3.ZAXIS ); - _scrollBar.SetScrollDirection(ScrollBar.Direction.Horizontal); - _scrollView.Add(_scrollBar); - - // Connect to the OnRelayout signal - _scrollView.OnRelayoutEvent += OnScrollViewRelayout; + _scrollView.Add(pageActor); } + } + + _scrollView.SetAxisAutoLock(true); + + // Set scroll view to have 3 pages in X axis and allow page snapping, + // and also disable scrolling in Y axis. + RulerPtr scrollRulerX = new RulerPtr(new FixedRuler(stageSize.width)); + RulerPtr scrollRulerY = new RulerPtr(new DefaultRuler()); + scrollRulerX.SetDomain(new RulerDomain(0.0f, stageSize.width * pageColumns, true)); + scrollRulerY.Disable(); + _scrollView.SetRulerX(scrollRulerX); + _scrollView.SetRulerY(scrollRulerY); + + // Create a horizontal scroll bar in the bottom of scroll view (which is optional) + _scrollBar = new ScrollBar(); + _scrollBar.ParentOrigin = NDalic.ParentOriginBottomLeft; + _scrollBar.AnchorPoint = NDalic.AnchorPointTopLeft; + _scrollBar.SetResizePolicy(ResizePolicyType.FIT_TO_CHILDREN, DimensionType.WIDTH); + _scrollBar.SetResizePolicy(ResizePolicyType.FILL_TO_PARENT, DimensionType.HEIGHT); + _scrollBar.Orientation = new Quaternion( new Radian( new Degree( 270.0f ) ), Vector3.ZAXIS ); + _scrollBar.SetScrollDirection(ScrollBar.Direction.Horizontal); + _scrollView.Add(_scrollBar); + + // Connect to the OnRelayout signal + _scrollView.OnRelayoutEvent += OnScrollViewRelayout; + _scrollView.Touched += OnTouch; + _scrollView.WheelMoved += Onwheel; + _scrollView.KeyInputFocusGained += OnKey; + _text = new TextLabel("View Touch Event Handler Test"); + _text.ParentOrigin = NDalic.ParentOriginCenter; + _text.AnchorPoint = NDalic.AnchorPointCenter; + _text.HorizontalAlignment = "CENTER"; + _text.PointSize = 48.0f; + + _scrollView.Add(_text); + } - private void OnScrollViewRelayout(object source, View.OnRelayoutEventArgs e) - { - // Set the correct scroll bar size after size negotiation of scroll view is done - _scrollBar.Size = new Vector3(0.0f, _scrollView.GetRelayoutSize(DimensionType.WIDTH), 0.0f); - } + // Callback for _animation finished signal handling + public void AnimationFinished(object source, Animation.FinishedEventArgs e) + { + Console.WriteLine("Customized Animation Finished Event handler"); + Console.WriteLine("Animation finished: duration = " + e.Animation.Duration); + } + private void OnKey(object source, View.KeyInputFocusGainedEventArgs e) + { + Console.WriteLine("View Keyevent EVENT callback...."); + } - public void MainLoop() - { - _application.MainLoop (); - } + private bool Onwheel(object source, View.WheelEventArgs e) + { + Console.WriteLine("View Wheel EVENT callback...."); + return true; + } - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) + private bool OnTouch(object source, View.TouchEventArgs e) + { + Console.WriteLine("View TOUCH EVENT callback...."); + + // Only animate the _text label when touch down happens + if( e.TouchData.GetState(0) == PointStateType.DOWN ) + { + Console.WriteLine("Customized Stage Touch event handler"); + // Create a new _animation + if( _animation ) { - Example example = new Example(Application.NewApplication()); - example.MainLoop (); + _animation.Reset(); } + + _animation = new Animation(1.0f); // 1 second of duration + + _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 180.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f)); + _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 0.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f)); + + // Connect the signal callback for animaiton finished signal + _animation.Finished += AnimationFinished; + + // Play the _animation + _animation.Play(); + } + return true; } + + private void OnScrollViewRelayout(object source, View.OnRelayoutEventArgs e) + { + Console.WriteLine("View OnRelayoutEventArgs EVENT callback...."); + + // Set the correct scroll bar size after size negotiation of scroll view is done + _scrollBar.Size = new Vector3(0.0f, _scrollView.GetRelayoutSize(DimensionType.WIDTH), 0.0f); + } + + public void MainLoop() + { + _application.MainLoop (); + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + Example example = new Example(Application.NewApplication()); + example.MainLoop (); + } + } }