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.
48 * | %Signal Name | Method |
49 * |--------------------------|-------------------------------------|
50 * | scroll-position-notified | @ref ScrollPositionNotifiedSignal() |
52 class DALI_IMPORT_API ScrollBar : public ScrollComponent
57 typedef Signal< void ( float ) > ScrollPositionNotifiedSignalType;
60 static const Property::Index PROPERTY_INDICATOR_HEIGHT_POLICY; ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type STRING
61 static const Property::Index PROPERTY_INDICATOR_FIXED_HEIGHT; ///< name "indicator-fixed-height", @see SetIndicatorFixedHeight(), type FLOAT
62 static const Property::Index PROPERTY_INDICATOR_SHOW_DURATION; ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type FLOAT
63 static const Property::Index PROPERTY_INDICATOR_HIDE_DURATION; ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type FLOAT
68 * @brief Indicator height policy.
70 enum IndicatorHeightPolicy
72 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content
73 Fixed ///< Fixed height regardless of the length of scroll content
77 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
78 * Calling member functions with an uninitialized Dali::Object is not allowed.
79 * or horizontally (false)
84 * @brief Copy constructor.
86 ScrollBar( const ScrollBar& scrollBar );
89 * @brief Assignment operator.
91 ScrollBar& operator=( const ScrollBar& scrollBar );
96 * This is non-virtual since derived Handle types must not contain data or virtual methods.
101 * @brief Create an initialized ScrollBar
102 * @return A pointer to the created ScrollBar.
104 static ScrollBar New();
107 * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
108 * downcast produces valid handle. If not the returned handle is left uninitialized.
109 * @param[in] handle Handle to an object
110 * @return handle to a ScrollBar or an uninitialized handle
112 static ScrollBar DownCast( BaseHandle handle );
115 * @brief Sets the image for the indicator of scroll bar.
117 * @pre The scroll bar actor has been initialised.
119 * The indicator image is resized (stretched according to scale settings),
120 * to reflect the size of the scroll indicator and minimum/maximum limits
121 * of the scroll position.
123 * @param[in] image The image of indicator that moves to indicate the current scroll position.
125 void SetIndicatorImage( Image image );
128 * @brief Gets the indicator of scroll bar.
130 * @pre The scroll bar actor has been initialised.
132 * @return The indicator indicates the current scroll position of the scrollable content.
134 Actor GetScrollIndicator();
137 * @brief Sets the values to get notification when the current scroll position of the scrollable
138 * content goes above or below any of these values.
140 * @pre The scroll bar actor has been initialised.
142 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
144 void SetPositionNotifications( const std::vector<float>& positions );
147 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
149 * @pre The scroll bar actor has been initialised.
151 * @param[in] policy The height policy of scroll indicator
153 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
156 * @brief Gets the height policy of scroll indicator.
158 * @return The height policy of scroll indicator
160 IndicatorHeightPolicy GetIndicatorHeightPolicy();
163 * @brief Sets the fixed height of scroll indicator.
164 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
165 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
166 * regardless of the length of scroll content.
168 * @pre The scroll bar actor has been initialised.
170 * @param[in] height The fixed height of the scroll indicator
172 void SetIndicatorFixedHeight( float height );
175 * @brief Gets the fix height of scroll indicator.
176 * @return The fixed height of the scroll indicator
178 float GetIndicatorFixedHeight();
181 * @brief Sets the duration in second for the scroll indicator to become fully visible
183 * @pre The scroll bar actor has been initialised.
185 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
187 void SetIndicatorShowDuration( float durationSeconds );
190 * @brief Gets the duration in second for the scroll indicator to become fully visible
191 * @return The duration for the scroll indicator to become fully visible
193 float GetIndicatorShowDuration();
196 * @brief Sets the duration in second for the scroll indicator to become fully invisible
198 * @pre The scroll bar actor has been initialised.
200 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
202 void SetIndicatorHideDuration( float durationSeconds );
205 * @brief Gets the duration in second for the scroll indicator to become fully invisible
206 * @return The duration for the scroll indicator to become fully invisible
208 float GetIndicatorHideDuration();
211 * @brief Shows the scroll indicator
216 * @brief Hides the scroll indicator
221 * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
222 * specified by SetPositionNotifications.
224 * A callback of the following type may be connected:
226 * void YourCallbackName(float currentScrollPosition);
228 * @pre The Object has been initialized.
229 * @return The signal to connect to.
231 ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
233 public: // Not intended for application developers
236 * Creates a handle using the Toolkit::Internal implementation.
237 * @param[in] implementation The Control implementation.
239 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
242 * Allows the creation of this Control from an Internal::CustomActor pointer.
243 * @param[in] internal A pointer to the internal CustomActor.
245 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
248 } // namespace Toolkit
255 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__