Partial fix for homescreen panning issue
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-effect-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_EFFECT_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_EFFECT_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 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
23 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
24
25 namespace Dali
26 {
27
28 class Animation;
29
30 namespace Toolkit
31 {
32
33 class ScrollView;
34
35 namespace Internal
36 {
37
38 class ScrollViewEffect;
39
40 /**
41  * @copydoc Toolkit::ScrollViewEffect
42  */
43 class ScrollViewEffect : public Dali::BaseObject, public ConnectionTracker
44 {
45
46 public:
47
48   ScrollViewEffect();
49
50   /**
51    * Attaches this effect to scrollView.
52    * @pre must not be already attached to a scrollView
53    * @note internally the scrollView effect holds a weak reference
54    * to scrollView.
55    * @param[in] scrollView The scrollView instance to attach to.
56    */
57   void Attach(Toolkit::ScrollView& scrollView);
58
59   /**
60    * Attaches this effect to scrollView.
61    * @pre must not be already attached to a scrollView
62    * @param[in] scrollView The scrollView instance to attach to.
63    */
64   void Detach(Toolkit::ScrollView& scrollView);
65
66 public:
67
68   /**
69    * Called upon Attaching of effect to a scrollView instance.
70    *
71    * This will be called once.
72    *
73    * @param[in] scrollView The attached scrollView instance.
74    */
75   virtual void OnAttach(Toolkit::ScrollView& scrollView) = 0;
76
77   /**
78    * Called upon Detaching of effect from a scrollView instance.
79    *
80    * This will be called once.
81    *
82    * @param[in] scrollView The attached scrollView instance.
83    */
84   virtual void OnDetach(Toolkit::ScrollView& scrollView) = 0;
85
86 protected:
87
88   /**
89    * Returns the ScrollView handle that this effect is
90    * attached to.
91    * @note if it's not attached to any ScrollView then
92    * will return an uninitialized handle.
93    * @return The scrollView handle is returned.
94    */
95   Toolkit::ScrollView GetScrollView();
96
97 protected:
98
99   /**
100    * A reference counted object may only be deleted by calling Unreference()
101    */
102   virtual ~ScrollViewEffect();
103
104 private:
105
106   Toolkit::Internal::ScrollView *mScrollViewImpl; ///< Attached ScrollView instance (pointer to implementation)
107
108 };
109
110 } // namespace Internal
111
112 // Helpers for public-api forwarding methods
113
114 inline Internal::ScrollViewEffect& GetImpl(Dali::Toolkit::ScrollViewEffect& obj)
115 {
116   DALI_ASSERT_ALWAYS(obj);
117
118   Dali::RefObject& handle = obj.GetBaseObject();
119
120   return static_cast<Internal::ScrollViewEffect&>(handle);
121 }
122
123 inline const Internal::ScrollViewEffect& GetImpl(const Dali::Toolkit::ScrollViewEffect& obj)
124 {
125   DALI_ASSERT_ALWAYS(obj);
126
127   const Dali::RefObject& handle = obj.GetBaseObject();
128
129   return static_cast<const Internal::ScrollViewEffect&>(handle);
130 }
131
132 } // namespace Toolkit
133
134 } // namespace Dali
135
136 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_EFFECT_H__