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
36 * @brief Base class for derived Scrollables that contains actors that can be scrolled manually
37 * (via touch) or automatically.
39 * Scrollables such as ScrollView and ItemView can be derived from this class.
42 * | %Signal Name | Method |
43 * |-------------------|------------------------------|
44 * | scroll-started | @ref ScrollStartedSignal() |
45 * | scroll-completed | @ref ScrollUpdatedSignal() |
46 * | scroll-updated | @ref ScrollCompletedSignal() |
48 class DALI_IMPORT_API Scrollable : public Control
53 * @brief The start and end property ranges for this control.
57 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
58 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices
60 ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
61 ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices
65 * @brief An enumeration of properties belonging to the Scrollable class.
71 // Event side properties
72 OVERSHOOT_EFFECT_COLOR = PROPERTY_START_INDEX, ///< Property, name "overshoot-effect-color", @see SetOvershootEffectColor(), type Vector4
73 OVERSHOOT_ANIMATION_SPEED, ///< Property, name "overshoot-animation-speed", @see SetOvershootAnimationSpeed(), type float
75 // Animatable properties
76 SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-relative-position", type Vector2
77 SCROLL_POSITION_MIN, ///< Property, name "scroll-position-min", type Vector2
78 SCROLL_POSITION_MIN_X, ///< Property, name "scroll-position-min-x", type float
79 SCROLL_POSITION_MIN_Y, ///< Property, name "scroll-position-min-y", type float
80 SCROLL_POSITION_MAX, ///< Property, name "scroll-position-max", type Vector2
81 SCROLL_POSITION_MAX_X, ///< Property, name "scroll-position-max-x", type float
82 SCROLL_POSITION_MAX_Y, ///< Property, name "scroll-position-max-y", type float
83 CAN_SCROLL_VERTICAL, ///< Property, name "can-scroll-vertical", type bool
84 CAN_SCROLL_HORIZONTAL ///< Property, name "can-scroll-horizontal", type bool
90 typedef Signal< void ( const Vector2& ) > ScrollStartedSignalType; ///< ScrollStarted signal type
91 typedef Signal< void ( const Vector2& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type
92 typedef Signal< void ( const Vector2& ) > ScrollUpdatedSignalType; ///< Scroll updated signal type
97 * @brief Creates an uninitialized Scrollable handle.
102 * @brief Copy constructor.
104 * Creates another handle that points to the same real object
106 * @param handle to copy from
108 Scrollable( const Scrollable& handle );
111 * @brief Assignment operator.
113 * Changes this handle to point to another real object
114 * @param[in] handle to copy from
115 * @return A reference to this
117 Scrollable& operator=( const Scrollable& handle );
122 * This is non-virtual since derived Handle types must not contain data or virtual methods.
127 * @brief Downcast an Object handle to Scrollable.
129 * If handle points to a Scrollable the downcast produces valid
130 * handle. If not the returned handle is left uninitialized.
132 * @param[in] handle Handle to an object
133 * @return handle to a Scrollable or an uninitialized handle
135 static Scrollable DownCast( BaseHandle handle );
138 * @brief Checks if scroll overshoot has been enabled or not.
140 * @return Whether the scroll obvershoot is enabled
142 bool IsOvershootEnabled() const;
145 * @brief Sets whether to enables or disable scroll overshoot.
147 * @param[in] enable Whether to enable the scroll obvershoot or not
149 void SetOvershootEnabled(bool enable);
152 * @brief Set the color of the overshoot effect.
154 * @param[in] color The color of the overshoot effect.
156 void SetOvershootEffectColor( const Vector4& color );
159 * @brief Get the color of the overshoot effect.
160 * @return The color of the overshoot effect.
162 Vector4 GetOvershootEffectColor() const;
165 * @brief Set the speed of overshoot animation in pixels per second.
166 * When the speed is not greater than 0, the overshoot is set instantly with no animation.
167 * @param[in] pixelsPerSecond The speed of the overshoot animation.
169 void SetOvershootAnimationSpeed( float pixelsPerSecond );
172 * @brief Get the speed of overshoot animation in pixels per second.
173 * @return The speed of the overshoot animation.
175 float GetOvershootAnimationSpeed() const;
180 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
182 * A callback of the following type may be connected:
184 * void YourCallbackName(const Vector2& currentScrollPosition);
186 * @pre The Object has been initialized.
187 * @return The signal to connect to.
189 ScrollStartedSignalType& ScrollStartedSignal();
192 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
194 * A callback of the following type may be connected:
196 * void YourCallbackName(const Vector2& currentScrollPosition);
198 * @pre The Object has been initialized.
199 * @return The signal to connect to.
201 ScrollUpdatedSignalType& ScrollUpdatedSignal();
204 * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
206 * A callback of the following type may be connected:
208 * void YourCallbackName(const Vector2& currentScrollPosition);
210 * @pre The Object has been initialized.
211 * @return The signal to connect to.
213 ScrollCompletedSignalType& ScrollCompletedSignal();
215 public: // Not intended for application developers
218 * @brief Creates a handle using the Toolkit::Internal implementation.
220 * @param[in] implementation The Control implementation.
222 DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
225 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
227 * @param[in] internal A pointer to the internal CustomActor.
229 explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
232 } // namespace Toolkit
236 #endif // __DALI_TOOLKIT_SCROLLABLE_H__