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 SCROLLABLE_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define SCROLLABLE_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
29 public class StartedEventArgs : EventArgs
31 private Vector2 _vector2;
33 public Vector2 Vector2
46 public class UpdatedEventArgs : EventArgs
48 private Vector2 _vector2;
50 public Vector2 Vector2
63 public class CompletedEventArgs : EventArgs
65 private Vector2 _vector2;
67 public Vector2 Vector2
80 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
81 public delegate void StartedEventHandler(object source, StartedEventArgs e);
83 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
84 public delegate void UpdatedEventHandler(object source, UpdatedEventArgs e);
86 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
87 public delegate void CompletedEventHandler(object source, CompletedEventArgs e);
89 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
90 private delegate void StartedCallbackDelegate(IntPtr vector2);
91 private StartedEventHandler _scrollableStartedEventHandler;
92 private StartedCallbackDelegate _scrollableStartedCallbackDelegate;
94 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
95 private delegate void UpdatedCallbackDelegate(IntPtr vector2);
96 private UpdatedEventHandler _scrollableUpdatedEventHandler;
97 private UpdatedCallbackDelegate _scrollableUpdatedCallbackDelegate;
99 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
100 private delegate void CompletedCallbackDelegate(IntPtr vector2);
101 private CompletedEventHandler _scrollableCompletedEventHandler;
102 private CompletedCallbackDelegate _scrollableCompletedCallbackDelegate;
104 public event StartedEventHandler ScrollStarted
110 // Restricted to only one listener
111 if (_scrollableStartedEventHandler == null)
113 _scrollableStartedEventHandler += value;
115 _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted);
116 this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate);
125 if (_scrollableStartedEventHandler != null)
127 this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
130 _scrollableStartedEventHandler -= value;
135 private void OnStarted(IntPtr vector2)
137 StartedEventArgs e = new StartedEventArgs();
139 // Populate all members of "e" (StartedEventArgs) with real data
140 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
142 if (_scrollableStartedEventHandler != null)
144 //here we send all data to user event handlers
145 _scrollableStartedEventHandler(this, e);
150 public event UpdatedEventHandler ScrollUpdated
156 // Restricted to only one listener
157 if (_scrollableUpdatedEventHandler == null)
159 _scrollableUpdatedEventHandler += value;
161 _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated);
162 this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate);
171 if (_scrollableUpdatedEventHandler != null)
173 this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
176 _scrollableUpdatedEventHandler -= value;
181 private void OnUpdated(IntPtr vector2)
183 UpdatedEventArgs e = new UpdatedEventArgs();
185 // Populate all members of "e" (UpdatedEventArgs) with real data
186 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
188 if (_scrollableUpdatedEventHandler != null)
190 //here we send all data to user event handlers
191 _scrollableUpdatedEventHandler(this, e);
196 public event CompletedEventHandler ScrollCompleted
202 // Restricted to only one listener
203 if (_scrollableCompletedEventHandler == null)
205 _scrollableCompletedEventHandler += value;
207 _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted);
208 this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate);
217 if (_scrollableCompletedEventHandler != null)
219 this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
222 _scrollableCompletedEventHandler -= value;
227 private void OnCompleted(IntPtr vector2)
229 CompletedEventArgs e = new CompletedEventArgs();
231 // Populate all members of "e" (CompletedEventArgs) with real data
232 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
234 if (_scrollableCompletedEventHandler != null)
236 //here we send all data to user event handlers
237 _scrollableCompletedEventHandler(this, e);
246 %define DALI_SCROLLABLE_EVENTHANDLER_PARAM( NameSpace, ClassName)
248 SCROLLABLE_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
249 SCROLLABLE_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
255 DALI_SCROLLABLE_EVENTHANDLER_PARAM( Dali::Toolkit, Scrollable);