1 #ifndef __DALI_TOOLKIT_SCROLL_BAR_H__
2 #define __DALI_TOOLKIT_SCROLL_BAR_H__
5 * Copyright (c) 2015 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/dali-vector.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 * @brief The start and end property ranges for this control.
61 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
62 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
66 * @brief An enumeration of properties belonging to the ScrollBar class.
72 INDICATOR_HEIGHT_POLICY = PROPERTY_START_INDEX, ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type std::string
73 INDICATOR_FIXED_HEIGHT, ///< name "indicator-fixed-height", @see SetIndicatorFixedHeight(), type float
74 INDICATOR_SHOW_DURATION, ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type float
75 INDICATOR_HIDE_DURATION, ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type float
80 typedef Signal< void ( float ) > ScrollPositionNotifiedSignalType;
85 * @brief Indicator height policy.
87 enum IndicatorHeightPolicy
89 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content
90 Fixed ///< Fixed height regardless of the length of scroll content
94 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
95 * Calling member functions with an uninitialized Dali::Object is not allowed.
96 * or horizontally (false)
101 * @brief Copy constructor.
103 ScrollBar( const ScrollBar& scrollBar );
106 * @brief Assignment operator.
108 ScrollBar& operator=( const ScrollBar& scrollBar );
113 * This is non-virtual since derived Handle types must not contain data or virtual methods.
118 * @brief Create an initialized ScrollBar
119 * @return A pointer to the created ScrollBar.
121 static ScrollBar New();
124 * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
125 * downcast produces valid handle. If not the returned handle is left uninitialized.
126 * @param[in] handle Handle to an object
127 * @return handle to a ScrollBar or an uninitialized handle
129 static ScrollBar DownCast( BaseHandle handle );
132 * @brief Sets the image for the indicator of scroll bar.
134 * @pre The scroll bar actor has been initialised.
136 * The indicator image is resized (stretched according to scale settings),
137 * to reflect the size of the scroll indicator and minimum/maximum limits
138 * of the scroll position.
140 * @param[in] image The image of indicator that moves to indicate the current scroll position.
142 void SetIndicatorImage( Image image );
145 * @brief Gets the indicator of scroll bar.
147 * @pre The scroll bar actor has been initialised.
149 * @return The indicator indicates the current scroll position of the scrollable content.
151 Actor GetScrollIndicator();
154 * @brief Sets the values to get notification when the current scroll position of the scrollable
155 * content goes above or below any of these values.
157 * @pre The scroll bar actor has been initialised.
159 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
161 void SetPositionNotifications( const Dali::Vector<float>& positions );
164 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
166 * @pre The scroll bar actor has been initialised.
168 * @param[in] policy The height policy of scroll indicator
170 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
173 * @brief Gets the height policy of scroll indicator.
175 * @return The height policy of scroll indicator
177 IndicatorHeightPolicy GetIndicatorHeightPolicy();
180 * @brief Sets the fixed height of scroll indicator.
181 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
182 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
183 * regardless of the length of scroll content.
185 * @pre The scroll bar actor has been initialised.
187 * @param[in] height The fixed height of the scroll indicator
189 void SetIndicatorFixedHeight( float height );
192 * @brief Gets the fix height of scroll indicator.
193 * @return The fixed height of the scroll indicator
195 float GetIndicatorFixedHeight();
198 * @brief Sets the duration in second for the scroll indicator to become fully visible
200 * @pre The scroll bar actor has been initialised.
202 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
204 void SetIndicatorShowDuration( float durationSeconds );
207 * @brief Gets the duration in second for the scroll indicator to become fully visible
208 * @return The duration for the scroll indicator to become fully visible
210 float GetIndicatorShowDuration();
213 * @brief Sets the duration in second for the scroll indicator to become fully invisible
215 * @pre The scroll bar actor has been initialised.
217 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
219 void SetIndicatorHideDuration( float durationSeconds );
222 * @brief Gets the duration in second for the scroll indicator to become fully invisible
223 * @return The duration for the scroll indicator to become fully invisible
225 float GetIndicatorHideDuration();
228 * @brief Shows the scroll indicator
233 * @brief Hides the scroll indicator
238 * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
239 * specified by SetPositionNotifications.
241 * A callback of the following type may be connected:
243 * void YourCallbackName(float currentScrollPosition);
245 * @pre The Object has been initialized.
246 * @return The signal to connect to.
248 ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
250 public: // Not intended for application developers
253 * Creates a handle using the Toolkit::Internal implementation.
254 * @param[in] implementation The Control implementation.
256 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
259 * Allows the creation of this Control from an Internal::CustomActor pointer.
260 * @param[in] internal A pointer to the internal CustomActor.
262 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
265 } // namespace Toolkit
272 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__