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 ScrollUpdatedSignal() |
50 * | scrollUpdated | @ref ScrollCompletedSignal() |
52 class DALI_IMPORT_API Scrollable : public Control
57 * @brief The start and end property ranges for this control.
61 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @since DALi 1.1.18
62 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices, @since DALi 1.1.18
64 ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
65 ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices
69 * @brief An enumeration of properties belonging to the Scrollable class.
75 // Event side properties
76 OVERSHOOT_EFFECT_COLOR = PROPERTY_START_INDEX, ///< Property, name "overshootEffectColor", @see SetOvershootEffectColor(), type Vector4
77 OVERSHOOT_ANIMATION_SPEED, ///< Property, name "overshootAnimationSpeed", @see SetOvershootAnimationSpeed(), type float
78 OVERSHOOT_ENABLED, ///< Property, name "overshootEnabled", @see SetOvershootEnabled(), type bool, @since DALi 1.1.18
80 // Animatable properties
81 SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollRelativePosition", type Vector2
82 SCROLL_POSITION_MIN, ///< Property, name "scrollPositionMin", type Vector2
83 SCROLL_POSITION_MIN_X, ///< Property, name "scrollPositionMinX", type float
84 SCROLL_POSITION_MIN_Y, ///< Property, name "scrollPositionMinY", type float
85 SCROLL_POSITION_MAX, ///< Property, name "scrollPositionMax", type Vector2
86 SCROLL_POSITION_MAX_X, ///< Property, name "scrollPositionMaxX", type float
87 SCROLL_POSITION_MAX_Y, ///< Property, name "scrollPositionMaxY", type float
88 CAN_SCROLL_VERTICAL, ///< Property, name "canScrollVertical", type bool
89 CAN_SCROLL_HORIZONTAL ///< Property, name "canScrollHorizontal", type bool
95 typedef Signal< void ( const Vector2& ) > ScrollStartedSignalType; ///< ScrollStarted signal type
96 typedef Signal< void ( const Vector2& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type
97 typedef Signal< void ( const Vector2& ) > ScrollUpdatedSignalType; ///< Scroll updated signal type
102 * @brief Creates an uninitialized Scrollable handle.
107 * @brief Copy constructor.
109 * Creates another handle that points to the same real object
111 * @param handle to copy from
113 Scrollable( const Scrollable& handle );
116 * @brief Assignment operator.
118 * Changes this handle to point to another real object
119 * @param[in] handle to copy from
120 * @return A reference to this
122 Scrollable& operator=( const Scrollable& handle );
127 * This is non-virtual since derived Handle types must not contain data or virtual methods.
132 * @brief Downcast an Object handle to Scrollable.
134 * If handle points to a Scrollable the downcast produces valid
135 * handle. If not the returned handle is left uninitialized.
137 * @param[in] handle Handle to an object
138 * @return handle to a Scrollable or an uninitialized handle
140 static Scrollable DownCast( BaseHandle handle );
143 * @brief Checks if scroll overshoot has been enabled or not.
145 * @return Whether the scroll obvershoot is enabled
147 bool IsOvershootEnabled() const;
150 * @brief Sets whether to enables or disable scroll overshoot.
152 * @param[in] enable Whether to enable the scroll obvershoot or not
154 void SetOvershootEnabled(bool enable);
157 * @brief Set the color of the overshoot effect.
159 * @param[in] color The color of the overshoot effect.
161 void SetOvershootEffectColor( const Vector4& color );
164 * @brief Get the color of the overshoot effect.
165 * @return The color of the overshoot effect.
167 Vector4 GetOvershootEffectColor() const;
170 * @brief Set the speed of overshoot animation in pixels per second.
171 * When the speed is not greater than 0, the overshoot is set instantly with no animation.
172 * @param[in] pixelsPerSecond The speed of the overshoot animation.
174 void SetOvershootAnimationSpeed( float pixelsPerSecond );
177 * @brief Get the speed of overshoot animation in pixels per second.
178 * @return The speed of the overshoot animation.
180 float GetOvershootAnimationSpeed() const;
185 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
187 * A callback of the following type may be connected:
189 * void YourCallbackName(const Vector2& currentScrollPosition);
191 * @pre The Object has been initialized.
192 * @return The signal to connect to.
194 ScrollStartedSignalType& ScrollStartedSignal();
197 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
199 * A callback of the following type may be connected:
201 * void YourCallbackName(const Vector2& currentScrollPosition);
203 * @pre The Object has been initialized.
204 * @return The signal to connect to.
206 ScrollUpdatedSignalType& ScrollUpdatedSignal();
209 * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
211 * A callback of the following type may be connected:
213 * void YourCallbackName(const Vector2& currentScrollPosition);
215 * @pre The Object has been initialized.
216 * @return The signal to connect to.
218 ScrollCompletedSignalType& ScrollCompletedSignal();
220 public: // Not intended for application developers
223 * @brief Creates a handle using the Toolkit::Internal implementation.
225 * @param[in] implementation The Control implementation.
227 DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
230 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
232 * @param[in] internal A pointer to the internal CustomActor.
234 explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
240 } // namespace Toolkit
244 #endif // __DALI_TOOLKIT_SCROLLABLE_H__