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.
75 * @brief An enumeration of properties belonging to the ScrollBar class.
81 * @brief name "scrollDirection", type std::string
82 * @see SetScrollDirection()
85 SCROLL_DIRECTION = PROPERTY_START_INDEX,
87 * @brief name "indicatorHeightPolicy", type std::string
88 * @see SetIndicatorHeightPolicy()
91 INDICATOR_HEIGHT_POLICY,
93 * @brief name "indicatorFixedHeight", type float
94 * @see SetIndicatorFixedHeight()
97 INDICATOR_FIXED_HEIGHT,
99 * @brief name "indicatorShowDuration", type float
100 * @see SetIndicatorShowDuration()
103 INDICATOR_SHOW_DURATION,
105 * @brief name "indicatorHideDuration", type float
106 * @see SetIndicatorHideDuration()
109 INDICATOR_HIDE_DURATION,
111 * @brief name "scrollPositionIntervals", type Property::Array
112 * @see SetScrollPositionIntervals()
115 SCROLL_POSITION_INTERVALS,
117 * @brief name "indicatorMinimumHeight", type float
118 * The minimum height for a variable size indicator.
121 INDICATOR_MINIMUM_HEIGHT,
123 * @brief name "indicatorStartPadding", type float
124 * The padding at the start of the indicator. For example, the top if scrollDirection is Vertical.
127 INDICATOR_START_PADDING,
129 * @brief name "indicatorEndPadding", type float
130 * The padding at the end of the indicator. For example, the bottom if scrollDirection is Vertical.
133 INDICATOR_END_PADDING
139 typedef Signal< void () > PanFinishedSignalType;
140 typedef Signal< void ( float ) > ScrollPositionIntervalReachedSignalType;
150 Vertical = 0, ///< Scroll in the vertical direction @SINCE_1_0.0
151 Horizontal ///< Scroll in the horizontal direction @SINCE_1_0.0
155 * @brief Indicator height policy.
158 enum IndicatorHeightPolicy
160 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content @SINCE_1_0.0
161 Fixed ///< Fixed height regardless of the length of scroll content @SINCE_1_0.0
165 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
166 * Calling member functions with an uninitialized Dali::Object is not allowed.
172 * @brief Copy constructor.
174 * @param[in] scrollBar Handle to an object
176 ScrollBar( const ScrollBar& scrollBar );
179 * @brief Assignment operator.
181 * @param[in] scrollBar Handle to an object
182 * @return A reference to this
184 ScrollBar& operator=( const ScrollBar& scrollBar );
189 * This is non-virtual since derived Handle types must not contain data or virtual methods.
195 * @brief Create an initialized ScrollBar
197 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
198 * @return A pointer to the created ScrollBar.
200 static ScrollBar New(Direction direction = Vertical);
203 * @brief Downcast a handle to ScrollBar handle.
205 * If handle points to a ScrollBar the
206 * downcast produces valid handle. If not the returned handle is left uninitialized.
208 * @param[in] handle Handle to an object
209 * @return handle to a ScrollBar or an uninitialized handle
211 static ScrollBar DownCast( BaseHandle handle );
214 * @brief Set the source of the scroll position properties.
216 * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
219 * @param[in] handle The handle of the object owing the scroll properties.
220 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float).
221 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float).
222 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float).
223 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float).
225 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
228 * @brief Sets the indicator of scroll bar.
231 * @param[in] indicator The indicator that moves to indicate the current scroll position.
232 * @pre The scroll bar actor has been initialised.
235 void SetScrollIndicator( Actor indicator );
238 * @brief Gets the indicator of scroll bar.
241 * @return The indicator indicates the current scroll position of the scrollable content.
242 * @pre The scroll bar actor has been initialised.
245 Actor GetScrollIndicator();
248 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
249 * object goes above or below any of these values.
252 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
253 * @pre The scroll bar actor has been initialised.
256 void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
259 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
260 * object goes above or below any of these values.
263 * @return The list of values to receive notifications for when the current scroll position crosses them
264 * @pre The scroll bar actor has been initialised.
267 Dali::Vector<float> GetScrollPositionIntervals() const;
270 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
273 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
274 * @pre The scroll bar actor has been initialised.
277 void SetScrollDirection( Direction direction );
280 * @brief Gets the direction of scroll bar.
283 * @return The direction of scroll bar.
285 Direction GetScrollDirection() const;
288 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
291 * @param[in] policy The height policy of scroll indicator
292 * @pre The scroll bar actor has been initialised.
295 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
298 * @brief Gets the height policy of scroll indicator.
301 * @return The height policy of scroll indicator
303 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
306 * @brief Sets the fixed height of scroll indicator.
308 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
309 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
310 * regardless of the length of scroll content.
313 * @param[in] height The fixed height of the scroll indicator
314 * @pre The scroll bar actor has been initialised.
317 void SetIndicatorFixedHeight( float height );
320 * @brief Gets the fix height of scroll indicator.
322 * @return The fixed height of the scroll indicator
324 float GetIndicatorFixedHeight() const;
327 * @brief Sets the duration in second for the scroll indicator to become fully visible
330 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
331 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
334 void SetIndicatorShowDuration( float durationSeconds );
337 * @brief Gets the duration in second for the scroll indicator to become fully visible
339 * @return The duration for the scroll indicator to become fully visible
341 float GetIndicatorShowDuration() const;
344 * @brief Sets the duration in second for the scroll indicator to become fully invisible
347 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
348 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
351 void SetIndicatorHideDuration( float durationSeconds );
354 * @brief Gets the duration in second for the scroll indicator to become fully invisible
356 * @return The duration for the scroll indicator to become fully invisible
358 float GetIndicatorHideDuration() const;
361 * @brief Shows the scroll indicator
364 void ShowIndicator();
367 * @brief Hides the scroll indicator
370 void HideIndicator();
375 * @brief Signal emitted when panning is finished on the scroll indicator.
377 * Signal only emitted when the source of the scroll position properties are set.
379 * A callback of the following type may be connected:
381 * void YourCallbackName();
384 * @return The signal to connect to.
385 * @pre The Object has been initialized.
387 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
390 * @brief Signal emitted when the current scroll position of the scrollable content
391 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
393 * Signal only emitted when the source of the scroll position properties are set.
395 * A callback of the following type may be connected:
397 * void YourCallbackName(float currentScrollPosition);
400 * @return The signal to connect to.
401 * @pre The Object has been initialized.
403 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
405 public: // Not intended for application developers
409 * @brief Creates a handle using the Toolkit::Internal implementation.
411 * @param[in] implementation The Control implementation.
413 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
416 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
418 * @param[in] internal A pointer to the internal CustomActor.
420 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
427 } // namespace Toolkit
431 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__