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/public-api/animation/alpha-functions.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
27 namespace Dali DALI_IMPORT_API
35 namespace Internal DALI_INTERNAL
37 class ScrollViewCustomEffect;
41 * @brief This class has many transition effects for use when scrolling pages, e.g opacity, rotation, swing, translation.
43 * It should be used on the following Actor hierarchy:
49 * You should ensure ScrollView's default constraints have been removed,
50 * by calling ScrollView::RemoveConstraintsFromChildren() before applying
51 * this effect to ScrollView.
54 * ApplyToPage(...) method should be called on every page.
56 * Automatic operation:
59 class ScrollViewCustomEffect : public ScrollViewEffect
63 * @brief Bitflags for effect types.
67 FlagTranslate = 0x0001, ///< indicates that translation is wanted
68 FlagTranslateIn = 0x0002, ///< translating onto the screen is a separate value
69 FlagTranslateOut = 0x0004, ///< translating off the screen is a separate value
70 FlagTranslateMask = FlagTranslate | FlagTranslateIn | FlagTranslateOut,
71 FlagRotate = 0x0008, ///< indicates that a positional rotation is wanted (rotate all pages around a single point like inner cube effect)
72 FlagRotateIn = 0x0010, ///< rotating onto the screen is a separate value
73 FlagRotateOut = 0x0020, ///< rotating off the screen is a separate value
74 FlagRotateAngleForcedOrigin = 0x0040,
75 FlagRotateMask = FlagRotate | FlagRotateIn | FlagRotateOut | FlagRotateAngleForcedOrigin,
76 FlagRotateOrigin = 0x0080, ///< indicates to use a global origin to rotate all pages around
77 FlagRotateOriginIn = 0x0100, ///<
78 FlagRotateOriginOut = 0x0200, ///<
79 FlagRotateOriginMask = FlagRotateOrigin | FlagRotateOriginIn | FlagRotateOriginOut,
80 FlagSwingAngle = 0x0400, ///< indicates that a SwingAngle is wanted (rotate all pages around a single point like inner cube effect)
81 FlagSwingAngleIn = 0x0800, ///< SwingAngle onto the screen is a separate value
82 FlagSwingAngleOut = 0x1000, ///< SwingAngle off the screen is a separate value
83 FlagSwingAngleMask = FlagSwingAngle | FlagSwingAngleIn | FlagSwingAngleOut,
84 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)
85 FlagSwingAnchorIn = 0x4000, ///< Swing anchor onto the screen is a separate value
86 FlagSwingAnchorOut = 0x8000, ///< Swing anchor off the screen is a separate value
87 FlagSwingAnchorMask = FlagSwingAnchor | FlagSwingAnchorIn | FlagSwingAnchorOut,
88 FlagOpacityThreshold = 0x00010000, ///<
89 FlagOpacityThresholdIn = 0x00020000, ///<
90 FlagOpacityThresholdOut = 0x00040000, ///<
91 FlagOpacityThresholdMask = FlagOpacityThreshold | FlagOpacityThresholdIn | FlagOpacityThresholdOut,
92 FlagTranslationAlphaFunctionIn = 0x00080000,
93 FlagTranslationAlphaFunctionOut = 0x00100000,
94 FlagTranslationAlphaFunctionMask = FlagTranslationAlphaFunctionIn | FlagTranslationAlphaFunctionOut,
95 FlagRotateAlphaFunctionIn = 0x00200000,
96 FlagRotateAlphaFunctionOut = 0x00400000,
97 FlagRotateAlphaFunctionMask = FlagRotateAlphaFunctionIn | FlagRotateAlphaFunctionOut,
98 FlagRotateOriginAlphaFunctionIn = 0x00800000,
99 FlagRotateOriginAlphaFunctionOut = 0x01000000,
100 FlagRotateOriginAlphaFunctionMask = FlagRotateOriginAlphaFunctionIn | FlagRotateOriginAlphaFunctionOut,
101 FlagSwingAngleAlphaFunctionIn = 0x02000000,
102 FlagSwingAngleAlphaFunctionOut = 0x04000000,
103 FlagSwingAngleAlphaFunctionMask = FlagSwingAngleAlphaFunctionIn | FlagSwingAngleAlphaFunctionOut,
104 FlagSwingAnchorAlphaFunctionIn = 0x08000000,
105 FlagSwingAnchorAlphaFunctionOut = 0x10000000,
106 FlagSwingAnchorAlphaFunctionMask = FlagSwingAnchorAlphaFunctionIn | FlagSwingAnchorAlphaFunctionOut,
107 FlagOpacityAlphaFunctionIn = 0x20000000,
108 FlagOpacityAlphaFunctionOut = 0x40000000,
109 FlagOpacityAlphaFunctionMask = FlagOpacityAlphaFunctionIn | FlagOpacityAlphaFunctionOut
113 * @brief Create an initialized ScrollViewCustomEffect.
115 * @return A handle to a newly allocated Dali resource.
117 static ScrollViewCustomEffect New();
120 * @brief Create an uninitialized ScrollViewCustomEffect; this can be initialized with ScrollViewCustomEffect::New().
122 * Calling member functions with an uninitialized Toolkit::ScrollViewCustomEffect is not allowed.
124 ScrollViewCustomEffect();
127 * @brief Downcast an Object handle to ScrollViewCustomEffect.
129 * If handle points to a ScrollViewCustomEffect the downcast
130 * produces valid handle. If not the returned handle is left
133 * @param[in] handle Handle to an object
134 * @return handle to a ScrollViewCustomEffect or an uninitialized handle
136 static ScrollViewCustomEffect DownCast( BaseHandle handle );
139 * @brief SetPageSpacing.
143 void SetPageSpacing(const Vector2& spacing);
146 * @brief SetPageTranslation sets a simple translate on/off value.
150 void SetPageTranslation(const Vector3& translation);
153 * @brief SetPageTranslation.
155 * @param translationIn
156 * @param translationOut
158 void SetPageTranslation(const Vector3& translationIn, const Vector3& translationOut);
161 * @brief SetPageTranslationIn.
164 void SetPageTranslationIn(const Vector3& translation);
167 * @brief SetPageTranslationOut.
171 void SetPageTranslationOut(const Vector3& translation);
174 * @brief SetPageTranslateAlphaFunction.
178 void SetPageTranslateAlphaFunction(AlphaFunction func);
181 * @brief SetPageTranslateAlphaFunction.
186 void SetPageTranslateAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
189 * @brief SetPageTranslateAlphaFunctionIn.
193 void SetPageTranslateAlphaFunctionIn(AlphaFunction func);
196 * @brief SetPageTranslateAlphaFunctionOut.
199 void SetPageTranslateAlphaFunctionOut(AlphaFunction func);
202 * @brief SetGlobalPageRotation.
207 void SetGlobalPageRotation(float angle, const Vector3& axis);
210 * @brief SetAnglePageRotation uses the angle and page size passed in on creation to create a faked origin (inner cube needs this method).
214 void SetAngledOriginPageRotation(const Vector3& angle);
217 * @brief SetGlobalPageRotation.
224 void SetGlobalPageRotation(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
227 * @brief SetGlobalPageRotationIn.
232 void SetGlobalPageRotationIn(float angle, const Vector3& axis);
235 * @brief SetGlobalPageRotationOut.
240 void SetGlobalPageRotationOut(float angle, const Vector3& axis);
243 * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
245 * - The default value is (0,0,0)
248 void SetGlobalPageRotationOrigin(const Vector3& origin);
251 * @brief SetGlobalPageRotationOrigin.
256 void SetGlobalPageRotationOrigin(const Vector3& originIn, const Vector3& originOut);
259 * @brief SetGlobalPageRotationOriginIn.
263 void SetGlobalPageRotationOriginIn(const Vector3& origin);
266 * @brief SetGlobalPageRotationOriginOut.
270 void SetGlobalPageRotationOriginOut(const Vector3& origin);
273 * @brief SetSwingAngle.
278 void SetSwingAngle(float angle, const Vector3& axis);
281 * @brief SetSwingAngle.
288 void SetSwingAngle(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
291 * @brief SetSwingAngleIn.
296 void SetSwingAngleIn(float angle, const Vector3& axis);
299 * @brief SetSwingAngleOut.
304 void SetSwingAngleOut(float angle, const Vector3& axis);
307 * @brief SetSwingAngleAlphaFunction.
311 void SetSwingAngleAlphaFunction(AlphaFunction func);
314 * @brief SetSwingAngleAlphaFunction.
319 void SetSwingAngleAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
322 * @brief SetSwingAngleAlphaFunctionIn.
326 void SetSwingAngleAlphaFunctionIn(AlphaFunction func);
329 * @brief SetSwingAngleAlphaFunctionOut.
333 void SetSwingAngleAlphaFunctionOut(AlphaFunction func);
336 * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
338 * - The default value is (0,0,0)
341 void SetSwingAnchor(const Vector3& anchor);
344 * @brief SetSwingAnchor.
349 void SetSwingAnchor(const Vector3& anchorIn, const Vector3& anchorOut);
352 * @brief SetSwingAnchorIn.
356 void SetSwingAnchorIn(const Vector3& anchor);
359 * @brief SetSwingAnchorOut.
363 void SetSwingAnchorOut(const Vector3& anchor);
366 * @brief SetSwingAnchorAlphaFunction.
370 void SetSwingAnchorAlphaFunction(AlphaFunction func);
373 * @brief SetSwingAnchorAlphaFunction.
378 void SetSwingAnchorAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
381 * @brief SetSwingAnchorAlphaFunctionIn.
385 void SetSwingAnchorAlphaFunctionIn(AlphaFunction func);
388 * @brief SetSwingAnchorAlphaFunctionOut.
391 void SetSwingAnchorAlphaFunctionOut(AlphaFunction func);
394 * @brief SetOpacityThreshold.
398 void SetOpacityThreshold(float thresh);
401 * @brief SetOpacityThreshold.
406 void SetOpacityThreshold(float threshIn, float threshOut);
409 * @brief SetOpacityThresholdIn.
413 void SetOpacityThresholdIn(float thresh);
416 * @brief SetOpacityThresholdOut.
420 void SetOpacityThresholdOut(float thresh);
423 * @brief SetOpacityAlphaFunction.
427 void SetOpacityAlphaFunction(AlphaFunction func);
430 * @brief SetOpacityAlphaFunction.
435 void SetOpacityAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
438 * @brief SetOpacityAlphaFunctionIn.
442 void SetOpacityAlphaFunctionIn(AlphaFunction func);
445 * @brief SetOpacityAlphaFunctionOut.
449 void SetOpacityAlphaFunctionOut(AlphaFunction func);
452 * @brief Applies the effect to a page.
454 * @param page the page to apply this effect to
455 * @param pageSize not needed, page size is determined by scroll view
458 void ApplyToPage(Actor page, Vector3 pageSize);
463 * @brief This constructor is used by Dali New() methods.
465 * @param [in] impl A pointer to a newly allocated Dali resource
467 ScrollViewCustomEffect( Internal::ScrollViewCustomEffect *impl );
471 } // namespace Toolkit
475 #endif // __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__