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