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 an Object handle to ScrollBar. If handle points to a ScrollBar the
149 * downcast produces valid handle. If not the returned handle is left uninitialized.
151 * @param[in] handle Handle to an object
152 * @return handle to a ScrollBar or an uninitialized handle
154 static ScrollBar DownCast( BaseHandle handle );
157 * @brief Set the source of the scroll position properties.
159 * * @pre The handle to the object owing the scroll properties has been initialised and the property index must be vaild.
162 * @param[in] handle The handle of the object owing the scroll properties.
163 * @param[in] propertyScrollPosition The index of the scroll position property (The scroll position, type float).
164 * @param[in] propertyMinScrollPosition The index of the minimum scroll position property (The minimum scroll position, type float).
165 * @param[in] propertyMaxScrollPosition The index of the maximum scroll position property (The maximum scroll position, type float).
166 * @param[in] propertyScrollContentSize The index of the scroll content size property (The size of the scrollable content in actor coordinates, type float).
168 void SetScrollPropertySource( Handle handle, Dali::Property::Index propertyScrollPosition, Dali::Property::Index propertyMinScrollPosition, Dali::Property::Index propertyMaxScrollPosition, Dali::Property::Index propertyScrollContentSize );
171 * @brief Sets the indicator of scroll bar.
174 * @param[in] indicator The indicator that moves to indicate the current scroll position.
175 * @pre The scroll bar actor has been initialised.
178 void SetScrollIndicator( Actor indicator );
181 * @brief Gets the indicator of scroll bar.
184 * @return The indicator indicates the current scroll position of the scrollable content.
185 * @pre The scroll bar actor has been initialised.
188 Actor GetScrollIndicator();
191 * @brief Sets the list of values to get notification when the current scroll position of the scrollable
192 * object goes above or below any of these values.
195 * @param[in] positions List of values to receive notifications for when the current scroll position crosses them
196 * @pre The scroll bar actor has been initialised.
199 void SetScrollPositionIntervals( const Dali::Vector<float>& positions );
202 * @brief Gets the list of values to receive notifications when the current scroll position of the scrollable
203 * object goes above or below any of these values.
206 * @return The list of values to receive notifications for when the current scroll position crosses them
207 * @pre The scroll bar actor has been initialised.
210 Dali::Vector<float> GetScrollPositionIntervals() const;
213 * @brief Sets the direction of scroll bar to scroll either vertically or horizontally.
216 * @param[in] direction The direction of scroll bar (either vertically or horizontally).
217 * @pre The scroll bar actor has been initialised.
220 void SetScrollDirection( Direction direction );
223 * @brief Gets the direction of scroll bar.
226 * @return The direction of scroll bar.
228 Direction GetScrollDirection() const;
231 * @brief Sets the height policy of scroll indicator to have either variable or fixed height.
234 * @param[in] policy The height policy of scroll indicator
235 * @pre The scroll bar actor has been initialised.
238 void SetIndicatorHeightPolicy( IndicatorHeightPolicy policy );
241 * @brief Gets the height policy of scroll indicator.
244 * @return The height policy of scroll indicator
246 IndicatorHeightPolicy GetIndicatorHeightPolicy() const;
249 * @brief Sets the fixed height of scroll indicator.
250 * Normally the height of scroll indicator is changed dynamically according to the length of scroll content.
251 * However, when the height policy of scroll indicator is set to be fixed, the height will keep fixed
252 * regardless of the length of scroll content.
255 * @param[in] height The fixed height of the scroll indicator
256 * @pre The scroll bar actor has been initialised.
259 void SetIndicatorFixedHeight( float height );
262 * @brief Gets the fix height of scroll indicator.
264 * @return The fixed height of the scroll indicator
266 float GetIndicatorFixedHeight() const;
269 * @brief Sets the duration in second for the scroll indicator to become fully visible
272 * @param[in] durationSeconds The duration for the scroll indicator to become fully visible
273 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be shown instantly.
276 void SetIndicatorShowDuration( float durationSeconds );
279 * @brief Gets the duration in second for the scroll indicator to become fully visible
281 * @return The duration for the scroll indicator to become fully visible
283 float GetIndicatorShowDuration() const;
286 * @brief Sets the duration in second for the scroll indicator to become fully invisible
289 * @param[in] durationSeconds The duration for the scroll indicator to become fully invisible
290 * @pre The scroll bar actor has been initialised; durationSeconds must be zero or greater; zero means the indicator will be hidden instantly.
293 void SetIndicatorHideDuration( float durationSeconds );
296 * @brief Gets the duration in second for the scroll indicator to become fully invisible
298 * @return The duration for the scroll indicator to become fully invisible
300 float GetIndicatorHideDuration() const;
303 * @brief Shows the scroll indicator
306 void ShowIndicator();
309 * @brief Hides the scroll indicator
312 void HideIndicator();
317 * @brief Signal emitted when panning is finished on the scroll indicator.
318 * Signal only emitted when the source of the scroll position properties are set.
320 * A callback of the following type may be connected:
322 * void YourCallbackName();
325 * @return The signal to connect to.
326 * @pre The Object has been initialized.
328 ScrollBar::PanFinishedSignalType& PanFinishedSignal();
331 * @brief Signal emitted when the current scroll position of the scrollable content
332 * goes above or below the values specified by SCROLL_POSITION_INTERVALS property.
333 * Signal only emitted when the source of the scroll position properties are set.
335 * A callback of the following type may be connected:
337 * void YourCallbackName(float currentScrollPosition);
340 * @return The signal to connect to.
341 * @pre The Object has been initialized.
343 ScrollBar::ScrollPositionIntervalReachedSignalType& ScrollPositionIntervalReachedSignal();
345 public: // Not intended for application developers
348 * @brief Creates a handle using the Toolkit::Internal implementation.
350 * @param[in] implementation The Control implementation.
352 DALI_INTERNAL ScrollBar( Internal::ScrollBar& implementation );
355 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
357 * @param[in] internal A pointer to the internal CustomActor.
359 explicit DALI_INTERNAL ScrollBar( Dali::Internal::CustomActor* internal );
365 } // namespace Toolkit
369 #endif // __DALI_TOOLKIT_SCROLL_BAR_H__