1 #ifndef DALI_TOOLKIT_SCROLLABLE_H
2 #define DALI_TOOLKIT_SCROLLABLE_H
5 * Copyright (c) 2020 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>
28 namespace Internal DALI_INTERNAL
33 * @addtogroup dali_toolkit_controls_scrollable
38 * @brief Base class for derived Scrollables that contains actors that can be scrolled manually
39 * (via touch) or automatically.
41 * Scrollables such as ScrollView and ItemView can be derived from this class.
44 * | %Signal Name | Method |
45 * |------------------|------------------------------|
46 * | scrollStarted | @ref ScrollStartedSignal() |
47 * | scrollCompleted | @ref ScrollCompletedSignal() |
48 * | scrollUpdated | @ref ScrollUpdatedSignal() |
51 class DALI_TOOLKIT_API Scrollable : public Control
55 * @brief Enumeration for the start and end property ranges for this control.
60 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
61 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices @SINCE_1_0.0
63 ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
64 ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices @SINCE_1_0.0
68 * @brief Enumeration for the instance of properties belonging to the Scrollable class.
74 * @brief Enumeration for the instance of properties belonging to the Scrollable class.
79 // Event side properties
80 OVERSHOOT_EFFECT_COLOR = PROPERTY_START_INDEX, ///< Property, name "overshootEffectColor", @see SetOvershootEffectColor(), type Vector4 @SINCE_1_0.0
81 OVERSHOOT_ANIMATION_SPEED, ///< Property, name "overshootAnimationSpeed", @see SetOvershootAnimationSpeed(), type float @SINCE_1_0.0
82 OVERSHOOT_ENABLED, ///< Property, name "overshootEnabled", @see SetOvershootEnabled(), type bool, @SINCE_1_1.18
83 OVERSHOOT_SIZE, ///< Property, name "overshootSize", type Vector2, @SINCE_1_1.31
84 SCROLL_TO_ALPHA_FUNCTION, ///< Property, name "scrollToAlphaFunction", type int, @SINCE_1_1.33
86 // Animatable properties
87 SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollRelativePosition", type Vector2 @SINCE_1_0.0
88 SCROLL_POSITION_MIN, ///< Property, name "scrollPositionMin", type Vector2 @SINCE_1_0.0
89 SCROLL_POSITION_MIN_X, ///< Property, name "scrollPositionMinX", type float @SINCE_1_0.0
90 SCROLL_POSITION_MIN_Y, ///< Property, name "scrollPositionMinY", type float @SINCE_1_0.0
91 SCROLL_POSITION_MAX, ///< Property, name "scrollPositionMax", type Vector2 @SINCE_1_0.0
92 SCROLL_POSITION_MAX_X, ///< Property, name "scrollPositionMaxX", type float @SINCE_1_0.0
93 SCROLL_POSITION_MAX_Y, ///< Property, name "scrollPositionMaxY", type float @SINCE_1_0.0
94 CAN_SCROLL_VERTICAL, ///< Property, name "canScrollVertical", type bool @SINCE_1_0.0
95 CAN_SCROLL_HORIZONTAL ///< Property, name "canScrollHorizontal", type bool @SINCE_1_0.0
101 typedef Signal<void(const Vector2&)> ScrollStartedSignalType; ///< ScrollStarted signal type @SINCE_1_0.0
102 typedef Signal<void(const Vector2&)> ScrollCompletedSignalType; ///< ScrollCompleted signal type @SINCE_1_0.0
103 typedef Signal<void(const Vector2&)> ScrollUpdatedSignalType; ///< Scroll updated signal type @SINCE_1_0.0
107 * @brief Creates an uninitialized Scrollable handle.
113 * @brief Copy constructor.
115 * Creates another handle that points to the same real object.
118 * @param handle to copy from
120 Scrollable(const Scrollable& handle);
123 * @brief Move constructor
126 * @param[in] rhs A reference to the moved handle
128 Scrollable(Scrollable&& rhs);
131 * @brief Assignment operator.
133 * Changes this handle to point to another real object.
135 * @param[in] handle Handle to copy from
136 * @return A reference to this
138 Scrollable& operator=(const Scrollable& handle);
141 * @brief Move assignment
144 * @param[in] rhs A reference to the moved handle
145 * @return A reference to this
147 Scrollable& operator=(Scrollable&& rhs);
152 * This is non-virtual since derived Handle types must not contain data or virtual methods.
158 * @brief Downcasts a handle to Scrollable handle.
160 * If handle points to a Scrollable, the downcast produces valid handle.
161 * If not, the returned handle is left uninitialized.
164 * @param[in] handle Handle to an object
165 * @return A handle to a Scrollable or an uninitialized handle
167 static Scrollable DownCast(BaseHandle handle);
170 * @brief Checks if scroll overshoot has been enabled or not.
173 * @return Whether the scroll overshoot is enabled
175 bool IsOvershootEnabled() const;
178 * @brief Sets whether to enables or disable scroll overshoot.
181 * @param[in] enable Whether to enable the scroll overshoot or not
183 void SetOvershootEnabled(bool enable);
186 * @brief Sets the color of the overshoot effect.
189 * @param[in] color The color of the overshoot effect
191 void SetOvershootEffectColor(const Vector4& color);
194 * @brief Gets the color of the overshoot effect.
196 * @return The color of the overshoot effect
198 Vector4 GetOvershootEffectColor() const;
201 * @brief Sets the speed of overshoot animation in pixels per second.
203 * When the speed is not greater than 0, the overshoot is set instantly with no animation.
205 * @param[in] pixelsPerSecond The speed of the overshoot animation
207 void SetOvershootAnimationSpeed(float pixelsPerSecond);
210 * @brief Gets the speed of overshoot animation in pixels per second.
212 * @return The speed of the overshoot animation
214 float GetOvershootAnimationSpeed() const;
218 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
220 * A callback of the following type may be connected:
222 * void YourCallbackName(const Vector2& currentScrollPosition);
225 * @return The signal to connect to
226 * @pre The Object has been initialized.
228 ScrollStartedSignalType& ScrollStartedSignal();
231 * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
233 * A callback of the following type may be connected:
235 * void YourCallbackName(const Vector2& currentScrollPosition);
238 * @return The signal to connect to
239 * @pre The Object has been initialized.
241 ScrollUpdatedSignalType& ScrollUpdatedSignal();
244 * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
246 * A callback of the following type may be connected:
248 * void YourCallbackName(const Vector2& currentScrollPosition);
251 * @return The signal to connect to
252 * @pre The Object has been initialized.
254 ScrollCompletedSignalType& ScrollCompletedSignal();
256 public: // Not intended for application developers
259 * @brief Creates a handle using the Toolkit::Internal implementation.
262 * @param[in] implementation The Control implementation
264 DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
267 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
270 * @param[in] internal A pointer to the internal CustomActor
272 explicit DALI_INTERNAL Scrollable(Dali::Internal::CustomActor* internal);
279 } // namespace Toolkit
283 #endif // DALI_TOOLKIT_SCROLLABLE_H