Conversion to Apache 2.0 license
[platform/core/uifw/dali-toolkit.git] / capi / dali-toolkit / public-api / controls / scrollable / scroll-view / scroll-view-twist-effect.h
1 #ifndef __DALI_TOOLKIT_SCROLL_VIEW_TWIST_EFFECT_H__
2 #define __DALI_TOOLKIT_SCROLL_VIEW_TWIST_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_SCROLL_VIEW_MODULE
23  * @{
24  */
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
28
29 namespace Dali DALI_IMPORT_API
30 {
31
32 class Actor;
33
34 namespace Toolkit
35 {
36
37 class ScrollViewEffect;
38
39 namespace Internal DALI_INTERNAL
40 {
41 class ScrollViewTwistEffect;
42 }
43
44 /**
45  * @brief ScrollView effect that twists pages onto screen when transitioning.
46  */
47 class ScrollViewTwistEffect : public ScrollViewEffect
48 {
49
50 public:
51
52   static const float DEFAULT_MINIMUM_DISTANCE_FOR_SHRINK; ///< The min distance for shrink
53
54 public:
55
56   /**
57    * @brief Create an initialized ScrollViewTwistEffect.
58    *
59    * @return A handle to a newly allocated Dali resource.
60    */
61   static ScrollViewTwistEffect New();
62
63   /**
64    * @brief Create an uninitialized ScrollViewTwistEffect; this can be initialized with ScrollViewTwistEffect::New().
65    *
66    * Calling member functions with an uninitialized Toolkit::ScrollViewTwistEffect is not allowed.
67    */
68   ScrollViewTwistEffect();
69
70   /**
71    * @brief Downcast an Object handle to ScrollViewTwistEffect.
72    *
73    * If handle points to a ScrollViewTwistEffect the
74    * downcast produces valid handle. If not the returned handle is left uninitialized.
75    * @param[in] handle Handle to an object
76    * @return handle to a ScrollViewTwistEffect or an uninitialized handle
77    */
78   static ScrollViewTwistEffect DownCast( BaseHandle handle );
79
80   /**
81    * @brief Gets the minimum animation distance for the shrink effect to
82    * occur.
83    *
84    * @return The minimum distance in seconds is returned.
85    */
86   float GetMinimumDistanceForShrink() const;
87
88   /**
89    * @brief Sets the minimum animation distance for the shrink effect
90    * to occur.
91    *
92    * @param[in] distance The minimum distance in pixels (default = 0.0)
93    * i.e. any flick will result in shrinking.
94    */
95   void SetMinimumDistanceForShrink(float distance);
96
97   /**
98    * @brief Enable or disable this effect.
99    *
100    * @param[in] enableFlag Set to true if the effect should be enabled.
101    */
102   void EnableEffect(bool enableFlag);
103
104   /**
105    * @brief Manually apply effect to an Actor.
106    *
107    * @param[in] child The child Actor to be affected by this effect.
108    * @param[in] additionalEffects Whether just the basic effect (delay)
109    * should be applied. Or all effects (delay, rotation, scaling).
110    * For all effects set to true. Default is true i.e. apply all effects.
111    * @param[in] angleSwing The maximum amount the child actor should
112    * rotate in radians for each axis (X and Y) if the scrollview reaches
113    * overshoot. Default is PI/2 i.e. 90 degrees rotation.
114    * @param[in] scaleAmount The relative amount to shrink Actors as they
115    * are panned fast (flick animation). default is 0.125 (12.5% shrinkage)
116    * @param[in] delayMin The minimum delay coefficient for Actors at the
117    * scroll-view center. Set to 0 for instantaneous, and 1 for infinite delay.
118    * Default is 0.0f
119    * @param[in] delayMax The maximum delay coefficient for Actors at the
120    * scroll-view approx 1 ScrollView size from the center. Set to 0 for
121    * instantaneous, and 1 for infinite delay. Default is 0.9f (a slight delay)
122    */
123   void ApplyToActor( Actor child,
124                      bool additionalEffects = true,
125                      const Vector2& angleSwing = Vector2( Math::PI_4, Math::PI_4 ),
126                      float scaleAmount = 0.125f,
127                      float delayMin = 0.0f,
128                      float delayMax = 0.9f );
129
130   /**
131    * @brief Set the maximum swing angle when at zero drop off.
132    *
133    * @param[in] maxSwingAngle maximum swing angle for x and y axes
134    */
135   void SetMaxSwingAngle(const Vector2& maxSwingAngle);
136
137   /**
138    * @brief Set the drop off values to affect the amount of swing
139    * angle applied to an actor the further it is from the scroll
140    * position.
141    *
142    * A drop off of 0.0f means no angle drop off while 1.0f will reduce
143    * the angle to zero over the distance supplied for that axis.
144    *
145    * Example maxSwingAngle.x is Pi, dropOff.x is 0.5f and distance.x is 100.0f:
146    *    The angle on the x axis will reduce to (0.5f * Pi) over 100 pixels
147    *
148    * @param[in] dropOff amount to reduce swing angle by in the range [0.0f, 1.0f]. 0.0f
149    * @param[in] distance distance to apply dropOff in pixels
150    * @param[in] function Alpha Function to affect how drop off is applied over distance, NULL for linear application
151    */
152   void SetSwingDropOff(const Vector2& dropOff, const Vector2& distance, AlphaFunction function = NULL);
153
154 protected:
155
156   /**
157    * @brief This constructor is used by Dali New() methods.
158    *
159    * @param [in] impl A pointer to a newly allocated Dali resource
160    */
161   ScrollViewTwistEffect(Internal::ScrollViewTwistEffect *impl);
162
163 };
164
165 } // namespace Toolkit
166
167 } // namespace Dali
168
169 /**
170  * @}
171  */
172 #endif // __DALI_TOOLKIT_SCROLL_VIEW_TWIST_EFFECT_H__