DALi C# binding - Change methods into Properties
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / actor-event.i
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 %define ACTOR_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
20     using System;
21     using System.Runtime.InteropServices;
22 %}
23
24 %enddef
25
26 %define ACTOR_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27   %typemap(cscode) NameSpace::ClassName %{
28
29
30     /**
31       * @brief Event arguments that passed via Touch signal
32       *
33       */
34     public class TouchEventArgs : EventArgs
35     {
36        private Actor _actor;
37        private TouchData _touchData;
38
39       /**
40         * @brief Actor - is the actor that is being touched
41         *
42         */
43       public Actor Actor
44       {
45         get
46         {
47           return _actor;
48         }
49         set
50         {
51           _actor = value;
52         }
53       }
54
55       /**
56         * @brief TouchData - contains the information of touch points
57         *
58         */
59       public TouchData TouchData
60       {
61         get
62         {
63           return _touchData;
64         }
65         set
66         {
67           _touchData = value;
68         }
69       }
70     }
71
72     /**
73       * @brief Event arguments that passed via Hover signal
74       *
75       */
76     public class HoverEventArgs : EventArgs
77     {
78     private Actor _actor;
79     private HoverEvent _hoverEvent;
80
81       /**
82         * @brief Actor - is the actor that is being hovered
83         *
84         */
85       public Actor Actor
86       {
87         get
88         {
89           return _actor;
90         }
91         set
92         {
93           _actor = value;
94         }
95       }
96
97       /**
98         * @brief HoverEvent - contains touch points that represent the points
99         * that are currently being hovered or the points where a hover has stopped
100         *
101         */
102       public HoverEvent HoverEvent
103       {
104         get
105         {
106           return _hoverEvent;
107         }
108         set
109         {
110           _hoverEvent = value;
111         }
112       }
113     }
114
115     /**
116       * @brief Event arguments that passed via Wheel signal
117       *
118       */
119     public class WheelEventArgs : EventArgs
120     {
121     private Actor _actor;
122     private WheelEvent _wheelEvent;
123
124       /**
125         * @brief Actor - is the actor that is being wheeled
126         *
127         */
128       public Actor Actor
129       {
130         get
131         {
132           return _actor;
133         }
134         set
135         {
136           _actor = value;
137         }
138       }
139
140       /**
141         * @brief WheelEvent - store a wheel rolling type : MOUSE_WHEEL or CUSTOM_WHEEL
142         *
143         */
144       public WheelEvent WheelEvent
145       {
146         get
147         {
148           return _wheelEvent;
149         }
150         set
151         {
152           _wheelEvent = value;
153         }
154       }
155     }
156
157     /**
158       * @brief Event arguments that passed via OnStage signal
159       *
160       */
161     public class OnStageEventArgs : EventArgs
162     {
163     private Actor _actor;
164
165       /**
166         * @brief Actor - is the actor that is being connected to the stage
167         *
168         */
169       public Actor Actor
170       {
171         get
172         {
173           return _actor;
174         }
175         set
176         {
177           _actor = value;
178         }
179       }
180     }
181
182     /**
183       * @brief Event arguments that passed via OffStage signal
184       *
185       */
186     public class OffStageEventArgs : EventArgs
187     {
188     private Actor _actor;
189
190       /**
191         * @brief Actor - is the actor that is being disconnected from the stage
192         *
193         */
194       public Actor Actor
195       {
196         get
197         {
198           return _actor;
199         }
200         set
201         {
202           _actor = value;
203         }
204       }
205     }
206
207     /**
208       * @brief Event arguments that passed via OnRelayout signal
209       *
210       */
211     public class OnRelayoutEventArgs : EventArgs
212     {
213       private Actor _actor;
214
215       /**
216         * @brief Actor - is the actor that is being resized upon relayout
217         *
218         */
219       public Actor Actor
220       {
221         get
222         {
223           return _actor;
224         }
225         set
226         {
227           _actor = value;
228         }
229       }
230     }
231
232
233     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
234     public delegate bool TouchEventHandler(object source, TouchEventArgs e);
235
236     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
237     public delegate bool HoverEventHandler(object source, HoverEventArgs e);
238
239     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
240     public delegate bool WheelEventHandler(object source, WheelEventArgs e);
241
242     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
243     public delegate void OnStageEventHandler(object source, OnStageEventArgs e);
244
245     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
246     public delegate void OffStageEventHandler(object source, OffStageEventArgs e);
247
248     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
249     public delegate void OnRelayoutEventHandler(object source, OnRelayoutEventArgs e);
250
251     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
252     private delegate bool TouchCallbackDelegate(IntPtr actor, IntPtr touchData);
253     private TouchEventHandler _actorTouchDataEventHandler;
254     private TouchCallbackDelegate _actorTouchDataCallbackDelegate;
255
256     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
257     private delegate bool HoverEventCallbackDelegate(IntPtr actor, IntPtr hoverEvent);
258     private HoverEventHandler _actorHoverEventHandler;
259     private HoverEventCallbackDelegate _actorHoverEventCallbackDelegate;
260
261     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
262     private delegate bool WheelEventCallbackDelegate(IntPtr actor, IntPtr wheelEvent);
263     private WheelEventHandler _actorWheelEventHandler;
264     private WheelEventCallbackDelegate _actorWheelEventCallbackDelegate;
265
266     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
267     private delegate void OnStageEventCallbackDelegate(IntPtr actor);
268     private OnStageEventHandler _actorOnStageEventHandler;
269     private OnStageEventCallbackDelegate _actorOnStageEventCallbackDelegate;
270
271     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
272     private delegate void OffStageEventCallbackDelegate(IntPtr actor);
273     private OffStageEventHandler _actorOffStageEventHandler;
274     private OffStageEventCallbackDelegate _actorOffStageEventCallbackDelegate;
275
276     [UnmanagedFunctionPointer(CallingConvention.StdCall)]
277     private delegate void OnRelayoutEventCallbackDelegate(IntPtr actor);
278     private OnRelayoutEventHandler _actorOnRelayoutEventHandler;
279     private OnRelayoutEventCallbackDelegate _actorOnRelayoutEventCallbackDelegate;
280
281     /**
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.
285       */
286     public event TouchEventHandler Touched
287     {
288       add
289       {
290         lock(this)
291         {
292           // Restricted to only one listener
293           if (_actorTouchDataEventHandler == null)
294           {
295             _actorTouchDataEventHandler += value;
296
297             _actorTouchDataCallbackDelegate = new TouchCallbackDelegate(OnTouch);
298             this.TouchSignal().Connect(_actorTouchDataCallbackDelegate);
299           }
300         }
301       }
302
303       remove
304       {
305         lock(this)
306         {
307           if (_actorTouchDataEventHandler != null)
308           {
309             this.TouchSignal().Disconnect(_actorTouchDataCallbackDelegate);
310           }
311
312           _actorTouchDataEventHandler -= value;
313         }
314       }
315     }
316
317     // Callback for Actor TouchSignal
318     private bool OnTouch(IntPtr actor, IntPtr touchData)
319     {
320       TouchEventArgs e = new TouchEventArgs();
321
322       // Populate all members of "e" (TouchEventArgs) with real data
323       e.Actor = Actor.GetActorFromPtr(actor);
324       e.TouchData = Dali.TouchData.GetTouchDataFromPtr(touchData);
325
326       if (_actorTouchDataEventHandler != null)
327       {
328         //here we send all data to user event handlers
329         return _actorTouchDataEventHandler(this, e);
330       }
331
332       return false;
333     }
334
335     /**
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.
339       */
340     public event HoverEventHandler Hovered
341     {
342       add
343       {
344         lock(this)
345         {
346           // Restricted to only one listener
347           if (_actorHoverEventHandler == null)
348           {
349             _actorHoverEventHandler += value;
350
351             _actorHoverEventCallbackDelegate = new HoverEventCallbackDelegate(OnHoverEvent);
352             this.HoveredSignal().Connect(_actorHoverEventCallbackDelegate);
353           }
354         }
355       }
356
357       remove
358       {
359         lock(this)
360         {
361           if (_actorHoverEventHandler != null)
362           {
363             this.HoveredSignal().Disconnect(_actorHoverEventCallbackDelegate);
364           }
365
366           _actorHoverEventHandler -= value;
367         }
368       }
369     }
370
371     // Callback for Actor Hover signal
372     private bool OnHoverEvent(IntPtr actor, IntPtr hoverEvent)
373     {
374       HoverEventArgs e = new HoverEventArgs();
375
376       // Populate all members of "e" (HoverEventArgs) with real data
377       e.Actor = Actor.GetActorFromPtr(actor);
378       e.HoverEvent = Dali.HoverEvent.GetHoverEventFromPtr(hoverEvent);
379
380       if (_actorHoverEventHandler != null)
381       {
382         //here we send all data to user event handlers
383         return _actorHoverEventHandler(this, e);
384       }
385
386       return false;
387     }
388
389     /**
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.
393       */
394     public event WheelEventHandler WheelMoved
395     {
396       add
397       {
398         lock(this)
399         {
400           // Restricted to only one listener
401           if (_actorWheelEventHandler == null)
402           {
403             _actorWheelEventHandler += value;
404
405             _actorWheelEventCallbackDelegate = new WheelEventCallbackDelegate(OnWheelEvent);
406             this.WheelEventSignal().Connect(_actorWheelEventCallbackDelegate);
407           }
408         }
409       }
410
411       remove
412       {
413         lock(this)
414         {
415           if (_actorWheelEventHandler != null)
416           {
417             this.WheelEventSignal().Disconnect(_actorWheelEventCallbackDelegate);
418           }
419
420           _actorWheelEventHandler -= value;
421         }
422       }
423     }
424
425     // Callback for Actor Wheel signal
426     private bool OnWheelEvent(IntPtr actor, IntPtr wheelEvent)
427     {
428       WheelEventArgs e = new WheelEventArgs();
429
430       // Populate all members of "e" (WheelEventArgs) with real data
431       e.Actor = Actor.GetActorFromPtr(actor);
432       e.WheelEvent = Dali.WheelEvent.GetWheelEventFromPtr(wheelEvent);
433
434       if (_actorWheelEventHandler != null)
435       {
436         //here we send all data to user event handlers
437         return _actorWheelEventHandler(this, e);
438       }
439
440       return false;
441     }
442
443     /**
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.
447       */
448     public event OnStageEventHandler OnStageEvent
449     {
450       add
451       {
452         lock(this)
453         {
454           // Restricted to only one listener
455           if (_actorOnStageEventHandler == null)
456           {
457             _actorOnStageEventHandler += value;
458
459             _actorOnStageEventCallbackDelegate = new OnStageEventCallbackDelegate(OnStage);
460             this.OnStageSignal().Connect(_actorOnStageEventCallbackDelegate);
461           }
462         }
463       }
464
465       remove
466       {
467         lock(this)
468         {
469           if (_actorOnStageEventHandler != null)
470           {
471             this.OnStageSignal().Disconnect(_actorOnStageEventCallbackDelegate);
472           }
473
474           _actorOnStageEventHandler -= value;
475         }
476       }
477     }
478
479     // Callback for Actor OnStage signal
480     private void OnStage(IntPtr data)
481     {
482       OnStageEventArgs e = new OnStageEventArgs();
483
484       // Populate all members of "e" (OnStageEventArgs) with real data
485       e.Actor = Actor.GetActorFromPtr(data);
486
487       if (_actorOnStageEventHandler != null)
488       {
489         //here we send all data to user event handlers
490         _actorOnStageEventHandler(this, e);
491       }
492     }
493
494     /**
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.
498       */
499     public event OffStageEventHandler OffStageEvent
500     {
501       add
502       {
503         lock(this)
504         {
505           // Restricted to only one listener
506           if (_actorOffStageEventHandler == null)
507           {
508             _actorOffStageEventHandler += value;
509
510             _actorOffStageEventCallbackDelegate = new OffStageEventCallbackDelegate(OffStage);
511             this.OnStageSignal().Connect(_actorOffStageEventCallbackDelegate);
512           }
513         }
514       }
515
516       remove
517       {
518         lock(this)
519         {
520           if (_actorOffStageEventHandler != null)
521           {
522             this.OnStageSignal().Disconnect(_actorOffStageEventCallbackDelegate);
523           }
524
525           _actorOffStageEventHandler -= value;
526         }
527       }
528     }
529
530     // Callback for Actor OffStage signal
531     private void OffStage(IntPtr data)
532     {
533       OffStageEventArgs e = new OffStageEventArgs();
534
535       // Populate all members of "e" (OffStageEventArgs) with real data
536       e.Actor = Actor.GetActorFromPtr(data);
537
538       if (_actorOffStageEventHandler != null)
539       {
540         //here we send all data to user event handlers
541         _actorOffStageEventHandler(this, e);
542       }
543     }
544
545     /**
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.
549       */
550     public event OnRelayoutEventHandler OnRelayoutEvent
551     {
552       add
553       {
554         lock(this)
555         {
556           // Restricted to only one listener
557           if (_actorOnRelayoutEventHandler == null)
558           {
559             _actorOnRelayoutEventHandler += value;
560
561             _actorOnRelayoutEventCallbackDelegate = new OnRelayoutEventCallbackDelegate(OnRelayout);
562             this.OnRelayoutSignal().Connect(_actorOnRelayoutEventCallbackDelegate);
563           }
564         }
565       }
566
567       remove
568       {
569         lock(this)
570         {
571           if (_actorOnRelayoutEventHandler != null)
572           {
573             this.OnRelayoutSignal().Disconnect(_actorOnRelayoutEventCallbackDelegate);
574           }
575
576           _actorOnRelayoutEventHandler -= value;
577         }
578       }
579     }
580
581     // Callback for Actor OnRelayout signal
582     private void OnRelayout(IntPtr data)
583     {
584       OnRelayoutEventArgs e = new OnRelayoutEventArgs();
585
586       // Populate all members of "e" (OnRelayoutEventArgs) with real data
587       e.Actor = Actor.GetActorFromPtr(data);
588
589       if (_actorOnRelayoutEventHandler != null)
590       {
591         //here we send all data to user event handlers
592         _actorOnRelayoutEventHandler(this, e);
593       }
594     }
595
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();
599       return ret;
600     }
601
602     public IntPtr GetPtrfrom ## ClassName ()
603     {
604        return (IntPtr)swigCPtr;
605     }
606
607     public Actor Parent
608     {
609       get
610       {
611         Actor parent = GetParent();
612         return parent;
613       }
614     }
615
616    public bool Vibility
617    {
618       get
619       {
620         bool visibility = IsVisible();
621         return visibility;
622       }
623     }
624
625    public float Opacity
626    {
627       set
628       {
629         SetOpacity(value);
630       }
631     }
632
633    public float CurrentOpacity
634    {
635       get
636       {
637         float ret = GetCurrentOpacity();
638         return ret;
639       }
640     }
641
642     public bool StateFocusEnable
643     {
644       set
645       {
646         SetKeyboardFocusable(value);
647       }
648       get
649       {
650         bool focusable = IsKeyboardFocusable();
651         return focusable;
652       }
653     }
654
655 %}
656
657 %enddef
658
659 %define DALI_ACTOR_EVENTHANDLER_PARAM( NameSpace, ClassName)
660
661 ACTOR_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
662 ACTOR_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
663
664 %enddef
665
666 namespace Dali
667 {
668   DALI_ACTOR_EVENTHANDLER_PARAM( Dali, Actor);
669 }