[dali_1.4.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / page-turn-view / page-turn-effect.h
1 #ifndef DALI_PAGE_TURN_EFFECT_H
2 #define DALI_PAGE_TURN_EFFECT_H
3
4 /*
5  * Copyright (c) 2019 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
23 namespace Dali
24 {
25
26 namespace Toolkit
27 {
28
29 namespace Internal
30 {
31
32
33 /**
34  * @brief Re-applies PageTurnEffect internal constraints
35  * The internal constraint uses the OriginalCenter property and the CURRENT_CENTER Property
36  * to update the variety of common parameters which are with the same value for all the vertices.
37  * Note: For each actor, the constraints are applied in the same order as the calls to Actor::ApplyConstraint().
38  * So if there are other contraints applied to the ORIGINAL_CENTER or CURRENT_CENTER while when using this effect,
39  * call this method to get the internal constraints and re-apply it afterwards.
40  *
41  * @param[in] actor The page turn actor to which internal constraints should be re-applied
42  * @param[in] pageHeight The page height.
43  */
44 void PageTurnApplyInternalConstraint( Actor& actor, float pageHeight );
45
46 /**
47  * @brief Create a new PageTurnEffect
48  * PageTurnEffect is a custom shader to achieve page turn effect for image views.
49  *
50  * Usage example:-
51  *
52  * // create shader used for doing page-turn effect\n
53  * Property::Map pageTurnEffect = CreatePageTurnEffect();
54  *
55  * // set image view custom shader to the page-turn one\n
56  * // for portrait view, the image is rendered as the front side of  page\n
57  * // for landscape view, the back side becomes visible when the page is turned over. \n
58  * //     in this case, the left and right half of the image are renderer as the front and back side separately. \n
59  * ImageView page = ImageView::New(....); \n
60  * page.SetProperty ( ImageView::Property::IMAGE, pageTurnEffect ); \n
61  *
62  * //set initial values
63  * page.SetProperty( page.GetPropertyIndex("uIsTurningBack",) bool );\n
64  * page.SetProperty( page.GetPropertyIndex("uSpineShadowParameter",) Vector2 );\n
65  * page.SetProperty( page.GetPropertyIndex("ORIGINAL_CENTER"), Vector2 );\n
66  * page.SetProperty( page.GetPropertyIndex("CURRENT_CENTER"), Vector2 );\n
67  * page.SetProperty( page.GetPropertyIndex("uCommonParameters"), Matrix );\n
68  * page.SetProperty( page.GetPropertyIndex("uTextureWidth"), float ); // Set to 1.0 for single-sided or 2.0 for double-sided \n
69  * PageTurnApplyInternalConstraint( page );\n
70  *
71  * //Animate it with the current center property\n
72  * Animation animation = Animation::New( ... );\n
73  * animation.AnimateTo(Property( page, "CURRENT_CENTER" ),
74  *                               currentCenter,
75  *                               AlphaFunction::...);\n
76  * animation.Play(); \n
77  *
78  */
79 Property::Map CreatePageTurnEffect();
80
81 } // namespace Internal
82
83 } // namespace Toolkit
84
85 } // namespace Dali
86
87 #endif // DALI_PAGE_TURN_EFFECT_H