Merge "Add support for new accessibility actions" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / shader-effects / page-turn-effect.h
1 #ifndef __DALI_PAGE_TURN_EFFECT_H_
2 #define __DALI_PAGE_TURN_EFFECT_H_
3
4 /*
5  * Copyright (c) 2015 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/shader-effects/shader-effect.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32
33 /**
34  * @brief PageTurnEffect implementation class.
35  */
36 class PageTurnEffect;
37
38 } // namespace Internal
39
40 /**
41  * @brief PageTurnEffect is a custom shader effect to achieve page turn effect for Image actors.
42  *
43  * Usage example:-
44  *
45  * // create shader used for doing page-turn effect\n
46  * PageTurnEffect pageTurnEffect = PageTurnEffect::New();
47  *
48  * // set image actor shader to the page-turn one\n
49  * // for portrait view, one image actor for each page\n
50  * // for landscape view, the page turned over is still visible, so back image is needed \n
51  * //     in this case, create another image Actor using the back image and added to the page actor \n
52  * ImageActor pageActor = ImageActor::New(....); \n
53  * ImageActor backImageActor = ImageActor::New(....); \n
54  * pageActor.Add(backPageActor);\n
55  * pageActor.SetShaderEffect ( pageTurnEffect ); \n
56  *
57  * //set initial values
58  * pageTurnEffect.SetPageSize();\n
59  * pageTurnEffect.SetOriginalCenter();\n
60  * pageTurnEffect.SetIsTurningBack();\n
61  * pageTurnEffect.SetCurrentCenter();\n
62  *
63  * //Animate it with the current center property\n
64  * Animation animation[mAnimationIndex] = Animation::New( ... );\n
65  * animation.AnimateTo(Property( pageTurnEffect, pageTurnEffect.PageTurnEffect::GetCurrentCenterPropertyName() ),
66  *                            currentCenter,
67  *                            AlphaFunction::...);\n
68  * animation[mAnimationIndex].Play(); \n
69  */
70
71 class DALI_IMPORT_API PageTurnEffect : public ShaderEffect
72 {
73 public:
74   /**
75    * @brief Create an uninitialized PageTurnEffect; this can be initialized with PageTurnEffect::New().
76    *
77    * Calling member functions with an uninitialized Dali::Object is not allowed.
78    */
79   PageTurnEffect();
80
81   /**
82    * @brief Destructor
83    *
84    * This is non-virtual since derived Handle types must not contain data or virtual methods.
85    */
86   ~PageTurnEffect();
87
88   /**
89    * @brief Create an initialized PageTurnEffect.
90    *
91    * If fake shadow is used, need to apply the ShaderEffect::HINT_BLENDING
92    * @param[in] enableBlending If true, apply HINT_BLENDING when creating the shader object; If false, disable the HINT_BLENDING
93    * @return A handle to a newly allocated Dali resource.
94    */
95   static PageTurnEffect New( bool enableBlending = true );
96
97   /**
98    * @brief Set the page size of the PageTurnEffect.
99    *
100    * @param [in] pageSize The page size.
101    */
102   void SetPageSize(const Vector2& pageSize);
103
104   /**
105    * @brief Set the origin point of the PageTurnEffect, the position where the mouse/finger is pushed from.
106    *
107    * @param [in] originalCenter The new origin point.
108    */
109   void SetOriginalCenter(const Vector2& originalCenter);
110
111   /**
112    * @brief Set the center point of the PageTurnEffect, the current position of touch motion.
113    *
114    * @param [in] currentCenter The new center point.
115    */
116   void SetCurrentCenter(const Vector2& currentCenter);
117
118   /**
119    * @brief Set whether the current page is turning forward or backward.
120    *
121    * @param [in] isTurningBack True for turning backward or False for turning forward
122    */
123   void SetIsTurningBack(bool isTurningBack);
124
125   /**
126    * @brief Set the width of shadow to be pageSize * shadowWidth.
127    *
128    * @param [in] shadowWidth The width for the simulated shadow
129    */
130   void SetShadowWidth(float shadowWidth);
131
132   /**
133    * @brief Set the spine shadow parameter.
134    *
135    * The two parameters are the major&minor radius (in pixels) to form an ellipse shape
136    * The top-left quarter of this ellipse is used to calculate spine normal for simulating shadow
137    * @param [in] spineShadowParameter The major&minor ellipse radius for the simulated spine shadow
138    */
139   void SetSpineShadowParameter(const Vector2& spineShadowParameter);
140
141   /**
142    * @brief Get the name for the page size property.
143    *
144    * @return A std::string containing the property name
145    */
146   const std::string& GetPageSizePropertyName() const;
147
148   /**
149   * @brief Get the name for the origin center property.
150   *
151   * @return A std::string containing the property name
152   */
153   const std::string& GetOriginalCenterPropertyName() const;
154
155   /**
156    * @brief Get the name for the current center property.
157    *
158    * which can be used in Animation API's
159    * @return A std::string containing the property name
160    */
161   const std::string& GetCurrentCenterPropertyName() const;
162
163 public: // Not intended for application developers
164
165   DALI_INTERNAL PageTurnEffect( ShaderEffect handle, Internal::PageTurnEffect* shaderExtension );
166
167 };  //end of PageTurnEffect class
168
169 } // namespace Toolkit
170
171 } // namespace Dali
172
173 #endif /* __DALI_TOOLKIT_SC_CURVE_EFFECT_H_ */