[AT-SPI] Fix role setting
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scrollable-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_SCROLLABLE_H
2 #define DALI_TOOLKIT_INTERNAL_SCROLLABLE_H
3
4 /*
5  * Copyright (c) 2019 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/animation/alpha-function.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 class Scrollable;
38 typedef IntrusivePtr<Scrollable> ScrollablePtr;
39
40 /**
41  * @copydoc Toolkit::Scrollable
42  */
43 class Scrollable : public Control
44 {
45 public:
46
47   /**
48    * @copydoc Dali::Toolkit::Scrollable::IsOvershootEnabled
49    */
50   bool IsOvershootEnabled() const;
51
52   /**
53    * @copydoc Dali::Toolkit::Scrollable::SetOvershootEnabled
54    */
55   void SetOvershootEnabled(bool enable);
56
57   /**
58    * Adds actor as an Overlay to Scrollable
59    * This method is called by Add-on UI components
60    * such as scroll bars, page indicators.
61    * @param[in] actor Actor to add as an overlay.
62    */
63   virtual void AddOverlay(Actor actor) = 0;
64
65   /**
66    * Removes overlay actor from Scrollable
67    * This method is called by Add-on UI components
68    * such as scroll bars, page indicators.
69    * @param[in] actor Actor overlay to remove.
70    */
71   virtual void RemoveOverlay(Actor actor) = 0;
72
73   /**
74    * Retrieves current scroll position.
75    * @returns The current scroll position.
76    */
77   virtual Vector2 GetCurrentScrollPosition() const = 0;
78
79   /**
80    * Scrolls Scrollable to position specified (contents will scroll to this position)
81    * Position 0,0 is the origin. Increasing X scrolls contents left, while
82    * increasing Y scrolls contents up.
83    * @param[in] position The position to scroll to.
84    * @param[in] duration The duration of the animation in seconds
85    */
86   virtual void ScrollTo(const Vector2 &position, float duration) = 0;
87
88   /**
89    * Set the color of the overshoot effect.
90    * @parm[in] color The color of the overshoot effect
91    */
92   virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
93
94   /**
95    * Retrieve the color of the overshoot effect.
96    * @return The color of the overshoot effect.
97    */
98   Vector4 GetOvershootEffectColor() const;
99
100   /**
101    * @copydoc Dali::Toolkit::Scrollable::SetOvershootAnimationSpeed(float pixelsPerSecond)
102    */
103   void SetOvershootAnimationSpeed( float pixelsPerSecond );
104
105   /**
106    * @copydoc Dali::Toolkit::Scrollable::GetOvershootAnimationSpeed()
107    */
108   float GetOvershootAnimationSpeed() const;
109
110   /**
111    * @copydoc Dali::Toolkit::Scrollable::GetOvershootSize()
112    */
113   const Vector2& GetOvershootSize() const;
114
115   /**
116    * Set the size of the overshoot effect.
117    * @parm[in] size The size of the overshoot effect
118    */
119   virtual void SetOvershootSize( const Vector2& size ) = 0;
120
121 protected: // From Control
122
123   /**
124    * @copydoc Control::OnInitialize
125    */
126   virtual void OnInitialize() override;
127
128 private:
129
130   /**
131    * Temporary function to override EnableScrollOvershoot functionality for overshoot
132    * Only ScrollView needs to override this as HQ has not requested disable functionality in ItemView
133    * @param[in] enable true to enable, false to disable overshoot indicator
134    */
135   virtual void EnableScrollOvershoot(bool enable) {}
136
137 public: //Signals
138
139   /**
140    * @copydoc Dali::Toolkit::Scrollable::ScrollStartedSignal()
141    */
142   Toolkit::Scrollable::ScrollStartedSignalType& ScrollStartedSignal();
143
144   /**
145    * @copydoc Dali::Toolkit::Scrollable::ScrollUpdatedSignal()
146    */
147   Toolkit::Scrollable::ScrollUpdatedSignalType& ScrollUpdatedSignal();
148
149   /**
150    * @copydoc Dali::Toolkit::Scrollable::ScrollCompletedSignal()
151    */
152   Toolkit::Scrollable::ScrollCompletedSignalType& ScrollCompletedSignal();
153
154   /**
155    * Connects a callback function with the object's signals.
156    * @param[in] object The object providing the signal.
157    * @param[in] tracker Used to disconnect the signal.
158    * @param[in] signalName The signal to connect to.
159    * @param[in] functor A newly allocated FunctorDelegate.
160    * @return True if the signal was connected.
161    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
162    */
163   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
164
165   //properties
166
167   /**
168    * Called when a property of an object of this type is set.
169    * @param[in] object The object whose property is set.
170    * @param[in] index The property index.
171    * @param[in] value The new property value.
172    */
173   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
174
175   /**
176    * Called to retrieve a property of an object of this type.
177    * @param[in] object The object whose property is to be retrieved.
178    * @param[in] index The property index.
179    * @return The current value of the property.
180    */
181   static Property::Value GetProperty( BaseObject* object, Property::Index index );
182
183 protected:
184
185   /**
186    * Removed default constructor.
187    */
188   Scrollable() = delete;
189
190   /**
191    * @brief Construct a new Scrollable.
192    *
193    * @param[in] behaviourFlags Flags to enable
194    */
195   Scrollable( ControlBehaviour behaviourFlags );
196
197   /**
198    * A reference counted object may only be deleted by calling Unreference()
199    */
200   virtual ~Scrollable();
201
202 private:
203
204   /**
205    * Gets position property.
206    *
207    * @return The current position
208    */
209   Vector2 GetPropertyPosition() const;
210
211 private:
212
213   // Undefined
214   Scrollable(const Scrollable&);
215
216   // Undefined
217   Scrollable& operator=(const Scrollable& rhs);
218
219 protected:
220
221   Vector4         mOvershootEffectColor;    ///<The color of the overshoot bouncing effect
222   float           mOvershootAnimationSpeed; ///<The speed of the overshoot animation (pixels per second)
223   Vector2         mOvershootSize;           ///<The size of the overshoot effect
224
225   Dali::AlphaFunction::BuiltinFunction mScrollToAlphaFunction; ///< The ScrollTo() animations use this
226
227   Toolkit::Scrollable::ScrollStartedSignalType mScrollStartedSignal;
228   Toolkit::Scrollable::ScrollUpdatedSignalType mScrollUpdatedSignal;
229   Toolkit::Scrollable::ScrollCompletedSignalType mScrollCompletedSignal;
230
231 private:
232
233   bool mOvershootEnabled:1;
234 };
235
236 } // namespace Internal
237
238 // Helpers for public-api forwarding methods
239
240 inline Toolkit::Internal::Scrollable& GetImpl(Toolkit::Scrollable& scrollable)
241 {
242   DALI_ASSERT_ALWAYS(scrollable);
243
244   Dali::RefObject& handle = scrollable.GetImplementation();
245
246   return static_cast<Toolkit::Internal::Scrollable&>(handle);
247 }
248
249 inline const Toolkit::Internal::Scrollable& GetImpl(const Toolkit::Scrollable& scrollable)
250 {
251   DALI_ASSERT_ALWAYS(scrollable);
252
253   const Dali::RefObject& handle = scrollable.GetImplementation();
254
255   return static_cast<const Toolkit::Internal::Scrollable&>(handle);
256 }
257
258 } // namespace Toolkit
259
260 } // namespace Dali
261
262 #endif // DALI_TOOLKIT_INTERNAL_SCROLLABLE_H