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