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