Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / capi / 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) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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  * @addtogroup CAPI_DALI_TOOLKIT_SCROLLABLE_MODULE
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/control.h>
27
28 namespace Dali DALI_IMPORT_API
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal DALI_INTERNAL
35 {
36 class Scrollable;
37 }
38
39 /**
40  * @brief How axes/rotation or scale are clamped
41  */
42 enum ClampState
43 {
44   NotClamped,   ///< The quantity isn't clamped
45   ClampedToMin, ///< The quantity is clamped to the min value
46   ClampedToMax  ///< The quantity is clamped to the max value
47 };
48
49 /**
50  * @brief A 2 dimensional clamp
51  */
52 struct ClampState2
53 {
54   ClampState x; ///< The clamp state of the x axis
55   ClampState y; ///< The clamp state of the y axis
56 };
57
58 /**
59  * @brief A 3 dimensional clamp
60  */
61 struct ClampState3
62 {
63   ClampState x; ///< The clamp state of the x axis
64   ClampState y; ///< The clamp state of the y axis
65   ClampState z; ///< The clamp state of the z axis
66 };
67
68 /**
69  * @brief Base class for derived Scrollables that contains actors that can be scrolled manually
70  * (via touch) or automatically.
71  *
72  * Scrollables such as ScrollView and ItemView can be derived from this class.
73  */
74 class Scrollable : public Control
75 {
76 public:
77
78   /**
79    * @brief Clamp signal event's data
80    */
81   struct ClampEvent
82   {
83     ClampState3 scale;       ///< Clamp information for scale axes
84     ClampState3 position;    ///< Clamp information for position axes
85     ClampState rotation;     ///< Clamp information for rotation
86   };
87
88   /**
89    * @brief Scroll component types
90    */
91   enum ScrollComponentType
92   {
93     HorizontalScrollBar,
94     VerticalScrollBar,
95     OvershootIndicator,
96   };
97
98   // Custom properties
99
100   static const std::string SCROLL_RELATIVE_POSITION_PROPERTY_NAME;      ///< Property, name "scroll-relative-position", type VECTOR3
101   static const std::string SCROLL_POSITION_MIN_PROPERTY_NAME;           ///< Property, name "scroll-position-min",      type VECTOR3
102   static const std::string SCROLL_POSITION_MAX_PROPERTY_NAME;           ///< Property, name "scroll-position-max",      type VECTOR3
103   static const std::string SCROLL_DIRECTION_PROPERTY_NAME;              ///< Property, name "scroll-direction",         type VECTOR2
104
105   //Signal Names
106   static const char* const SIGNAL_SCROLL_STARTED;   ///< "scroll-started";
107   static const char* const SIGNAL_SCROLL_COMPLETED; ///< "scroll-completed";
108   static const char* const SIGNAL_SCROLL_UPDATED;   ///< "scroll-updated";
109   static const char* const SIGNAL_SCROLL_CLAMPED;   ///< "scroll-clamped";
110
111 public:
112
113   typedef SignalV2< void ( const Vector3& ) > ScrollStartedSignalV2;   ///< ScrollStarted signal type
114   typedef SignalV2< void ( const Vector3& ) > ScrollCompletedSignalV2; ///< ScrollCompleted signal type
115   typedef SignalV2< void ( const Vector3& ) > ScrollUpdatedSignalV2;   ///< Scroll updated signal type
116   typedef SignalV2< void ( const ClampEvent& ) > ScrollClampedSignalV2; ///< Scroll clamped signal type
117
118   /**
119    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
120    */
121   ScrollStartedSignalV2& ScrollStartedSignal();
122
123   /**
124    * @brief Signal emitted when the Scrollable has moved (whether by touch or animation).
125    */
126   ScrollUpdatedSignalV2& ScrollUpdatedSignal();
127
128   /**
129    * @brief Signal emitted when the Scrollable has completed movement (whether by touch or animation).
130    */
131   ScrollCompletedSignalV2& ScrollCompletedSignal();
132
133   /**
134    * @brief Signal emitted when the Scrollable is pushing against a domain boundary
135    * (in either position, scale, or rotation).
136    *
137    * @return The signal to connect to
138    */
139   ScrollClampedSignalV2& ScrollClampedSignal();
140
141 public:
142
143   /**
144    * @brief Creates an uninitialized Scrollable handle.
145    */
146   Scrollable();
147
148   /**
149    * @brief Copy constructor.
150    *
151    * Creates another handle that points to the same real object
152    *
153    * @param handle to copy from
154    */
155   Scrollable( const Scrollable& handle );
156
157   /**
158    * @brief Assignment operator.
159    *
160    * Changes this handle to point to another real object
161    * @param[in] handle to copy from
162    * @return A reference to this
163    */
164   Scrollable& operator=( const Scrollable& handle );
165
166   /**
167    * @brief Virtual destructor.
168    *
169    * Dali::Object derived classes typically do not contain member data.
170    */
171   virtual ~Scrollable();
172
173   /**
174    * @brief Downcast an Object handle to Scrollable.
175    *
176    * If handle points to a Scrollable the downcast produces valid
177    * handle. If not the returned handle is left uninitialized.
178    *
179    * @param[in] handle Handle to an object
180    * @return handle to a Scrollable or an uninitialized handle
181    */
182   static Scrollable DownCast( BaseHandle handle );
183
184   /**
185    * @brief Checks if a ScrollComponent has been enabled or not.
186    *
187    * @param[in] type The Scroll Component Type to check
188    * @return True (if Enabled)
189    */
190   bool IsScrollComponentEnabled(Scrollable::ScrollComponentType type) const;
191
192   /**
193    * @brief Enables a ScrollComponent.
194    *
195    * @param[in] type The Scroll Component Type to enable
196    */
197   void EnableScrollComponent(Scrollable::ScrollComponentType type);
198
199   /**
200    * @brief Disables a ScrollComponent.
201    *
202    * @param[in] type The Scroll Component Type to disable
203    */
204   void DisableScrollComponent(Scrollable::ScrollComponentType type);
205
206 public: // Not intended for application developers
207
208   /**
209    * @brief Creates a handle using the Toolkit::Internal implementation.
210    *
211    * @param[in]  implementation  The Control implementation.
212    */
213   Scrollable(Internal::Scrollable& implementation);
214
215   /**
216    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
217    *
218    * @param[in]  internal  A pointer to the internal CustomActor.
219    */
220   Scrollable( Dali::Internal::CustomActor* internal );
221 };
222
223 } // namespace Toolkit
224
225 } // namespace Dali
226
227 /**
228  * @}
229  */
230 #endif // __DALI_TOOLKIT_SCROLLABLE_H__