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 private delegate void StartedCallbackDelegate(IntPtr vector2);
82 private DaliEventHandler<object,StartedEventArgs> _scrollableStartedEventHandler;
83 private StartedCallbackDelegate _scrollableStartedCallbackDelegate;
85 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86 private delegate void UpdatedCallbackDelegate(IntPtr vector2);
87 private DaliEventHandler<object,UpdatedEventArgs> _scrollableUpdatedEventHandler;
88 private UpdatedCallbackDelegate _scrollableUpdatedCallbackDelegate;
90 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
91 private delegate void CompletedCallbackDelegate(IntPtr vector2);
92 private DaliEventHandler<object,CompletedEventArgs> _scrollableCompletedEventHandler;
93 private CompletedCallbackDelegate _scrollableCompletedCallbackDelegate;
95 public event DaliEventHandler<object,StartedEventArgs> ScrollStarted
101 // Restricted to only one listener
102 if (_scrollableStartedEventHandler == null)
104 _scrollableStartedEventHandler += value;
106 _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted);
107 this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate);
116 if (_scrollableStartedEventHandler != null)
118 this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
121 _scrollableStartedEventHandler -= value;
126 private void OnStarted(IntPtr vector2)
128 StartedEventArgs e = new StartedEventArgs();
130 // Populate all members of "e" (StartedEventArgs) with real data
131 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
133 if (_scrollableStartedEventHandler != null)
135 //here we send all data to user event handlers
136 _scrollableStartedEventHandler(this, e);
141 public event DaliEventHandler<object,UpdatedEventArgs> ScrollUpdated
147 // Restricted to only one listener
148 if (_scrollableUpdatedEventHandler == null)
150 _scrollableUpdatedEventHandler += value;
152 _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated);
153 this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate);
162 if (_scrollableUpdatedEventHandler != null)
164 this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
167 _scrollableUpdatedEventHandler -= value;
172 private void OnUpdated(IntPtr vector2)
174 UpdatedEventArgs e = new UpdatedEventArgs();
176 // Populate all members of "e" (UpdatedEventArgs) with real data
177 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
179 if (_scrollableUpdatedEventHandler != null)
181 //here we send all data to user event handlers
182 _scrollableUpdatedEventHandler(this, e);
187 public event DaliEventHandler<object,CompletedEventArgs> ScrollCompleted
193 // Restricted to only one listener
194 if (_scrollableCompletedEventHandler == null)
196 _scrollableCompletedEventHandler += value;
198 _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted);
199 this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate);
208 if (_scrollableCompletedEventHandler != null)
210 this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
213 _scrollableCompletedEventHandler -= value;
218 private void OnCompleted(IntPtr vector2)
220 CompletedEventArgs e = new CompletedEventArgs();
222 // Populate all members of "e" (CompletedEventArgs) with real data
223 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
225 if (_scrollableCompletedEventHandler != null)
227 //here we send all data to user event handlers
228 _scrollableCompletedEventHandler(this, e);
233 /* Properties earlier added by Ruby Script */
235 public Dali.CSharp.Color OvershootEffectColor
239 Vector4 temp = new Vector4(0.0f,0.0f,0.0f,0.0f);
240 GetProperty( Scrollable.Property.OVERSHOOT_EFFECT_COLOR).Get( temp );
241 Dali.CSharp.Color ret = new Dali.CSharp.Color(temp.r, temp.g, temp.b, temp.a);
246 SetProperty( Scrollable.Property.OVERSHOOT_EFFECT_COLOR, new Dali.Property.Value( value ) );
249 public float OvershootAnimationSpeed
254 GetProperty( Scrollable.Property.OVERSHOOT_ANIMATION_SPEED).Get( ref temp );
259 SetProperty( Scrollable.Property.OVERSHOOT_ANIMATION_SPEED, new Dali.Property.Value( value ) );
262 public bool OvershootEnabled
267 GetProperty( Scrollable.Property.OVERSHOOT_ENABLED).Get( ref temp );
272 SetProperty( Scrollable.Property.OVERSHOOT_ENABLED, new Dali.Property.Value( value ) );
275 public Dali.CSharp.Size OvershootSize
279 Vector2 temp = new Vector2(0.0f,0.0f);
280 GetProperty( Scrollable.Property.OVERSHOOT_SIZE).Get( temp );
281 Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
286 SetProperty( Scrollable.Property.OVERSHOOT_SIZE, new Dali.Property.Value( value ) );
289 public int ScrollToAlphaFunction
294 GetProperty( Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION).Get( ref temp );
299 SetProperty( Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION, new Dali.Property.Value( value ) );
302 public Dali.CSharp.Size ScrollRelativePosition
306 Vector2 temp = new Vector2(0.0f,0.0f);
307 GetProperty( Scrollable.Property.SCROLL_RELATIVE_POSITION).Get( temp );
308 Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
313 SetProperty( Scrollable.Property.SCROLL_RELATIVE_POSITION, new Dali.Property.Value( value ) );
316 public Dali.CSharp.Size ScrollPositionMin
320 Vector2 temp = new Vector2(0.0f,0.0f);
321 GetProperty( Scrollable.Property.SCROLL_POSITION_MIN).Get( temp );
322 Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
327 SetProperty( Scrollable.Property.SCROLL_POSITION_MIN, new Dali.Property.Value( value ) );
330 public Dali.CSharp.Size ScrollPositionMax
334 Vector2 temp = new Vector2(0.0f,0.0f);
335 GetProperty( Scrollable.Property.SCROLL_POSITION_MAX).Get( temp );
336 Dali.CSharp.Size ret = new Dali.CSharp.Size(temp.x, temp.y);
341 SetProperty( Scrollable.Property.SCROLL_POSITION_MAX, new Dali.Property.Value( value ) );
344 public bool CanScrollVertical
349 GetProperty( Scrollable.Property.CAN_SCROLL_VERTICAL).Get( ref temp );
354 SetProperty( Scrollable.Property.CAN_SCROLL_VERTICAL, new Dali.Property.Value( value ) );
357 public bool CanScrollHorizontal
362 GetProperty( Scrollable.Property.CAN_SCROLL_HORIZONTAL).Get( ref temp );
367 SetProperty( Scrollable.Property.CAN_SCROLL_HORIZONTAL, new Dali.Property.Value( value ) );
371 /* Properties ends */
377 %define DALI_SCROLLABLE_EVENTHANDLER_PARAM( NameSpace, ClassName)
379 SCROLLABLE_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
380 SCROLLABLE_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
386 DALI_SCROLLABLE_EVENTHANDLER_PARAM( Dali::Toolkit, Scrollable);