1 #ifndef __DALI_TOOLKIT_SCROLL_BAR_H__
2 #define __DALI_TOOLKIT_SCROLL_BAR_H__
5 * Copyright (c) 2015 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 * 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() |
51 class DALI_IMPORT_API ScrollBar : public Control
58 * @brief The start and end property ranges for this control.
62 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
63 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
67 * @brief An enumeration of properties belonging to the ScrollBar class.
73 SCROLL_DIRECTION = PROPERTY_START_INDEX, ///< name "scrollDirection", @see SetScrollDirection(), type std::string
74 INDICATOR_HEIGHT_POLICY, ///< name "indicatorHeightPolicy", @see SetIndicatorHeightPolicy(), type std::string
75 INDICATOR_FIXED_HEIGHT, ///< name "indicatorFixedHeight", @see SetIndicatorFixedHeight(), type float
76 INDICATOR_SHOW_DURATION, ///< name "indicatorShowDuration", @see SetIndicatorShowDuration(), type float
77 INDICATOR_HIDE_DURATION, ///< name "indicatorHideDuration", @see SetIndicatorHideDuration(), type float
78 SCROLL_POSITION_INTERVALS ///< name "scrollPositionIntervals", @see SetScrollPositionIntervals() type Property::Array
84 typedef Signal< void () > PanFinishedSignalType;
85 typedef Signal< void ( float ) > ScrollPositionIntervalReachedSignalType;
94 Vertical = 0, ///< Scroll in the vertical direction
95 Horizontal ///< Scroll in the horizontal direction
99 * @brief Indicator height policy.
101 enum IndicatorHeightPolicy
103 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content
104 Fixed ///< Fixed height regardless of the length of scroll content
108 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
109 * Calling member functions with an uninitialized Dali::Object is not allowed.
114 * @brief Copy constructor.
116 ScrollBar( const ScrollBar& scrollBar );
119 * @brief Assignment operator.
121 ScrollBar& operator=( const ScrollBar& scrollBar );
126 * This is non-virtual since derived Handle types must not contain data or virtual methods.
131 * @brief Create an initialized ScrollBar
132 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
133 * @return A pointer to the created ScrollBar.
135 static ScrollBar New(Direction direction = Vertical);
138 * @brief Downcast an Object handle to ScrollBar. If handle points to a ScrollBar the
139 * downcast produces valid handle. If not the returned handle is left uninitialized.
140 * @param[in] handle Handle to an object
141 * @return handle to a ScrollBar or an uninitialized handle
143 static ScrollBar DownCast( BaseHandle handle );
146 * @brief Set the source of the scroll position properties.
148 * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
150 * @param[in] handle The handle of the object owing the scroll properties.
151 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float).
152 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float).
153 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float).
154 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float).
156 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
159 * @brief Sets the indicator of scroll bar.
161 * @pre The scroll bar actor has been initialised.
163 * @param[in] indicator The indicator that moves to indicate the current scroll position.
165 void SetScrollIndicator( Actor indicator );
168 * @brief Gets the indicator of scroll bar.
170 * @pre The scroll bar actor has been initialised.
172 * @return The indicator indicates the current scroll position of the scrollable content.
174 Actor GetScrollIndicator();
177 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
178 * object goes above or below any of these values.
180 * @pre The scroll bar actor has been initialised.
182 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
184 void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
187 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
188 * object goes above or below any of these values.
190 * @pre The scroll bar actor has been initialised.
192 * @return The list of values to receive notifications for when the current scroll position crosses them
194 Dali::Vector<float> GetScrollPositionIntervals() const;
197 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
199 * @pre The scroll bar actor has been initialised.
201 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
203 void SetScrollDirection( Direction direction );
206 * @brief Gets the direction of scroll bar.
208 * @return The direction of scroll bar.
210 Direction GetScrollDirection() const;
213 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
215 * @pre The scroll bar actor has been initialised.
217 * @param[in] policy The height policy of scroll indicator
219 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
222 * @brief Gets the height policy of scroll indicator.
224 * @return The height policy of scroll indicator
226 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
229 * @brief Sets the fixed height of scroll indicator.
230 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
231 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
232 * regardless of the length of scroll content.
234 * @pre The scroll bar actor has been initialised.
236 * @param[in] height The fixed height of the scroll indicator
238 void SetIndicatorFixedHeight( float height );
241 * @brief Gets the fix height of scroll indicator.
242 * @return The fixed height of the scroll indicator
244 float GetIndicatorFixedHeight() const;
247 * @brief Sets the duration in second for the scroll indicator to become fully visible
249 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
251 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
253 void SetIndicatorShowDuration( float durationSeconds );
256 * @brief Gets the duration in second for the scroll indicator to become fully visible
257 * @return The duration for the scroll indicator to become fully visible
259 float GetIndicatorShowDuration() const;
262 * @brief Sets the duration in second for the scroll indicator to become fully invisible
264 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
266 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
268 void SetIndicatorHideDuration( float durationSeconds );
271 * @brief Gets the duration in second for the scroll indicator to become fully invisible
272 * @return The duration for the scroll indicator to become fully invisible
274 float GetIndicatorHideDuration() const;
277 * @brief Shows the scroll indicator
279 void ShowIndicator();
282 * @brief Hides the scroll indicator
284 void HideIndicator();
289 * @brief Signal emitted when panning is finished on the scroll indicator.
290 * Signal only emitted when the source of the scroll position properties are set.
292 * A callback of the following type may be connected:
294 * void YourCallbackName();
296 * @pre The Object has been initialized.
297 * @return The signal to connect to.
299 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
302 * @brief Signal emitted when the current scroll position of the scrollable content
303 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
304 * Signal only emitted when the source of the scroll position properties are set.
306 * A callback of the following type may be connected:
308 * void YourCallbackName(float currentScrollPosition);
310 * @pre The Object has been initialized.
311 * @return The signal to connect to.
313 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
315 public: // Not intended for application developers
318 * Creates a handle using the Toolkit::Internal implementation.
319 * @param[in] implementation The Control implementation.
321 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
324 * Allows the creation of this Control from an Internal::CustomActor pointer.
325 * @param[in] internal A pointer to the internal CustomActor.
327 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
333 } // namespace Toolkit
337 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__