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