fad7fb26d6ed8d7bc3c5e2a3169fabd725bfaa3f
[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 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 // INTERNAL INCLUDES
21 #include <dali/dali.h>
22
23 namespace Dali DALI_IMPORT_API
24 {
25
26 namespace Toolkit
27 {
28
29 namespace Internal DALI_INTERNAL
30 {
31 class ScrollConnector;
32 }
33
34 /**
35  * ScrollConnector is used to connect scrollable containers with components such as scroll bars, indicators etc.
36  *
37  * This basically consists of:
38  *   - A "scroll-position" property which controls which part of the scrollable content is visible
39  *   - The minimum/maximum limits of the scroll position, which corresponds to the start & end points of the scollable list etc.
40  *
41  * The provider of the scrollable content is responsible for calling SetLimits(). Scroll-bar components are then expected to
42  * receive these values via the LIMITS_CHANGED signal.
43  *
44  * The scroll-position property is accessible via GetScrollPositionObject(). This is intended to be shared by multiple controls
45  * e.g. a list control may be scrolled by panning the list content, or indirectly by dragging a connected scroll-bar control.
46  */
47 class ScrollConnector : public BaseHandle
48 {
49 public:
50
51   static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
52   static const Property::Index SCROLL_POSITION;           ///< The index of the "scroll-position" property
53
54   // Signals
55   static const char* const LIMITS_CHANGED_SIGNAL_NAME;    ///< "limits-changed" signal name
56   typedef SignalV2< void ( float min, float max ) > LimitsChangedSignalType;
57
58   /**
59    * Create a ScrollConnector.
60    * @return A handle to a newly allocated ScrollConnector.
61    */
62   static ScrollConnector New();
63
64   /**
65    * Create an empty handle.
66    */
67   ScrollConnector();
68
69   /**
70    * Copy constructor.
71    * @param handle A handle to copy.
72    */
73   ScrollConnector( const ScrollConnector& handle );
74
75   /**
76    * @copydoc Dali::BaseHandle::operator=
77    */
78   using Dali::BaseHandle::operator=;
79
80   /**
81    * Virtual destructor.
82    */
83   virtual ~ScrollConnector();
84
85   /**
86    * Downcast a BaseHandle to ScrollConnector handle.
87    * @return A handle to a ScrollConnector or an empty handle.
88    */
89   static ScrollConnector DownCast( BaseHandle handle );
90
91   /**
92    * Set The min/max values, corresponding to the start & end position of the scrollable content.
93    * @param[in] min The minimum value.
94    * @param[in] max The maximum value.
95    */
96   void SetLimits( float min, float max );
97
98   /**
99    * Retrieve the min limit.
100    * @return The minimum value.
101    */
102   float GetMinLimit() const;
103
104   /**
105    * Retrieve the max limit.
106    * @return The maximum value.
107    */
108   float GetMaxLimit() const;
109
110   /**
111    * Signal emitted after the SetLimits() method has been called.
112    */
113   ScrollConnector::LimitsChangedSignalType& LimitsChangedSignal();
114
115   /**
116    * Retrieve the object which provides the "scroll-position" property.
117    * @return The scroll-position object.
118    */
119   Constrainable GetScrollPositionObject() const;
120
121 public: // Not intended for application developers
122
123   /**
124    * Creates a handle using the Toolkit::Internal implementation.
125    * @param[in] impl The Control implementation.
126    */
127   ScrollConnector( Internal::ScrollConnector* impl );
128 };
129
130 } // namespace Toolkit
131
132 } // namespace Dali
133
134 #endif // __DALI_TOOLKIT_SCROLL_CONNECTOR_H__