Merge "Scrollable public API clean-up phase 1" into tizen
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scroll-connector-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_CONNECTOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_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/base-object.h>
23 #include <dali/public-api/signals/dali-signal.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 /**
38  * @copydoc Toolkit::ScrollConnector
39  */
40 class ScrollConnector : public Dali::BaseObject
41 {
42 public:
43
44   typedef Toolkit::ScrollConnector::DomainChangedSignalType DomainChangedSignalType;
45   typedef Toolkit::ScrollConnector::ScrollPositionChangedSignalType ScrollPositionChangedSignalType;
46
47   static const Property::Index SCROLL_POSITION;
48   static const Property::Index OVERSHOOT;
49
50   /**
51    * Create a ScrollConnector.
52    * @return A newly allocated ScrollConnector.
53    */
54   static ScrollConnector* New();
55
56   /**
57    * @copydoc Toolkit::ScrollConnector::SetScrollDomain()
58    */
59   void SetScrollDomain( float min, float max, float length );
60
61   /**
62    * @copydoc Toolkit::ScrollConnector::GetMinLimit()
63    */
64   float GetMinLimit() const
65   {
66     return mMinLimit;
67   }
68
69   /**
70    * @copydoc Toolkit::ScrollConnector::GetMaxLimit()
71    */
72   float GetMaxLimit() const
73   {
74     return mMaxLimit;
75   }
76
77   /**
78    * @copydoc Toolkit::ScrollConnector::GetContentLength()
79    */
80   float GetContentLength() const
81   {
82     return mContentLength;
83   }
84
85   /**
86    * @copydoc Toolkit::ScrollConnector::SetScrollPosition()
87    */
88   void SetScrollPosition( float position );
89
90   /**
91    * @copydoc Toolkit::ScrollConnector::GetScrollPosition()
92    */
93   float GetScrollPosition() const
94   {
95     return mScrollPositionObject.GetProperty<float>( Toolkit::ScrollConnector::SCROLL_POSITION );
96   }
97
98   /**
99    * Signal emitted after the SetScrollPosition() method has been called.
100    */
101   ScrollPositionChangedSignalType& ScrollPositionChangedSignal()
102   {
103     return mScrollPositionChangedSignal;
104   }
105
106   /**
107    * Signal emitted after the SetScrollDomain() method has been called.
108    */
109   DomainChangedSignalType& DomainChangedSignal()
110   {
111     return mDomainChangedSignal;
112   }
113
114   /**
115    * Retrieve the object which provides the "scroll-position" property.
116    * @return The scroll-position object.
117    */
118   Handle GetScrollPositionObject() const
119   {
120     return mScrollPositionObject;
121   }
122
123   /**
124    * Connects a callback function with the object's signals.
125    * @param[in] object The object providing the signal.
126    * @param[in] tracker Used to disconnect the signal.
127    * @param[in] signalName The signal to connect to.
128    * @param[in] functor A newly allocated FunctorDelegate.
129    * @return True if the signal was connected.
130    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
131    */
132   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
133
134 private:
135
136   /**
137    * Create a new ScrollConnector.
138    */
139   ScrollConnector();
140
141   /**
142    * Virtual destructor
143    */
144   virtual ~ScrollConnector();
145
146   // Undefined
147   ScrollConnector(const ScrollConnector&);
148
149   // Undefined
150   ScrollConnector& operator=(const ScrollConnector& rhs);
151
152 private:
153
154   Handle mScrollPositionObject;
155
156   DomainChangedSignalType mDomainChangedSignal;
157   ScrollPositionChangedSignalType mScrollPositionChangedSignal;
158
159   float mMinLimit;
160   float mMaxLimit;
161   float mContentLength;
162 };
163
164 } // namespace Internal
165
166 inline Internal::ScrollConnector& GetImpl(Dali::Toolkit::ScrollConnector& obj)
167 {
168   DALI_ASSERT_ALWAYS(obj);
169
170   Dali::BaseObject& handle = obj.GetBaseObject();
171
172   return static_cast<Internal::ScrollConnector&>(handle);
173 }
174
175 inline const Internal::ScrollConnector& GetImpl(const Dali::Toolkit::ScrollConnector& obj)
176 {
177   DALI_ASSERT_ALWAYS(obj);
178
179   const Dali::BaseObject& handle = obj.GetBaseObject();
180
181   return static_cast<const Internal::ScrollConnector&>(handle);
182 }
183
184 } // namespace Toolkit
185
186 } // namespace Dali
187
188 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_CONNECTOR_H__