[Tizen] Fix build warnings: use the new keyword
[platform/core/csapi/nui.git] / 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             DisConnectFromSignals();
57
58             if (swigCPtr.Handle != global::System.IntPtr.Zero)
59             {
60                 if (swigCMemOwn)
61                 {
62                     swigCMemOwn = false;
63                     NDalicPINVOKE.delete_Scrollable(swigCPtr);
64                 }
65                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
66             }
67
68             base.Dispose(type);
69         }
70
71         private void DisConnectFromSignals()
72         {
73             // Save current CPtr.
74             global::System.Runtime.InteropServices.HandleRef currentCPtr = swigCPtr;
75
76             // Use BaseHandle CPtr as current might have been deleted already in derived classes.
77             swigCPtr = GetBaseHandleCPtrHandleRef;
78
79             if (_scrollableCompletedCallbackDelegate != null)
80             {
81                 this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
82             }
83
84             if (_scrollableUpdatedCallbackDelegate != null)
85             {
86                 this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
87             }
88
89             if (_scrollableStartedCallbackDelegate != null)
90             {
91                 this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
92             }
93
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;
97         }
98
99         public class StartedEventArgs : EventArgs
100         {
101             private Vector2 _vector2;
102
103             public Vector2 Vector2
104             {
105                 get
106                 {
107                     return _vector2;
108                 }
109                 set
110                 {
111                     _vector2 = value;
112                 }
113             }
114         }
115
116         public class UpdatedEventArgs : EventArgs
117         {
118             private Vector2 _vector2;
119
120             public Vector2 Vector2
121             {
122                 get
123                 {
124                     return _vector2;
125                 }
126                 set
127                 {
128                     _vector2 = value;
129                 }
130             }
131         }
132
133         public class CompletedEventArgs : EventArgs
134         {
135             private Vector2 _vector2;
136
137             public Vector2 Vector2
138             {
139                 get
140                 {
141                     return _vector2;
142                 }
143                 set
144                 {
145                     _vector2 = value;
146                 }
147             }
148         }
149
150         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
151         private delegate void StartedCallbackDelegate(IntPtr vector2);
152         private DaliEventHandler<object, StartedEventArgs> _scrollableStartedEventHandler;
153         private StartedCallbackDelegate _scrollableStartedCallbackDelegate;
154
155         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
156         private delegate void UpdatedCallbackDelegate(IntPtr vector2);
157         private DaliEventHandler<object, UpdatedEventArgs> _scrollableUpdatedEventHandler;
158         private UpdatedCallbackDelegate _scrollableUpdatedCallbackDelegate;
159
160         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
161         private delegate void CompletedCallbackDelegate(IntPtr vector2);
162         private DaliEventHandler<object, CompletedEventArgs> _scrollableCompletedEventHandler;
163         private CompletedCallbackDelegate _scrollableCompletedCallbackDelegate;
164
165         public event DaliEventHandler<object, StartedEventArgs> ScrollStarted
166         {
167             add
168             {
169                 lock (this)
170                 {
171                     // Restricted to only one listener
172                     if (_scrollableStartedEventHandler == null)
173                     {
174                         _scrollableStartedEventHandler += value;
175
176                         _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted);
177                         this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate);
178                     }
179                 }
180             }
181
182             remove
183             {
184                 lock (this)
185                 {
186                     if (_scrollableStartedEventHandler != null)
187                     {
188                         this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
189                     }
190
191                     _scrollableStartedEventHandler -= value;
192                 }
193             }
194         }
195
196         private void OnStarted(IntPtr vector2)
197         {
198             StartedEventArgs e = new StartedEventArgs();
199
200             // Populate all members of "e" (StartedEventArgs) with real data
201             e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
202
203             if (_scrollableStartedEventHandler != null)
204             {
205                 //here we send all data to user event handlers
206                 _scrollableStartedEventHandler(this, e);
207             }
208
209         }
210
211         public event DaliEventHandler<object, UpdatedEventArgs> ScrollUpdated
212         {
213             add
214             {
215                 lock (this)
216                 {
217                     // Restricted to only one listener
218                     if (_scrollableUpdatedEventHandler == null)
219                     {
220                         _scrollableUpdatedEventHandler += value;
221
222                         _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated);
223                         this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate);
224                     }
225                 }
226             }
227
228             remove
229             {
230                 lock (this)
231                 {
232                     if (_scrollableUpdatedEventHandler != null)
233                     {
234                         this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
235                     }
236
237                     _scrollableUpdatedEventHandler -= value;
238                 }
239             }
240         }
241
242         private void OnUpdated(IntPtr vector2)
243         {
244             UpdatedEventArgs e = new UpdatedEventArgs();
245
246             // Populate all members of "e" (UpdatedEventArgs) with real data
247             e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
248
249             if (_scrollableUpdatedEventHandler != null)
250             {
251                 //here we send all data to user event handlers
252                 _scrollableUpdatedEventHandler(this, e);
253             }
254
255         }
256
257         public event DaliEventHandler<object, CompletedEventArgs> ScrollCompleted
258         {
259             add
260             {
261                 lock (this)
262                 {
263                     // Restricted to only one listener
264                     if (_scrollableCompletedEventHandler == null)
265                     {
266                         _scrollableCompletedEventHandler += value;
267
268                         _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted);
269                         this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate);
270                     }
271                 }
272             }
273
274             remove
275             {
276                 lock (this)
277                 {
278                     if (_scrollableCompletedEventHandler != null)
279                     {
280                         this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
281                     }
282
283                     _scrollableCompletedEventHandler -= value;
284                 }
285             }
286         }
287
288         private void OnCompleted(IntPtr vector2)
289         {
290             CompletedEventArgs e = new CompletedEventArgs();
291
292             // Populate all members of "e" (CompletedEventArgs) with real data
293             e.Vector2 = Tizen.NUI.Vector2.GetVector2FromPtr(vector2);
294
295             if (_scrollableCompletedEventHandler != null)
296             {
297                 //here we send all data to user event handlers
298                 _scrollableCompletedEventHandler(this, e);
299             }
300
301         }
302
303
304         public new class Property
305         {
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();
320
321         }
322
323         public Scrollable() : this(NDalicPINVOKE.new_Scrollable__SWIG_0(), true)
324         {
325             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326         }
327
328         private bool IsOvershootEnabled()
329         {
330             bool ret = NDalicPINVOKE.Scrollable_IsOvershootEnabled(swigCPtr);
331             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
332             return ret;
333         }
334
335         private void SetOvershootEnabled(bool enable)
336         {
337             NDalicPINVOKE.Scrollable_SetOvershootEnabled(swigCPtr, enable);
338             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339         }
340
341         private void SetOvershootEffectColor(Vector4 color)
342         {
343             NDalicPINVOKE.Scrollable_SetOvershootEffectColor(swigCPtr, Vector4.getCPtr(color));
344             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
345         }
346
347         private Vector4 GetOvershootEffectColor()
348         {
349             Vector4 ret = new Vector4(NDalicPINVOKE.Scrollable_GetOvershootEffectColor(swigCPtr), true);
350             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
351             return ret;
352         }
353
354         private void SetOvershootAnimationSpeed(float pixelsPerSecond)
355         {
356             NDalicPINVOKE.Scrollable_SetOvershootAnimationSpeed(swigCPtr, pixelsPerSecond);
357             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358         }
359
360         private float GetOvershootAnimationSpeed()
361         {
362             float ret = NDalicPINVOKE.Scrollable_GetOvershootAnimationSpeed(swigCPtr);
363             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364             return ret;
365         }
366
367         internal ScrollableSignal ScrollStartedSignal()
368         {
369             ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollStartedSignal(swigCPtr), false);
370             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371             return ret;
372         }
373
374         internal ScrollableSignal ScrollUpdatedSignal()
375         {
376             ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollUpdatedSignal(swigCPtr), false);
377             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
378             return ret;
379         }
380
381         internal ScrollableSignal ScrollCompletedSignal()
382         {
383             ScrollableSignal ret = new ScrollableSignal(NDalicPINVOKE.Scrollable_ScrollCompletedSignal(swigCPtr), false);
384             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385             return ret;
386         }
387
388         public Vector4 OvershootEffectColor
389         {
390             get
391             {
392                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
393                 GetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR).Get(temp);
394                 return temp;
395             }
396             set
397             {
398                 SetProperty(Scrollable.Property.OVERSHOOT_EFFECT_COLOR, new Tizen.NUI.PropertyValue(value));
399             }
400         }
401         public float OvershootAnimationSpeed
402         {
403             get
404             {
405                 float temp = 0.0f;
406                 GetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED).Get(out temp);
407                 return temp;
408             }
409             set
410             {
411                 SetProperty(Scrollable.Property.OVERSHOOT_ANIMATION_SPEED, new Tizen.NUI.PropertyValue(value));
412             }
413         }
414         public bool OvershootEnabled
415         {
416             get
417             {
418                 bool temp = false;
419                 GetProperty(Scrollable.Property.OVERSHOOT_ENABLED).Get(out temp);
420                 return temp;
421             }
422             set
423             {
424                 SetProperty(Scrollable.Property.OVERSHOOT_ENABLED, new Tizen.NUI.PropertyValue(value));
425             }
426         }
427         public Vector2 OvershootSize
428         {
429             get
430             {
431                 Vector2 temp = new Vector2(0.0f, 0.0f);
432                 GetProperty(Scrollable.Property.OVERSHOOT_SIZE).Get(temp);
433                 return temp;
434             }
435             set
436             {
437                 SetProperty(Scrollable.Property.OVERSHOOT_SIZE, new Tizen.NUI.PropertyValue(value));
438             }
439         }
440         public int ScrollToAlphaFunction
441         {
442             get
443             {
444                 int temp = 0;
445                 GetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION).Get(out temp);
446                 return temp;
447             }
448             set
449             {
450                 SetProperty(Scrollable.Property.SCROLL_TO_ALPHA_FUNCTION, new Tizen.NUI.PropertyValue(value));
451             }
452         }
453         public Vector2 ScrollRelativePosition
454         {
455             get
456             {
457                 Vector2 temp = new Vector2(0.0f, 0.0f);
458                 GetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION).Get(temp);
459                 return temp;
460             }
461             set
462             {
463                 SetProperty(Scrollable.Property.SCROLL_RELATIVE_POSITION, new Tizen.NUI.PropertyValue(value));
464             }
465         }
466         public Vector2 ScrollPositionMin
467         {
468             get
469             {
470                 Vector2 temp = new Vector2(0.0f, 0.0f);
471                 GetProperty(Scrollable.Property.SCROLL_POSITION_MIN).Get(temp);
472                 return temp;
473             }
474             set
475             {
476                 SetProperty(Scrollable.Property.SCROLL_POSITION_MIN, new Tizen.NUI.PropertyValue(value));
477             }
478         }
479         public Vector2 ScrollPositionMax
480         {
481             get
482             {
483                 Vector2 temp = new Vector2(0.0f, 0.0f);
484                 GetProperty(Scrollable.Property.SCROLL_POSITION_MAX).Get(temp);
485                 return temp;
486             }
487             set
488             {
489                 SetProperty(Scrollable.Property.SCROLL_POSITION_MAX, new Tizen.NUI.PropertyValue(value));
490             }
491         }
492         public bool CanScrollVertical
493         {
494             get
495             {
496                 bool temp = false;
497                 GetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL).Get(out temp);
498                 return temp;
499             }
500             set
501             {
502                 SetProperty(Scrollable.Property.CAN_SCROLL_VERTICAL, new Tizen.NUI.PropertyValue(value));
503             }
504         }
505         public bool CanScrollHorizontal
506         {
507             get
508             {
509                 bool temp = false;
510                 GetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL).Get(out temp);
511                 return temp;
512             }
513             set
514             {
515                 SetProperty(Scrollable.Property.CAN_SCROLL_HORIZONTAL, new Tizen.NUI.PropertyValue(value));
516             }
517         }
518
519     }
520
521 }