1 #ifndef __DALI_TOOLKIT_SCROLL_BAR_H__
2 #define __DALI_TOOLKIT_SCROLL_BAR_H__
5 * Copyright (c) 2016 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 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 An enumeration of properties belonging to the ScrollBar class.
77 * @brief name "scrollDirection", type std::string
78 * @see SetScrollDirection()
81 SCROLL_DIRECTION = PROPERTY_START_INDEX,
83 * @brief name "indicatorHeightPolicy", type std::string
84 * @see SetIndicatorHeightPolicy()
87 INDICATOR_HEIGHT_POLICY,
89 * @brief name "indicatorFixedHeight", type float
90 * @see SetIndicatorFixedHeight()
93 INDICATOR_FIXED_HEIGHT,
95 * @brief name "indicatorShowDuration", type float
96 * @see SetIndicatorShowDuration()
99 INDICATOR_SHOW_DURATION,
101 * @brief name "indicatorHideDuration", type float
102 * @see SetIndicatorHideDuration()
105 INDICATOR_HIDE_DURATION,
107 * @brief name "scrollPositionIntervals", type Property::Array
108 * @see SetScrollPositionIntervals()
111 SCROLL_POSITION_INTERVALS,
113 * @brief name "indicatorMinimumHeight", type float
114 * The minimum height for a variable size indicator.
117 INDICATOR_MINIMUM_HEIGHT,
119 * @brief name "indicatorStartPadding", type float
120 * The padding at the start of the indicator. For example, the top if scrollDirection is Vertical.
123 INDICATOR_START_PADDING,
125 * @brief name "indicatorEndPadding", type float
126 * The padding at the end of the indicator. For example, the bottom if scrollDirection is Vertical.
129 INDICATOR_END_PADDING
135 typedef Signal< void () > PanFinishedSignalType;
136 typedef Signal< void ( float ) > ScrollPositionIntervalReachedSignalType;
146 Vertical = 0, ///< Scroll in the vertical direction @SINCE_1_0.0
147 Horizontal ///< Scroll in the horizontal direction @SINCE_1_0.0
151 * @brief Indicator height policy.
154 enum IndicatorHeightPolicy
156 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content @SINCE_1_0.0
157 Fixed ///< Fixed height regardless of the length of scroll content @SINCE_1_0.0
161 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
162 * Calling member functions with an uninitialized Dali::Object is not allowed.
168 * @brief Copy constructor.
171 ScrollBar( const ScrollBar& scrollBar );
174 * @brief Assignment operator.
177 ScrollBar& operator=( const ScrollBar& scrollBar );
182 * This is non-virtual since derived Handle types must not contain data or virtual methods.
188 * @brief Create an initialized ScrollBar
190 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
191 * @return A pointer to the created ScrollBar.
193 static ScrollBar New(Direction direction = Vertical);
196 * @brief Downcast a handle to ScrollBar handle.
198 * If handle points to a ScrollBar the
199 * downcast produces valid handle. If not the returned handle is left uninitialized.
201 * @param[in] handle Handle to an object
202 * @return handle to a ScrollBar or an uninitialized handle
204 static ScrollBar DownCast( BaseHandle handle );
207 * @brief Set the source of the scroll position properties.
209 * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
212 * @param[in] handle The handle of the object owing the scroll properties.
213 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float).
214 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float).
215 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float).
216 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float).
218 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
221 * @brief Sets the indicator of scroll bar.
224 * @param[in] indicator The indicator that moves to indicate the current scroll position.
225 * @pre The scroll bar actor has been initialised.
228 void SetScrollIndicator( Actor indicator );
231 * @brief Gets the indicator of scroll bar.
234 * @return The indicator indicates the current scroll position of the scrollable content.
235 * @pre The scroll bar actor has been initialised.
238 Actor GetScrollIndicator();
241 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
242 * object goes above or below any of these values.
245 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
246 * @pre The scroll bar actor has been initialised.
249 void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
252 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
253 * object goes above or below any of these values.
256 * @return The list of values to receive notifications for when the current scroll position crosses them
257 * @pre The scroll bar actor has been initialised.
260 Dali::Vector<float> GetScrollPositionIntervals() const;
263 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
266 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
267 * @pre The scroll bar actor has been initialised.
270 void SetScrollDirection( Direction direction );
273 * @brief Gets the direction of scroll bar.
276 * @return The direction of scroll bar.
278 Direction GetScrollDirection() const;
281 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
284 * @param[in] policy The height policy of scroll indicator
285 * @pre The scroll bar actor has been initialised.
288 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
291 * @brief Gets the height policy of scroll indicator.
294 * @return The height policy of scroll indicator
296 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
299 * @brief Sets the fixed height of scroll indicator.
301 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
302 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
303 * regardless of the length of scroll content.
306 * @param[in] height The fixed height of the scroll indicator
307 * @pre The scroll bar actor has been initialised.
310 void SetIndicatorFixedHeight( float height );
313 * @brief Gets the fix height of scroll indicator.
315 * @return The fixed height of the scroll indicator
317 float GetIndicatorFixedHeight() const;
320 * @brief Sets the duration in second for the scroll indicator to become fully visible
323 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
324 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
327 void SetIndicatorShowDuration( float durationSeconds );
330 * @brief Gets the duration in second for the scroll indicator to become fully visible
332 * @return The duration for the scroll indicator to become fully visible
334 float GetIndicatorShowDuration() const;
337 * @brief Sets the duration in second for the scroll indicator to become fully invisible
340 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
341 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
344 void SetIndicatorHideDuration( float durationSeconds );
347 * @brief Gets the duration in second for the scroll indicator to become fully invisible
349 * @return The duration for the scroll indicator to become fully invisible
351 float GetIndicatorHideDuration() const;
354 * @brief Shows the scroll indicator
357 void ShowIndicator();
360 * @brief Hides the scroll indicator
363 void HideIndicator();
368 * @brief Signal emitted when panning is finished on the scroll indicator.
370 * Signal only emitted when the source of the scroll position properties are set.
372 * A callback of the following type may be connected:
374 * void YourCallbackName();
377 * @return The signal to connect to.
378 * @pre The Object has been initialized.
380 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
383 * @brief Signal emitted when the current scroll position of the scrollable content
384 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
386 * Signal only emitted when the source of the scroll position properties are set.
388 * A callback of the following type may be connected:
390 * void YourCallbackName(float currentScrollPosition);
393 * @return The signal to connect to.
394 * @pre The Object has been initialized.
396 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
398 public: // Not intended for application developers
402 * @brief Creates a handle using the Toolkit::Internal implementation.
404 * @param[in] implementation The Control implementation.
406 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
409 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
411 * @param[in] internal A pointer to the internal CustomActor.
413 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
420 } // namespace Toolkit
424 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__