1 #ifndef DALI_TOOLKIT_SCROLL_BAR_H
2 #define DALI_TOOLKIT_SCROLL_BAR_H
5 * Copyright (c) 2020 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>
28 namespace Internal DALI_INTERNAL
30 // Forward declarations
33 } // namespace DALI_INTERNAL
35 * @addtogroup dali_toolkit_controls_scroll_bar
40 * @brief ScrollBar is a UI component that can be linked to the scrollable objects
41 * indicating the current scroll position of the scrollable object.
44 * | %Signal Name | Method |
45 * |-------------------------------|--------------------------------------------|
46 * | panFinished | @ref PanFinishedSignal() |
47 * | scrollPositionIntervalReached | @ref ScrollPositionIntervalReachedSignal() |
50 class DALI_TOOLKIT_API ScrollBar : public Control
56 * @brief Enumeration for the start and end property ranges for this control.
61 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
62 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices @SINCE_1_0.0
66 * @brief Enumeration for the instance of properties belonging to the ScrollBar class.
72 * @brief Enumeration for the instance of properties belonging to the ScrollBar class.
78 * @brief The scrolling direction of the indicator.
79 * @details Name "scrollDirection", type Property::STRING.
80 * Possible values are "VERTICAL" and "HORIZONTAL".
82 * @see SetScrollDirection()
84 SCROLL_DIRECTION = PROPERTY_START_INDEX,
87 * @brief The indicator height policy.
88 * @details Name "indicatorHeightPolicy", type Property::STRING.
89 * Possible values are "VARIABLE" and "FIXED".
91 * @see SetIndicatorHeightPolicy()
93 INDICATOR_HEIGHT_POLICY,
96 * @brief The fixed height of the indicator.
97 * @details Name "indicatorFixedHeight", type Property::FLOAT.
99 * @see SetIndicatorFixedHeight()
101 INDICATOR_FIXED_HEIGHT,
104 * @brief The duration in seconds to show the indicator.
105 * @details Name "indicatorShowDuration", type Property::FLOAT.
107 * @see SetIndicatorShowDuration()
109 INDICATOR_SHOW_DURATION,
112 * @brief The duration in seconds to hide the indicator.
113 * @details Name "indicatorHideDuration", type Property::FLOAT.
115 * @see SetIndicatorHideDuration()
117 INDICATOR_HIDE_DURATION,
120 * @brief The intervals at which point a notification is emitted.
121 * @details Name "scrollPositionIntervals", type Property::ARRAY.
123 * @see SetScrollPositionIntervals()
125 SCROLL_POSITION_INTERVALS,
128 * @brief The minimum height for a variable size indicator.
129 * @details Name "indicatorMinimumHeight", type Property::FLOAT.
132 INDICATOR_MINIMUM_HEIGHT,
135 * @brief The padding at the start of the indicator.
136 * @details Name "indicatorStartPadding", type Property::FLOAT.
137 * For example, the padding at the top if scrollDirection is VERTICAL.
140 INDICATOR_START_PADDING,
143 * @brief The padding at the end of the indicator.
144 * @details Name "indicatorEndPadding", type Property::FLOAT.
145 * For example, the padding at the bottom if scrollDirection is VERTICAL.
148 INDICATOR_END_PADDING,
151 * @brief The duration that transient indicators will remain fully visible.
152 * @details name "indicatorTransientDuration", type Property::FLOAT.
155 INDICATOR_TRANSIENT_DURATION,
161 typedef Signal<void()> PanFinishedSignalType;
162 typedef Signal<void(float)> ScrollPositionIntervalReachedSignalType;
171 VERTICAL = 0, ///< Scroll in the vertical direction @SINCE_1_9.28
172 HORIZONTAL ///< Scroll in the horizontal direction @SINCE_1_9.28
176 * @brief Indicator height policy.
179 enum IndicatorHeightPolicy
181 VARIABLE = 0, ///< VARIABLE height changed dynamically according to the length of scroll content @SINCE_1_9.28
182 FIXED ///< FIXED height regardless of the length of scroll content @SINCE_1_9.28
186 * @brief Creates an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
187 * Calling member functions with an uninitialized Dali::Object is not allowed.
193 * @brief Copy constructor.
195 * @param[in] scrollBar Handle to an object
197 ScrollBar(const ScrollBar& scrollBar);
200 * @brief Assignment operator.
202 * @param[in] scrollBar Handle to an object
203 * @return A reference to this
205 ScrollBar& operator=(const ScrollBar& scrollBar);
210 * This is non-virtual since derived Handle types must not contain data or virtual methods.
216 * @brief Creates an initialized ScrollBar.
218 * @param[in] direction The direction of scroll bar (either vertically or horizontally)
219 * @return A pointer to the created ScrollBar
221 static ScrollBar New(Direction direction = VERTICAL);
224 * @brief Downcasts a handle to ScrollBar handle.
226 * If handle points to a ScrollBar, the downcast produces valid handle.
227 * If not, the returned handle is left uninitialized.
229 * @param[in] handle Handle to an object
230 * @return Handle to a ScrollBar or an uninitialized handle
232 static ScrollBar DownCast(BaseHandle handle);
235 * @brief Sets the source of the scroll position properties.
238 * @param[in] handle The handle of the object owing the scroll properties
239 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float)
240 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float)
241 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float)
242 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float)
243 * @pre The handle to the object owing the scroll properties has been initialised and the property index must be valid.
245 void SetScrollPropertySource(Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize);
248 * @brief Sets the indicator of scroll bar.
251 * @param[in] indicator The indicator that moves to indicate the current scroll position
252 * @pre The scroll bar actor has been initialized.
254 void SetScrollIndicator(Actor indicator);
257 * @brief Gets the indicator of scroll bar.
260 * @return The indicator indicates the current scroll position of the scrollable content
261 * @pre The scroll bar actor has been initialized.
263 Actor GetScrollIndicator();
266 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
267 * object goes above or below any of these values.
270 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
271 * @pre The scroll bar actor has been initialized.
273 void SetScrollPositionIntervals(const Dali::Vector<float>& positions);
276 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
277 * object goes above or below any of these values.
280 * @return The list of values to receive notifications for when the current scroll position crosses them
281 * @pre The scroll bar actor has been initialized.
284 Dali::Vector<float> GetScrollPositionIntervals() const;
287 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
290 * @param[in] direction The direction of scroll bar (either vertically or horizontally)
291 * @pre The scroll bar actor has been initialized.
293 void SetScrollDirection(Direction direction);
296 * @brief Gets the direction of scroll bar.
299 * @return The direction of scroll bar
301 Direction GetScrollDirection() const;
304 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
307 * @param[in] policy The height policy of scroll indicator
308 * @pre The scroll bar actor has been initialized.
310 void SetIndicatorHeightPolicy(IndicatorHeightPolicy policy);
313 * @brief Gets the height policy of scroll indicator.
316 * @return The height policy of scroll indicator
318 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
321 * @brief Sets the fixed height of scroll indicator.
323 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
324 * However, when the height policy of scroll indicator is set to be fixed, the height will be kept fixed
325 * regardless of the length of scroll content.
328 * @param[in] height The fixed height of the scroll indicator
329 * @pre The scroll bar actor has been initialized.
332 void SetIndicatorFixedHeight(float height);
335 * @brief Gets the fix height of scroll indicator.
337 * @return The fixed height of the scroll indicator
339 float GetIndicatorFixedHeight() const;
342 * @brief Sets the duration in seconds for the scroll indicator to become fully visible.
345 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
346 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
349 void SetIndicatorShowDuration(float durationSeconds);
352 * @brief Gets the duration in seconds for the scroll indicator to become fully visible.
354 * @return The duration for the scroll indicator to become fully visible
356 float GetIndicatorShowDuration() const;
359 * @brief Sets the duration in seconds for the scroll indicator to become fully invisible.
362 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
363 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
366 void SetIndicatorHideDuration(float durationSeconds);
369 * @brief Gets the duration in seconds for the scroll indicator to become fully invisible.
371 * @return The duration for the scroll indicator to become fully invisible
373 float GetIndicatorHideDuration() const;
376 * @brief Shows the scroll indicator.
379 void ShowIndicator();
382 * @brief Hides the scroll indicator.
385 void HideIndicator();
389 * @brief Signal emitted when panning is finished on the scroll indicator.
391 * Signal only emitted when the source of the scroll position properties are set.
393 * A callback of the following type may be connected:
395 * void YourCallbackName();
398 * @return The signal to connect to
399 * @pre The Object has been initialized.
401 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
404 * @brief Signal emitted when the current scroll position of the scrollable content
405 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
407 * Signal only emitted when the source of the scroll position properties are set.
409 * A callback of the following type may be connected:
411 * void YourCallbackName(float currentScrollPosition);
414 * @return The signal to connect to
415 * @pre The Object has been initialized.
417 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
419 public: // Not intended for application developers
422 * @brief Creates a handle using the Toolkit::Internal implementation.
424 * @param[in] implementation The Control implementation
426 DALI_INTERNAL ScrollBar(Internal::ScrollBar& implementation);
429 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
431 * @param[in] internal A pointer to the internal CustomActor
433 explicit DALI_INTERNAL ScrollBar(Dali::Internal::CustomActor* internal);
440 } // namespace Toolkit
444 #endif // DALI_TOOLKIT_SCROLL_BAR_H