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-toolkit/public-api/controls/control.h>
30 namespace Internal DALI_INTERNAL
32 // Forward declarations
38 * ScrollBar is a UI component that can be linked to the scrollable objects
39 * indicating the current scroll position of the scrollable object.
42 * | %Signal Name | Method |
43 * |----------------------------------|--------------------------------------------|
44 * | pan-finished | @ref PanFinishedSignal() |
45 * | scroll-position-interval-reached | @ref ScrollPositionIntervalReachedSignal() |
47 class DALI_IMPORT_API ScrollBar : public Control
54 * @brief The start and end property ranges for this control.
58 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
59 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
63 * @brief An enumeration of properties belonging to the ScrollBar class.
69 SCROLL_DIRECTION = PROPERTY_START_INDEX, ///< name "scroll-direction", @see SetScrollDirection(), type std::string
70 INDICATOR_HEIGHT_POLICY, ///< name "indicator-height-policy", @see SetIndicatorHeightPolicy(), type std::string
71 INDICATOR_FIXED_HEIGHT, ///< name "indicator-fixed-height", @see SetIndicatorFixedHeight(), type float
72 INDICATOR_SHOW_DURATION, ///< name "indicator-show-duration", @see SetIndicatorShowDuration(), type float
73 INDICATOR_HIDE_DURATION, ///< name "indicator-hide-duration", @see SetIndicatorHideDuration(), type float
74 SCROLL_POSITION_INTERVALS ///< name "scroll-position-intervals", type float
80 typedef Signal< void () > PanFinishedSignalType;
81 typedef Signal< void ( float ) > ScrollPositionIntervalReachedSignalType;
90 Vertical = 0, ///< Scroll in the vertical direction
91 Horizontal ///< Scroll in the horizontal direction
95 * @brief Indicator height policy.
97 enum IndicatorHeightPolicy
99 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content
100 Fixed ///< Fixed height regardless of the length of scroll content
104 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
105 * Calling member functions with an uninitialized Dali::Object is not allowed.
110 * @brief Copy constructor.
112 ScrollBar( const ScrollBar& scrollBar );
115 * @brief Assignment operator.
117 ScrollBar& operator=( const ScrollBar& scrollBar );
122 * This is non-virtual since derived Handle types must not contain data or virtual methods.
127 * @brief Create an initialized ScrollBar
128 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
129 * @return A pointer to the created ScrollBar.
131 static ScrollBar New(Direction direction = Vertical);
134 * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
135 * downcast produces valid handle. If not the returned handle is left uninitialized.
136 * @param[in] handle Handle to an object
137 * @return handle to a ScrollBar or an uninitialized handle
139 static ScrollBar DownCast( BaseHandle handle );
142 * @brief Set the source of the scroll position properties.
144 * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
146 * @param[in] handle The handle of the object owing the scroll properties.
147 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float).
148 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float).
149 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float).
150 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float).
152 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
155 * @brief Sets the indicator of scroll bar.
157 * @pre The scroll bar actor has been initialised.
159 * @param[in] indicator The indicator that moves to indicate the current scroll position.
161 void SetScrollIndicator( Actor indicator );
164 * @brief Gets the indicator of scroll bar.
166 * @pre The scroll bar actor has been initialised.
168 * @return The indicator indicates the current scroll position of the scrollable content.
170 Actor GetScrollIndicator();
173 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
174 * object goes above or below any of these values.
176 * @pre The scroll bar actor has been initialised.
178 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
180 void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
183 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
184 * object goes above or below any of these values.
186 * @pre The scroll bar actor has been initialised.
188 * @return The list of values to receive notifications for when the current scroll position crosses them
190 Dali::Vector<float> GetScrollPositionIntervals() const;
193 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
195 * @pre The scroll bar actor has been initialised.
197 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
199 void SetScrollDirection( Direction direction );
202 * @brief Gets the direction of scroll bar.
204 * @return The direction of scroll bar.
206 Direction GetScrollDirection() const;
209 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
211 * @pre The scroll bar actor has been initialised.
213 * @param[in] policy The height policy of scroll indicator
215 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
218 * @brief Gets the height policy of scroll indicator.
220 * @return The height policy of scroll indicator
222 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
225 * @brief Sets the fixed height of scroll indicator.
226 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
227 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
228 * regardless of the length of scroll content.
230 * @pre The scroll bar actor has been initialised.
232 * @param[in] height The fixed height of the scroll indicator
234 void SetIndicatorFixedHeight( float height );
237 * @brief Gets the fix height of scroll indicator.
238 * @return The fixed height of the scroll indicator
240 float GetIndicatorFixedHeight() const;
243 * @brief Sets the duration in second for the scroll indicator to become fully visible
245 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
247 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
249 void SetIndicatorShowDuration( float durationSeconds );
252 * @brief Gets the duration in second for the scroll indicator to become fully visible
253 * @return The duration for the scroll indicator to become fully visible
255 float GetIndicatorShowDuration() const;
258 * @brief Sets the duration in second for the scroll indicator to become fully invisible
260 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
262 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
264 void SetIndicatorHideDuration( float durationSeconds );
267 * @brief Gets the duration in second for the scroll indicator to become fully invisible
268 * @return The duration for the scroll indicator to become fully invisible
270 float GetIndicatorHideDuration() const;
273 * @brief Shows the scroll indicator
275 void ShowIndicator();
278 * @brief Hides the scroll indicator
280 void HideIndicator();
285 * @brief Signal emitted when panning is finished on the scroll indicator.
286 * Signal only emitted when the source of the scroll position properties are set.
288 * A callback of the following type may be connected:
290 * void YourCallbackName();
292 * @pre The Object has been initialized.
293 * @return The signal to connect to.
295 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
298 * @brief Signal emitted when the current scroll position of the scrollable content
299 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
300 * Signal only emitted when the source of the scroll position properties are set.
302 * A callback of the following type may be connected:
304 * void YourCallbackName(float currentScrollPosition);
306 * @pre The Object has been initialized.
307 * @return The signal to connect to.
309 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
311 public: // Not intended for application developers
314 * Creates a handle using the Toolkit::Internal implementation.
315 * @param[in] implementation The Control implementation.
317 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
320 * Allows the creation of this Control from an Internal::CustomActor pointer.
321 * @param[in] internal A pointer to the internal CustomActor.
323 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
326 } // namespace Toolkit
333 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__