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 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
24 namespace Dali DALI_IMPORT_API
32 namespace Internal DALI_INTERNAL
34 class ScrollViewCustomEffect;
38 * @brief This class has many transition effects for use when scrolling pages, e.g opacity, rotation, swing, translation.
40 * It should be used on the following Actor hierarchy:
46 * You should ensure ScrollView's default constraints have been removed,
47 * by calling ScrollView::RemoveConstraintsFromChildren() before applying
48 * this effect to ScrollView.
51 * ApplyToPage(...) method should be called on every page.
53 * Automatic operation:
56 class ScrollViewCustomEffect : public ScrollViewEffect
60 * @brief Bitflags for effect types.
64 FlagTranslate = 0x0001, ///< indicates that translation is wanted
65 FlagTranslateIn = 0x0002, ///< translating onto the screen is a separate value
66 FlagTranslateOut = 0x0004, ///< translating off the screen is a separate value
67 FlagTranslateMask = FlagTranslate | FlagTranslateIn | FlagTranslateOut,
68 FlagRotate = 0x0008, ///< indicates that a positional rotation is wanted (rotate all pages around a single point like inner cube effect)
69 FlagRotateIn = 0x0010, ///< rotating onto the screen is a separate value
70 FlagRotateOut = 0x0020, ///< rotating off the screen is a separate value
71 FlagRotateAngleForcedOrigin = 0x0040,
72 FlagRotateMask = FlagRotate | FlagRotateIn | FlagRotateOut | FlagRotateAngleForcedOrigin,
73 FlagRotateOrigin = 0x0080, ///< indicates to use a global origin to rotate all pages around
74 FlagRotateOriginIn = 0x0100, ///<
75 FlagRotateOriginOut = 0x0200, ///<
76 FlagRotateOriginMask = FlagRotateOrigin | FlagRotateOriginIn | FlagRotateOriginOut,
77 FlagSwingAngle = 0x0400, ///< indicates that a SwingAngle is wanted (rotate all pages around a single point like inner cube effect)
78 FlagSwingAngleIn = 0x0800, ///< SwingAngle onto the screen is a separate value
79 FlagSwingAngleOut = 0x1000, ///< SwingAngle off the screen is a separate value
80 FlagSwingAngleMask = FlagSwingAngle | FlagSwingAngleIn | FlagSwingAngleOut,
81 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)
82 FlagSwingAnchorIn = 0x4000, ///< Swing anchor onto the screen is a separate value
83 FlagSwingAnchorOut = 0x8000, ///< Swing anchor off the screen is a separate value
84 FlagSwingAnchorMask = FlagSwingAnchor | FlagSwingAnchorIn | FlagSwingAnchorOut,
85 FlagOpacityThreshold = 0x00010000, ///<
86 FlagOpacityThresholdIn = 0x00020000, ///<
87 FlagOpacityThresholdOut = 0x00040000, ///<
88 FlagOpacityThresholdMask = FlagOpacityThreshold | FlagOpacityThresholdIn | FlagOpacityThresholdOut,
89 FlagTranslationAlphaFunctionIn = 0x00080000,
90 FlagTranslationAlphaFunctionOut = 0x00100000,
91 FlagTranslationAlphaFunctionMask = FlagTranslationAlphaFunctionIn | FlagTranslationAlphaFunctionOut,
92 FlagRotateAlphaFunctionIn = 0x00200000,
93 FlagRotateAlphaFunctionOut = 0x00400000,
94 FlagRotateAlphaFunctionMask = FlagRotateAlphaFunctionIn | FlagRotateAlphaFunctionOut,
95 FlagRotateOriginAlphaFunctionIn = 0x00800000,
96 FlagRotateOriginAlphaFunctionOut = 0x01000000,
97 FlagRotateOriginAlphaFunctionMask = FlagRotateOriginAlphaFunctionIn | FlagRotateOriginAlphaFunctionOut,
98 FlagSwingAngleAlphaFunctionIn = 0x02000000,
99 FlagSwingAngleAlphaFunctionOut = 0x04000000,
100 FlagSwingAngleAlphaFunctionMask = FlagSwingAngleAlphaFunctionIn | FlagSwingAngleAlphaFunctionOut,
101 FlagSwingAnchorAlphaFunctionIn = 0x08000000,
102 FlagSwingAnchorAlphaFunctionOut = 0x10000000,
103 FlagSwingAnchorAlphaFunctionMask = FlagSwingAnchorAlphaFunctionIn | FlagSwingAnchorAlphaFunctionOut,
104 FlagOpacityAlphaFunctionIn = 0x20000000,
105 FlagOpacityAlphaFunctionOut = 0x40000000,
106 FlagOpacityAlphaFunctionMask = FlagOpacityAlphaFunctionIn | FlagOpacityAlphaFunctionOut
110 * @brief Create an initialized ScrollViewCustomEffect.
112 * @return A handle to a newly allocated Dali resource.
114 static ScrollViewCustomEffect New();
117 * @brief Create an uninitialized ScrollViewCustomEffect; this can be initialized with ScrollViewCustomEffect::New().
119 * Calling member functions with an uninitialized Toolkit::ScrollViewCustomEffect is not allowed.
121 ScrollViewCustomEffect();
124 * @brief Downcast an Object handle to ScrollViewCustomEffect.
126 * If handle points to a ScrollViewCustomEffect the downcast
127 * produces valid handle. If not the returned handle is left
130 * @param[in] handle Handle to an object
131 * @return handle to a ScrollViewCustomEffect or an uninitialized handle
133 static ScrollViewCustomEffect DownCast( BaseHandle handle );
136 * @brief SetPageSpacing.
140 void SetPageSpacing(const Vector2& spacing);
143 * @brief SetPageTranslation sets a simple translate on/off value.
147 void SetPageTranslation(const Vector3& translation);
150 * @brief SetPageTranslation.
152 * @param translationIn
153 * @param translationOut
155 void SetPageTranslation(const Vector3& translationIn, const Vector3& translationOut);
158 * @brief SetPageTranslationIn.
161 void SetPageTranslationIn(const Vector3& translation);
164 * @brief SetPageTranslationOut.
168 void SetPageTranslationOut(const Vector3& translation);
171 * @brief SetPageTranslateAlphaFunction.
175 void SetPageTranslateAlphaFunction(AlphaFunction func);
178 * @brief SetPageTranslateAlphaFunction.
183 void SetPageTranslateAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
186 * @brief SetPageTranslateAlphaFunctionIn.
190 void SetPageTranslateAlphaFunctionIn(AlphaFunction func);
193 * @brief SetPageTranslateAlphaFunctionOut.
196 void SetPageTranslateAlphaFunctionOut(AlphaFunction func);
199 * @brief SetGlobalPageRotation.
204 void SetGlobalPageRotation(float angle, const Vector3& axis);
207 * @brief SetAnglePageRotation uses the angle and page size passed in on creation to create a faked origin (inner cube needs this method).
211 void SetAngledOriginPageRotation(const Vector3& angle);
214 * @brief SetGlobalPageRotation.
221 void SetGlobalPageRotation(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
224 * @brief SetGlobalPageRotationIn.
229 void SetGlobalPageRotationIn(float angle, const Vector3& axis);
232 * @brief SetGlobalPageRotationOut.
237 void SetGlobalPageRotationOut(float angle, const Vector3& axis);
240 * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
242 * - The default value is (0,0,0)
245 void SetGlobalPageRotationOrigin(const Vector3& origin);
248 * @brief SetGlobalPageRotationOrigin.
253 void SetGlobalPageRotationOrigin(const Vector3& originIn, const Vector3& originOut);
256 * @brief SetGlobalPageRotationOriginIn.
260 void SetGlobalPageRotationOriginIn(const Vector3& origin);
263 * @brief SetGlobalPageRotationOriginOut.
267 void SetGlobalPageRotationOriginOut(const Vector3& origin);
270 * @brief SetSwingAngle.
275 void SetSwingAngle(float angle, const Vector3& axis);
278 * @brief SetSwingAngle.
285 void SetSwingAngle(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
288 * @brief SetSwingAngleIn.
293 void SetSwingAngleIn(float angle, const Vector3& axis);
296 * @brief SetSwingAngleOut.
301 void SetSwingAngleOut(float angle, const Vector3& axis);
304 * @brief SetSwingAngleAlphaFunction.
308 void SetSwingAngleAlphaFunction(AlphaFunction func);
311 * @brief SetSwingAngleAlphaFunction.
316 void SetSwingAngleAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
319 * @brief SetSwingAngleAlphaFunctionIn.
323 void SetSwingAngleAlphaFunctionIn(AlphaFunction func);
326 * @brief SetSwingAngleAlphaFunctionOut.
330 void SetSwingAngleAlphaFunctionOut(AlphaFunction func);
333 * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
335 * - The default value is (0,0,0)
338 void SetSwingAnchor(const Vector3& anchor);
341 * @brief SetSwingAnchor.
346 void SetSwingAnchor(const Vector3& anchorIn, const Vector3& anchorOut);
349 * @brief SetSwingAnchorIn.
353 void SetSwingAnchorIn(const Vector3& anchor);
356 * @brief SetSwingAnchorOut.
360 void SetSwingAnchorOut(const Vector3& anchor);
363 * @brief SetSwingAnchorAlphaFunction.
367 void SetSwingAnchorAlphaFunction(AlphaFunction func);
370 * @brief SetSwingAnchorAlphaFunction.
375 void SetSwingAnchorAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
378 * @brief SetSwingAnchorAlphaFunctionIn.
382 void SetSwingAnchorAlphaFunctionIn(AlphaFunction func);
385 * @brief SetSwingAnchorAlphaFunctionOut.
388 void SetSwingAnchorAlphaFunctionOut(AlphaFunction func);
391 * @brief SetOpacityThreshold.
395 void SetOpacityThreshold(float thresh);
398 * @brief SetOpacityThreshold.
403 void SetOpacityThreshold(float threshIn, float threshOut);
406 * @brief SetOpacityThresholdIn.
410 void SetOpacityThresholdIn(float thresh);
413 * @brief SetOpacityThresholdOut.
417 void SetOpacityThresholdOut(float thresh);
420 * @brief SetOpacityAlphaFunction.
424 void SetOpacityAlphaFunction(AlphaFunction func);
427 * @brief SetOpacityAlphaFunction.
432 void SetOpacityAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
435 * @brief SetOpacityAlphaFunctionIn.
439 void SetOpacityAlphaFunctionIn(AlphaFunction func);
442 * @brief SetOpacityAlphaFunctionOut.
446 void SetOpacityAlphaFunctionOut(AlphaFunction func);
449 * @brief Applies the effect to a page.
451 * @param page the page to apply this effect to
452 * @param pageSize not needed, page size is determined by scroll view
455 void ApplyToPage(Actor page, Vector3 pageSize);
460 * @brief This constructor is used by Dali New() methods.
462 * @param [in] impl A pointer to a newly allocated Dali resource
464 ScrollViewCustomEffect( Internal::ScrollViewCustomEffect *impl );
468 } // namespace Toolkit
472 #endif // __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__