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-toolkit/public-api/controls/scrollable/scroll-component.h>
25 namespace Dali DALI_IMPORT_API
31 // Forward declarations
32 class ScrollConnector;
34 namespace Internal DALI_INTERNAL
36 // Forward declarations
42 * ScrollBar is a UI component that can be added to the scrollable controls
43 * indicating the current scroll position of the scrollable content.
45 class ScrollBar : public ScrollComponent
50 static const char* const SCROLL_POSITION_NOTIFIED_SIGNAL_NAME; ///< "scroll-position-notified" signal name
51 typedef SignalV2< void ( float ) > ScrollPositionNotifiedSignalType;
54 static const Property::Index PROPERTY_INDICATOR_HEIGHT_POLICY; ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type STRING
55 static const Property::Index PROPERTY_INDICATOR_FIXED_HEIGHT; ///< name "indicator-fixed-height", @see SetIndicatorFixedHeight(), type FLOAT
56 static const Property::Index PROPERTY_INDICATOR_SHOW_DURATION; ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type FLOAT
57 static const Property::Index PROPERTY_INDICATOR_HIDE_DURATION; ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type FLOAT
62 * @brief Indicator height policy.
64 enum IndicatorHeightPolicy
66 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content
67 Fixed ///< Fixed height regardless of the length of scroll content
71 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
72 * Calling member functions with an uninitialized Dali::Object is not allowed.
73 * or horizontally (false)
78 * @brief Copy constructor.
80 ScrollBar( const ScrollBar& scrollBar );
83 * @brief Assignment operator.
85 ScrollBar& operator=( const ScrollBar& scrollBar );
90 * This is non-virtual since derived Handle types must not contain data or virtual methods.
95 * @brief Create an initialized ScrollBar
96 * @return A pointer to the created ScrollBar.
98 static ScrollBar New();
101 * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
102 * downcast produces valid handle. If not the returned handle is left uninitialized.
103 * @param[in] handle Handle to an object
104 * @return handle to a ScrollBar or an uninitialized handle
106 static ScrollBar DownCast( BaseHandle handle );
109 * @brief Sets the image for the indicator of scroll bar.
111 * @pre The scroll bar actor has been initialised.
113 * The indicator image is resized (stretched according to scale settings),
114 * to reflect the size of the scroll indicator and minimum/maximum limits
115 * of the scroll position.
117 * @param[in] image The image of indicator that moves to indicate the current scroll position.
119 void SetIndicatorImage( Image image );
122 * @brief Gets the indicator of scroll bar.
124 * @pre The scroll bar actor has been initialised.
126 * @return The indicator indicates the current scroll position of the scrollable content.
128 Actor GetScrollIndicator();
131 * @brief Sets the values to get notification when the current scroll position of the scrollable
132 * content goes above or below any of these values.
134 * @pre The scroll bar actor has been initialised.
136 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
138 void SetPositionNotifications( const std::vector<float>& positions );
141 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
143 * @pre The scroll bar actor has been initialised.
145 * @param[in] policy The height policy of scroll indicator
147 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
150 * @brief Gets the height policy of scroll indicator.
152 * @return The height policy of scroll indicator
154 IndicatorHeightPolicy GetIndicatorHeightPolicy();
157 * @brief Sets the fixed height of scroll indicator.
158 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
159 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
160 * regardless of the length of scroll content.
162 * @pre The scroll bar actor has been initialised.
164 * @param[in] height The fixed height of the scroll indicator
166 void SetIndicatorFixedHeight( float height );
169 * @brief Gets the fix height of scroll indicator.
170 * @return The fixed height of the scroll indicator
172 float GetIndicatorFixedHeight();
175 * @brief Sets the duration in second for the scroll indicator to become fully visible
177 * @pre The scroll bar actor has been initialised.
179 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
181 void SetIndicatorShowDuration( float durationSeconds );
184 * @brief Gets the duration in second for the scroll indicator to become fully visible
185 * @return The duration for the scroll indicator to become fully visible
187 float GetIndicatorShowDuration();
190 * @brief Sets the duration in second for the scroll indicator to become fully invisible
192 * @pre The scroll bar actor has been initialised.
194 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
196 void SetIndicatorHideDuration( float durationSeconds );
199 * @brief Gets the duration in second for the scroll indicator to become fully invisible
200 * @return The duration for the scroll indicator to become fully invisible
202 float GetIndicatorHideDuration();
205 * @brief Shows the scroll indicator
210 * @brief Hides the scroll indicator
215 * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
216 * specified by SetPositionNotifications.
218 * A callback of the following type may be connected:
220 * void YourCallbackName(float currentScrollPosition);
222 * @pre The Object has been initialized.
223 * @return The signal to connect to.
225 ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
227 public: // Not intended for application developers
230 * Creates a handle using the Toolkit::Internal implementation.
231 * @param[in] implementation The Control implementation.
233 ScrollBar( Internal::ScrollBar& implementation );
236 * Allows the creation of this Control from an Internal::CustomActor pointer.
237 * @param[in] internal A pointer to the internal CustomActor.
239 ScrollBar( Dali::Internal::CustomActor* internal );
242 } // namespace Toolkit
249 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__