Merge "Change BuildRequires of dali2-toolkit to Requires" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-page-path-effect-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_PAGE_PATH_EFFECT_H
2 #define DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_PAGE_PATH_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/devel-api/animation/path-constrainer.h>
23 #include <dali/public-api/animation/linear-constrainer.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-effect-impl.h>
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-page-path-effect.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Internal
34 {
35 /**
36  * @copydoc Toolkit::ScrollViewPagePathEffect
37  */
38 class ScrollViewPagePathEffect : public ScrollViewEffect
39 {
40 public:
41   /**
42    * Constructor
43    * @param[in] path Pages will follow this path
44    * @param[in] forward Vector in page local space which will be aligned with tangent of the path
45    * @param[in] inputPropertyIndex index of the property in the scrollview used to drivce the path
46    * @param[in] viewPageSize size of a page in the scrollview
47    * @param[in] pageCount total number of pages in the scrollview
48    */
49   ScrollViewPagePathEffect(Path path, const Vector3& forward, Dali::Property::Index inputPropertyIndex, const Vector3& viewPageSize, unsigned int pageCount);
50
51 public:
52   /**
53    * @copydoc ScrollViewEffect::ApplyToActor
54    */
55   void ApplyToPage(Actor child, unsigned int pageOrder);
56
57 public:
58   /**
59    * @copydoc ScrollViewEffect::OnAttach
60    */
61   void OnAttach(Toolkit::ScrollView& scrollView) override;
62
63   /**
64    * @copydoc ScrollViewEffect::OnDetach
65    */
66   void OnDetach(Toolkit::ScrollView& scrollView) override;
67
68 protected:
69   /**
70    * A reference counted object may only be deleted by calling Unreference()
71    */
72   virtual ~ScrollViewPagePathEffect();
73
74 private:
75   Vector3               mPageSize;           ///< The logical page size for the 3D effect.
76   PathConstrainer       mPathConstrainer;    ///< PathConstrainer used to constraint position and orientation
77   LinearConstrainer     mLinearConstrainer;  ///< LinearConstrainer used to constraint opacity
78   Dali::Property::Index mInputPropertyIndex; ///< Index of the property in the scrollview used as the parameter for the path
79   unsigned int          mPageCount;          ///< Total number of pages (Needed for wrapping)
80 };
81
82 } // namespace Internal
83
84 // Helpers for public-api forwarding methods
85
86 inline Internal::ScrollViewPagePathEffect& GetImpl(Dali::Toolkit::ScrollViewPagePathEffect& obj)
87 {
88   DALI_ASSERT_ALWAYS(obj);
89
90   Dali::RefObject& handle = obj.GetBaseObject();
91
92   return static_cast<Internal::ScrollViewPagePathEffect&>(handle);
93 }
94
95 inline const Internal::ScrollViewPagePathEffect& GetImpl(const Dali::Toolkit::ScrollViewPagePathEffect& obj)
96 {
97   DALI_ASSERT_ALWAYS(obj);
98
99   const Dali::RefObject& handle = obj.GetBaseObject();
100
101   return static_cast<const Internal::ScrollViewPagePathEffect&>(handle);
102 }
103
104 } // namespace Toolkit
105
106 } // namespace Dali
107
108 #endif // DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_PAGE_PATH_EFFECT_H