DALi C# binding - Write pure C# Color & Position classes and use typemaps to do the...
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / pangesture-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 PANGESTURE_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
20 using System;
21 using System.Runtime.InteropServices;
22
23 %}
24
25 %enddef
26
27 %define PANGESTURE_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
29
30
31 public class DetectedEventArgs : EventArgs
32 {
33    private Actor _actor;
34    private PanGesture _panGesture;
35
36    public Actor Actor
37    {
38       get
39       {
40          return _actor;
41       }
42       set
43       {
44          _actor = value;
45       }
46    }
47
48    public PanGesture PanGesture
49    {
50       get
51       {
52          return _panGesture;
53       }
54       set
55       {
56          _panGesture = value;
57       }
58    }
59 }
60
61   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
62   private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr panGesture);
63   private DaliEventHandler<object,DetectedEventArgs> _panGestureEventHandler;
64   private DetectedCallbackDelegate _panGestureCallbackDelegate;
65
66
67   public event DaliEventHandler<object,DetectedEventArgs> Detected
68   {
69      add
70      {
71         lock(this)
72         {
73            // Restricted to only one listener
74            if (_panGestureEventHandler == null)
75            {
76               _panGestureEventHandler += value;
77
78               _panGestureCallbackDelegate = new DetectedCallbackDelegate(OnPanGestureDetected);
79               this.DetectedSignal().Connect(_panGestureCallbackDelegate);
80            }
81         }
82      }
83
84      remove
85      {
86         lock(this)
87         {
88            if (_panGestureEventHandler != null)
89            {
90               this.DetectedSignal().Disconnect(_panGestureCallbackDelegate);
91            }
92
93            _panGestureEventHandler -= value;
94         }
95      }
96   }
97
98  private void OnPanGestureDetected(IntPtr actor, IntPtr panGesture)
99   {
100    DetectedEventArgs e = new DetectedEventArgs();
101
102    // Populate all members of "e" (PanGestureEventArgs) with real data
103    e.Actor = Actor.GetActorFromPtr(actor);
104    e.PanGesture = Dali.PanGesture.GetPanGestureFromPtr(panGesture);
105
106    if (_panGestureEventHandler != null)
107    {
108       //here we send all data to user event handlers
109       _panGestureEventHandler(this, e);
110    }
111
112   }
113
114
115 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
116     ClassName ret = new ClassName(cPtr, false);
117    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118     return ret;
119   }
120
121 /* Properties earlier added by Ruby Script */
122
123   public Dali.CSharp.Size ScreenPosition
124   {
125     get
126     {
127       Vector2 temp = new Vector2(0.0f,0.0f);
128       GetProperty( PanGestureDetector.Property.SCREEN_POSITION).Get(  temp );
129       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
130       return ret;
131     }
132 }  public Dali.CSharp.Size ScreenDisplacement
133   {
134     get
135     {
136       Vector2 temp = new Vector2(0.0f,0.0f);
137       GetProperty( PanGestureDetector.Property.SCREEN_DISPLACEMENT).Get(  temp );
138       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
139       return ret;
140     }
141 }  public Dali.CSharp.Size ScreenVelocity
142   {
143     get
144     {
145       Vector2 temp = new Vector2(0.0f,0.0f);
146       GetProperty( PanGestureDetector.Property.SCREEN_VELOCITY).Get(  temp );
147       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
148       return ret;
149     }
150 }  public Dali.CSharp.Size LocalPosition
151   {
152     get
153     {
154       Vector2 temp = new Vector2(0.0f,0.0f);
155       GetProperty( PanGestureDetector.Property.LOCAL_POSITION).Get(  temp );
156       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
157       return ret;
158     }
159 }  public Dali.CSharp.Size LocalDisplacement
160   {
161     get
162     {
163       Vector2 temp = new Vector2(0.0f,0.0f);
164       GetProperty( PanGestureDetector.Property.LOCAL_DISPLACEMENT).Get(  temp );
165       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
166       return ret;
167     }
168 }  public Dali.CSharp.Size LocalVelocity
169   {
170     get
171     {
172       Vector2 temp = new Vector2(0.0f,0.0f);
173       GetProperty( PanGestureDetector.Property.LOCAL_VELOCITY).Get(  temp );
174       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
175       return ret;
176     }
177 }  public bool Panning
178   {
179     get
180     {
181       bool temp = false;
182       GetProperty( PanGestureDetector.Property.PANNING).Get( ref temp );
183       return temp;
184     }
185 }
186
187 /* Properties ends */
188
189 %}
190
191 %enddef
192
193 %define DALI_PANGESTURE_EVENTHANDLER_PARAM( NameSpace, ClassName)
194
195   PANGESTURE_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
196   PANGESTURE_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
197
198 %enddef
199
200 namespace Dali
201 {
202   DALI_PANGESTURE_EVENTHANDLER_PARAM( Dali, PanGestureDetector);
203 }