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 * | scroll-started | @ref ScrollStartedSignal() |
49 * | scroll-completed | @ref ScrollUpdatedSignal() |
50 * | scroll-updated | @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,
62 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices
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 "overshoot-effect-color", @see SetOvershootEffectColor(), type Vector4
77 OVERSHOOT_ANIMATION_SPEED, ///< Property, name "overshoot-animation-speed", @see SetOvershootAnimationSpeed(), type float
79 // Animatable properties
80 SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-relative-position", type Vector2
81 SCROLL_POSITION_MIN, ///< Property, name "scroll-position-min", type Vector2
82 SCROLL_POSITION_MIN_X, ///< Property, name "scroll-position-min-x", type float
83 SCROLL_POSITION_MIN_Y, ///< Property, name "scroll-position-min-y", type float
84 SCROLL_POSITION_MAX, ///< Property, name "scroll-position-max", type Vector2
85 SCROLL_POSITION_MAX_X, ///< Property, name "scroll-position-max-x", type float
86 SCROLL_POSITION_MAX_Y, ///< Property, name "scroll-position-max-y", type float
87 CAN_SCROLL_VERTICAL, ///< Property, name "can-scroll-vertical", type bool
88 CAN_SCROLL_HORIZONTAL ///< Property, name "can-scroll-horizontal", type bool
94 typedef Signal< void ( const Vector2& ) > ScrollStartedSignalType; ///< ScrollStarted signal type
95 typedef Signal< void ( const Vector2& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type
96 typedef Signal< void ( const Vector2& ) > ScrollUpdatedSignalType; ///< Scroll updated signal type
101 * @brief Creates an uninitialized Scrollable handle.
106 * @brief Copy constructor.
108 * Creates another handle that points to the same real object
110 * @param handle to copy from
112 Scrollable( const Scrollable& handle );
115 * @brief Assignment operator.
117 * Changes this handle to point to another real object
118 * @param[in] handle to copy from
119 * @return A reference to this
121 Scrollable& operator=( const Scrollable& handle );
126 * This is non-virtual since derived Handle types must not contain data or virtual methods.
131 * @brief Downcast an Object handle to Scrollable.
133 * If handle points to a Scrollable the downcast produces valid
134 * handle. If not the returned handle is left uninitialized.
136 * @param[in] handle Handle to an object
137 * @return handle to a Scrollable or an uninitialized handle
139 static Scrollable DownCast( BaseHandle handle );
142 * @brief Checks if scroll overshoot has been enabled or not.
144 * @return Whether the scroll obvershoot is enabled
146 bool IsOvershootEnabled() const;
149 * @brief Sets whether to enables or disable scroll overshoot.
151 * @param[in] enable Whether to enable the scroll obvershoot or not
153 void SetOvershootEnabled(bool enable);
156 * @brief Set the color of the overshoot effect.
158 * @param[in] color The color of the overshoot effect.
160 void SetOvershootEffectColor( const Vector4& color );
163 * @brief Get the color of the overshoot effect.
164 * @return The color of the overshoot effect.
166 Vector4 GetOvershootEffectColor() const;
169 * @brief Set the speed of overshoot animation in pixels per second.
170 * When the speed is not greater than 0, the overshoot is set instantly with no animation.
171 * @param[in] pixelsPerSecond The speed of the overshoot animation.
173 void SetOvershootAnimationSpeed( float pixelsPerSecond );
176 * @brief Get the speed of overshoot animation in pixels per second.
177 * @return The speed of the overshoot animation.
179 float GetOvershootAnimationSpeed() const;
184 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
186 * A callback of the following type may be connected:
188 * void YourCallbackName(const Vector2& currentScrollPosition);
190 * @pre The Object has been initialized.
191 * @return The signal to connect to.
193 ScrollStartedSignalType& ScrollStartedSignal();
196 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
198 * A callback of the following type may be connected:
200 * void YourCallbackName(const Vector2& currentScrollPosition);
202 * @pre The Object has been initialized.
203 * @return The signal to connect to.
205 ScrollUpdatedSignalType& ScrollUpdatedSignal();
208 * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
210 * A callback of the following type may be connected:
212 * void YourCallbackName(const Vector2& currentScrollPosition);
214 * @pre The Object has been initialized.
215 * @return The signal to connect to.
217 ScrollCompletedSignalType& ScrollCompletedSignal();
219 public: // Not intended for application developers
222 * @brief Creates a handle using the Toolkit::Internal implementation.
224 * @param[in] implementation The Control implementation.
226 DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
229 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
231 * @param[in] internal A pointer to the internal CustomActor.
233 explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
239 } // namespace Toolkit
243 #endif // __DALI_TOOLKIT_SCROLLABLE_H__