2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 %define ACTOR_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define ACTOR_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
31 * @brief Event arguments that passed via Touch signal
34 public class TouchEventArgs : EventArgs
37 private TouchData _touchData;
40 * @brief Actor - is the actor that is being touched
56 * @brief TouchData - contains the information of touch points
59 public TouchData TouchData
73 * @brief Event arguments that passed via Hover signal
76 public class HoverEventArgs : EventArgs
79 private HoverEvent _hoverEvent;
82 * @brief Actor - is the actor that is being hovered
98 * @brief HoverEvent - contains touch points that represent the points
99 * that are currently being hovered or the points where a hover has stopped
102 public HoverEvent HoverEvent
116 * @brief Event arguments that passed via Wheel signal
119 public class WheelEventArgs : EventArgs
121 private Actor _actor;
122 private WheelEvent _wheelEvent;
125 * @brief Actor - is the actor that is being wheeled
141 * @brief WheelEvent - store a wheel rolling type : MOUSE_WHEEL or CUSTOM_WHEEL
144 public WheelEvent WheelEvent
158 * @brief Event arguments that passed via OnStage signal
161 public class OnStageEventArgs : EventArgs
163 private Actor _actor;
166 * @brief Actor - is the actor that is being connected to the stage
183 * @brief Event arguments that passed via OffStage signal
186 public class OffStageEventArgs : EventArgs
188 private Actor _actor;
191 * @brief Actor - is the actor that is being disconnected from the stage
208 * @brief Event arguments that passed via OnRelayout signal
211 public class OnRelayoutEventArgs : EventArgs
213 private Actor _actor;
216 * @brief Actor - is the actor that is being resized upon relayout
233 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
234 public delegate bool TouchEventHandler(object source, TouchEventArgs e);
236 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
237 public delegate bool HoverEventHandler(object source, HoverEventArgs e);
239 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
240 public delegate bool WheelEventHandler(object source, WheelEventArgs e);
242 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
243 public delegate void OnStageEventHandler(object source, OnStageEventArgs e);
245 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
246 public delegate void OffStageEventHandler(object source, OffStageEventArgs e);
248 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
249 public delegate void OnRelayoutEventHandler(object source, OnRelayoutEventArgs e);
251 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
252 private delegate bool TouchCallbackDelegate(IntPtr actor, IntPtr touchData);
253 private TouchEventHandler _actorTouchDataEventHandler;
254 private TouchCallbackDelegate _actorTouchDataCallbackDelegate;
256 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
257 private delegate bool HoverEventCallbackDelegate(IntPtr actor, IntPtr hoverEvent);
258 private HoverEventHandler _actorHoverEventHandler;
259 private HoverEventCallbackDelegate _actorHoverEventCallbackDelegate;
261 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
262 private delegate bool WheelEventCallbackDelegate(IntPtr actor, IntPtr wheelEvent);
263 private WheelEventHandler _actorWheelEventHandler;
264 private WheelEventCallbackDelegate _actorWheelEventCallbackDelegate;
266 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
267 private delegate void OnStageEventCallbackDelegate(IntPtr actor);
268 private OnStageEventHandler _actorOnStageEventHandler;
269 private OnStageEventCallbackDelegate _actorOnStageEventCallbackDelegate;
271 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
272 private delegate void OffStageEventCallbackDelegate(IntPtr actor);
273 private OffStageEventHandler _actorOffStageEventHandler;
274 private OffStageEventCallbackDelegate _actorOffStageEventCallbackDelegate;
276 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
277 private delegate void OnRelayoutEventCallbackDelegate(IntPtr actor);
278 private OnRelayoutEventHandler _actorOnRelayoutEventHandler;
279 private OnRelayoutEventCallbackDelegate _actorOnRelayoutEventCallbackDelegate;
282 * @brief Event for Touched signal which can be used to subscribe/unsubscribe the event handler
283 * (in the type of TouchEventHandler) provided by the user.
284 * Touched signal is emitted when touch input is received.
286 public event TouchEventHandler Touched
292 // Restricted to only one listener
293 if (_actorTouchDataEventHandler == null)
295 _actorTouchDataEventHandler += value;
297 _actorTouchDataCallbackDelegate = new TouchCallbackDelegate(OnTouch);
298 this.TouchSignal().Connect(_actorTouchDataCallbackDelegate);
307 if (_actorTouchDataEventHandler != null)
309 this.TouchSignal().Disconnect(_actorTouchDataCallbackDelegate);
312 _actorTouchDataEventHandler -= value;
317 // Callback for Actor TouchSignal
318 private bool OnTouch(IntPtr actor, IntPtr touchData)
320 TouchEventArgs e = new TouchEventArgs();
322 // Populate all members of "e" (TouchEventArgs) with real data
323 e.Actor = Actor.GetActorFromPtr(actor);
324 e.TouchData = Dali.TouchData.GetTouchDataFromPtr(touchData);
326 if (_actorTouchDataEventHandler != null)
328 //here we send all data to user event handlers
329 return _actorTouchDataEventHandler(this, e);
336 * @brief Event for Hovered signal which can be used to subscribe/unsubscribe the event handler
337 * (in the type of HoverEventHandler) provided by the user.
338 * Hovered signal is emitted when hover input is received.
340 public event HoverEventHandler Hovered
346 // Restricted to only one listener
347 if (_actorHoverEventHandler == null)
349 _actorHoverEventHandler += value;
351 _actorHoverEventCallbackDelegate = new HoverEventCallbackDelegate(OnHoverEvent);
352 this.HoveredSignal().Connect(_actorHoverEventCallbackDelegate);
361 if (_actorHoverEventHandler != null)
363 this.HoveredSignal().Disconnect(_actorHoverEventCallbackDelegate);
366 _actorHoverEventHandler -= value;
371 // Callback for Actor Hover signal
372 private bool OnHoverEvent(IntPtr actor, IntPtr hoverEvent)
374 HoverEventArgs e = new HoverEventArgs();
376 // Populate all members of "e" (HoverEventArgs) with real data
377 e.Actor = Actor.GetActorFromPtr(actor);
378 e.HoverEvent = Dali.HoverEvent.GetHoverEventFromPtr(hoverEvent);
380 if (_actorHoverEventHandler != null)
382 //here we send all data to user event handlers
383 return _actorHoverEventHandler(this, e);
390 * @brief Event for WheelMoved signal which can be used to subscribe/unsubscribe the event handler
391 * (in the type of WheelEventHandler) provided by the user.
392 * WheelMoved signal is emitted when wheel event is received.
394 public event WheelEventHandler WheelMoved
400 // Restricted to only one listener
401 if (_actorWheelEventHandler == null)
403 _actorWheelEventHandler += value;
405 _actorWheelEventCallbackDelegate = new WheelEventCallbackDelegate(OnWheelEvent);
406 this.WheelEventSignal().Connect(_actorWheelEventCallbackDelegate);
415 if (_actorWheelEventHandler != null)
417 this.WheelEventSignal().Disconnect(_actorWheelEventCallbackDelegate);
420 _actorWheelEventHandler -= value;
425 // Callback for Actor Wheel signal
426 private bool OnWheelEvent(IntPtr actor, IntPtr wheelEvent)
428 WheelEventArgs e = new WheelEventArgs();
430 // Populate all members of "e" (WheelEventArgs) with real data
431 e.Actor = Actor.GetActorFromPtr(actor);
432 e.WheelEvent = Dali.WheelEvent.GetWheelEventFromPtr(wheelEvent);
434 if (_actorWheelEventHandler != null)
436 //here we send all data to user event handlers
437 return _actorWheelEventHandler(this, e);
444 * @brief Event for OnStage signal which can be used to subscribe/unsubscribe the event handler
445 * (in the type of OnStageEventHandler) provided by the user.
446 * OnStage signal is emitted after the actor has been connected to the stage.
448 public event OnStageEventHandler OnStageEvent
454 // Restricted to only one listener
455 if (_actorOnStageEventHandler == null)
457 _actorOnStageEventHandler += value;
459 _actorOnStageEventCallbackDelegate = new OnStageEventCallbackDelegate(OnStage);
460 this.OnStageSignal().Connect(_actorOnStageEventCallbackDelegate);
469 if (_actorOnStageEventHandler != null)
471 this.OnStageSignal().Disconnect(_actorOnStageEventCallbackDelegate);
474 _actorOnStageEventHandler -= value;
479 // Callback for Actor OnStage signal
480 private void OnStage(IntPtr data)
482 OnStageEventArgs e = new OnStageEventArgs();
484 // Populate all members of "e" (OnStageEventArgs) with real data
485 e.Actor = Actor.GetActorFromPtr(data);
487 if (_actorOnStageEventHandler != null)
489 //here we send all data to user event handlers
490 _actorOnStageEventHandler(this, e);
495 * @brief Event for OffStage signal which can be used to subscribe/unsubscribe the event handler
496 * (in the type of OffStageEventHandler) provided by the user.
497 * OffStage signal is emitted after the actor has been disconnected from the stage.
499 public event OffStageEventHandler OffStageEvent
505 // Restricted to only one listener
506 if (_actorOffStageEventHandler == null)
508 _actorOffStageEventHandler += value;
510 _actorOffStageEventCallbackDelegate = new OffStageEventCallbackDelegate(OffStage);
511 this.OnStageSignal().Connect(_actorOffStageEventCallbackDelegate);
520 if (_actorOffStageEventHandler != null)
522 this.OnStageSignal().Disconnect(_actorOffStageEventCallbackDelegate);
525 _actorOffStageEventHandler -= value;
530 // Callback for Actor OffStage signal
531 private void OffStage(IntPtr data)
533 OffStageEventArgs e = new OffStageEventArgs();
535 // Populate all members of "e" (OffStageEventArgs) with real data
536 e.Actor = Actor.GetActorFromPtr(data);
538 if (_actorOffStageEventHandler != null)
540 //here we send all data to user event handlers
541 _actorOffStageEventHandler(this, e);
546 * @brief Event for OnRelayout signal which can be used to subscribe/unsubscribe the event handler
547 * (in the type of OnRelayoutEventHandler) provided by the user.
548 * OnRelayout signal is emitted after the size has been set on the actor during relayout.
550 public event OnRelayoutEventHandler OnRelayoutEvent
556 // Restricted to only one listener
557 if (_actorOnRelayoutEventHandler == null)
559 _actorOnRelayoutEventHandler += value;
561 _actorOnRelayoutEventCallbackDelegate = new OnRelayoutEventCallbackDelegate(OnRelayout);
562 this.OnRelayoutSignal().Connect(_actorOnRelayoutEventCallbackDelegate);
571 if (_actorOnRelayoutEventHandler != null)
573 this.OnRelayoutSignal().Disconnect(_actorOnRelayoutEventCallbackDelegate);
576 _actorOnRelayoutEventHandler -= value;
581 // Callback for Actor OnRelayout signal
582 private void OnRelayout(IntPtr data)
584 OnRelayoutEventArgs e = new OnRelayoutEventArgs();
586 // Populate all members of "e" (OnRelayoutEventArgs) with real data
587 e.Actor = Actor.GetActorFromPtr(data);
589 if (_actorOnRelayoutEventHandler != null)
591 //here we send all data to user event handlers
592 _actorOnRelayoutEventHandler(this, e);
596 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
597 ClassName ret = new ClassName(cPtr, false);
598 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602 public IntPtr GetPtrfrom ## ClassName ()
604 return (IntPtr)swigCPtr;
611 Actor parent = GetParent();
620 bool visibility = IsVisible();
633 public float CurrentOpacity
637 float ret = GetCurrentOpacity();
642 public bool StateFocusEnable
646 SetKeyboardFocusable(value);
650 bool focusable = IsKeyboardFocusable();
659 %define DALI_ACTOR_EVENTHANDLER_PARAM( NameSpace, ClassName)
661 ACTOR_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
662 ACTOR_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
668 DALI_ACTOR_EVENTHANDLER_PARAM( Dali, Actor);