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 Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/dali.h>
22 #include <dali-toolkit/public-api/controls/scrollable/scroll-component.h>
24 namespace Dali DALI_IMPORT_API
30 // Forward declarations
31 class ScrollConnector;
33 namespace Internal DALI_INTERNAL
35 // Forward declarations
41 * ScrollBar is a UI component that can be added to the scrollable controls
42 * indicating the current scroll position of the scrollable content.
44 class ScrollBar : public ScrollComponent
49 static const char* const SCROLL_POSITION_NOTIFIED_SIGNAL_NAME; ///< "scroll-position-notified" signal name
50 typedef SignalV2< void ( float ) > ScrollPositionNotifiedSignalType;
53 static const Property::Index PROPERTY_INDICATOR_HEIGHT_POLICY; ///< name "indicator-height-policy", type STRING
54 static const Property::Index PROPERTY_INDICATOR_FIXED_HEIGHT; ///< name "indicator-fixed-height", type FLOAT
59 * @brief Indicator height policy.
61 enum IndicatorHeightPolicy
63 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content
64 Fixed ///< Fixed height regardless of the length of scroll content
68 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
69 * Calling member functions with an uninitialized Dali::Object is not allowed.
70 * or horizontally (false)
75 * @brief Copy constructor.
77 ScrollBar( const ScrollBar& scrollBar );
80 * @brief Assignment operator.
82 ScrollBar& operator=( const ScrollBar& scrollBar );
85 * @brief Virtual destructor.
86 * Dali::Object derived classes typically do not contain member data.
91 * @brief Create an initialized ScrollBar
92 * @return A pointer to the created ScrollBar.
94 static ScrollBar New();
97 * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
98 * downcast produces valid handle. If not the returned handle is left uninitialized.
99 * @param[in] handle Handle to an object
100 * @return handle to a ScrollBar or an uninitialized handle
102 static ScrollBar DownCast( BaseHandle handle );
105 * @brief Sets the image for the background of scroll indicator.
107 * @pre The scroll bar actor has been initialised.
109 * The background image is resized (stretched according to scale settings),
110 * to the size of the ScrollBar.
112 * @param[in] image The image to cover background
113 * @param[in] border The nine patch border for the image.
115 void SetBackgroundImage( Image image, const Vector4& border );
118 * @brief Sets the image for the indicator of scroll bar.
120 * @pre The scroll bar actor has been initialised.
122 * The indicator image is resized (stretched according to scale settings),
123 * to reflect the size of the scroll indicator and minimum/maximum limits
124 * of the scroll position.
126 * @param[in] image The image of indicator that moves to indicate the current scroll position.
127 * @param[in] border The nine patch border for the image.
129 void SetIndicatorImage( Image image, const Vector4& border );
132 * @brief Gets the indicator of scroll bar.
134 * @pre The scroll bar actor has been initialised.
136 * @return The indicator indicates the current scroll position of the scrollable content.
138 Actor GetScrollIndicator();
141 * @brief Sets the values to get notification when the current scroll position of the scrollable
142 * content goes above or below any of these values.
144 * @pre The scroll bar actor has been initialised.
146 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
148 void SetPositionNotifications( const std::vector<float>& positions );
151 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
153 * @pre The scroll bar actor has been initialised.
155 * @param[in] policy The height policy of scroll indicator
157 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
160 * @brief Gets the height policy of scroll indicator.
162 * @return The height policy of scroll indicator
164 IndicatorHeightPolicy GetIndicatorHeightPolicy();
167 * @brief Sets the fixed height of scroll indicator.
168 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
169 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
170 * regardless of the length of scroll content.
172 * @pre The scroll bar actor has been initialised.
174 * @param[in] height The fixed height of the scroll indicator
176 void SetIndicatorFixedHeight( float height );
179 * @brief Gets the fix height of scroll indicator.
180 * @return The fixed height of the scroll indicator
182 float GetIndicatorFixedHeight();
185 * @brief Shows the scroll indicator
190 * @brief Hides the scroll indicator
195 * @brief Signal emitted when the current scroll position of the scrollable content goes above or below the values
196 * specified by SetPositionNotifications.
198 * A callback of the following type may be connected:
200 * void YourCallbackName(float currentScrollPosition);
202 * @pre The Object has been initialized.
203 * @return The signal to connect to.
205 ScrollBar::ScrollPositionNotifiedSignalType& ScrollPositionNotifiedSignal();
207 public: // Not intended for application developers
210 * Creates a handle using the Toolkit::Internal implementation.
211 * @param[in] implementation The Control implementation.
213 ScrollBar( Internal::ScrollBar& implementation );
216 * Allows the creation of this Control from an Internal::CustomActor pointer.
217 * @param[in] internal A pointer to the internal CustomActor.
219 ScrollBar( Dali::Internal::CustomActor* internal );
222 } // namespace Toolkit
229 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__