Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-toolkit.git] / capi / dali-toolkit / public-api / controls / scrollable / scroll-connector.h
1 #ifndef __DALI_TOOLKIT_SCROLL_CONNECTOR_H__
2 #define __DALI_TOOLKIT_SCROLL_CONNECTOR_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_SCROLL_CONNECTOR_MODULE
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali/dali.h>
27
28 namespace Dali DALI_IMPORT_API
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal DALI_INTERNAL
35 {
36 class ScrollConnector;
37 }
38
39 /**
40  * ScrollConnector is used to connect scrollable containers with components such as scroll bars, indicators etc.
41  *
42  * This basically consists of:
43  *   - A "scroll-position" property which controls which part of the scrollable content is visible
44  *   - The minimum/maximum limits of the scroll position, which corresponds to the start & end points of the scollable list etc.
45  *   - An "overshoot" property which shows any attempts to exceed the start & end points.
46  *   - The scrollable content size, which corresponds to the length of the scrollable content in the scrollable container in actor coordinates.
47  *
48  * The provider of the scrollable content is responsible for calling SetScrollDomain(). Scroll-bar components are then expected to
49  * receive these values via the DOMAIN_CHANGED signal.
50  *
51  * The scroll-position property is accessible via GetScrollPositionObject(). This is intended to be shared by multiple controls
52  * e.g. a list control may be scrolled by panning the list content, or indirectly by dragging a connected scroll-bar control.
53  *
54  * The overshoot property is intended for implementing 'end of list' style indicators. This property is expected to be in the range
55  * -1 to 1, where -1 shows an attempt the scroll beyond the minimum limit, and 1 shows an attempt the scroll beyond the maximum limit.
56  * Zero indicates normal scrolling i.e. when overshoot indicators should be hidden.
57  */
58 class ScrollConnector : public BaseHandle
59 {
60 public:
61
62   static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
63   static const char* const OVERSHOOT_PROPERTY_NAME;       ///< This float "overshoot" property is available via GetScrollPositionObject()
64
65   static const Property::Index SCROLL_POSITION;           ///< The index of the "scroll-position" property
66   static const Property::Index OVERSHOOT;                 ///< The index of the "overshoot" property
67
68   // Signals
69   static const char* const DOMAIN_CHANGED_SIGNAL_NAME;    ///< "domain-changed" signal name
70   typedef SignalV2< void ( float min, float max, float size ) > DomainChangedSignalType;
71
72   /**
73    * Create a ScrollConnector.
74    * @return A handle to a newly allocated ScrollConnector.
75    */
76   static ScrollConnector New();
77
78   /**
79    * Create an empty handle.
80    */
81   ScrollConnector();
82
83   /**
84    * Copy constructor.
85    * @param handle A handle to copy.
86    */
87   ScrollConnector( const ScrollConnector& handle );
88
89   /**
90    * @copydoc Dali::BaseHandle::operator=
91    */
92   using Dali::BaseHandle::operator=;
93
94   /**
95    * Virtual destructor.
96    */
97   virtual ~ScrollConnector();
98
99   /**
100    * Downcast a BaseHandle to ScrollConnector handle.
101    * @return A handle to a ScrollConnector or an empty handle.
102    */
103   static ScrollConnector DownCast( BaseHandle handle );
104
105   /**
106    * Set the scroll domain, corresponding to the start & end position, and size of the scrollable content in actor coordinates.
107    * @param[in] min The minimum scroll position limit.
108    * @param[in] max The maximum scroll position limit.
109    * @param[in] length The length of the scrollable content in actor coordinates.
110    */
111   void SetScrollDomain( float min, float max, float length );
112
113   /**
114    * Retrieve the min limit.
115    * @return The minimum value.
116    */
117   float GetMinLimit() const;
118
119   /**
120    * Retrieve the max limit.
121    * @return The maximum value.
122    */
123   float GetMaxLimit() const;
124
125   /**
126    * Retrieve the length of the scrollable content in actor coordinates.
127    * @return The length of the scrollable content.
128    */
129   float GetContentLength() const;
130
131   /**
132    * Signal emitted after the SetScrollDomain() method has been called.
133    */
134   ScrollConnector::DomainChangedSignalType& DomainChangedSignal();
135
136   /**
137    * Retrieve the object which provides the "scroll-position" property.
138    * @return The scroll-position object.
139    */
140   Constrainable GetScrollPositionObject() const;
141
142 public: // Not intended for application developers
143
144   /**
145    * Creates a handle using the Toolkit::Internal implementation.
146    * @param[in] impl The Control implementation.
147    */
148   ScrollConnector( Internal::ScrollConnector* impl );
149 };
150
151 } // namespace Toolkit
152
153 } // namespace Dali
154
155 /**
156  * @}
157  */
158
159 #endif // __DALI_TOOLKIT_SCROLL_CONNECTOR_H__