1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 namespace Tizen.NUI.BaseComponents
21 using System.Runtime.InteropServices;
23 public class Scrollable : View
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27 internal Scrollable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Scrollable_SWIGUpcast(cPtr), cMemoryOwn)
29 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
32 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Scrollable obj)
34 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
37 protected override void Dispose(DisposeTypes type)
44 if (type == DisposeTypes.Explicit)
47 //Release your own managed resources here.
48 //You should release all of your own disposable objects here.
52 //Release your own unmanaged resources here.
53 //You should not access any managed member here except static instance.
54 //because the execution order of Finalizes is non-deterministic.
56 if (swigCPtr.Handle != global::System.IntPtr.Zero)
61 NDalicPINVOKE.delete_Scrollable(swigCPtr);
63 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
69 public class StartedEventArgs : EventArgs
71 private Vector2 _vector2;
73 public Vector2 Vector2
86 public class UpdatedEventArgs : EventArgs
88 private Vector2 _vector2;
90 public Vector2 Vector2
103 public class CompletedEventArgs : EventArgs
105 private Vector2 _vector2;
107 public Vector2 Vector2
120 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
121 private delegate void StartedCallbackDelegate(IntPtr vector2);
122 private DaliEventHandler<object, StartedEventArgs> _scrollableStartedEventHandler;
123 private StartedCallbackDelegate _scrollableStartedCallbackDelegate;
125 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
126 private delegate void UpdatedCallbackDelegate(IntPtr vector2);
127 private DaliEventHandler<object, UpdatedEventArgs> _scrollableUpdatedEventHandler;
128 private UpdatedCallbackDelegate _scrollableUpdatedCallbackDelegate;
130 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
131 private delegate void CompletedCallbackDelegate(IntPtr vector2);
132 private DaliEventHandler<object, CompletedEventArgs> _scrollableCompletedEventHandler;
133 private CompletedCallbackDelegate _scrollableCompletedCallbackDelegate;
135 public event DaliEventHandler<object, StartedEventArgs> ScrollStarted
141 // Restricted to only one listener
142 if (_scrollableStartedEventHandler == null)
144 _scrollableStartedEventHandler += value;
146 _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted);
147 this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate);
156 if (_scrollableStartedEventHandler != null)
158 this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
161 _scrollableStartedEventHandler -= value;
166 private void OnStarted(IntPtr vector2)
168 StartedEventArgs e = new StartedEventArgs();
170 // Populate all members of "e" (StartedEventArgs) with real data
171 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
173 if (_scrollableStartedEventHandler != null)
175 //here we send all data to user event handlers
176 _scrollableStartedEventHandler(this, e);
181 public event DaliEventHandler<object, UpdatedEventArgs> ScrollUpdated
187 // Restricted to only one listener
188 if (_scrollableUpdatedEventHandler == null)
190 _scrollableUpdatedEventHandler += value;
192 _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated);
193 this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate);
202 if (_scrollableUpdatedEventHandler != null)
204 this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
207 _scrollableUpdatedEventHandler -= value;
212 private void OnUpdated(IntPtr vector2)
214 UpdatedEventArgs e = new UpdatedEventArgs();
216 // Populate all members of "e" (UpdatedEventArgs) with real data
217 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
219 if (_scrollableUpdatedEventHandler != null)
221 //here we send all data to user event handlers
222 _scrollableUpdatedEventHandler(this, e);
227 public event DaliEventHandler<object, CompletedEventArgs> ScrollCompleted
233 // Restricted to only one listener
234 if (_scrollableCompletedEventHandler == null)
236 _scrollableCompletedEventHandler += value;
238 _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted);
239 this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate);
248 if (_scrollableCompletedEventHandler != null)
250 this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
253 _scrollableCompletedEventHandler -= value;
258 private void OnCompleted(IntPtr vector2)
260 CompletedEventArgs e = new CompletedEventArgs();
262 // Populate all members of "e" (CompletedEventArgs) with real data
263 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
265 if (_scrollableCompletedEventHandler != null)
267 //here we send all data to user event handlers
268 _scrollableCompletedEventHandler(this, e);
274 public class Property
276 public static readonly int OVERSHOOT_EFFECT_COLOR = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_EFFECT_COLOR_get();
277 public static readonly int OVERSHOOT_ANIMATION_SPEED = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_ANIMATION_SPEED_get();
278 public static readonly int OVERSHOOT_ENABLED = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_ENABLED_get();
279 public static readonly int OVERSHOOT_SIZE = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_SIZE_get();
280 public static readonly int SCROLL_TO_ALPHA_FUNCTION = NDalicPINVOKE.Scrollable_Property_SCROLL_TO_ALPHA_FUNCTION_get();
281 public static readonly int SCROLL_RELATIVE_POSITION = NDalicPINVOKE.Scrollable_Property_SCROLL_RELATIVE_POSITION_get();
282 public static readonly int SCROLL_POSITION_MIN = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_get();
283 public static readonly int SCROLL_POSITION_MIN_X = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_X_get();
284 public static readonly int SCROLL_POSITION_MIN_Y = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_Y_get();
285 public static readonly int SCROLL_POSITION_MAX = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_get();
286 public static readonly int SCROLL_POSITION_MAX_X = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_X_get();
287 public static readonly int SCROLL_POSITION_MAX_Y = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_Y_get();
288 public static readonly int CAN_SCROLL_VERTICAL = NDalicPINVOKE.Scrollable_Property_CAN_SCROLL_VERTICAL_get();
289 public static readonly int CAN_SCROLL_HORIZONTAL = NDalicPINVOKE.Scrollable_Property_CAN_SCROLL_HORIZONTAL_get();
293 public Scrollable() : this(NDalicPINVOKE.new_Scrollable__SWIG_0(), true)
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
298 private bool IsOvershootEnabled()
300 bool ret = NDalicPINVOKE.Scrollable_IsOvershootEnabled(swigCPtr);
301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305 private void SetOvershootEnabled(bool enable)
307 NDalicPINVOKE.Scrollable_SetOvershootEnabled(swigCPtr, enable);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 private void SetOvershootEffectColor(Vector4 color)
313 NDalicPINVOKE.Scrollable_SetOvershootEffectColor(swigCPtr, Vector4.getCPtr(color));
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 private Vector4 GetOvershootEffectColor()
319 Vector4 ret = new Vector4(NDalicPINVOKE.Scrollable_GetOvershootEffectColor(swigCPtr), true);
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 private void SetOvershootAnimationSpeed(float pixelsPerSecond)
326 NDalicPINVOKE.Scrollable_SetOvershootAnimationSpeed(swigCPtr, pixelsPerSecond);
327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330 private float GetOvershootAnimationSpeed()
332 float ret = NDalicPINVOKE.Scrollable_GetOvershootAnimationSpeed(swigCPtr);
333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
337 internal ScrollableSignal ScrollStartedSignal()
339 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollStartedSignal(swigCPtr), false);
340 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344 internal ScrollableSignal ScrollUpdatedSignal()
346 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollUpdatedSignal(swigCPtr), false);
347 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351 internal ScrollableSignal ScrollCompletedSignal()
353 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollCompletedSignal(swigCPtr), false);
354 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358 public Vector4 OvershootEffectColor
362 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
363 GetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR).Get(temp);
368 SetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR, new Tizen.NUI.PropertyValue(value));
371 public float OvershootAnimationSpeed
376 GetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED).Get(out temp);
381 SetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED, new Tizen.NUI.PropertyValue(value));
384 public bool OvershootEnabled
389 GetProperty(Scrollable.Property.OVERSHOOT_ENABLED).Get(out temp);
394 SetProperty(Scrollable.Property.OVERSHOOT_ENABLED, new Tizen.NUI.PropertyValue(value));
397 public Vector2 OvershootSize
401 Vector2 temp = new Vector2(0.0f, 0.0f);
402 GetProperty(Scrollable.Property.OVERSHOOT_SIZE).Get(temp);
407 SetProperty(Scrollable.Property.OVERSHOOT_SIZE, new Tizen.NUI.PropertyValue(value));
410 public int ScrollToAlphaFunction
415 GetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION).Get(out temp);
420 SetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION, new Tizen.NUI.PropertyValue(value));
423 public Vector2 ScrollRelativePosition
427 Vector2 temp = new Vector2(0.0f, 0.0f);
428 GetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION).Get(temp);
433 SetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION, new Tizen.NUI.PropertyValue(value));
436 public Vector2 ScrollPositionMin
440 Vector2 temp = new Vector2(0.0f, 0.0f);
441 GetProperty(Scrollable.Property.SCROLL_POSITION_MIN).Get(temp);
446 SetProperty(Scrollable.Property.SCROLL_POSITION_MIN, new Tizen.NUI.PropertyValue(value));
449 public Vector2 ScrollPositionMax
453 Vector2 temp = new Vector2(0.0f, 0.0f);
454 GetProperty(Scrollable.Property.SCROLL_POSITION_MAX).Get(temp);
459 SetProperty(Scrollable.Property.SCROLL_POSITION_MAX, new Tizen.NUI.PropertyValue(value));
462 public bool CanScrollVertical
467 GetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL).Get(out temp);
472 SetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL, new Tizen.NUI.PropertyValue(value));
475 public bool CanScrollHorizontal
480 GetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL).Get(out temp);
485 SetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL, new Tizen.NUI.PropertyValue(value));