Change PositionUsesAnchorPoint property to PositionUsesPivotPoint
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / UIComponents / ScrollBar.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 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 //------------------------------------------------------------------------------
18 // <auto-generated />
19 //
20 // This file was automatically generated by SWIG (http://www.swig.org).
21 // Version 3.0.9
22 //
23 // Do not make changes to this file unless you know what you are doing--modify
24 // the SWIG interface file instead.
25 //------------------------------------------------------------------------------
26
27 namespace Tizen.NUI.UIComponents
28 {
29
30     using System;
31     using System.Runtime.InteropServices;
32     using Tizen.NUI.BaseComponents;
33
34     /// <summary>
35     /// ScrollBar is a UI component that can be linked to the scrollable objects
36     /// indicating the current scroll position of the scrollable object.<br>
37     /// </summary>
38     public class ScrollBar : View
39     {
40         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
41
42         internal ScrollBar(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ScrollBar_SWIGUpcast(cPtr), cMemoryOwn)
43         {
44             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
45         }
46
47         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ScrollBar obj)
48         {
49             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
50         }
51
52         /// <summary>
53         /// To make ScrollBar instance be disposed.
54         /// </summary>
55         protected override void Dispose(DisposeTypes type)
56         {
57             if (disposed)
58             {
59                 return;
60             }
61
62             if(type == DisposeTypes.Explicit)
63             {
64                 //Called by User
65                 //Release your own managed resources here.
66                 //You should release all of your own disposable objects here.
67             }
68
69             //Release your own unmanaged resources here.
70             //You should not access any managed member here except static instance.
71             //because the execution order of Finalizes is non-deterministic.
72
73             if (swigCPtr.Handle != global::System.IntPtr.Zero)
74             {
75                 if (swigCMemOwn)
76                 {
77                     swigCMemOwn = false;
78                     NDalicPINVOKE.delete_ScrollBar(swigCPtr);
79                 }
80                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
81             }
82
83             base.Dispose(type);
84         }
85
86         /// <summary>
87         /// Event arguments that passed via PanFinished event
88         /// </summary>
89         public class PanFinishedEventArgs : EventArgs
90         {
91         }
92
93         /// <summary>
94         /// Event arguments that passed via ScrollPositionIntervalReached event
95         /// </summary>
96         public class ScrollIntervalEventArgs : EventArgs
97         {
98             private float _currentScrollPosition;
99
100             /// <summary>
101             /// current scroll position of the scrollable content
102             /// </summary>
103             public float CurrentScrollPosition
104             {
105                 get
106                 {
107                     return _currentScrollPosition;
108                 }
109                 set
110                 {
111                     _currentScrollPosition = value;
112                 }
113             }
114         }
115
116         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
117         private delegate void PanFinishedEventCallbackDelegate();
118         private EventHandler<PanFinishedEventArgs> _scrollBarPanFinishedEventHandler;
119         private PanFinishedEventCallbackDelegate _scrollBarPanFinishedEventCallbackDelegate;
120
121         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
122         private delegate void ScrollPositionIntervalReachedEventCallbackDelegate();
123         private EventHandler<ScrollIntervalEventArgs> _scrollBarScrollPositionIntervalReachedEventHandler;
124         private ScrollPositionIntervalReachedEventCallbackDelegate _scrollBarScrollPositionIntervalReachedEventCallbackDelegate;
125
126         /// <summary>
127         /// Event emitted when panning is finished on the scroll indicator.
128         /// </summary>
129         public event EventHandler<PanFinishedEventArgs> PanFinished
130         {
131             add
132             {
133                 if (_scrollBarPanFinishedEventHandler == null)
134                 {
135                     _scrollBarPanFinishedEventCallbackDelegate = (OnScrollBarPanFinished);
136                     PanFinishedSignal().Connect(_scrollBarPanFinishedEventCallbackDelegate);
137                 }
138                 _scrollBarPanFinishedEventHandler += value;
139             }
140             remove
141             {
142                 _scrollBarPanFinishedEventHandler -= value;
143                 if (_scrollBarPanFinishedEventHandler == null && PanFinishedSignal().Empty() == false)
144                 {
145                     PanFinishedSignal().Disconnect(_scrollBarPanFinishedEventCallbackDelegate);
146                 }
147             }
148         }
149
150         // Callback for ScrollBar PanFinishedSignal
151         private void OnScrollBarPanFinished()
152         {
153             PanFinishedEventArgs e = new PanFinishedEventArgs();
154
155             if (_scrollBarPanFinishedEventHandler != null)
156             {
157                 //here we send all data to user event handlers
158                 _scrollBarPanFinishedEventHandler(this, e);
159             }
160         }
161
162
163         /// <summary>
164         /// Event emitted when the current scroll position of the scrollable content
165         /// </summary>
166         public event EventHandler<ScrollIntervalEventArgs> ScrollInterval
167         {
168             add
169             {
170                 if (_scrollBarScrollPositionIntervalReachedEventHandler == null)
171                 {
172                     _scrollBarScrollPositionIntervalReachedEventCallbackDelegate = (OnScrollBarScrollPositionIntervalReached);
173                     ScrollPositionIntervalReachedSignal().Connect(_scrollBarScrollPositionIntervalReachedEventCallbackDelegate);
174                 }
175                 _scrollBarScrollPositionIntervalReachedEventHandler += value;
176             }
177             remove
178             {
179                 _scrollBarScrollPositionIntervalReachedEventHandler -= value;
180                 if (_scrollBarScrollPositionIntervalReachedEventHandler == null && ScrollPositionIntervalReachedSignal().Empty() == false)
181                 {
182                     ScrollPositionIntervalReachedSignal().Disconnect(_scrollBarScrollPositionIntervalReachedEventCallbackDelegate);
183                 }
184             }
185         }
186
187         // Callback for ScrollBar ScrollPositionIntervalReachedSignal
188         private void OnScrollBarScrollPositionIntervalReached()
189         {
190             ScrollIntervalEventArgs e = new ScrollIntervalEventArgs();
191
192             if (_scrollBarScrollPositionIntervalReachedEventHandler != null)
193             {
194                 //here we send all data to user event handlers
195                 _scrollBarScrollPositionIntervalReachedEventHandler(this, e);
196             }
197         }
198
199
200         internal class Property
201         {
202             internal static readonly int SCROLL_DIRECTION = NDalicPINVOKE.ScrollBar_Property_SCROLL_DIRECTION_get();
203             internal static readonly int INDICATOR_HEIGHT_POLICY = NDalicPINVOKE.ScrollBar_Property_INDICATOR_HEIGHT_POLICY_get();
204             internal static readonly int INDICATOR_FIXED_HEIGHT = NDalicPINVOKE.ScrollBar_Property_INDICATOR_FIXED_HEIGHT_get();
205             internal static readonly int INDICATOR_SHOW_DURATION = NDalicPINVOKE.ScrollBar_Property_INDICATOR_SHOW_DURATION_get();
206             internal static readonly int INDICATOR_HIDE_DURATION = NDalicPINVOKE.ScrollBar_Property_INDICATOR_HIDE_DURATION_get();
207             internal static readonly int SCROLL_POSITION_INTERVALS = NDalicPINVOKE.ScrollBar_Property_SCROLL_POSITION_INTERVALS_get();
208             internal static readonly int INDICATOR_MINIMUM_HEIGHT = NDalicPINVOKE.ScrollBar_Property_INDICATOR_MINIMUM_HEIGHT_get();
209             internal static readonly int INDICATOR_START_PADDING = NDalicPINVOKE.ScrollBar_Property_INDICATOR_START_PADDING_get();
210             internal static readonly int INDICATOR_END_PADDING = NDalicPINVOKE.ScrollBar_Property_INDICATOR_END_PADDING_get();
211         }
212
213         /// <summary>
214         /// Creates an initialized ScrollBar.
215         /// </summary>
216         /// <param name="direction">The direction of scroll bar (either vertically or horizontally)</param>
217         public ScrollBar(ScrollBar.Direction direction) : this(NDalicPINVOKE.ScrollBar_New__SWIG_0((int)direction), true)
218         {
219             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220         }
221
222         /// <summary>
223         /// Creates an uninitialized ScrollBar
224         /// </summary>
225         public ScrollBar() : this(NDalicPINVOKE.ScrollBar_New__SWIG_1(), true)
226         {
227             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228
229         }
230         internal ScrollBar(ScrollBar scrollBar) : this(NDalicPINVOKE.new_ScrollBar__SWIG_1(ScrollBar.getCPtr(scrollBar)), true)
231         {
232             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233         }
234
235         internal void SetScrollPropertySource(Animatable handle, int propertyScrollPosition, int propertyMinScrollPosition, int propertyMaxScrollPosition, int propertyScrollContentSize)
236         {
237             NDalicPINVOKE.ScrollBar_SetScrollPropertySource(swigCPtr, Animatable.getCPtr(handle), propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
238             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239         }
240
241         internal void SetScrollIndicator(View indicator)
242         {
243             NDalicPINVOKE.ScrollBar_SetScrollIndicator(swigCPtr, View.getCPtr(indicator));
244             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245         }
246
247         internal View GetScrollIndicator()
248         {
249             View ret = new View(NDalicPINVOKE.ScrollBar_GetScrollIndicator(swigCPtr), true);
250             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251             return ret;
252         }
253
254         internal void SetScrollDirection(ScrollBar.Direction direction)
255         {
256             NDalicPINVOKE.ScrollBar_SetScrollDirection(swigCPtr, (int)direction);
257             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258         }
259
260         internal ScrollBar.Direction GetScrollDirection()
261         {
262             ScrollBar.Direction ret = (ScrollBar.Direction)NDalicPINVOKE.ScrollBar_GetScrollDirection(swigCPtr);
263             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264             return ret;
265         }
266
267         internal void SetIndicatorHeightPolicy(ScrollBar.IndicatorHeightPolicyType policy)
268         {
269             NDalicPINVOKE.ScrollBar_SetIndicatorHeightPolicy(swigCPtr, (int)policy);
270             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271         }
272
273         internal ScrollBar.IndicatorHeightPolicyType GetIndicatorHeightPolicy()
274         {
275             ScrollBar.IndicatorHeightPolicyType ret = (ScrollBar.IndicatorHeightPolicyType)NDalicPINVOKE.ScrollBar_GetIndicatorHeightPolicy(swigCPtr);
276             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277             return ret;
278         }
279
280         internal void SetIndicatorFixedHeight(float height)
281         {
282             NDalicPINVOKE.ScrollBar_SetIndicatorFixedHeight(swigCPtr, height);
283             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284         }
285
286         internal float GetIndicatorFixedHeight()
287         {
288             float ret = NDalicPINVOKE.ScrollBar_GetIndicatorFixedHeight(swigCPtr);
289             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290             return ret;
291         }
292
293         internal void SetIndicatorShowDuration(float durationSeconds)
294         {
295             NDalicPINVOKE.ScrollBar_SetIndicatorShowDuration(swigCPtr, durationSeconds);
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297         }
298
299         internal float GetIndicatorShowDuration()
300         {
301             float ret = NDalicPINVOKE.ScrollBar_GetIndicatorShowDuration(swigCPtr);
302             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303             return ret;
304         }
305
306         internal void SetIndicatorHideDuration(float durationSeconds)
307         {
308             NDalicPINVOKE.ScrollBar_SetIndicatorHideDuration(swigCPtr, durationSeconds);
309             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310         }
311
312         internal float GetIndicatorHideDuration()
313         {
314             float ret = NDalicPINVOKE.ScrollBar_GetIndicatorHideDuration(swigCPtr);
315             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316             return ret;
317         }
318
319         internal void ShowIndicator()
320         {
321             NDalicPINVOKE.ScrollBar_ShowIndicator(swigCPtr);
322             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323         }
324
325         internal void HideIndicator()
326         {
327             NDalicPINVOKE.ScrollBar_HideIndicator(swigCPtr);
328             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329         }
330
331         internal VoidSignal PanFinishedSignal()
332         {
333             VoidSignal ret = new VoidSignal(NDalicPINVOKE.ScrollBar_PanFinishedSignal(swigCPtr), false);
334             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335             return ret;
336         }
337
338         internal FloatSignal ScrollPositionIntervalReachedSignal()
339         {
340             FloatSignal ret = new FloatSignal(NDalicPINVOKE.ScrollBar_ScrollPositionIntervalReachedSignal(swigCPtr), false);
341             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342             return ret;
343         }
344
345         /// <summary>
346         /// Direction of scroll bar
347         /// </summary>
348         public enum Direction
349         {
350             Vertical = 0,
351             Horizontal
352         }
353
354         /// <summary>
355         /// Indicator height policy.
356         /// </summary>
357         public enum IndicatorHeightPolicyType
358         {
359             Variable = 0,
360             Fixed
361         }
362
363         /// <summary>
364         /// Direction of scroll bar
365         /// </summary>
366         public Direction ScrollDirection
367         {
368             get
369             {
370                 string temp;
371                 if (GetProperty(ScrollBar.Property.SCROLL_DIRECTION).Get(out temp) == false)
372                 {
373 #if DEBUG_ON
374                     Tizen.Log.Error("NUI", "ScrollDirection get error!");
375 #endif
376                 }
377
378                 switch (temp)
379                 {
380                     case "Vertical":
381                         return Direction.Vertical;
382                     case "Horizontal":
383                         return Direction.Horizontal;
384                     default:
385                         return Direction.Vertical;
386                 }
387             }
388             set
389             {
390                 string valueToString = "";
391                 switch (value)
392                 {
393                     case Direction.Vertical:
394                     {
395                         valueToString = "Vertical";
396                         break;
397                     }
398                     case Direction.Horizontal:
399                     {
400                         valueToString = "Horizontal";
401                         break;
402                     }
403                     default:
404                     {
405                         valueToString = "Vertical";
406                         break;
407                     }
408                 }
409                 SetProperty(ScrollBar.Property.SCROLL_DIRECTION, new Tizen.NUI.PropertyValue(valueToString));
410             }
411         }
412
413         /// <summary>
414         /// Indicator height policy.
415         /// </summary>
416         public IndicatorHeightPolicyType IndicatorHeightPolicy
417         {
418             get
419             {
420                 string temp;
421                 if (GetProperty(ScrollBar.Property.INDICATOR_HEIGHT_POLICY).Get(out temp) == false)
422                 {
423 #if DEBUG_ON
424                     Tizen.Log.Error("NUI", "IndicatorHeightPolicy get error!");
425 #endif
426                 }
427
428                 switch (temp)
429                 {
430                     case "Variable":
431                         return IndicatorHeightPolicyType.Variable;
432                     case "Fixed":
433                         return IndicatorHeightPolicyType.Fixed;
434                     default:
435                         return IndicatorHeightPolicyType.Variable;
436                 }
437             }
438             set
439             {
440                 string valueToString = "";
441                 switch (value)
442                 {
443                     case IndicatorHeightPolicyType.Variable:
444                     {
445                         valueToString = "Variable";
446                         break;
447                     }
448                     case IndicatorHeightPolicyType.Fixed:
449                     {
450                         valueToString = "Fixed";
451                         break;
452                     }
453                     default:
454                     {
455                         valueToString = "Variable";
456                         break;
457                     }
458                 }
459                 SetProperty(ScrollBar.Property.INDICATOR_HEIGHT_POLICY, new Tizen.NUI.PropertyValue(valueToString));
460             }
461         }
462
463         /// <summary>
464         /// the fixed height of scroll indicator.
465         /// </summary>
466         public float IndicatorFixedHeight
467         {
468             get
469             {
470                 float temp = 0.0f;
471                 GetProperty(ScrollBar.Property.INDICATOR_FIXED_HEIGHT).Get(out temp);
472                 return temp;
473             }
474             set
475             {
476                 SetProperty(ScrollBar.Property.INDICATOR_FIXED_HEIGHT, new Tizen.NUI.PropertyValue(value));
477             }
478         }
479
480         /// <summary>
481         /// the duration in seconds for the scroll indicator to become fully visible.
482         /// </summary>
483         public float IndicatorShowDuration
484         {
485             get
486             {
487                 float temp = 0.0f;
488                 GetProperty(ScrollBar.Property.INDICATOR_SHOW_DURATION).Get(out temp);
489                 return temp;
490             }
491             set
492             {
493                 SetProperty(ScrollBar.Property.INDICATOR_SHOW_DURATION, new Tizen.NUI.PropertyValue(value));
494             }
495         }
496
497         /// <summary>
498         /// the duration in seconds for the scroll indicator to become fully invisible.
499         /// </summary>
500         public float IndicatorHideDuration
501         {
502             get
503             {
504                 float temp = 0.0f;
505                 GetProperty(ScrollBar.Property.INDICATOR_HIDE_DURATION).Get(out temp);
506                 return temp;
507             }
508             set
509             {
510                 SetProperty(ScrollBar.Property.INDICATOR_HIDE_DURATION, new Tizen.NUI.PropertyValue(value));
511             }
512         }
513
514         /// <summary>
515         /// the list of values to get notification when the current scroll position of the scrollable object goes above or below any of these values.
516         /// </summary>
517         public Tizen.NUI.PropertyArray ScrollPositionIntervals
518         {
519             get
520             {
521                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
522                 GetProperty(ScrollBar.Property.SCROLL_POSITION_INTERVALS).Get(temp);
523                 return temp;
524             }
525             set
526             {
527                 SetProperty(ScrollBar.Property.SCROLL_POSITION_INTERVALS, new Tizen.NUI.PropertyValue(value));
528             }
529         }
530
531         /// <summary>
532         /// The minimum height for a variable size indicator.
533         /// </summary>
534         public float IndicatorMinimumHeight
535         {
536             get
537             {
538                 float temp = 0.0f;
539                 GetProperty(ScrollBar.Property.INDICATOR_MINIMUM_HEIGHT).Get(out temp);
540                 return temp;
541             }
542             set
543             {
544                 SetProperty(ScrollBar.Property.INDICATOR_MINIMUM_HEIGHT, new Tizen.NUI.PropertyValue(value));
545             }
546         }
547
548         /// <summary>
549         /// The padding at the start of the indicator. For example, the top if scrollDirection is Vertical.
550         /// </summary>
551         public float IndicatorStartPadding
552         {
553             get
554             {
555                 float temp = 0.0f;
556                 GetProperty(ScrollBar.Property.INDICATOR_START_PADDING).Get(out temp);
557                 return temp;
558             }
559             set
560             {
561                 SetProperty(ScrollBar.Property.INDICATOR_START_PADDING, new Tizen.NUI.PropertyValue(value));
562             }
563         }
564
565         /// <summary>
566         /// The padding at the end of the indicator. For example, the bottom if scrollDirection is Vertical.
567         /// </summary>
568         public float IndicatorEndPadding
569         {
570             get
571             {
572                 float temp = 0.0f;
573                 GetProperty(ScrollBar.Property.INDICATOR_END_PADDING).Get(out temp);
574                 return temp;
575             }
576             set
577             {
578                 SetProperty(ScrollBar.Property.INDICATOR_END_PADDING, new Tizen.NUI.PropertyValue(value));
579             }
580         }
581
582     }
583
584 }