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 / scrollview-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 SCROLLVIEW_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 SCROLLVIEW_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
28
29 /**
30   * @brief Event arguments that passed via SnapStarted signal
31   *
32   */
33 public class SnapStartedEventArgs : EventArgs
34 {
35    private Dali.ScrollView.SnapEvent _snapEvent;
36
37    /**
38      * @brief SnapEvent - is the SnapEvent information like snap or flick (it tells the target position, scale, rotation for the snap or flick).
39      *
40      */
41    public Dali.ScrollView.SnapEvent SnapEventInfo
42    {
43       get
44       {
45          return _snapEvent;
46       }
47       set
48       {
49          _snapEvent = value;
50       }
51    }
52 }
53
54   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
55   private delegate void SnapStartedCallbackDelegate(IntPtr data);
56   private DaliEventHandler<object,SnapStartedEventArgs> _scrollViewSnapStartedEventHandler;
57   private SnapStartedCallbackDelegate _scrollViewSnapStartedCallbackDelegate;
58
59   /**
60     * @brief Event for SnapStarted signal which can be used to subscribe/unsubscribe the event handler
61     * (in the type of SnapStartedEventHandler-DaliEventHandler<object,SnapStartedEventArgs>) provided by the user.
62     * SnapStarted signal is emitted hen the ScrollView has started to snap or flick (it tells the target
63     * position, scale, rotation for the snap or flick).
64     *
65     */
66  public event DaliEventHandler<object,SnapStartedEventArgs> SnapStarted
67   {
68      add
69      {
70         lock(this)
71         {
72            // Restricted to only one listener
73            if (_scrollViewSnapStartedEventHandler == null)
74            {
75               _scrollViewSnapStartedEventHandler += value;
76
77               _scrollViewSnapStartedCallbackDelegate = new SnapStartedCallbackDelegate(OnSnapStarted);
78               this.SnapStartedSignal().Connect(_scrollViewSnapStartedCallbackDelegate);
79            }
80         }
81      }
82
83      remove
84      {
85         lock(this)
86         {
87            if (_scrollViewSnapStartedEventHandler != null)
88            {
89               this.SnapStartedSignal().Disconnect(_scrollViewSnapStartedCallbackDelegate);
90            }
91
92            _scrollViewSnapStartedEventHandler -= value;
93         }
94      }
95   }
96
97   // Callback for ScrollView SnapStarted signal
98   private void OnSnapStarted(IntPtr data)
99   {
100      SnapStartedEventArgs e = new SnapStartedEventArgs();
101
102      // Populate all members of "e" (SnapStartedEventArgs) with real data
103      e.SnapEventInfo = SnapEvent.GetSnapEventFromPtr( data );
104
105      if (_scrollViewSnapStartedEventHandler != null)
106      {
107         //here we send all data to user event handlers
108         _scrollViewSnapStartedEventHandler(this, e);
109      }
110   }
111
112 /* Properties earlier added by Ruby Script */
113
114   public bool WrapEnabled
115   {
116     get
117     {
118       bool temp = false;
119       GetProperty( ScrollView.Property.WRAP_ENABLED).Get( ref temp );
120       return temp;
121     }
122     set
123     {
124       SetProperty( ScrollView.Property.WRAP_ENABLED, new Dali.Property.Value( value ) );
125     }
126   }
127   public bool PanningEnabled
128   {
129     get
130     {
131       bool temp = false;
132       GetProperty( ScrollView.Property.PANNING_ENABLED).Get( ref temp );
133       return temp;
134     }
135     set
136     {
137       SetProperty( ScrollView.Property.PANNING_ENABLED, new Dali.Property.Value( value ) );
138     }
139   }
140   public bool AxisAutoLockEnabled
141   {
142     get
143     {
144       bool temp = false;
145       GetProperty( ScrollView.Property.AXIS_AUTO_LOCK_ENABLED).Get( ref temp );
146       return temp;
147     }
148     set
149     {
150       SetProperty( ScrollView.Property.AXIS_AUTO_LOCK_ENABLED, new Dali.Property.Value( value ) );
151     }
152   }
153   public Dali.CSharp.Size WheelScrollDistanceStep
154   {
155     get
156     {
157       Vector2 temp = new Vector2(0.0f,0.0f);
158       GetProperty( ScrollView.Property.WHEEL_SCROLL_DISTANCE_STEP).Get(  temp );
159       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
160       return ret;
161     }
162     set
163     {
164       SetProperty( ScrollView.Property.WHEEL_SCROLL_DISTANCE_STEP, new Dali.Property.Value( value ) );
165     }
166   }
167   public Dali.CSharp.Size ScrollPosition
168   {
169     get
170     {
171       Vector2 temp = new Vector2(0.0f,0.0f);
172       GetProperty( ScrollView.Property.SCROLL_POSITION).Get(  temp );
173       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
174       return ret;
175     }
176     set
177     {
178       SetProperty( ScrollView.Property.SCROLL_POSITION, new Dali.Property.Value( value ) );
179     }
180   }
181   public Dali.CSharp.Size ScrollPrePosition
182   {
183     get
184     {
185       Vector2 temp = new Vector2(0.0f,0.0f);
186       GetProperty( ScrollView.Property.SCROLL_PRE_POSITION).Get(  temp );
187       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
188       return ret;
189     }
190     set
191     {
192       SetProperty( ScrollView.Property.SCROLL_PRE_POSITION, new Dali.Property.Value( value ) );
193     }
194   }
195   public Dali.CSharp.Size ScrollPrePositionMax
196   {
197     get
198     {
199       Vector2 temp = new Vector2(0.0f,0.0f);
200       GetProperty( ScrollView.Property.SCROLL_PRE_POSITION_MAX).Get(  temp );
201       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
202       return ret;
203     }
204     set
205     {
206       SetProperty( ScrollView.Property.SCROLL_PRE_POSITION_MAX, new Dali.Property.Value( value ) );
207     }
208   }
209   public float OvershootX
210   {
211     get
212     {
213       float temp = 0.0f;
214       GetProperty( ScrollView.Property.OVERSHOOT_X).Get( ref temp );
215       return temp;
216     }
217     set
218     {
219       SetProperty( ScrollView.Property.OVERSHOOT_X, new Dali.Property.Value( value ) );
220     }
221   }
222   public float OvershootY
223   {
224     get
225     {
226       float temp = 0.0f;
227       GetProperty( ScrollView.Property.OVERSHOOT_Y).Get( ref temp );
228       return temp;
229     }
230     set
231     {
232       SetProperty( ScrollView.Property.OVERSHOOT_Y, new Dali.Property.Value( value ) );
233     }
234   }
235   public Dali.CSharp.Size ScrollFinal
236   {
237     get
238     {
239       Vector2 temp = new Vector2(0.0f,0.0f);
240       GetProperty( ScrollView.Property.SCROLL_FINAL).Get(  temp );
241       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
242       return ret;
243     }
244     set
245     {
246       SetProperty( ScrollView.Property.SCROLL_FINAL, new Dali.Property.Value( value ) );
247     }
248   }
249   public bool Wrap
250   {
251     get
252     {
253       bool temp = false;
254       GetProperty( ScrollView.Property.WRAP).Get( ref temp );
255       return temp;
256     }
257     set
258     {
259       SetProperty( ScrollView.Property.WRAP, new Dali.Property.Value( value ) );
260     }
261   }
262   public bool Panning
263   {
264     get
265     {
266       bool temp = false;
267       GetProperty( ScrollView.Property.PANNING).Get( ref temp );
268       return temp;
269     }
270     set
271     {
272       SetProperty( ScrollView.Property.PANNING, new Dali.Property.Value( value ) );
273     }
274   }
275   public bool Scrolling
276   {
277     get
278     {
279       bool temp = false;
280       GetProperty( ScrollView.Property.SCROLLING).Get( ref temp );
281       return temp;
282     }
283     set
284     {
285       SetProperty( ScrollView.Property.SCROLLING, new Dali.Property.Value( value ) );
286     }
287   }
288   public Dali.CSharp.Size ScrollDomainSize
289   {
290     get
291     {
292       Vector2 temp = new Vector2(0.0f,0.0f);
293       GetProperty( ScrollView.Property.SCROLL_DOMAIN_SIZE).Get(  temp );
294       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
295       return ret;
296     }
297     set
298     {
299       SetProperty( ScrollView.Property.SCROLL_DOMAIN_SIZE, new Dali.Property.Value( value ) );
300     }
301   }
302   public Dali.CSharp.Size ScrollDomainOffset
303   {
304     get
305     {
306       Vector2 temp = new Vector2(0.0f,0.0f);
307       GetProperty( ScrollView.Property.SCROLL_DOMAIN_OFFSET).Get(  temp );
308       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
309       return ret;
310     }
311     set
312     {
313       SetProperty( ScrollView.Property.SCROLL_DOMAIN_OFFSET, new Dali.Property.Value( value ) );
314     }
315   }
316   public Dali.CSharp.Size ScrollPositionDelta
317   {
318     get
319     {
320       Vector2 temp = new Vector2(0.0f,0.0f);
321       GetProperty( ScrollView.Property.SCROLL_POSITION_DELTA).Get(  temp );
322       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
323       return ret;
324     }
325     set
326     {
327       SetProperty( ScrollView.Property.SCROLL_POSITION_DELTA, new Dali.Property.Value( value ) );
328     }
329   }
330   public Dali.CSharp.Position StartPagePosition
331   {
332     get
333     {
334       Vector3 temp = new Vector3(0.0f,0.0f,0.0f);
335       GetProperty( ScrollView.Property.START_PAGE_POSITION).Get(  temp );
336       Dali.CSharp.Position ret = new Dali.CSharp.Position(temp.x, temp.y, temp.z);
337       return ret;
338     }
339     set
340     {
341       SetProperty( ScrollView.Property.START_PAGE_POSITION, new Dali.Property.Value( value ) );
342     }
343   }
344
345
346 /* Properties ends */
347
348 %}
349
350 %enddef
351
352
353 %define DALI_SCROLLVIEW_EVENTHANDLER_PARAM( NameSpace, ClassName)
354
355   SCROLLVIEW_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
356   SCROLLVIEW_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
357
358 %enddef
359
360 namespace Dali
361 {
362   DALI_SCROLLVIEW_EVENTHANDLER_PARAM( Dali::Toolkit, ScrollView);
363 }