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.
170 * @param[in] scrollBar Handle to an object
172 ScrollBar( const ScrollBar& scrollBar );
175 * @brief Assignment operator.
177 * @param[in] scrollBar Handle to an object
178 * @return A reference to this
180 ScrollBar& operator=( const ScrollBar& scrollBar );
185 * This is non-virtual since derived Handle types must not contain data or virtual methods.
191 * @brief Create an initialized ScrollBar
193 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
194 * @return A pointer to the created ScrollBar.
196 static ScrollBar New(Direction direction = Vertical);
199 * @brief Downcast a handle to ScrollBar handle.
201 * If handle points to a ScrollBar the
202 * downcast produces valid handle. If not the returned handle is left uninitialized.
204 * @param[in] handle Handle to an object
205 * @return handle to a ScrollBar or an uninitialized handle
207 static ScrollBar DownCast( BaseHandle handle );
210 * @brief Set the source of the scroll position properties.
212 * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
215 * @param[in] handle The handle of the object owing the scroll properties.
216 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float).
217 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float).
218 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float).
219 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float).
221 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
224 * @brief Sets the indicator of scroll bar.
227 * @param[in] indicator The indicator that moves to indicate the current scroll position.
228 * @pre The scroll bar actor has been initialised.
231 void SetScrollIndicator( Actor indicator );
234 * @brief Gets the indicator of scroll bar.
237 * @return The indicator indicates the current scroll position of the scrollable content.
238 * @pre The scroll bar actor has been initialised.
241 Actor GetScrollIndicator();
244 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
245 * object goes above or below any of these values.
248 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
249 * @pre The scroll bar actor has been initialised.
252 void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
255 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
256 * object goes above or below any of these values.
259 * @return The list of values to receive notifications for when the current scroll position crosses them
260 * @pre The scroll bar actor has been initialised.
263 Dali::Vector<float> GetScrollPositionIntervals() const;
266 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
269 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
270 * @pre The scroll bar actor has been initialised.
273 void SetScrollDirection( Direction direction );
276 * @brief Gets the direction of scroll bar.
279 * @return The direction of scroll bar.
281 Direction GetScrollDirection() const;
284 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
287 * @param[in] policy The height policy of scroll indicator
288 * @pre The scroll bar actor has been initialised.
291 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
294 * @brief Gets the height policy of scroll indicator.
297 * @return The height policy of scroll indicator
299 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
302 * @brief Sets the fixed height of scroll indicator.
304 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
305 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
306 * regardless of the length of scroll content.
309 * @param[in] height The fixed height of the scroll indicator
310 * @pre The scroll bar actor has been initialised.
313 void SetIndicatorFixedHeight( float height );
316 * @brief Gets the fix height of scroll indicator.
318 * @return The fixed height of the scroll indicator
320 float GetIndicatorFixedHeight() const;
323 * @brief Sets the duration in second for the scroll indicator to become fully visible
326 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
327 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
330 void SetIndicatorShowDuration( float durationSeconds );
333 * @brief Gets the duration in second for the scroll indicator to become fully visible
335 * @return The duration for the scroll indicator to become fully visible
337 float GetIndicatorShowDuration() const;
340 * @brief Sets the duration in second for the scroll indicator to become fully invisible
343 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
344 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
347 void SetIndicatorHideDuration( float durationSeconds );
350 * @brief Gets the duration in second for the scroll indicator to become fully invisible
352 * @return The duration for the scroll indicator to become fully invisible
354 float GetIndicatorHideDuration() const;
357 * @brief Shows the scroll indicator
360 void ShowIndicator();
363 * @brief Hides the scroll indicator
366 void HideIndicator();
371 * @brief Signal emitted when panning is finished on the scroll indicator.
373 * Signal only emitted when the source of the scroll position properties are set.
375 * A callback of the following type may be connected:
377 * void YourCallbackName();
380 * @return The signal to connect to.
381 * @pre The Object has been initialized.
383 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
386 * @brief Signal emitted when the current scroll position of the scrollable content
387 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
389 * Signal only emitted when the source of the scroll position properties are set.
391 * A callback of the following type may be connected:
393 * void YourCallbackName(float currentScrollPosition);
396 * @return The signal to connect to.
397 * @pre The Object has been initialized.
399 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
401 public: // Not intended for application developers
405 * @brief Creates a handle using the Toolkit::Internal implementation.
407 * @param[in] implementation The Control implementation.
409 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
412 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
414 * @param[in] internal A pointer to the internal CustomActor.
416 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
423 } // namespace Toolkit
427 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__