[SRUK] Initial copy from Tizen 2.2 version
[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_FRAMEWORK
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 enum ClampState
40 {
41   NotClamped,
42   ClampedToMin,
43   ClampedToMax
44 };
45
46 struct ClampState2
47 {
48   ClampState x;
49   ClampState y;
50 };
51
52 struct ClampState3
53 {
54   ClampState x;
55   ClampState y;
56   ClampState z;
57 };
58
59 /**
60  * Base class for derived Scrollables that contains actors that can be scrolled manually
61  * (via touch) or automatically. Scrollables such as ScrollView and ItemView can be derived
62  * from this class.
63  */
64 class Scrollable : public Control
65 {
66 public:
67
68   /**
69    * Clamp signal event's data
70    */
71   struct ClampEvent
72   {
73     ClampState3 scale;                                                  ///< Clamp information for scale axes
74     ClampState3 position;                                               ///< Clamp information for position axes
75     ClampState rotation;                                                ///< Clamp information for rotation
76   };
77
78   /**
79    * Scroll component types
80    */
81   enum ScrollComponentType
82   {
83     HorizontalScrollBar,
84     VerticalScrollBar,
85     OvershootIndicator,
86   };
87
88   // Custom properties
89
90   static const std::string SCROLL_RELATIVE_POSITION_PROPERTY_NAME;      ///< Property, name "scroll-relative-position", type VECTOR3
91   static const std::string SCROLL_POSITION_MIN_PROPERTY_NAME;           ///< Property, name "scroll-position-min",      type VECTOR3
92   static const std::string SCROLL_POSITION_MAX_PROPERTY_NAME;           ///< Property, name "scroll-position-max",      type VECTOR3
93   static const std::string SCROLL_DIRECTION_PROPERTY_NAME;              ///< Property, name "scroll-direction",         type VECTOR2
94
95   //Signal Names
96   static const char* const SIGNAL_SCROLL_STARTED;
97   static const char* const SIGNAL_SCROLL_COMPLETED;
98   static const char* const SIGNAL_SCROLL_UPDATED;
99   static const char* const SIGNAL_SCROLL_CLAMPED;
100
101 public:
102
103   typedef SignalV2< void ( const Vector3& ) > ScrollStartedSignalV2;
104
105   typedef SignalV2< void ( const Vector3& ) > ScrollUpdatedSignalV2;
106
107   typedef SignalV2< void ( const Vector3& ) > ScrollCompletedSignalV2;
108
109   typedef SignalV2< void ( const ClampEvent& ) > ScrollClampedSignalV2;
110
111   /**
112    * Signal emitted when the Scrollable has moved (whether by touch or animation)
113    */
114   ScrollStartedSignalV2& ScrollStartedSignal();
115
116   /**
117    * Signal emitted when the Scrollable has moved (whether by touch or animation)
118    */
119   ScrollUpdatedSignalV2& ScrollUpdatedSignal();
120
121   /**
122    * Signal emitted when the Scrollable has completed movement (whether by touch or animation)
123    */
124   ScrollCompletedSignalV2& ScrollCompletedSignal();
125
126   /**
127    * Signal emitted when the Scrollable is pushing against a domain boundary
128    * (in either position, scale, or rotation)
129    */
130   ScrollClampedSignalV2& ScrollClampedSignal();
131
132 public:
133
134   /**
135    * Creates an uninitialized Scrollable handle
136    */
137   Scrollable();
138
139   /**
140    * Copy constructor. Creates another handle that points to the same real object
141    * @param handle to copy from
142    */
143   Scrollable( const Scrollable& handle );
144
145   /**
146    * Assignment operator. Changes this handle to point to another real object
147    */
148   Scrollable& operator=( const Scrollable& handle );
149
150   /**
151    * Virtual destructor.
152    * Dali::Object derived classes typically do not contain member data.
153    */
154   virtual ~Scrollable();
155
156   /**
157    * Downcast an Object handle to Scrollable. If handle points to a Scrollable the
158    * downcast produces valid handle. If not the returned handle is left uninitialized.
159    * @param[in] handle Handle to an object
160    * @return handle to a Scrollable or an uninitialized handle
161    */
162   static Scrollable DownCast( BaseHandle handle );
163
164   /**
165    * Checks if a ScrollComponent has been enabled or not.
166    * @param[in] type The Scroll Component Type to check
167    * @return True (if Enabled)
168    */
169   bool IsScrollComponentEnabled(Scrollable::ScrollComponentType type) const;
170
171   /**
172    * Enables a ScrollComponent
173    * @param[in] type The Scroll Component Type to enable
174    */
175   void EnableScrollComponent(Scrollable::ScrollComponentType type);
176
177   /**
178    * Disables a ScrollComponent
179    * @param[in] type The Scroll Component Type to disable
180    */
181   void DisableScrollComponent(Scrollable::ScrollComponentType type);
182
183 public: // Not intended for application developers
184
185   /**
186    * Creates a handle using the Toolkit::Internal implementation.
187    * @param[in]  implementation  The Control implementation.
188    */
189   Scrollable(Internal::Scrollable& implementation);
190
191   /**
192    * Allows the creation of this Control from an Internal::CustomActor pointer.
193    * @param[in]  internal  A pointer to the internal CustomActor.
194    */
195   Scrollable( Dali::Internal::CustomActor* internal );
196 };
197
198 } // namespace Toolkit
199
200 } // namespace Dali
201
202 /**
203  * @}
204  */
205 #endif // __DALI_TOOLKIT_SCROLLABLE_H__