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 DisConnectFromSignals();
58 if (swigCPtr.Handle != global::System.IntPtr.Zero)
63 NDalicPINVOKE.delete_Scrollable(swigCPtr);
65 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
71 private void DisConnectFromSignals()
74 global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
76 // Use BaseHandle CPtr as current might have been deleted already in derived classes.
77 swigCPtr = GetBaseHandleCPtrHandleRef;
79 if (_scrollableCompletedCallbackDelegate != null)
81 this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
84 if (_scrollableUpdatedCallbackDelegate != null)
86 this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
89 if (_scrollableStartedCallbackDelegate != null)
91 this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
94 // BaseHandle CPtr is used in Registry and there is danger of deletion if we keep using it here.
95 // Restore current CPtr.
96 swigCPtr = currentCPtr;
99 public class StartedEventArgs : EventArgs
101 private Vector2 _vector2;
103 public Vector2 Vector2
116 public class UpdatedEventArgs : EventArgs
118 private Vector2 _vector2;
120 public Vector2 Vector2
133 public class CompletedEventArgs : EventArgs
135 private Vector2 _vector2;
137 public Vector2 Vector2
150 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
151 private delegate void StartedCallbackDelegate(IntPtr vector2);
152 private DaliEventHandler<object, StartedEventArgs> _scrollableStartedEventHandler;
153 private StartedCallbackDelegate _scrollableStartedCallbackDelegate;
155 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
156 private delegate void UpdatedCallbackDelegate(IntPtr vector2);
157 private DaliEventHandler<object, UpdatedEventArgs> _scrollableUpdatedEventHandler;
158 private UpdatedCallbackDelegate _scrollableUpdatedCallbackDelegate;
160 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
161 private delegate void CompletedCallbackDelegate(IntPtr vector2);
162 private DaliEventHandler<object, CompletedEventArgs> _scrollableCompletedEventHandler;
163 private CompletedCallbackDelegate _scrollableCompletedCallbackDelegate;
165 public event DaliEventHandler<object, StartedEventArgs> ScrollStarted
171 // Restricted to only one listener
172 if (_scrollableStartedEventHandler == null)
174 _scrollableStartedEventHandler += value;
176 _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted);
177 this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate);
186 if (_scrollableStartedEventHandler != null)
188 this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
191 _scrollableStartedEventHandler -= value;
196 private void OnStarted(IntPtr vector2)
198 StartedEventArgs e = new StartedEventArgs();
200 // Populate all members of "e" (StartedEventArgs) with real data
201 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
203 if (_scrollableStartedEventHandler != null)
205 //here we send all data to user event handlers
206 _scrollableStartedEventHandler(this, e);
211 public event DaliEventHandler<object, UpdatedEventArgs> ScrollUpdated
217 // Restricted to only one listener
218 if (_scrollableUpdatedEventHandler == null)
220 _scrollableUpdatedEventHandler += value;
222 _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated);
223 this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate);
232 if (_scrollableUpdatedEventHandler != null)
234 this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
237 _scrollableUpdatedEventHandler -= value;
242 private void OnUpdated(IntPtr vector2)
244 UpdatedEventArgs e = new UpdatedEventArgs();
246 // Populate all members of "e" (UpdatedEventArgs) with real data
247 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
249 if (_scrollableUpdatedEventHandler != null)
251 //here we send all data to user event handlers
252 _scrollableUpdatedEventHandler(this, e);
257 public event DaliEventHandler<object, CompletedEventArgs> ScrollCompleted
263 // Restricted to only one listener
264 if (_scrollableCompletedEventHandler == null)
266 _scrollableCompletedEventHandler += value;
268 _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted);
269 this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate);
278 if (_scrollableCompletedEventHandler != null)
280 this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
283 _scrollableCompletedEventHandler -= value;
288 private void OnCompleted(IntPtr vector2)
290 CompletedEventArgs e = new CompletedEventArgs();
292 // Populate all members of "e" (CompletedEventArgs) with real data
293 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
295 if (_scrollableCompletedEventHandler != null)
297 //here we send all data to user event handlers
298 _scrollableCompletedEventHandler(this, e);
304 public new class Property
306 public static readonly int OVERSHOOT_EFFECT_COLOR = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_EFFECT_COLOR_get();
307 public static readonly int OVERSHOOT_ANIMATION_SPEED = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_ANIMATION_SPEED_get();
308 public static readonly int OVERSHOOT_ENABLED = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_ENABLED_get();
309 public static readonly int OVERSHOOT_SIZE = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_SIZE_get();
310 public static readonly int SCROLL_TO_ALPHA_FUNCTION = NDalicPINVOKE.Scrollable_Property_SCROLL_TO_ALPHA_FUNCTION_get();
311 public static readonly int SCROLL_RELATIVE_POSITION = NDalicPINVOKE.Scrollable_Property_SCROLL_RELATIVE_POSITION_get();
312 public static readonly int SCROLL_POSITION_MIN = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_get();
313 public static readonly int SCROLL_POSITION_MIN_X = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_X_get();
314 public static readonly int SCROLL_POSITION_MIN_Y = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_Y_get();
315 public static readonly int SCROLL_POSITION_MAX = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_get();
316 public static readonly int SCROLL_POSITION_MAX_X = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_X_get();
317 public static readonly int SCROLL_POSITION_MAX_Y = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_Y_get();
318 public static readonly int CAN_SCROLL_VERTICAL = NDalicPINVOKE.Scrollable_Property_CAN_SCROLL_VERTICAL_get();
319 public static readonly int CAN_SCROLL_HORIZONTAL = NDalicPINVOKE.Scrollable_Property_CAN_SCROLL_HORIZONTAL_get();
323 public Scrollable() : this(NDalicPINVOKE.new_Scrollable__SWIG_0(), true)
325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328 private bool IsOvershootEnabled()
330 bool ret = NDalicPINVOKE.Scrollable_IsOvershootEnabled(swigCPtr);
331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335 private void SetOvershootEnabled(bool enable)
337 NDalicPINVOKE.Scrollable_SetOvershootEnabled(swigCPtr, enable);
338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 private void SetOvershootEffectColor(Vector4 color)
343 NDalicPINVOKE.Scrollable_SetOvershootEffectColor(swigCPtr, Vector4.getCPtr(color));
344 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 private Vector4 GetOvershootEffectColor()
349 Vector4 ret = new Vector4(NDalicPINVOKE.Scrollable_GetOvershootEffectColor(swigCPtr), true);
350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
354 private void SetOvershootAnimationSpeed(float pixelsPerSecond)
356 NDalicPINVOKE.Scrollable_SetOvershootAnimationSpeed(swigCPtr, pixelsPerSecond);
357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360 private float GetOvershootAnimationSpeed()
362 float ret = NDalicPINVOKE.Scrollable_GetOvershootAnimationSpeed(swigCPtr);
363 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
367 internal ScrollableSignal ScrollStartedSignal()
369 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollStartedSignal(swigCPtr), false);
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374 internal ScrollableSignal ScrollUpdatedSignal()
376 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollUpdatedSignal(swigCPtr), false);
377 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381 internal ScrollableSignal ScrollCompletedSignal()
383 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollCompletedSignal(swigCPtr), false);
384 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388 public Vector4 OvershootEffectColor
392 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
393 GetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR).Get(temp);
398 SetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR, new Tizen.NUI.PropertyValue(value));
401 public float OvershootAnimationSpeed
406 GetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED).Get(out temp);
411 SetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED, new Tizen.NUI.PropertyValue(value));
414 public bool OvershootEnabled
419 GetProperty(Scrollable.Property.OVERSHOOT_ENABLED).Get(out temp);
424 SetProperty(Scrollable.Property.OVERSHOOT_ENABLED, new Tizen.NUI.PropertyValue(value));
427 public Vector2 OvershootSize
431 Vector2 temp = new Vector2(0.0f, 0.0f);
432 GetProperty(Scrollable.Property.OVERSHOOT_SIZE).Get(temp);
437 SetProperty(Scrollable.Property.OVERSHOOT_SIZE, new Tizen.NUI.PropertyValue(value));
440 public int ScrollToAlphaFunction
445 GetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION).Get(out temp);
450 SetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION, new Tizen.NUI.PropertyValue(value));
453 public Vector2 ScrollRelativePosition
457 Vector2 temp = new Vector2(0.0f, 0.0f);
458 GetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION).Get(temp);
463 SetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION, new Tizen.NUI.PropertyValue(value));
466 public Vector2 ScrollPositionMin
470 Vector2 temp = new Vector2(0.0f, 0.0f);
471 GetProperty(Scrollable.Property.SCROLL_POSITION_MIN).Get(temp);
476 SetProperty(Scrollable.Property.SCROLL_POSITION_MIN, new Tizen.NUI.PropertyValue(value));
479 public Vector2 ScrollPositionMax
483 Vector2 temp = new Vector2(0.0f, 0.0f);
484 GetProperty(Scrollable.Property.SCROLL_POSITION_MAX).Get(temp);
489 SetProperty(Scrollable.Property.SCROLL_POSITION_MAX, new Tizen.NUI.PropertyValue(value));
492 public bool CanScrollVertical
497 GetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL).Get(out temp);
502 SetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL, new Tizen.NUI.PropertyValue(value));
505 public bool CanScrollHorizontal
510 GetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL).Get(out temp);
515 SetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL, new Tizen.NUI.PropertyValue(value));