1 #ifndef __DALI_TOOLKIT_SCROLL_BAR_H__
2 #define __DALI_TOOLKIT_SCROLL_BAR_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/vector-wrapper.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
33 // Forward declarations
34 class ScrollConnector;
36 namespace Internal DALI_INTERNAL
38 // Forward declarations
44 * ScrollBar is a UI component that can be added to the scrollable controls
45 * indicating the current scroll position of the scrollable content.
47 class DALI_IMPORT_API ScrollBar : public ScrollComponent
52 static const char* const SCROLL_POSITION_NOTIFIED_SIGNAL_NAME; ///< "scroll-position-notified" signal name
53 typedef Signal< void ( float ) > ScrollPositionNotifiedSignalType;
56 static const Property::Index PROPERTY_INDICATOR_HEIGHT_POLICY; ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type STRING
57 static const Property::Index PROPERTY_INDICATOR_FIXED_HEIGHT; ///< name "indicator-fixed-height", @see SetIndicatorFixedHeight(), type FLOAT
58 static const Property::Index PROPERTY_INDICATOR_SHOW_DURATION; ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type FLOAT
59 static const Property::Index PROPERTY_INDICATOR_HIDE_DURATION; ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type FLOAT
64 * @brief Indicator height policy.
66 enum IndicatorHeightPolicy
68 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content
69 Fixed ///< Fixed height regardless of the length of scroll content
73 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
74 * Calling member functions with an uninitialized Dali::Object is not allowed.
75 * or horizontally (false)
80 * @brief Copy constructor.
82 ScrollBar( const ScrollBar& scrollBar );
85 * @brief Assignment operator.
87 ScrollBar& operator=( const ScrollBar& scrollBar );
92 * This is non-virtual since derived Handle types must not contain data or virtual methods.
97 * @brief Create an initialized ScrollBar
98 * @return A pointer to the created ScrollBar.
100 static ScrollBar New();
103 * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
104 * downcast produces valid handle. If not the returned handle is left uninitialized.
105 * @param[in] handle Handle to an object
106 * @return handle to a ScrollBar or an uninitialized handle
108 static ScrollBar DownCast( BaseHandle handle );
111 * @brief Sets the image for the indicator of scroll bar.
113 * @pre The scroll bar actor has been initialised.
115 * The indicator image is resized (stretched according to scale settings),
116 * to reflect the size of the scroll indicator and minimum/maximum limits
117 * of the scroll position.
119 * @param[in] image The image of indicator that moves to indicate the current scroll position.
121 void SetIndicatorImage( Image image );
124 * @brief Gets the indicator of scroll bar.
126 * @pre The scroll bar actor has been initialised.
128 * @return The indicator indicates the current scroll position of the scrollable content.
130 Actor GetScrollIndicator();
133 * @brief Sets the values to get notification when the current scroll position of the scrollable
134 * content goes above or below any of these values.
136 * @pre The scroll bar actor has been initialised.
138 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
140 void SetPositionNotifications( const std::vector<float>& positions );
143 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
145 * @pre The scroll bar actor has been initialised.
147 * @param[in] policy The height policy of scroll indicator
149 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
152 * @brief Gets the height policy of scroll indicator.
154 * @return The height policy of scroll indicator
156 IndicatorHeightPolicy GetIndicatorHeightPolicy();
159 * @brief Sets the fixed height of scroll indicator.
160 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
161 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
162 * regardless of the length of scroll content.
164 * @pre The scroll bar actor has been initialised.
166 * @param[in] height The fixed height of the scroll indicator
168 void SetIndicatorFixedHeight( float height );
171 * @brief Gets the fix height of scroll indicator.
172 * @return The fixed height of the scroll indicator
174 float GetIndicatorFixedHeight();
177 * @brief Sets the duration in second for the scroll indicator to become fully visible
179 * @pre The scroll bar actor has been initialised.
181 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
183 void SetIndicatorShowDuration( float durationSeconds );
186 * @brief Gets the duration in second for the scroll indicator to become fully visible
187 * @return The duration for the scroll indicator to become fully visible
189 float GetIndicatorShowDuration();
192 * @brief Sets the duration in second for the scroll indicator to become fully invisible
194 * @pre The scroll bar actor has been initialised.
196 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
198 void SetIndicatorHideDuration( float durationSeconds );
201 * @brief Gets the duration in second for the scroll indicator to become fully invisible
202 * @return The duration for the scroll indicator to become fully invisible
204 float GetIndicatorHideDuration();
207 * @brief Shows the scroll indicator
212 * @brief Hides the scroll indicator
217 * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
218 * specified by SetPositionNotifications.
220 * A callback of the following type may be connected:
222 * void YourCallbackName(float currentScrollPosition);
224 * @pre The Object has been initialized.
225 * @return The signal to connect to.
227 ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
229 public: // Not intended for application developers
232 * Creates a handle using the Toolkit::Internal implementation.
233 * @param[in] implementation The Control implementation.
235 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
238 * Allows the creation of this Control from an Internal::CustomActor pointer.
239 * @param[in] internal A pointer to the internal CustomActor.
241 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
244 } // namespace Toolkit
251 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__