Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / Scrollable.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
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
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 *
15 */
16
17 namespace Tizen.NUI.BaseComponents
18 {
19
20     using System;
21     using System.Runtime.InteropServices;
22
23     public class Scrollable : View
24     {
25         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26
27         internal Scrollable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Scrollable_SWIGUpcast(cPtr), cMemoryOwn)
28         {
29             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
30         }
31
32         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Scrollable obj)
33         {
34             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
35         }
36
37         protected override void Dispose(DisposeTypes type)
38         {
39             if (disposed)
40             {
41                 return;
42             }
43
44             if (type == DisposeTypes.Explicit)
45             {
46                 //Called by User
47                 //Release your own managed resources here.
48                 //You should release all of your own disposable objects here.
49
50             }
51
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.
55
56             if (swigCPtr.Handle != global::System.IntPtr.Zero)
57             {
58                 if (swigCMemOwn)
59                 {
60                     swigCMemOwn = false;
61                     NDalicPINVOKE.delete_Scrollable(swigCPtr);
62                 }
63                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
64             }
65
66             base.Dispose(type);
67         }
68
69         public class StartedEventArgs : EventArgs
70         {
71             private Vector2 _vector2;
72
73             public Vector2 Vector2
74             {
75                 get
76                 {
77                     return _vector2;
78                 }
79                 set
80                 {
81                     _vector2 = value;
82                 }
83             }
84         }
85
86         public class UpdatedEventArgs : EventArgs
87         {
88             private Vector2 _vector2;
89
90             public Vector2 Vector2
91             {
92                 get
93                 {
94                     return _vector2;
95                 }
96                 set
97                 {
98                     _vector2 = value;
99                 }
100             }
101         }
102
103         public class CompletedEventArgs : EventArgs
104         {
105             private Vector2 _vector2;
106
107             public Vector2 Vector2
108             {
109                 get
110                 {
111                     return _vector2;
112                 }
113                 set
114                 {
115                     _vector2 = value;
116                 }
117             }
118         }
119
120         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
121         private delegate void StartedCallbackDelegate(IntPtr vector2);
122         private DaliEventHandler<object, StartedEventArgs> _scrollableStartedEventHandler;
123         private StartedCallbackDelegate _scrollableStartedCallbackDelegate;
124
125         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
126         private delegate void UpdatedCallbackDelegate(IntPtr vector2);
127         private DaliEventHandler<object, UpdatedEventArgs> _scrollableUpdatedEventHandler;
128         private UpdatedCallbackDelegate _scrollableUpdatedCallbackDelegate;
129
130         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
131         private delegate void CompletedCallbackDelegate(IntPtr vector2);
132         private DaliEventHandler<object, CompletedEventArgs> _scrollableCompletedEventHandler;
133         private CompletedCallbackDelegate _scrollableCompletedCallbackDelegate;
134
135         public event DaliEventHandler<object, StartedEventArgs> ScrollStarted
136         {
137             add
138             {
139                 lock (this)
140                 {
141                     // Restricted to only one listener
142                     if (_scrollableStartedEventHandler == null)
143                     {
144                         _scrollableStartedEventHandler += value;
145
146                         _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted);
147                         this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate);
148                     }
149                 }
150             }
151
152             remove
153             {
154                 lock (this)
155                 {
156                     if (_scrollableStartedEventHandler != null)
157                     {
158                         this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
159                     }
160
161                     _scrollableStartedEventHandler -= value;
162                 }
163             }
164         }
165
166         private void OnStarted(IntPtr vector2)
167         {
168             StartedEventArgs e = new StartedEventArgs();
169
170             // Populate all members of "e" (StartedEventArgs) with real data
171             e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
172
173             if (_scrollableStartedEventHandler != null)
174             {
175                 //here we send all data to user event handlers
176                 _scrollableStartedEventHandler(this, e);
177             }
178
179         }
180
181         public event DaliEventHandler<object, UpdatedEventArgs> ScrollUpdated
182         {
183             add
184             {
185                 lock (this)
186                 {
187                     // Restricted to only one listener
188                     if (_scrollableUpdatedEventHandler == null)
189                     {
190                         _scrollableUpdatedEventHandler += value;
191
192                         _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated);
193                         this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate);
194                     }
195                 }
196             }
197
198             remove
199             {
200                 lock (this)
201                 {
202                     if (_scrollableUpdatedEventHandler != null)
203                     {
204                         this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
205                     }
206
207                     _scrollableUpdatedEventHandler -= value;
208                 }
209             }
210         }
211
212         private void OnUpdated(IntPtr vector2)
213         {
214             UpdatedEventArgs e = new UpdatedEventArgs();
215
216             // Populate all members of "e" (UpdatedEventArgs) with real data
217             e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
218
219             if (_scrollableUpdatedEventHandler != null)
220             {
221                 //here we send all data to user event handlers
222                 _scrollableUpdatedEventHandler(this, e);
223             }
224
225         }
226
227         public event DaliEventHandler<object, CompletedEventArgs> ScrollCompleted
228         {
229             add
230             {
231                 lock (this)
232                 {
233                     // Restricted to only one listener
234                     if (_scrollableCompletedEventHandler == null)
235                     {
236                         _scrollableCompletedEventHandler += value;
237
238                         _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted);
239                         this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate);
240                     }
241                 }
242             }
243
244             remove
245             {
246                 lock (this)
247                 {
248                     if (_scrollableCompletedEventHandler != null)
249                     {
250                         this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
251                     }
252
253                     _scrollableCompletedEventHandler -= value;
254                 }
255             }
256         }
257
258         private void OnCompleted(IntPtr vector2)
259         {
260             CompletedEventArgs e = new CompletedEventArgs();
261
262             // Populate all members of "e" (CompletedEventArgs) with real data
263             e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
264
265             if (_scrollableCompletedEventHandler != null)
266             {
267                 //here we send all data to user event handlers
268                 _scrollableCompletedEventHandler(this, e);
269             }
270
271         }
272
273
274         public class Property
275         {
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();
290
291         }
292
293         public Scrollable() : this(NDalicPINVOKE.new_Scrollable__SWIG_0(), true)
294         {
295             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296         }
297
298         private bool IsOvershootEnabled()
299         {
300             bool ret = NDalicPINVOKE.Scrollable_IsOvershootEnabled(swigCPtr);
301             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302             return ret;
303         }
304
305         private void SetOvershootEnabled(bool enable)
306         {
307             NDalicPINVOKE.Scrollable_SetOvershootEnabled(swigCPtr, enable);
308             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309         }
310
311         private void SetOvershootEffectColor(Vector4 color)
312         {
313             NDalicPINVOKE.Scrollable_SetOvershootEffectColor(swigCPtr, Vector4.getCPtr(color));
314             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
315         }
316
317         private Vector4 GetOvershootEffectColor()
318         {
319             Vector4 ret = new Vector4(NDalicPINVOKE.Scrollable_GetOvershootEffectColor(swigCPtr), true);
320             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321             return ret;
322         }
323
324         private void SetOvershootAnimationSpeed(float pixelsPerSecond)
325         {
326             NDalicPINVOKE.Scrollable_SetOvershootAnimationSpeed(swigCPtr, pixelsPerSecond);
327             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328         }
329
330         private float GetOvershootAnimationSpeed()
331         {
332             float ret = NDalicPINVOKE.Scrollable_GetOvershootAnimationSpeed(swigCPtr);
333             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334             return ret;
335         }
336
337         internal ScrollableSignal ScrollStartedSignal()
338         {
339             ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollStartedSignal(swigCPtr), false);
340             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341             return ret;
342         }
343
344         internal ScrollableSignal ScrollUpdatedSignal()
345         {
346             ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollUpdatedSignal(swigCPtr), false);
347             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348             return ret;
349         }
350
351         internal ScrollableSignal ScrollCompletedSignal()
352         {
353             ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollCompletedSignal(swigCPtr), false);
354             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
355             return ret;
356         }
357
358         public Vector4 OvershootEffectColor
359         {
360             get
361             {
362                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
363                 GetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR).Get(temp);
364                 return temp;
365             }
366             set
367             {
368                 SetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR, new Tizen.NUI.PropertyValue(value));
369             }
370         }
371         public float OvershootAnimationSpeed
372         {
373             get
374             {
375                 float temp = 0.0f;
376                 GetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED).Get(out temp);
377                 return temp;
378             }
379             set
380             {
381                 SetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED, new Tizen.NUI.PropertyValue(value));
382             }
383         }
384         public bool OvershootEnabled
385         {
386             get
387             {
388                 bool temp = false;
389                 GetProperty(Scrollable.Property.OVERSHOOT_ENABLED).Get(out temp);
390                 return temp;
391             }
392             set
393             {
394                 SetProperty(Scrollable.Property.OVERSHOOT_ENABLED, new Tizen.NUI.PropertyValue(value));
395             }
396         }
397         public Vector2 OvershootSize
398         {
399             get
400             {
401                 Vector2 temp = new Vector2(0.0f, 0.0f);
402                 GetProperty(Scrollable.Property.OVERSHOOT_SIZE).Get(temp);
403                 return temp;
404             }
405             set
406             {
407                 SetProperty(Scrollable.Property.OVERSHOOT_SIZE, new Tizen.NUI.PropertyValue(value));
408             }
409         }
410         public int ScrollToAlphaFunction
411         {
412             get
413             {
414                 int temp = 0;
415                 GetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION).Get(out temp);
416                 return temp;
417             }
418             set
419             {
420                 SetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION, new Tizen.NUI.PropertyValue(value));
421             }
422         }
423         public Vector2 ScrollRelativePosition
424         {
425             get
426             {
427                 Vector2 temp = new Vector2(0.0f, 0.0f);
428                 GetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION).Get(temp);
429                 return temp;
430             }
431             set
432             {
433                 SetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION, new Tizen.NUI.PropertyValue(value));
434             }
435         }
436         public Vector2 ScrollPositionMin
437         {
438             get
439             {
440                 Vector2 temp = new Vector2(0.0f, 0.0f);
441                 GetProperty(Scrollable.Property.SCROLL_POSITION_MIN).Get(temp);
442                 return temp;
443             }
444             set
445             {
446                 SetProperty(Scrollable.Property.SCROLL_POSITION_MIN, new Tizen.NUI.PropertyValue(value));
447             }
448         }
449         public Vector2 ScrollPositionMax
450         {
451             get
452             {
453                 Vector2 temp = new Vector2(0.0f, 0.0f);
454                 GetProperty(Scrollable.Property.SCROLL_POSITION_MAX).Get(temp);
455                 return temp;
456             }
457             set
458             {
459                 SetProperty(Scrollable.Property.SCROLL_POSITION_MAX, new Tizen.NUI.PropertyValue(value));
460             }
461         }
462         public bool CanScrollVertical
463         {
464             get
465             {
466                 bool temp = false;
467                 GetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL).Get(out temp);
468                 return temp;
469             }
470             set
471             {
472                 SetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL, new Tizen.NUI.PropertyValue(value));
473             }
474         }
475         public bool CanScrollHorizontal
476         {
477             get
478             {
479                 bool temp = false;
480                 GetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL).Get(out temp);
481                 return temp;
482             }
483             set
484             {
485                 SetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL, new Tizen.NUI.PropertyValue(value));
486             }
487         }
488
489     }
490
491 }