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 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 name "scrollDirection", type std::string.
83 * @see SetScrollDirection()
85 SCROLL_DIRECTION = PROPERTY_START_INDEX,
87 * @brief name "indicatorHeightPolicy", type std::string.
89 * @see SetIndicatorHeightPolicy()
91 INDICATOR_HEIGHT_POLICY,
93 * @brief name "indicatorFixedHeight", type float.
95 * @see SetIndicatorFixedHeight()
97 INDICATOR_FIXED_HEIGHT,
99 * @brief name "indicatorShowDuration", type float.
101 * @see SetIndicatorShowDuration()
103 INDICATOR_SHOW_DURATION,
105 * @brief name "indicatorHideDuration", type float.
107 * @see SetIndicatorHideDuration()
109 INDICATOR_HIDE_DURATION,
111 * @brief name "scrollPositionIntervals", type Property::Array.
113 * @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 Creates 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 Creates 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 Downcasts a handle to ScrollBar handle.
205 * If handle points to a ScrollBar, the downcast produces valid handle.
206 * 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 Sets the source of the scroll position properties.
217 * @param[in] handle The handle of the object owing the scroll properties
218 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float)
219 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float)
220 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float)
221 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float)
222 * @pre The handle to the object owing the scroll properties has been initialised and the property index must be valid.
224 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
227 * @brief Sets the indicator of scroll bar.
230 * @param[in] indicator The indicator that moves to indicate the current scroll position
231 * @pre The scroll bar actor has been initialized.
233 void SetScrollIndicator( Actor indicator );
236 * @brief Gets the indicator of scroll bar.
239 * @return The indicator indicates the current scroll position of the scrollable content
240 * @pre The scroll bar actor has been initialized.
242 Actor GetScrollIndicator();
245 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
246 * object goes above or below any of these values.
249 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
250 * @pre The scroll bar actor has been initialized.
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 initialized.
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 initialized.
272 void SetScrollDirection( Direction direction );
275 * @brief Gets the direction of scroll bar.
278 * @return The direction of scroll bar
280 Direction GetScrollDirection() const;
283 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
286 * @param[in] policy The height policy of scroll indicator
287 * @pre The scroll bar actor has been initialized.
289 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
292 * @brief Gets the height policy of scroll indicator.
295 * @return The height policy of scroll indicator
297 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
300 * @brief Sets the fixed height of scroll indicator.
302 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
303 * However, when the height policy of scroll indicator is set to be fixed, the height will be kept fixed
304 * regardless of the length of scroll content.
307 * @param[in] height The fixed height of the scroll indicator
308 * @pre The scroll bar actor has been initialized.
311 void SetIndicatorFixedHeight( float height );
314 * @brief Gets the fix height of scroll indicator.
316 * @return The fixed height of the scroll indicator
318 float GetIndicatorFixedHeight() const;
321 * @brief Sets the duration in seconds for the scroll indicator to become fully visible.
324 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
325 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
328 void SetIndicatorShowDuration( float durationSeconds );
331 * @brief Gets the duration in seconds for the scroll indicator to become fully visible.
333 * @return The duration for the scroll indicator to become fully visible
335 float GetIndicatorShowDuration() const;
338 * @brief Sets the duration in seconds for the scroll indicator to become fully invisible.
341 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
342 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
345 void SetIndicatorHideDuration( float durationSeconds );
348 * @brief Gets the duration in seconds for the scroll indicator to become fully invisible.
350 * @return The duration for the scroll indicator to become fully invisible
352 float GetIndicatorHideDuration() const;
355 * @brief Shows the scroll indicator.
358 void ShowIndicator();
361 * @brief Hides the scroll indicator.
364 void HideIndicator();
369 * @brief Signal emitted when panning is finished on the scroll indicator.
371 * Signal only emitted when the source of the scroll position properties are set.
373 * A callback of the following type may be connected:
375 * void YourCallbackName();
378 * @return The signal to connect to
379 * @pre The Object has been initialized.
381 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
384 * @brief Signal emitted when the current scroll position of the scrollable content
385 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
387 * Signal only emitted when the source of the scroll position properties are set.
389 * A callback of the following type may be connected:
391 * void YourCallbackName(float currentScrollPosition);
394 * @return The signal to connect to
395 * @pre The Object has been initialized.
397 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
399 public: // Not intended for application developers
403 * @brief Creates a handle using the Toolkit::Internal implementation.
405 * @param[in] implementation The Control implementation
407 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
410 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
412 * @param[in] internal A pointer to the internal CustomActor
414 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
421 } // namespace Toolkit
425 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__