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