1 #ifndef __DALI_TOOLKIT_SCROLL_BAR_H__
2 #define __DALI_TOOLKIT_SCROLL_BAR_H__
5 * Copyright (c) 2017 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
37 * @addtogroup dali_toolkit_controls_scroll_bar
42 * @brief ScrollBar is a UI component that can be linked to the scrollable objects
43 * indicating the current scroll position of the scrollable object.
46 * | %Signal Name | Method |
47 * |-------------------------------|--------------------------------------------|
48 * | panFinished | @ref PanFinishedSignal() |
49 * | scrollPositionIntervalReached | @ref ScrollPositionIntervalReachedSignal() |
52 class DALI_IMPORT_API ScrollBar : public Control
59 * @brief Enumeration for the start and end property ranges for this control.
64 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
65 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices @SINCE_1_0.0
69 * @brief Enumeration for the instance of properties belonging to the ScrollBar class.
75 * @brief Enumeration for the instance of properties belonging to the ScrollBar class.
81 * @brief The scrolling direction of the indicator.
82 * @details Name "scrollDirection", type Property::STRING.
83 * Possible values are "Vertical" and "Horizontal".
85 * @see SetScrollDirection()
87 SCROLL_DIRECTION = PROPERTY_START_INDEX,
90 * @brief The indicator height policy.
91 * @details Name "indicatorHeightPolicy", type Property::STRING.
92 * Possible values are "Variable" and "Fixed".
94 * @see SetIndicatorHeightPolicy()
96 INDICATOR_HEIGHT_POLICY,
99 * @brief The fixed height of the indicator.
100 * @details Name "indicatorFixedHeight", type Property::FLOAT.
102 * @see SetIndicatorFixedHeight()
104 INDICATOR_FIXED_HEIGHT,
107 * @brief The duration in seconds to show the indicator.
108 * @details Name "indicatorShowDuration", type Property::FLOAT.
110 * @see SetIndicatorShowDuration()
112 INDICATOR_SHOW_DURATION,
115 * @brief The duration in seconds to hide the indicator.
116 * @details Name "indicatorHideDuration", type Property::FLOAT.
118 * @see SetIndicatorHideDuration()
120 INDICATOR_HIDE_DURATION,
123 * @brief The intervals at which point a notification is emitted.
124 * @details Name "scrollPositionIntervals", type Property::ARRAY.
126 * @see SetScrollPositionIntervals()
128 SCROLL_POSITION_INTERVALS,
131 * @brief The minimum height for a variable size indicator.
132 * @details Name "indicatorMinimumHeight", type Property::FLOAT.
135 INDICATOR_MINIMUM_HEIGHT,
138 * @brief The padding at the start of the indicator.
139 * @details Name "indicatorStartPadding", type Property::FLOAT.
140 * For example, the padding at the top if scrollDirection is Vertical.
143 INDICATOR_START_PADDING,
146 * @brief The padding at the end of the indicator.
147 * @details Name "indicatorEndPadding", type Property::FLOAT.
148 * For example, the padding at the bottom if scrollDirection is Vertical.
151 INDICATOR_END_PADDING,
154 * @brief The duration that transient indicators will remain fully visible.
155 * @details name "indicatorTransientDuration", type Property::FLOAT.
158 INDICATOR_TRANSIENT_DURATION,
164 typedef Signal< void () > PanFinishedSignalType;
165 typedef Signal< void ( float ) > ScrollPositionIntervalReachedSignalType;
175 Vertical = 0, ///< Scroll in the vertical direction @SINCE_1_0.0
176 Horizontal ///< Scroll in the horizontal direction @SINCE_1_0.0
180 * @brief Indicator height policy.
183 enum IndicatorHeightPolicy
185 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content @SINCE_1_0.0
186 Fixed ///< Fixed height regardless of the length of scroll content @SINCE_1_0.0
190 * @brief Creates an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
191 * Calling member functions with an uninitialized Dali::Object is not allowed.
197 * @brief Copy constructor.
199 * @param[in] scrollBar Handle to an object
201 ScrollBar( const ScrollBar& scrollBar );
204 * @brief Assignment operator.
206 * @param[in] scrollBar Handle to an object
207 * @return A reference to this
209 ScrollBar& operator=( const ScrollBar& scrollBar );
214 * This is non-virtual since derived Handle types must not contain data or virtual methods.
220 * @brief Creates an initialized ScrollBar.
222 * @param[in] direction The direction of scroll bar (either vertically or horizontally)
223 * @return A pointer to the created ScrollBar
225 static ScrollBar New(Direction direction = Vertical);
228 * @brief Downcasts a handle to ScrollBar handle.
230 * If handle points to a ScrollBar, the downcast produces valid handle.
231 * If not, the returned handle is left uninitialized.
233 * @param[in] handle Handle to an object
234 * @return Handle to a ScrollBar or an uninitialized handle
236 static ScrollBar DownCast( BaseHandle handle );
239 * @brief Sets the source of the scroll position properties.
242 * @param[in] handle The handle of the object owing the scroll properties
243 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float)
244 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float)
245 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float)
246 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float)
247 * @pre The handle to the object owing the scroll properties has been initialised and the property index must be valid.
249 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
252 * @brief Sets the indicator of scroll bar.
255 * @param[in] indicator The indicator that moves to indicate the current scroll position
256 * @pre The scroll bar actor has been initialized.
258 void SetScrollIndicator( Actor indicator );
261 * @brief Gets the indicator of scroll bar.
264 * @return The indicator indicates the current scroll position of the scrollable content
265 * @pre The scroll bar actor has been initialized.
267 Actor GetScrollIndicator();
270 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
271 * object goes above or below any of these values.
274 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
275 * @pre The scroll bar actor has been initialized.
277 void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
280 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
281 * object goes above or below any of these values.
284 * @return The list of values to receive notifications for when the current scroll position crosses them
285 * @pre The scroll bar actor has been initialized.
288 Dali::Vector<float> GetScrollPositionIntervals() const;
291 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
294 * @param[in] direction The direction of scroll bar (either vertically or horizontally)
295 * @pre The scroll bar actor has been initialized.
297 void SetScrollDirection( Direction direction );
300 * @brief Gets the direction of scroll bar.
303 * @return The direction of scroll bar
305 Direction GetScrollDirection() const;
308 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
311 * @param[in] policy The height policy of scroll indicator
312 * @pre The scroll bar actor has been initialized.
314 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
317 * @brief Gets the height policy of scroll indicator.
320 * @return The height policy of scroll indicator
322 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
325 * @brief Sets the fixed height of scroll indicator.
327 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
328 * However, when the height policy of scroll indicator is set to be fixed, the height will be kept fixed
329 * regardless of the length of scroll content.
332 * @param[in] height The fixed height of the scroll indicator
333 * @pre The scroll bar actor has been initialized.
336 void SetIndicatorFixedHeight( float height );
339 * @brief Gets the fix height of scroll indicator.
341 * @return The fixed height of the scroll indicator
343 float GetIndicatorFixedHeight() const;
346 * @brief Sets the duration in seconds for the scroll indicator to become fully visible.
349 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
350 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
353 void SetIndicatorShowDuration( float durationSeconds );
356 * @brief Gets the duration in seconds for the scroll indicator to become fully visible.
358 * @return The duration for the scroll indicator to become fully visible
360 float GetIndicatorShowDuration() const;
363 * @brief Sets the duration in seconds for the scroll indicator to become fully invisible.
366 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
367 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
370 void SetIndicatorHideDuration( float durationSeconds );
373 * @brief Gets the duration in seconds for the scroll indicator to become fully invisible.
375 * @return The duration for the scroll indicator to become fully invisible
377 float GetIndicatorHideDuration() const;
380 * @brief Shows the scroll indicator.
383 void ShowIndicator();
386 * @brief Hides the scroll indicator.
389 void HideIndicator();
394 * @brief Signal emitted when panning is finished on the scroll indicator.
396 * Signal only emitted when the source of the scroll position properties are set.
398 * A callback of the following type may be connected:
400 * void YourCallbackName();
403 * @return The signal to connect to
404 * @pre The Object has been initialized.
406 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
409 * @brief Signal emitted when the current scroll position of the scrollable content
410 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
412 * Signal only emitted when the source of the scroll position properties are set.
414 * A callback of the following type may be connected:
416 * void YourCallbackName(float currentScrollPosition);
419 * @return The signal to connect to
420 * @pre The Object has been initialized.
422 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
424 public: // Not intended for application developers
428 * @brief Creates a handle using the Toolkit::Internal implementation.
430 * @param[in] implementation The Control implementation
432 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
435 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
437 * @param[in] internal A pointer to the internal CustomActor
439 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
446 } // namespace Toolkit
450 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__