1 #ifndef __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__
2 #define __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
21 * @addtogroup CAPI_DALI_TOOLKIT_SCROLL_VIEW_MODULE
26 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
28 namespace Dali DALI_IMPORT_API
36 namespace Internal DALI_INTERNAL
38 class ScrollViewCustomEffect;
42 * @brief This class has many transition effects for use when scrolling pages, e.g opacity, rotation, swing, translation.
44 * It should be used on the following Actor hierarchy:
50 * You should ensure ScrollView's default constraints have been removed,
51 * by calling ScrollView::RemoveConstraintsFromChildren() before applying
52 * this effect to ScrollView.
55 * ApplyToPage(...) method should be called on every page.
57 * Automatic operation:
60 class ScrollViewCustomEffect : public ScrollViewEffect
64 * @brief Bitflags for effect types.
68 FlagTranslate = 0x0001, ///< indicates that translation is wanted
69 FlagTranslateIn = 0x0002, ///< translating onto the screen is a separate value
70 FlagTranslateOut = 0x0004, ///< translating off the screen is a separate value
71 FlagTranslateMask = FlagTranslate | FlagTranslateIn | FlagTranslateOut,
72 FlagRotate = 0x0008, ///< indicates that a positional rotation is wanted (rotate all pages around a single point like inner cube effect)
73 FlagRotateIn = 0x0010, ///< rotating onto the screen is a separate value
74 FlagRotateOut = 0x0020, ///< rotating off the screen is a separate value
75 FlagRotateAngleForcedOrigin = 0x0040,
76 FlagRotateMask = FlagRotate | FlagRotateIn | FlagRotateOut | FlagRotateAngleForcedOrigin,
77 FlagRotateOrigin = 0x0080, ///< indicates to use a global origin to rotate all pages around
78 FlagRotateOriginIn = 0x0100, ///<
79 FlagRotateOriginOut = 0x0200, ///<
80 FlagRotateOriginMask = FlagRotateOrigin | FlagRotateOriginIn | FlagRotateOriginOut,
81 FlagSwingAngle = 0x0400, ///< indicates that a SwingAngle is wanted (rotate all pages around a single point like inner cube effect)
82 FlagSwingAngleIn = 0x0800, ///< SwingAngle onto the screen is a separate value
83 FlagSwingAngleOut = 0x1000, ///< SwingAngle off the screen is a separate value
84 FlagSwingAngleMask = FlagSwingAngle | FlagSwingAngleIn | FlagSwingAngleOut,
85 FlagSwingAnchor = 0x2000, ///< indicates that a swing requires a specified anchor point, otherwise swings around centre of actor (rotate all pages around a single point like inner cube effect)
86 FlagSwingAnchorIn = 0x4000, ///< Swing anchor onto the screen is a separate value
87 FlagSwingAnchorOut = 0x8000, ///< Swing anchor off the screen is a separate value
88 FlagSwingAnchorMask = FlagSwingAnchor | FlagSwingAnchorIn | FlagSwingAnchorOut,
89 FlagOpacityThreshold = 0x00010000, ///<
90 FlagOpacityThresholdIn = 0x00020000, ///<
91 FlagOpacityThresholdOut = 0x00040000, ///<
92 FlagOpacityThresholdMask = FlagOpacityThreshold | FlagOpacityThresholdIn | FlagOpacityThresholdOut,
93 FlagTranslationAlphaFunctionIn = 0x00080000,
94 FlagTranslationAlphaFunctionOut = 0x00100000,
95 FlagTranslationAlphaFunctionMask = FlagTranslationAlphaFunctionIn | FlagTranslationAlphaFunctionOut,
96 FlagRotateAlphaFunctionIn = 0x00200000,
97 FlagRotateAlphaFunctionOut = 0x00400000,
98 FlagRotateAlphaFunctionMask = FlagRotateAlphaFunctionIn | FlagRotateAlphaFunctionOut,
99 FlagRotateOriginAlphaFunctionIn = 0x00800000,
100 FlagRotateOriginAlphaFunctionOut = 0x01000000,
101 FlagRotateOriginAlphaFunctionMask = FlagRotateOriginAlphaFunctionIn | FlagRotateOriginAlphaFunctionOut,
102 FlagSwingAngleAlphaFunctionIn = 0x02000000,
103 FlagSwingAngleAlphaFunctionOut = 0x04000000,
104 FlagSwingAngleAlphaFunctionMask = FlagSwingAngleAlphaFunctionIn | FlagSwingAngleAlphaFunctionOut,
105 FlagSwingAnchorAlphaFunctionIn = 0x08000000,
106 FlagSwingAnchorAlphaFunctionOut = 0x10000000,
107 FlagSwingAnchorAlphaFunctionMask = FlagSwingAnchorAlphaFunctionIn | FlagSwingAnchorAlphaFunctionOut,
108 FlagOpacityAlphaFunctionIn = 0x20000000,
109 FlagOpacityAlphaFunctionOut = 0x40000000,
110 FlagOpacityAlphaFunctionMask = FlagOpacityAlphaFunctionIn | FlagOpacityAlphaFunctionOut
114 * @brief Create an initialized ScrollViewCustomEffect.
116 * @return A handle to a newly allocated Dali resource.
118 static ScrollViewCustomEffect New();
121 * @brief Create an uninitialized ScrollViewCustomEffect; this can be initialized with ScrollViewCustomEffect::New().
123 * Calling member functions with an uninitialized Toolkit::ScrollViewCustomEffect is not allowed.
125 ScrollViewCustomEffect();
128 * @brief Downcast an Object handle to ScrollViewCustomEffect.
130 * If handle points to a ScrollViewCustomEffect the downcast
131 * produces valid handle. If not the returned handle is left
134 * @param[in] handle Handle to an object
135 * @return handle to a ScrollViewCustomEffect or an uninitialized handle
137 static ScrollViewCustomEffect DownCast( BaseHandle handle );
140 * @brief SetPageSpacing.
144 void SetPageSpacing(const Vector2& spacing);
147 * @brief SetPageTranslation sets a simple translate on/off value.
151 void SetPageTranslation(const Vector3& translation);
154 * @brief SetPageTranslation.
156 * @param translationIn
157 * @param translationOut
159 void SetPageTranslation(const Vector3& translationIn, const Vector3& translationOut);
162 * @brief SetPageTranslationIn.
165 void SetPageTranslationIn(const Vector3& translation);
168 * @brief SetPageTranslationOut.
172 void SetPageTranslationOut(const Vector3& translation);
175 * @brief SetPageTranslateAlphaFunction.
179 void SetPageTranslateAlphaFunction(AlphaFunction func);
182 * @brief SetPageTranslateAlphaFunction.
187 void SetPageTranslateAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
190 * @brief SetPageTranslateAlphaFunctionIn.
194 void SetPageTranslateAlphaFunctionIn(AlphaFunction func);
197 * @brief SetPageTranslateAlphaFunctionOut.
200 void SetPageTranslateAlphaFunctionOut(AlphaFunction func);
203 * @brief SetGlobalPageRotation.
208 void SetGlobalPageRotation(float angle, const Vector3& axis);
211 * @brief SetAnglePageRotation uses the angle and page size passed in on creation to create a faked origin (inner cube needs this method).
215 void SetAngledOriginPageRotation(const Vector3& angle);
218 * @brief SetGlobalPageRotation.
225 void SetGlobalPageRotation(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
228 * @brief SetGlobalPageRotationIn.
233 void SetGlobalPageRotationIn(float angle, const Vector3& axis);
236 * @brief SetGlobalPageRotationOut.
241 void SetGlobalPageRotationOut(float angle, const Vector3& axis);
244 * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
246 * - The default value is (0,0,0)
249 void SetGlobalPageRotationOrigin(const Vector3& origin);
252 * @brief SetGlobalPageRotationOrigin.
257 void SetGlobalPageRotationOrigin(const Vector3& originIn, const Vector3& originOut);
260 * @brief SetGlobalPageRotationOriginIn.
264 void SetGlobalPageRotationOriginIn(const Vector3& origin);
267 * @brief SetGlobalPageRotationOriginOut.
271 void SetGlobalPageRotationOriginOut(const Vector3& origin);
274 * @brief SetSwingAngle.
279 void SetSwingAngle(float angle, const Vector3& axis);
282 * @brief SetSwingAngle.
289 void SetSwingAngle(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
292 * @brief SetSwingAngleIn.
297 void SetSwingAngleIn(float angle, const Vector3& axis);
300 * @brief SetSwingAngleOut.
305 void SetSwingAngleOut(float angle, const Vector3& axis);
308 * @brief SetSwingAngleAlphaFunction.
312 void SetSwingAngleAlphaFunction(AlphaFunction func);
315 * @brief SetSwingAngleAlphaFunction.
320 void SetSwingAngleAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
323 * @brief SetSwingAngleAlphaFunctionIn.
327 void SetSwingAngleAlphaFunctionIn(AlphaFunction func);
330 * @brief SetSwingAngleAlphaFunctionOut.
334 void SetSwingAngleAlphaFunctionOut(AlphaFunction func);
337 * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
339 * - The default value is (0,0,0)
342 void SetSwingAnchor(const Vector3& anchor);
345 * @brief SetSwingAnchor.
350 void SetSwingAnchor(const Vector3& anchorIn, const Vector3& anchorOut);
353 * @brief SetSwingAnchorIn.
357 void SetSwingAnchorIn(const Vector3& anchor);
360 * @brief SetSwingAnchorOut.
364 void SetSwingAnchorOut(const Vector3& anchor);
367 * @brief SetSwingAnchorAlphaFunction.
371 void SetSwingAnchorAlphaFunction(AlphaFunction func);
374 * @brief SetSwingAnchorAlphaFunction.
379 void SetSwingAnchorAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
382 * @brief SetSwingAnchorAlphaFunctionIn.
386 void SetSwingAnchorAlphaFunctionIn(AlphaFunction func);
389 * @brief SetSwingAnchorAlphaFunctionOut.
392 void SetSwingAnchorAlphaFunctionOut(AlphaFunction func);
395 * @brief SetOpacityThreshold.
399 void SetOpacityThreshold(float thresh);
402 * @brief SetOpacityThreshold.
407 void SetOpacityThreshold(float threshIn, float threshOut);
410 * @brief SetOpacityThresholdIn.
414 void SetOpacityThresholdIn(float thresh);
417 * @brief SetOpacityThresholdOut.
421 void SetOpacityThresholdOut(float thresh);
424 * @brief SetOpacityAlphaFunction.
428 void SetOpacityAlphaFunction(AlphaFunction func);
431 * @brief SetOpacityAlphaFunction.
436 void SetOpacityAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
439 * @brief SetOpacityAlphaFunctionIn.
443 void SetOpacityAlphaFunctionIn(AlphaFunction func);
446 * @brief SetOpacityAlphaFunctionOut.
450 void SetOpacityAlphaFunctionOut(AlphaFunction func);
453 * @brief Applies the effect to a page.
455 * @param page the page to apply this effect to
456 * @param pageSize not needed, page size is determined by scroll view
459 void ApplyToPage(Actor page, Vector3 pageSize);
464 * @brief This constructor is used by Dali New() methods.
466 * @param [in] impl A pointer to a newly allocated Dali resource
468 ScrollViewCustomEffect( Internal::ScrollViewCustomEffect *impl );
472 } // namespace Toolkit
479 #endif // __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__