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