Toolkit - Fixes TC build issues and compile warnings.
[platform/core/uifw/dali-toolkit.git] / base / 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 // INTERNAL INCLUDES
22 #include <dali/dali.h>
23
24 namespace Dali DALI_IMPORT_API
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 class ScrollConnector : public BaseHandle
55 {
56 public:
57
58   static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
59   static const char* const OVERSHOOT_PROPERTY_NAME;       ///< This float "overshoot" property is available via GetScrollPositionObject()
60
61   static const Property::Index SCROLL_POSITION;           ///< The index of the "scroll-position" property
62   static const Property::Index OVERSHOOT;                 ///< The index of the "overshoot" property
63
64   // Signals
65   static const char* const DOMAIN_CHANGED_SIGNAL_NAME;    ///< "domain-changed" signal name
66   typedef SignalV2< void ( float min, float max, float size ) > DomainChangedSignalType;
67
68   static const char* const SCROLL_POSITION_CHANGED_SIGNAL_NAME;    ///< "scroll-position-changed" signal name
69   typedef SignalV2< void ( float position ) > ScrollPositionChangedSignalType;
70
71   /**
72    * Create a ScrollConnector.
73    * @return A handle to a newly allocated ScrollConnector.
74    */
75   static ScrollConnector New();
76
77   /**
78    * Create an empty handle.
79    */
80   ScrollConnector();
81
82   /**
83    * Copy constructor.
84    * @param handle A handle to copy.
85    */
86   ScrollConnector( const ScrollConnector& handle );
87
88   /**
89    * @copydoc Dali::BaseHandle::operator=
90    */
91   using Dali::BaseHandle::operator=;
92
93   /**
94    * @brief Destructor
95    *
96    * This is non-virtual since derived Handle types must not contain data or virtual methods.
97    */
98   ~ScrollConnector();
99
100   /**
101    * @brief Downcast a BaseHandle to ScrollConnector handle.
102    * @return A handle to a ScrollConnector or an empty handle.
103    */
104   static ScrollConnector DownCast( BaseHandle handle );
105
106   /**
107    * @brief Set the scroll domain, corresponding to the start & end position, and size of the scrollable content in actor coordinates.
108    * @param[in] min The minimum scroll position limit.
109    * @param[in] max The maximum scroll position limit.
110    * @param[in] length The length of the scrollable content in actor coordinates.
111    */
112   void SetScrollDomain( float min, float max, float length );
113
114   /**
115    * @brief Retrieve the min limit.
116    * @return The minimum value.
117    */
118   float GetMinLimit() const;
119
120   /**
121    * @brief Retrieve the max limit.
122    * @return The maximum value.
123    */
124   float GetMaxLimit() const;
125
126   /**
127    * @brief Retrieve the length of the scrollable content in actor coordinates.
128    * @return The length of the scrollable content.
129    */
130   float GetContentLength() const;
131
132   /**
133    * @brief Set the scroll position.
134    *
135    * This will set the "scroll-position" property and emit the ScrollPositionChanged signal.
136    *
137    * @param[in] position The scroll position.
138    */
139   void SetScrollPosition( float position );
140
141   /**
142    * @brief Retrieve the scroll position.
143    * @return The scroll position.
144    */
145   float GetScrollPosition() const;
146
147   /**
148    * @brief Signal emitted after the SetScrollPosition() method has been called.
149    */
150   ScrollConnector::ScrollPositionChangedSignalType& ScrollPositionChangedSignal();
151
152   /**
153    * @brief Signal emitted after the SetScrollDomain() method has been called.
154    */
155   ScrollConnector::DomainChangedSignalType& DomainChangedSignal();
156
157   /**
158    * @brief Retrieve the object which provides the "scroll-position" property.
159    * @return The scroll-position object.
160    */
161   Constrainable GetScrollPositionObject() const;
162
163 public: // Not intended for application developers
164
165   /**
166    * Creates a handle using the Toolkit::Internal implementation.
167    * @param[in] impl The Control implementation.
168    */
169   ScrollConnector( Internal::ScrollConnector* impl );
170 };
171
172 } // namespace Toolkit
173
174 } // namespace Dali
175
176 #endif // __DALI_TOOLKIT_SCROLL_CONNECTOR_H__