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