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/dali.h>
23 #include <dali/public-api/common/vector-wrapper.h>
26 #include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
28 namespace Dali DALI_IMPORT_API
34 // Forward declarations
35 class ScrollConnector;
37 namespace Internal DALI_INTERNAL
39 // Forward declarations
45 * ScrollBar is a UI component that can be added to the scrollable controls
46 * indicating the current scroll position of the scrollable content.
48 class ScrollBar : public ScrollComponent
53 static const char* const SCROLL_POSITION_NOTIFIED_SIGNAL_NAME; ///< "scroll-position-notified" signal name
54 typedef SignalV2< void ( float ) > ScrollPositionNotifiedSignalType;
57 static const Property::Index PROPERTY_INDICATOR_HEIGHT_POLICY; ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type STRING
58 static const Property::Index PROPERTY_INDICATOR_FIXED_HEIGHT; ///< name "indicator-fixed-height", @see SetIndicatorFixedHeight(), type FLOAT
59 static const Property::Index PROPERTY_INDICATOR_SHOW_DURATION; ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type FLOAT
60 static const Property::Index PROPERTY_INDICATOR_HIDE_DURATION; ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type FLOAT
65 * @brief Indicator height policy.
67 enum IndicatorHeightPolicy
69 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content
70 Fixed ///< Fixed height regardless of the length of scroll content
74 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
75 * Calling member functions with an uninitialized Dali::Object is not allowed.
76 * or horizontally (false)
81 * @brief Copy constructor.
83 ScrollBar( const ScrollBar& scrollBar );
86 * @brief Assignment operator.
88 ScrollBar& operator=( const ScrollBar& scrollBar );
93 * This is non-virtual since derived Handle types must not contain data or virtual methods.
98 * @brief Create an initialized ScrollBar
99 * @return A pointer to the created ScrollBar.
101 static ScrollBar New();
104 * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
105 * downcast produces valid handle. If not the returned handle is left uninitialized.
106 * @param[in] handle Handle to an object
107 * @return handle to a ScrollBar or an uninitialized handle
109 static ScrollBar DownCast( BaseHandle handle );
112 * @brief Sets the image for the indicator of scroll bar.
114 * @pre The scroll bar actor has been initialised.
116 * The indicator image is resized (stretched according to scale settings),
117 * to reflect the size of the scroll indicator and minimum/maximum limits
118 * of the scroll position.
120 * @param[in] image The image of indicator that moves to indicate the current scroll position.
122 void SetIndicatorImage( Image image );
125 * @brief Gets the indicator of scroll bar.
127 * @pre The scroll bar actor has been initialised.
129 * @return The indicator indicates the current scroll position of the scrollable content.
131 Actor GetScrollIndicator();
134 * @brief Sets the values to get notification when the current scroll position of the scrollable
135 * content goes above or below any of these values.
137 * @pre The scroll bar actor has been initialised.
139 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
141 void SetPositionNotifications( const std::vector<float>& positions );
144 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
146 * @pre The scroll bar actor has been initialised.
148 * @param[in] policy The height policy of scroll indicator
150 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
153 * @brief Gets the height policy of scroll indicator.
155 * @return The height policy of scroll indicator
157 IndicatorHeightPolicy GetIndicatorHeightPolicy();
160 * @brief Sets the fixed height of scroll indicator.
161 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
162 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
163 * regardless of the length of scroll content.
165 * @pre The scroll bar actor has been initialised.
167 * @param[in] height The fixed height of the scroll indicator
169 void SetIndicatorFixedHeight( float height );
172 * @brief Gets the fix height of scroll indicator.
173 * @return The fixed height of the scroll indicator
175 float GetIndicatorFixedHeight();
178 * @brief Sets the duration in second for the scroll indicator to become fully visible
180 * @pre The scroll bar actor has been initialised.
182 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
184 void SetIndicatorShowDuration( float durationSeconds );
187 * @brief Gets the duration in second for the scroll indicator to become fully visible
188 * @return The duration for the scroll indicator to become fully visible
190 float GetIndicatorShowDuration();
193 * @brief Sets the duration in second for the scroll indicator to become fully invisible
195 * @pre The scroll bar actor has been initialised.
197 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
199 void SetIndicatorHideDuration( float durationSeconds );
202 * @brief Gets the duration in second for the scroll indicator to become fully invisible
203 * @return The duration for the scroll indicator to become fully invisible
205 float GetIndicatorHideDuration();
208 * @brief Shows the scroll indicator
213 * @brief Hides the scroll indicator
218 * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
219 * specified by SetPositionNotifications.
221 * A callback of the following type may be connected:
223 * void YourCallbackName(float currentScrollPosition);
225 * @pre The Object has been initialized.
226 * @return The signal to connect to.
228 ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
230 public: // Not intended for application developers
233 * Creates a handle using the Toolkit::Internal implementation.
234 * @param[in] implementation The Control implementation.
236 ScrollBar( Internal::ScrollBar& implementation );
239 * Allows the creation of this Control from an Internal::CustomActor pointer.
240 * @param[in] internal A pointer to the internal CustomActor.
242 ScrollBar( Dali::Internal::CustomActor* internal );
245 } // namespace Toolkit
252 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__