2 * Copyright(c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System.ComponentModel;
18 using Tizen.NUI.BaseComponents;
20 namespace Tizen.NUI.Components
23 /// The ScrollbarBase is an abstract class that can be linked to the scrollable objects
24 /// indicating the current scrolled position of the scrollable object.
25 /// This only contains non-graphical functionalities of basic scrollbar.
27 [EditorBrowsable(EditorBrowsableState.Never)]
28 public abstract class ScrollbarBase : Control
30 private bool mScrollEnabled = true;
35 /// Create an empty ScrollbarBase.
37 protected ScrollbarBase()
42 /// Create an empty Scrollbar with a ViewStyle instance to set style properties.
44 [EditorBrowsable(EditorBrowsableState.Never)]
45 protected ScrollbarBase(ControlStyle style) : base(style)
50 /// Static constructor to initialize bindable properties when loading.
52 static ScrollbarBase()
56 #endregion Constructors
62 /// Removes a view from its parent ScrollableBase. If a view has no parent, this method does nothing.
64 public new void Unparent()
66 (GetParent() as ScrollableBase)?.BaseRemove(this);
70 /// Update content length and position at once.
72 /// <param name="contentLength">The total length of the content.</param>
73 /// <param name="position">The destination position of the View in content length. This is the View's top position if the scroller is vertical, otherwise, View's left position.</param>
74 /// <param name="durationMs">The time it takes to scroll in milliseconds.</param>
75 /// <param name="alphaFunction">The timing function used in animation. It describes the rate of change of the animation parameter over time. (e.g. EaseOut)</param>
76 [EditorBrowsable(EditorBrowsableState.Never)]
77 public abstract void Update(float contentLength, float position, uint durationMs = 0, AlphaFunction alphaFunction = null);
80 /// Scroll content to a specific position.
82 /// <param name="position">The destination to scroll.</param>
83 /// <param name="durationMs">The time it takes to scroll in milliseconds.</param>
84 /// <param name="alphaFunction">The timing function used in animation. It describes the rate of change of the animation parameter over time. (e.g. EaseOut)</param>
85 [EditorBrowsable(EditorBrowsableState.Never)]
86 public abstract void ScrollTo(float position, uint durationMs = 0, AlphaFunction alphaFunction = null);
89 /// Initialize the scroll bar.
91 /// <param name="contentLength">The length of the scrollable content area.</param>
92 /// <param name="viewportLength">The length of the viewport representing the amount of visible content.</param>
93 /// <param name="currentPosition">The current position of the viewport in scrollable content area. This is the viewport's top position if the scroller is vertical, otherwise, left.</param>
94 /// <param name="isHorizontal">Whether the direction of scrolling is horizontal or not. It is vertical by default.</param>
95 [EditorBrowsable(EditorBrowsableState.Never)]
96 public abstract void Initialize(float contentLength, float viewportLength, float currentPosition, bool isHorizontal = false);
99 /// Enable or disable scrolling.
101 [EditorBrowsable(EditorBrowsableState.Never)]
102 public abstract bool ScrollEnabled { get; set; }
105 /// Scroll position given to ScrollTo or Update.
107 [EditorBrowsable(EditorBrowsableState.Never)]
108 public abstract Position ScrollPosition { get; }
111 /// Current scroll position in the middle of ScrollTo or Update animation.
113 [EditorBrowsable(EditorBrowsableState.Never)]
114 public abstract Position ScrollCurrentPosition { get; }