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