Notify the IMF when backspace/cut empties the TextField
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scrollable / scrollable.h
1 #ifndef __DALI_TOOLKIT_SCROLLABLE_H__
2 #define __DALI_TOOLKIT_SCROLLABLE_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class Scrollable;
33 }
34
35 /**
36  * @brief Base class for derived Scrollables that contains actors that can be scrolled manually
37  * (via touch) or automatically.
38  *
39  * Scrollables such as ScrollView and ItemView can be derived from this class.
40  *
41  * Signals
42  * | %Signal Name      | Method                       |
43  * |-------------------|------------------------------|
44  * | scroll-started    | @ref ScrollStartedSignal()   |
45  * | scroll-completed  | @ref ScrollUpdatedSignal()   |
46  * | scroll-updated    | @ref ScrollCompletedSignal() |
47  */
48 class DALI_IMPORT_API Scrollable : public Control
49 {
50 public:
51
52   /**
53    * @brief The start and end property ranges for this control.
54    */
55   enum PropertyRange
56   {
57     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
58     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000,             ///< Reserve property indices
59
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
62   };
63
64   /**
65    * @brief An enumeration of properties belonging to the Scrollable class.
66    */
67   struct Property
68   {
69     enum
70     {
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
74
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
85     };
86   };
87
88   // Typedefs
89
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
93
94 public:
95
96   /**
97    * @brief Creates an uninitialized Scrollable handle.
98    */
99   Scrollable();
100
101   /**
102    * @brief Copy constructor.
103    *
104    * Creates another handle that points to the same real object
105    *
106    * @param handle to copy from
107    */
108   Scrollable( const Scrollable& handle );
109
110   /**
111    * @brief Assignment operator.
112    *
113    * Changes this handle to point to another real object
114    * @param[in] handle to copy from
115    * @return A reference to this
116    */
117   Scrollable& operator=( const Scrollable& handle );
118
119   /**
120    * @brief Destructor
121    *
122    * This is non-virtual since derived Handle types must not contain data or virtual methods.
123    */
124   ~Scrollable();
125
126   /**
127    * @brief Downcast an Object handle to Scrollable.
128    *
129    * If handle points to a Scrollable the downcast produces valid
130    * handle. If not the returned handle is left uninitialized.
131    *
132    * @param[in] handle Handle to an object
133    * @return handle to a Scrollable or an uninitialized handle
134    */
135   static Scrollable DownCast( BaseHandle handle );
136
137   /**
138    * @brief Checks if scroll overshoot has been enabled or not.
139    *
140    * @return Whether the scroll obvershoot is enabled
141    */
142   bool IsOvershootEnabled() const;
143
144   /**
145    * @brief Sets whether to enables or disable scroll overshoot.
146    *
147    * @param[in] enable Whether to enable the scroll obvershoot or not
148    */
149   void SetOvershootEnabled(bool enable);
150
151   /**
152    * @brief Set the color of the overshoot effect.
153    *
154    * @param[in] color The color of the overshoot effect.
155    */
156   void SetOvershootEffectColor( const Vector4& color );
157
158   /**
159    * @brief Get the color of the overshoot effect.
160    * @return The color of the overshoot effect.
161    */
162   Vector4 GetOvershootEffectColor() const;
163
164   /**
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.
168    */
169   void SetOvershootAnimationSpeed( float pixelsPerSecond );
170
171   /**
172    * @brief Get the speed of overshoot animation in pixels per second.
173    * @return The speed of the overshoot animation.
174    */
175   float GetOvershootAnimationSpeed() const;
176
177 public: // Signals
178
179   /**
180    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
181    *
182    * A callback of the following type may be connected:
183    * @code
184    *   void YourCallbackName(const Vector2& currentScrollPosition);
185    * @endcode
186    * @pre The Object has been initialized.
187    * @return The signal to connect to.
188    */
189   ScrollStartedSignalType& ScrollStartedSignal();
190
191   /**
192    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
193    *
194    * A callback of the following type may be connected:
195    * @code
196    *   void YourCallbackName(const Vector2& currentScrollPosition);
197    * @endcode
198    * @pre The Object has been initialized.
199    * @return The signal to connect to.
200    */
201   ScrollUpdatedSignalType& ScrollUpdatedSignal();
202
203   /**
204    * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
205    *
206    * A callback of the following type may be connected:
207    * @code
208    *   void YourCallbackName(const Vector2& currentScrollPosition);
209    * @endcode
210    * @pre The Object has been initialized.
211    * @return The signal to connect to.
212    */
213   ScrollCompletedSignalType& ScrollCompletedSignal();
214
215 public: // Not intended for application developers
216
217   /**
218    * @brief Creates a handle using the Toolkit::Internal implementation.
219    *
220    * @param[in]  implementation  The Control implementation.
221    */
222   DALI_INTERNAL Scrollable(Internal::Scrollable& implementation);
223
224   /**
225    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
226    *
227    * @param[in]  internal  A pointer to the internal CustomActor.
228    */
229   explicit DALI_INTERNAL Scrollable( Dali::Internal::CustomActor* internal );
230 };
231
232 } // namespace Toolkit
233
234 } // namespace Dali
235
236 #endif // __DALI_TOOLKIT_SCROLLABLE_H__