0458d0dfc0b17a9dc6070057f2e58164da194959
[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 // 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  *   - An "overshoot" property which shows any attempts to exceed the start & end points.
41  *   - The scrollable content size, which corresponds to the length of the scrollable content in the scrollable container in actor coordinates.
42  *
43  * The provider of the scrollable content is responsible for calling SetScrollDomain(). Scroll-bar components are then expected to
44  * receive these values via the DOMAIN_CHANGED signal.
45  *
46  * The scroll-position property is accessible via GetScrollPositionObject(). This is intended to be shared by multiple controls
47  * e.g. a list control may be scrolled by panning the list content, or indirectly by dragging a connected scroll-bar control.
48  *
49  * The overshoot property is intended for implementing 'end of list' style indicators. This property is expected to be in the range
50  * -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.
51  * Zero indicates normal scrolling i.e. when overshoot indicators should be hidden.
52  */
53 class ScrollConnector : public BaseHandle
54 {
55 public:
56
57   static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
58   static const char* const OVERSHOOT_PROPERTY_NAME;       ///< This float "overshoot" property is available via GetScrollPositionObject()
59
60   static const Property::Index SCROLL_POSITION;           ///< The index of the "scroll-position" property
61   static const Property::Index OVERSHOOT;                 ///< The index of the "overshoot" property
62
63   // Signals
64   static const char* const DOMAIN_CHANGED_SIGNAL_NAME;    ///< "domain-changed" signal name
65   typedef SignalV2< void ( float min, float max, float size ) > DomainChangedSignalType;
66
67   /**
68    * Create a ScrollConnector.
69    * @return A handle to a newly allocated ScrollConnector.
70    */
71   static ScrollConnector New();
72
73   /**
74    * Create an empty handle.
75    */
76   ScrollConnector();
77
78   /**
79    * Copy constructor.
80    * @param handle A handle to copy.
81    */
82   ScrollConnector( const ScrollConnector& handle );
83
84   /**
85    * @copydoc Dali::BaseHandle::operator=
86    */
87   using Dali::BaseHandle::operator=;
88
89   /**
90    * Virtual destructor.
91    */
92   virtual ~ScrollConnector();
93
94   /**
95    * Downcast a BaseHandle to ScrollConnector handle.
96    * @return A handle to a ScrollConnector or an empty handle.
97    */
98   static ScrollConnector DownCast( BaseHandle handle );
99
100   /**
101    * Set the scroll domain, corresponding to the start & end position, and size of the scrollable content in actor coordinates.
102    * @param[in] min The minimum scroll position limit.
103    * @param[in] max The maximum scroll position limit.
104    * @param[in] length The length of the scrollable content in actor coordinates.
105    */
106   void SetScrollDomain( float min, float max, float length );
107
108   /**
109    * Retrieve the min limit.
110    * @return The minimum value.
111    */
112   float GetMinLimit() const;
113
114   /**
115    * Retrieve the max limit.
116    * @return The maximum value.
117    */
118   float GetMaxLimit() const;
119
120   /**
121    * Retrieve the length of the scrollable content in actor coordinates.
122    * @return The length of the scrollable content.
123    */
124   float GetContentLength() const;
125
126   /**
127    * Signal emitted after the SetScrollDomain() method has been called.
128    */
129   ScrollConnector::DomainChangedSignalType& DomainChangedSignal();
130
131   /**
132    * Retrieve the object which provides the "scroll-position" property.
133    * @return The scroll-position object.
134    */
135   Constrainable GetScrollPositionObject() const;
136
137 public: // Not intended for application developers
138
139   /**
140    * Creates a handle using the Toolkit::Internal implementation.
141    * @param[in] impl The Control implementation.
142    */
143   ScrollConnector( Internal::ScrollConnector* impl );
144 };
145
146 } // namespace Toolkit
147
148 } // namespace Dali
149
150 #endif // __DALI_TOOLKIT_SCROLL_CONNECTOR_H__