e00a6ef332215fd6d00afc64be1645bfd959ae20
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / events / itemview-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 ITEMVIEW_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
20 using System;
21 using System.Runtime.InteropServices;
22
23 %}
24 %enddef
25
26
27 %define ITEMVIEW_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
29
30   public class LayoutActivatedEventArgs : EventArgs
31   {
32   }
33
34   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
35   private delegate void LayoutActivatedEventCallbackDelegate();
36   private DaliEventHandler<object,LayoutActivatedEventArgs> _itemViewLayoutActivatedEventHandler;
37   private LayoutActivatedEventCallbackDelegate _itemViewLayoutActivatedEventCallbackDelegate;
38
39   public event DaliEventHandler<object,LayoutActivatedEventArgs> LayoutActivated
40   {
41      add
42      {
43         lock(this)
44         {
45            // Restricted to only one listener
46            if (_itemViewLayoutActivatedEventHandler == null)
47            {
48               _itemViewLayoutActivatedEventHandler += value;
49
50               _itemViewLayoutActivatedEventCallbackDelegate = new LayoutActivatedEventCallbackDelegate(OnLayoutActivated);
51               this.LayoutActivatedSignal().Connect(_itemViewLayoutActivatedEventCallbackDelegate);
52            }
53         }
54      }
55
56      remove
57      {
58         lock(this)
59         {
60            if (_itemViewLayoutActivatedEventHandler != null)
61            {
62               this.LayoutActivatedSignal().Disconnect(_itemViewLayoutActivatedEventCallbackDelegate);
63            }
64
65            _itemViewLayoutActivatedEventHandler -= value;
66         }
67      }
68   }
69
70   // Callback for ItemView LayoutActivatedSignal
71   private void OnLayoutActivated()
72   {
73      LayoutActivatedEventArgs e = new LayoutActivatedEventArgs();
74
75      if (_itemViewLayoutActivatedEventHandler != null)
76      {
77         //here we send all data to user event handlers
78         _itemViewLayoutActivatedEventHandler(this, e);
79      }
80   }
81
82 /* Properties earlier added by Ruby Script */
83
84   public float MinimumSwipeSpeed
85   {
86     get
87     {
88       float temp = 0.0f;
89       GetProperty( ItemView.Property.MINIMUM_SWIPE_SPEED).Get( ref temp );
90       return temp;
91     }
92     set
93     {
94       SetProperty( ItemView.Property.MINIMUM_SWIPE_SPEED, new Dali.Property.Value( value ) );
95     }
96   }
97   public float MinimumSwipeDistance
98   {
99     get
100     {
101       float temp = 0.0f;
102       GetProperty( ItemView.Property.MINIMUM_SWIPE_DISTANCE).Get( ref temp );
103       return temp;
104     }
105     set
106     {
107       SetProperty( ItemView.Property.MINIMUM_SWIPE_DISTANCE, new Dali.Property.Value( value ) );
108     }
109   }
110   public float WheelScrollDistanceStep
111   {
112     get
113     {
114       float temp = 0.0f;
115       GetProperty( ItemView.Property.WHEEL_SCROLL_DISTANCE_STEP).Get( ref temp );
116       return temp;
117     }
118     set
119     {
120       SetProperty( ItemView.Property.WHEEL_SCROLL_DISTANCE_STEP, new Dali.Property.Value( value ) );
121     }
122   }
123   public bool SnapToItemEnabled
124   {
125     get
126     {
127       bool temp = false;
128       GetProperty( ItemView.Property.SNAP_TO_ITEM_ENABLED).Get( ref temp );
129       return temp;
130     }
131     set
132     {
133       SetProperty( ItemView.Property.SNAP_TO_ITEM_ENABLED, new Dali.Property.Value( value ) );
134     }
135   }
136   public float RefreshInterval
137   {
138     get
139     {
140       float temp = 0.0f;
141       GetProperty( ItemView.Property.REFRESH_INTERVAL).Get( ref temp );
142       return temp;
143     }
144     set
145     {
146       SetProperty( ItemView.Property.REFRESH_INTERVAL, new Dali.Property.Value( value ) );
147     }
148   }
149   public float LayoutPosition
150   {
151     get
152     {
153       float temp = 0.0f;
154       GetProperty( ItemView.Property.LAYOUT_POSITION).Get( ref temp );
155       return temp;
156     }
157     set
158     {
159       SetProperty( ItemView.Property.LAYOUT_POSITION, new Dali.Property.Value( value ) );
160     }
161   }
162   public float ScrollSpeed
163   {
164     get
165     {
166       float temp = 0.0f;
167       GetProperty( ItemView.Property.SCROLL_SPEED).Get( ref temp );
168       return temp;
169     }
170     set
171     {
172       SetProperty( ItemView.Property.SCROLL_SPEED, new Dali.Property.Value( value ) );
173     }
174   }
175   public float Overshoot
176   {
177     get
178     {
179       float temp = 0.0f;
180       GetProperty( ItemView.Property.OVERSHOOT).Get( ref temp );
181       return temp;
182     }
183     set
184     {
185       SetProperty( ItemView.Property.OVERSHOOT, new Dali.Property.Value( value ) );
186     }
187   }
188   public Dali.CSharp.Size ScrollDirection
189   {
190     get
191     {
192       Vector2 temp = new Vector2(0.0f,0.0f);
193       GetProperty( ItemView.Property.SCROLL_DIRECTION).Get(  temp );
194       Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
195       return ret;
196     }
197     set
198     {
199       SetProperty( ItemView.Property.SCROLL_DIRECTION, new Dali.Property.Value( value ) );
200     }
201   }
202   public int LayoutOrientation
203   {
204     get
205     {
206       int temp = 0;
207       GetProperty( ItemView.Property.LAYOUT_ORIENTATION).Get( ref temp );
208       return temp;
209     }
210     set
211     {
212       SetProperty( ItemView.Property.LAYOUT_ORIENTATION, new Dali.Property.Value( value ) );
213     }
214   }
215   public float ScrollContentSize
216   {
217     get
218     {
219       float temp = 0.0f;
220       GetProperty( ItemView.Property.SCROLL_CONTENT_SIZE).Get( ref temp );
221       return temp;
222     }
223     set
224     {
225       SetProperty( ItemView.Property.SCROLL_CONTENT_SIZE, new Dali.Property.Value( value ) );
226     }
227   }
228
229 /* Properties ends */
230
231 %}
232 %enddef
233
234 %define DALI_ITEMVIEW_EVENTHANDLER_PARAM( NameSpace, ClassName)
235   ITEMVIEW_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
236   ITEMVIEW_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
237 %enddef
238
239 namespace Dali
240 {
241   DALI_ITEMVIEW_EVENTHANDLER_PARAM( Dali::Toolkit, ItemView);
242 }
243