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 * @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.
76 SCROLL_DIRECTION = PROPERTY_START_INDEX, ///< name "scrollDirection", @see SetScrollDirection(), type std::string @SINCE_1_0.0
77 INDICATOR_HEIGHT_POLICY, ///< name "indicatorHeightPolicy", @see SetIndicatorHeightPolicy(), type std::string @SINCE_1_0.0
78 INDICATOR_FIXED_HEIGHT, ///< name "indicatorFixedHeight", @see SetIndicatorFixedHeight(), type float @SINCE_1_0.0
79 INDICATOR_SHOW_DURATION, ///< name "indicatorShowDuration", @see SetIndicatorShowDuration(), type float @SINCE_1_0.0
80 INDICATOR_HIDE_DURATION, ///< name "indicatorHideDuration", @see SetIndicatorHideDuration(), type float @SINCE_1_0.0
81 SCROLL_POSITION_INTERVALS ///< name "scrollPositionIntervals", @see SetScrollPositionIntervals() type Property::Array @SINCE_1_0.0
87 typedef Signal< void () > PanFinishedSignalType;
88 typedef Signal< void ( float ) > ScrollPositionIntervalReachedSignalType;
98 Vertical = 0, ///< Scroll in the vertical direction @SINCE_1_0.0
99 Horizontal ///< Scroll in the horizontal direction @SINCE_1_0.0
103 * @brief Indicator height policy.
106 enum IndicatorHeightPolicy
108 Variable = 0, ///< Variable height changed dynamically according to the length of scroll content @SINCE_1_0.0
109 Fixed ///< Fixed height regardless of the length of scroll content @SINCE_1_0.0
113 * @brief Create an uninitialized ScrollBar; this can be initialized with ScrollBar::New()
114 * Calling member functions with an uninitialized Dali::Object is not allowed.
120 * @brief Copy constructor.
123 ScrollBar( const ScrollBar& scrollBar );
126 * @brief Assignment operator.
129 ScrollBar& operator=( const ScrollBar& scrollBar );
134 * This is non-virtual since derived Handle types must not contain data or virtual methods.
140 * @brief Create an initialized ScrollBar
142 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
143 * @return A pointer to the created ScrollBar.
145 static ScrollBar New(Direction direction = Vertical);
148 * @brief Downcast a handle to ScrollBar handle.
150 * If handle points to a ScrollBar the
151 * downcast produces valid handle. If not the returned handle is left uninitialized.
153 * @param[in] handle Handle to an object
154 * @return handle to a ScrollBar or an uninitialized handle
156 static ScrollBar DownCast( BaseHandle handle );
159 * @brief Set the source of the scroll position properties.
161 * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
164 * @param[in] handle The handle of the object owing the scroll properties.
165 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float).
166 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float).
167 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float).
168 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float).
170 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
173 * @brief Sets the indicator of scroll bar.
176 * @param[in] indicator The indicator that moves to indicate the current scroll position.
177 * @pre The scroll bar actor has been initialised.
180 void SetScrollIndicator( Actor indicator );
183 * @brief Gets the indicator of scroll bar.
186 * @return The indicator indicates the current scroll position of the scrollable content.
187 * @pre The scroll bar actor has been initialised.
190 Actor GetScrollIndicator();
193 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
194 * object goes above or below any of these values.
197 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
198 * @pre The scroll bar actor has been initialised.
201 void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
204 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
205 * object goes above or below any of these values.
208 * @return The list of values to receive notifications for when the current scroll position crosses them
209 * @pre The scroll bar actor has been initialised.
212 Dali::Vector<float> GetScrollPositionIntervals() const;
215 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
218 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
219 * @pre The scroll bar actor has been initialised.
222 void SetScrollDirection( Direction direction );
225 * @brief Gets the direction of scroll bar.
228 * @return The direction of scroll bar.
230 Direction GetScrollDirection() const;
233 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
236 * @param[in] policy The height policy of scroll indicator
237 * @pre The scroll bar actor has been initialised.
240 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
243 * @brief Gets the height policy of scroll indicator.
246 * @return The height policy of scroll indicator
248 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
251 * @brief Sets the fixed height of scroll indicator.
253 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
254 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
255 * regardless of the length of scroll content.
258 * @param[in] height The fixed height of the scroll indicator
259 * @pre The scroll bar actor has been initialised.
262 void SetIndicatorFixedHeight( float height );
265 * @brief Gets the fix height of scroll indicator.
267 * @return The fixed height of the scroll indicator
269 float GetIndicatorFixedHeight() const;
272 * @brief Sets the duration in second for the scroll indicator to become fully visible
275 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
276 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
279 void SetIndicatorShowDuration( float durationSeconds );
282 * @brief Gets the duration in second for the scroll indicator to become fully visible
284 * @return The duration for the scroll indicator to become fully visible
286 float GetIndicatorShowDuration() const;
289 * @brief Sets the duration in second for the scroll indicator to become fully invisible
292 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
293 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
296 void SetIndicatorHideDuration( float durationSeconds );
299 * @brief Gets the duration in second for the scroll indicator to become fully invisible
301 * @return The duration for the scroll indicator to become fully invisible
303 float GetIndicatorHideDuration() const;
306 * @brief Shows the scroll indicator
309 void ShowIndicator();
312 * @brief Hides the scroll indicator
315 void HideIndicator();
320 * @brief Signal emitted when panning is finished on the scroll indicator.
322 * Signal only emitted when the source of the scroll position properties are set.
324 * A callback of the following type may be connected:
326 * void YourCallbackName();
329 * @return The signal to connect to.
330 * @pre The Object has been initialized.
332 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
335 * @brief Signal emitted when the current scroll position of the scrollable content
336 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
338 * Signal only emitted when the source of the scroll position properties are set.
340 * A callback of the following type may be connected:
342 * void YourCallbackName(float currentScrollPosition);
345 * @return The signal to connect to.
346 * @pre The Object has been initialized.
348 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
350 public: // Not intended for application developers
353 * @brief Creates a handle using the Toolkit::Internal implementation.
355 * @param[in] implementation The Control implementation.
357 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
360 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
362 * @param[in] internal A pointer to the internal CustomActor.
364 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
370 } // namespace Toolkit
374 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__