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)
62 //Unreference this instance from Registry.
63 Registry.Unregister(this);
65 NDalicPINVOKE.delete_Scrollable(swigCPtr);
67 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
73 public class StartedEventArgs : EventArgs
75 private Vector2 _vector2;
77 public Vector2 Vector2
90 public class UpdatedEventArgs : EventArgs
92 private Vector2 _vector2;
94 public Vector2 Vector2
107 public class CompletedEventArgs : EventArgs
109 private Vector2 _vector2;
111 public Vector2 Vector2
124 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
125 private delegate void StartedCallbackDelegate(IntPtr vector2);
126 private DaliEventHandler<object, StartedEventArgs> _scrollableStartedEventHandler;
127 private StartedCallbackDelegate _scrollableStartedCallbackDelegate;
129 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
130 private delegate void UpdatedCallbackDelegate(IntPtr vector2);
131 private DaliEventHandler<object, UpdatedEventArgs> _scrollableUpdatedEventHandler;
132 private UpdatedCallbackDelegate _scrollableUpdatedCallbackDelegate;
134 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
135 private delegate void CompletedCallbackDelegate(IntPtr vector2);
136 private DaliEventHandler<object, CompletedEventArgs> _scrollableCompletedEventHandler;
137 private CompletedCallbackDelegate _scrollableCompletedCallbackDelegate;
139 public event DaliEventHandler<object, StartedEventArgs> ScrollStarted
145 // Restricted to only one listener
146 if (_scrollableStartedEventHandler == null)
148 _scrollableStartedEventHandler += value;
150 _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted);
151 this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate);
160 if (_scrollableStartedEventHandler != null)
162 this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
165 _scrollableStartedEventHandler -= value;
170 private void OnStarted(IntPtr vector2)
172 StartedEventArgs e = new StartedEventArgs();
174 // Populate all members of "e" (StartedEventArgs) with real data
175 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
177 if (_scrollableStartedEventHandler != null)
179 //here we send all data to user event handlers
180 _scrollableStartedEventHandler(this, e);
185 public event DaliEventHandler<object, UpdatedEventArgs> ScrollUpdated
191 // Restricted to only one listener
192 if (_scrollableUpdatedEventHandler == null)
194 _scrollableUpdatedEventHandler += value;
196 _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated);
197 this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate);
206 if (_scrollableUpdatedEventHandler != null)
208 this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
211 _scrollableUpdatedEventHandler -= value;
216 private void OnUpdated(IntPtr vector2)
218 UpdatedEventArgs e = new UpdatedEventArgs();
220 // Populate all members of "e" (UpdatedEventArgs) with real data
221 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
223 if (_scrollableUpdatedEventHandler != null)
225 //here we send all data to user event handlers
226 _scrollableUpdatedEventHandler(this, e);
231 public event DaliEventHandler<object, CompletedEventArgs> ScrollCompleted
237 // Restricted to only one listener
238 if (_scrollableCompletedEventHandler == null)
240 _scrollableCompletedEventHandler += value;
242 _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted);
243 this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate);
252 if (_scrollableCompletedEventHandler != null)
254 this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
257 _scrollableCompletedEventHandler -= value;
262 private void OnCompleted(IntPtr vector2)
264 CompletedEventArgs e = new CompletedEventArgs();
266 // Populate all members of "e" (CompletedEventArgs) with real data
267 e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
269 if (_scrollableCompletedEventHandler != null)
271 //here we send all data to user event handlers
272 _scrollableCompletedEventHandler(this, e);
278 public class Property
280 public static readonly int OVERSHOOT_EFFECT_COLOR = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_EFFECT_COLOR_get();
281 public static readonly int OVERSHOOT_ANIMATION_SPEED = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_ANIMATION_SPEED_get();
282 public static readonly int OVERSHOOT_ENABLED = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_ENABLED_get();
283 public static readonly int OVERSHOOT_SIZE = NDalicPINVOKE.Scrollable_Property_OVERSHOOT_SIZE_get();
284 public static readonly int SCROLL_TO_ALPHA_FUNCTION = NDalicPINVOKE.Scrollable_Property_SCROLL_TO_ALPHA_FUNCTION_get();
285 public static readonly int SCROLL_RELATIVE_POSITION = NDalicPINVOKE.Scrollable_Property_SCROLL_RELATIVE_POSITION_get();
286 public static readonly int SCROLL_POSITION_MIN = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_get();
287 public static readonly int SCROLL_POSITION_MIN_X = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_X_get();
288 public static readonly int SCROLL_POSITION_MIN_Y = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MIN_Y_get();
289 public static readonly int SCROLL_POSITION_MAX = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_get();
290 public static readonly int SCROLL_POSITION_MAX_X = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_X_get();
291 public static readonly int SCROLL_POSITION_MAX_Y = NDalicPINVOKE.Scrollable_Property_SCROLL_POSITION_MAX_Y_get();
292 public static readonly int CAN_SCROLL_VERTICAL = NDalicPINVOKE.Scrollable_Property_CAN_SCROLL_VERTICAL_get();
293 public static readonly int CAN_SCROLL_HORIZONTAL = NDalicPINVOKE.Scrollable_Property_CAN_SCROLL_HORIZONTAL_get();
297 public Scrollable() : this(NDalicPINVOKE.new_Scrollable__SWIG_0(), true)
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 private bool IsOvershootEnabled()
304 bool ret = NDalicPINVOKE.Scrollable_IsOvershootEnabled(swigCPtr);
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309 private void SetOvershootEnabled(bool enable)
311 NDalicPINVOKE.Scrollable_SetOvershootEnabled(swigCPtr, enable);
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
315 private void SetOvershootEffectColor(Vector4 color)
317 NDalicPINVOKE.Scrollable_SetOvershootEffectColor(swigCPtr, Vector4.getCPtr(color));
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321 private Vector4 GetOvershootEffectColor()
323 Vector4 ret = new Vector4(NDalicPINVOKE.Scrollable_GetOvershootEffectColor(swigCPtr), true);
324 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328 private void SetOvershootAnimationSpeed(float pixelsPerSecond)
330 NDalicPINVOKE.Scrollable_SetOvershootAnimationSpeed(swigCPtr, pixelsPerSecond);
331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334 private float GetOvershootAnimationSpeed()
336 float ret = NDalicPINVOKE.Scrollable_GetOvershootAnimationSpeed(swigCPtr);
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 internal ScrollableSignal ScrollStartedSignal()
343 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollStartedSignal(swigCPtr), false);
344 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348 internal ScrollableSignal ScrollUpdatedSignal()
350 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollUpdatedSignal(swigCPtr), false);
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
355 internal ScrollableSignal ScrollCompletedSignal()
357 ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollCompletedSignal(swigCPtr), false);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362 public Vector4 OvershootEffectColor
366 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
367 GetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR).Get(temp);
372 SetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR, new Tizen.NUI.PropertyValue(value));
375 public float OvershootAnimationSpeed
380 GetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED).Get(out temp);
385 SetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED, new Tizen.NUI.PropertyValue(value));
388 public bool OvershootEnabled
393 GetProperty(Scrollable.Property.OVERSHOOT_ENABLED).Get(out temp);
398 SetProperty(Scrollable.Property.OVERSHOOT_ENABLED, new Tizen.NUI.PropertyValue(value));
401 public Vector2 OvershootSize
405 Vector2 temp = new Vector2(0.0f, 0.0f);
406 GetProperty(Scrollable.Property.OVERSHOOT_SIZE).Get(temp);
411 SetProperty(Scrollable.Property.OVERSHOOT_SIZE, new Tizen.NUI.PropertyValue(value));
414 public int ScrollToAlphaFunction
419 GetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION).Get(out temp);
424 SetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION, new Tizen.NUI.PropertyValue(value));
427 public Vector2 ScrollRelativePosition
431 Vector2 temp = new Vector2(0.0f, 0.0f);
432 GetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION).Get(temp);
437 SetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION, new Tizen.NUI.PropertyValue(value));
440 public Vector2 ScrollPositionMin
444 Vector2 temp = new Vector2(0.0f, 0.0f);
445 GetProperty(Scrollable.Property.SCROLL_POSITION_MIN).Get(temp);
450 SetProperty(Scrollable.Property.SCROLL_POSITION_MIN, new Tizen.NUI.PropertyValue(value));
453 public Vector2 ScrollPositionMax
457 Vector2 temp = new Vector2(0.0f, 0.0f);
458 GetProperty(Scrollable.Property.SCROLL_POSITION_MAX).Get(temp);
463 SetProperty(Scrollable.Property.SCROLL_POSITION_MAX, new Tizen.NUI.PropertyValue(value));
466 public bool CanScrollVertical
471 GetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL).Get(out temp);
476 SetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL, new Tizen.NUI.PropertyValue(value));
479 public bool CanScrollHorizontal
484 GetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL).Get(out temp);
489 SetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL, new Tizen.NUI.PropertyValue(value));