1 #ifndef __DALI_TOOLKIT_SCROLLABLE_H__
2 #define __DALI_TOOLKIT_SCROLLABLE_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
35 * @addtogroup dali_toolkit_controls_scrollable
40 * @brief Base class for derived Scrollables that contains actors that can be scrolled manually
41 * (via touch) or automatically.
43 * Scrollables such as ScrollView and ItemView can be derived from this class.
46 * | %Signal Name | Method |
47 * |------------------|------------------------------|
48 * | scrollStarted | @ref ScrollStartedSignal() |
49 * | scrollCompleted | @ref ScrollCompletedSignal() |
50 * | scrollUpdated | @ref ScrollUpdatedSignal() |
53 class DALI_IMPORT_API Scrollable : public Control
58 * @brief The start and end property ranges for this control.
63 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
64 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices @SINCE_1_0.0
66 ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
67 ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices @SINCE_1_0.0
71 * @brief An enumeration of properties belonging to the Scrollable class.
77 * @brief An enumeration of properties belonging to the Scrollable class.
82 // Event side properties
83 OVERSHOOT_EFFECT_COLOR = PROPERTY_START_INDEX, ///< Property, name "overshootEffectColor", @see SetOvershootEffectColor(), type Vector4 @SINCE_1_0.0
84 OVERSHOOT_ANIMATION_SPEED, ///< Property, name "overshootAnimationSpeed", @see SetOvershootAnimationSpeed(), type float @SINCE_1_0.0
85 OVERSHOOT_ENABLED, ///< Property, name "overshootEnabled", @see SetOvershootEnabled(), type bool, @SINCE_1_1.18
86 OVERSHOOT_SIZE, ///< Property, name "overshootSize", type Vector2, @SINCE_1_1.31
87 SCROLL_TO_ALPHA_FUNCTION, ///< Property, name "scrollToAlphaFunction", type int, @SINCE_1_1.33
89 // Animatable properties
90 SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollRelativePosition", type Vector2 @SINCE_1_0.0
91 SCROLL_POSITION_MIN, ///< Property, name "scrollPositionMin", type Vector2 @SINCE_1_0.0
92 SCROLL_POSITION_MIN_X, ///< Property, name "scrollPositionMinX", type float @SINCE_1_0.0
93 SCROLL_POSITION_MIN_Y, ///< Property, name "scrollPositionMinY", type float @SINCE_1_0.0
94 SCROLL_POSITION_MAX, ///< Property, name "scrollPositionMax", type Vector2 @SINCE_1_0.0
95 SCROLL_POSITION_MAX_X, ///< Property, name "scrollPositionMaxX", type float @SINCE_1_0.0
96 SCROLL_POSITION_MAX_Y, ///< Property, name "scrollPositionMaxY", type float @SINCE_1_0.0
97 CAN_SCROLL_VERTICAL, ///< Property, name "canScrollVertical", type bool @SINCE_1_0.0
98 CAN_SCROLL_HORIZONTAL ///< Property, name "canScrollHorizontal", type bool @SINCE_1_0.0
104 typedef Signal< void ( const Vector2& ) > ScrollStartedSignalType; ///< ScrollStarted signal type @SINCE_1_0.0
105 typedef Signal< void ( const Vector2& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type @SINCE_1_0.0
106 typedef Signal< void ( const Vector2& ) > ScrollUpdatedSignalType; ///< Scroll updated signal type @SINCE_1_0.0
111 * @brief Creates an uninitialized Scrollable handle.
117 * @brief Copy constructor.
119 * Creates another handle that points to the same real object.
122 * @param handle to copy from
124 Scrollable( const Scrollable& handle );
127 * @brief Assignment operator.
129 * Changes this handle to point to another real object.
131 * @param[in] handle to copy from
132 * @return A reference to this
134 Scrollable& operator=( const Scrollable& handle );
139 * This is non-virtual since derived Handle types must not contain data or virtual methods.
145 * @brief Downcast a handle to Scrollable handle.
147 * If handle points to a Scrollable the downcast produces valid
148 * handle. If not the returned handle is left uninitialized.
151 * @param[in] handle Handle to an object
152 * @return A handle to a Scrollable or an uninitialized handle
154 static Scrollable DownCast( BaseHandle handle );
157 * @brief Checks if scroll overshoot has been enabled or not.
160 * @return Whether the scroll overshoot is enabled
162 bool IsOvershootEnabled() const;
165 * @brief Sets whether to enables or disable scroll overshoot.
168 * @param[in] enable Whether to enable the scroll overshoot or not
170 void SetOvershootEnabled(bool enable);
173 * @brief Set the color of the overshoot effect.
176 * @param[in] color The color of the overshoot effect.
178 void SetOvershootEffectColor( const Vector4& color );
181 * @brief Get the color of the overshoot effect.
183 * @return The color of the overshoot effect.
185 Vector4 GetOvershootEffectColor() const;
188 * @brief Set the speed of overshoot animation in pixels per second.
190 * When the speed is not greater than 0, the overshoot is set instantly with no animation.
192 * @param[in] pixelsPerSecond The speed of the overshoot animation.
194 void SetOvershootAnimationSpeed( float pixelsPerSecond );
197 * @brief Get the speed of overshoot animation in pixels per second.
199 * @return The speed of the overshoot animation.
201 float GetOvershootAnimationSpeed() const;
206 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
208 * A callback of the following type may be connected:
210 * void YourCallbackName(const Vector2& currentScrollPosition);
213 * @return The signal to connect to.
214 * @pre The Object has been initialized.
216 ScrollStartedSignalType& ScrollStartedSignal();
219 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
221 * A callback of the following type may be connected:
223 * void YourCallbackName(const Vector2& currentScrollPosition);
226 * @return The signal to connect to.
227 * @pre The Object has been initialized.
229 ScrollUpdatedSignalType& ScrollUpdatedSignal();
232 * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
234 * A callback of the following type may be connected:
236 * void YourCallbackName(const Vector2& currentScrollPosition);
239 * @return The signal to connect to.
240 * @pre The Object has been initialized.
242 ScrollCompletedSignalType& ScrollCompletedSignal();
244 public: // Not intended for application developers
248 * @brief Creates a handle using the Toolkit::Internal implementation.
251 * @param[in] implementation The Control implementation.
253 DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
256 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
259 * @param[in] internal A pointer to the internal CustomActor.
261 explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
268 } // namespace Toolkit
272 #endif // __DALI_TOOLKIT_SCROLLABLE_H__