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