1 #ifndef __DALI_TOOLKIT_SCROLLABLE_H__
2 #define __DALI_TOOLKIT_SCROLLABLE_H__
5 * Copyright (c) 2014 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 How axes/rotation or scale are clamped
40 NotClamped, ///< The quantity isn't clamped
41 ClampedToMin, ///< The quantity is clamped to the min value
42 ClampedToMax ///< The quantity is clamped to the max value
46 * @brief A 2 dimensional clamp
50 ClampState x; ///< The clamp state of the x axis
51 ClampState y; ///< The clamp state of the y axis
55 * @brief A 3 dimensional clamp
59 ClampState x; ///< The clamp state of the x axis
60 ClampState y; ///< The clamp state of the y axis
61 ClampState z; ///< The clamp state of the z axis
65 * @brief Base class for derived Scrollables that contains actors that can be scrolled manually
66 * (via touch) or automatically.
68 * Scrollables such as ScrollView and ItemView can be derived from this class.
70 class DALI_IMPORT_API Scrollable : public Control
75 * @brief Clamp signal event's data
79 ClampState3 scale; ///< Clamp information for scale axes
80 ClampState3 position; ///< Clamp information for position axes
81 ClampState rotation; ///< Clamp information for rotation
85 * @brief Scroll component types
87 enum ScrollComponentType
96 static const std::string SCROLL_RELATIVE_POSITION_PROPERTY_NAME; ///< Property, name "scroll-relative-position", type VECTOR3
97 static const std::string SCROLL_POSITION_MIN_PROPERTY_NAME; ///< Property, name "scroll-position-min", type VECTOR3
98 static const std::string SCROLL_POSITION_MAX_PROPERTY_NAME; ///< Property, name "scroll-position-max", type VECTOR3
99 static const std::string SCROLL_DIRECTION_PROPERTY_NAME; ///< Property, name "scroll-direction", type VECTOR2
103 static const Property::Index PROPERTY_OVERSHOOT_EFFECT_COLOR; ///< Property, name "overshoot-effect-color", @see SetOvershootEffectColor(), type VECTOR4
104 static const Property::Index PROPERTY_OVERSHOOT_ANIMATION_SPEED; ///< Property, name "overshoot-animation-speed", @see SetOvershootAnimationSpeed(), type FLOAT
109 static const char* const SIGNAL_SCROLL_STARTED; ///< "scroll-started";
110 static const char* const SIGNAL_SCROLL_COMPLETED; ///< "scroll-completed";
111 static const char* const SIGNAL_SCROLL_UPDATED; ///< "scroll-updated";
112 static const char* const SIGNAL_SCROLL_CLAMPED; ///< "scroll-clamped";
117 typedef Signal< void ( const Vector3& ) > ScrollStartedSignalType; ///< ScrollStarted signal type
118 typedef Signal< void ( const Vector3& ) > ScrollCompletedSignalType; ///< ScrollCompleted signal type
119 typedef Signal< void ( const Vector3& ) > ScrollUpdatedSignalType; ///< Scroll updated signal type
120 typedef Signal< void ( const ClampEvent& ) > ScrollClampedSignalType; ///< Scroll clamped signal type
123 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
125 ScrollStartedSignalType& ScrollStartedSignal();
128 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
130 ScrollUpdatedSignalType& ScrollUpdatedSignal();
133 * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
135 ScrollCompletedSignalType& ScrollCompletedSignal();
138 * @brief Signal emitted when the Scrollable is pushing against a domain boundary
139 * (in either position, scale, or rotation).
141 * @return The signal to connect to
143 ScrollClampedSignalType& ScrollClampedSignal();
148 * @brief Creates an uninitialized Scrollable handle.
153 * @brief Copy constructor.
155 * Creates another handle that points to the same real object
157 * @param handle to copy from
159 Scrollable( const Scrollable& handle );
162 * @brief Assignment operator.
164 * Changes this handle to point to another real object
165 * @param[in] handle to copy from
166 * @return A reference to this
168 Scrollable& operator=( const Scrollable& handle );
173 * This is non-virtual since derived Handle types must not contain data or virtual methods.
178 * @brief Downcast an Object handle to Scrollable.
180 * If handle points to a Scrollable the downcast produces valid
181 * handle. If not the returned handle is left uninitialized.
183 * @param[in] handle Handle to an object
184 * @return handle to a Scrollable or an uninitialized handle
186 static Scrollable DownCast( BaseHandle handle );
189 * @brief Checks if a ScrollComponent has been enabled or not.
191 * @param[in] type The Scroll Component Type to check
192 * @return True (if Enabled)
194 bool IsScrollComponentEnabled(Scrollable::ScrollComponentType type) const;
197 * @brief Enables a ScrollComponent.
199 * @param[in] type The Scroll Component Type to enable
201 void EnableScrollComponent(Scrollable::ScrollComponentType type);
204 * @brief Disables a ScrollComponent.
206 * @param[in] type The Scroll Component Type to disable
208 void DisableScrollComponent(Scrollable::ScrollComponentType type);
211 * @brief Set the color of the overshoot effect.
213 * @param[in] color The color of the overshoot effect.
215 void SetOvershootEffectColor( const Vector4& color );
218 * @brief Get the color of the overshoot effect.
219 * @return The color of the overshoot effect.
221 Vector4 GetOvershootEffectColor() const;
224 * @brief Set the speed of overshoot animation in pixels per second.
225 * When the speed is not greater than 0, the overshoot is set instantly with no animation.
226 * @param[in] pixelsPerSecond The speed of the overshoot animation.
228 void SetOvershootAnimationSpeed( float pixelsPerSecond );
231 * @brief Get the speed of overshoot animation in pixels per second.
232 * @return The speed of the overshoot animation.
234 float GetOvershootAnimationSpeed() const;
236 public: // Not intended for application developers
239 * @brief Creates a handle using the Toolkit::Internal implementation.
241 * @param[in] implementation The Control implementation.
243 DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
246 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
248 * @param[in] internal A pointer to the internal CustomActor.
250 explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
253 } // namespace Toolkit
257 #endif // __DALI_TOOLKIT_SCROLLABLE_H__