Include required header files directly rather than through dali.h
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / controls / scrollable / scroll-view / scroll-view-custom-effect.h
1 #ifndef __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__
2 #define __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_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 DALI_IMPORT_API
28 {
29
30 class Actor;
31
32 namespace Toolkit
33 {
34
35 namespace Internal DALI_INTERNAL
36 {
37 class ScrollViewCustomEffect;
38 }
39
40 /**
41  * @brief This class has many transition effects for use when scrolling pages, e.g opacity, rotation, swing, translation.
42  *
43  * It should be used on the following Actor hierarchy:
44  *
45  * ScrollView
46  * |
47  * Page (1..n)
48  *
49  * You should ensure ScrollView's default constraints have been removed,
50  * by calling ScrollView::RemoveConstraintsFromChildren() before applying
51  * this effect to ScrollView.
52  *
53  * Manual operation:
54  * ApplyToPage(...) method should be called on every page.
55  *
56  * Automatic operation:
57  * not implemented.
58  */
59 class ScrollViewCustomEffect : public ScrollViewEffect
60 {
61 public:
62   /**
63    * @brief Bitflags for effect types.
64    */
65   enum EFlag
66   {
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
110   };
111
112   /**
113    * @brief Create an initialized ScrollViewCustomEffect.
114    *
115    * @return A handle to a newly allocated Dali resource.
116    */
117   static ScrollViewCustomEffect New();
118
119   /**
120    * @brief Create an uninitialized ScrollViewCustomEffect; this can be initialized with ScrollViewCustomEffect::New().
121    *
122    * Calling member functions with an uninitialized Toolkit::ScrollViewCustomEffect is not allowed.
123    */
124   ScrollViewCustomEffect();
125
126   /**
127    * @brief Downcast an Object handle to ScrollViewCustomEffect.
128    *
129    * If handle points to a ScrollViewCustomEffect the downcast
130    * produces valid handle. If not the returned handle is left
131    * uninitialized.
132    *
133    * @param[in] handle Handle to an object
134    * @return handle to a ScrollViewCustomEffect or an uninitialized handle
135    */
136   static ScrollViewCustomEffect DownCast( BaseHandle handle );
137
138   /**
139    * @brief SetPageSpacing.
140    *
141    * @param spacing
142    */
143   void SetPageSpacing(const Vector2& spacing);
144
145   /**
146    * @brief SetPageTranslation sets a simple translate on/off value.
147    *
148    * @param translation
149    */
150   void SetPageTranslation(const Vector3& translation);
151
152   /**
153    * @brief SetPageTranslation.
154    *
155    * @param translationIn
156    * @param translationOut
157    */
158   void SetPageTranslation(const Vector3& translationIn, const Vector3& translationOut);
159
160   /**
161    * @brief SetPageTranslationIn.
162    * @param translation
163    */
164   void SetPageTranslationIn(const Vector3& translation);
165
166   /**
167    * @brief SetPageTranslationOut.
168    *
169    * @param translation
170    */
171   void SetPageTranslationOut(const Vector3& translation);
172
173   /**
174    * @brief SetPageTranslateAlphaFunction.
175    *
176    * @param func
177    */
178   void SetPageTranslateAlphaFunction(AlphaFunction func);
179
180   /**
181    * @brief SetPageTranslateAlphaFunction.
182    *
183    * @param funcIn
184    * @param funcOut
185    */
186   void SetPageTranslateAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
187
188   /**
189    * @brief SetPageTranslateAlphaFunctionIn.
190    *
191    * @param func
192    */
193   void SetPageTranslateAlphaFunctionIn(AlphaFunction func);
194
195   /**
196    * @brief SetPageTranslateAlphaFunctionOut.
197    * @param func
198    */
199   void SetPageTranslateAlphaFunctionOut(AlphaFunction func);
200
201   /**
202    * @brief SetGlobalPageRotation.
203    *
204    * @param angle
205    * @param axis
206    */
207   void SetGlobalPageRotation(float angle, const Vector3& axis);
208
209   /**
210    * @brief SetAnglePageRotation uses the angle and page size passed in on creation to create a faked origin (inner cube needs this method).
211    *
212    * @param angle
213    */
214   void SetAngledOriginPageRotation(const Vector3& angle);
215
216   /**
217    * @brief SetGlobalPageRotation.
218    *
219    * @param angleIn
220    * @param axisIn
221    * @param angleOut
222    * @param axisOut
223    */
224   void SetGlobalPageRotation(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
225
226   /**
227    * @brief SetGlobalPageRotationIn.
228    *
229    * @param angle
230    * @param axis
231    */
232   void SetGlobalPageRotationIn(float angle, const Vector3& axis);
233
234   /**
235    * @brief SetGlobalPageRotationOut.
236    *
237    * @param angle
238    * @param axis
239    */
240   void SetGlobalPageRotationOut(float angle, const Vector3& axis);
241
242   /**
243    * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
244    *
245    *        - The default value is (0,0,0)
246    * @param origin
247    */
248   void SetGlobalPageRotationOrigin(const Vector3& origin);
249
250   /**
251    * @brief SetGlobalPageRotationOrigin.
252    *
253    * @param originIn
254    * @param originOut
255    */
256   void SetGlobalPageRotationOrigin(const Vector3& originIn, const Vector3& originOut);
257
258   /**
259    * @brief SetGlobalPageRotationOriginIn.
260    *
261    * @param origin
262    */
263   void SetGlobalPageRotationOriginIn(const Vector3& origin);
264
265   /**
266    * @brief SetGlobalPageRotationOriginOut.
267    *
268    * @param origin
269    */
270   void SetGlobalPageRotationOriginOut(const Vector3& origin);
271
272   /**
273    * @brief SetSwingAngle.
274    *
275    * @param angle
276    * @param axis
277    */
278   void SetSwingAngle(float angle, const Vector3& axis);
279
280   /**
281    * @brief SetSwingAngle.
282    *
283    * @param angleIn
284    * @param axisIn
285    * @param angleOut
286    * @param axisOut
287    */
288   void SetSwingAngle(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
289
290   /**
291    * @brief SetSwingAngleIn.
292    *
293    * @param angle
294    * @param axis
295    */
296   void SetSwingAngleIn(float angle, const Vector3& axis);
297
298   /**
299    * @brief SetSwingAngleOut.
300    *
301    * @param angle
302    * @param axis
303    */
304   void SetSwingAngleOut(float angle, const Vector3& axis);
305
306   /**
307    * @brief SetSwingAngleAlphaFunction.
308    *
309    * @param func
310    */
311   void SetSwingAngleAlphaFunction(AlphaFunction func);
312
313   /**
314    * @brief SetSwingAngleAlphaFunction.
315    *
316    * @param funcIn
317    * @param funcOut
318    */
319   void SetSwingAngleAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
320
321   /**
322    * @brief SetSwingAngleAlphaFunctionIn.
323    *
324    * @param func
325    */
326   void SetSwingAngleAlphaFunctionIn(AlphaFunction func);
327
328   /**
329    * @brief SetSwingAngleAlphaFunctionOut.
330    *
331    * @param func
332    */
333   void SetSwingAngleAlphaFunctionOut(AlphaFunction func);
334
335   /**
336    * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
337    *
338    *        - The default value is (0,0,0)
339    * @param anchor
340    */
341   void SetSwingAnchor(const Vector3& anchor);
342
343   /**
344    * @brief SetSwingAnchor.
345    *
346    * @param anchorIn
347    * @param anchorOut
348    */
349   void SetSwingAnchor(const Vector3& anchorIn, const Vector3& anchorOut);
350
351   /**
352    * @brief SetSwingAnchorIn.
353    *
354    * @param anchor
355    */
356   void SetSwingAnchorIn(const Vector3& anchor);
357
358   /**
359    * @brief SetSwingAnchorOut.
360    *
361    * @param anchor
362    */
363   void SetSwingAnchorOut(const Vector3& anchor);
364
365   /**
366    * @brief SetSwingAnchorAlphaFunction.
367    *
368    * @param func
369    */
370   void SetSwingAnchorAlphaFunction(AlphaFunction func);
371
372   /**
373    * @brief SetSwingAnchorAlphaFunction.
374    *
375    * @param funcIn
376    * @param funcOut
377    */
378   void SetSwingAnchorAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
379
380   /**
381    * @brief SetSwingAnchorAlphaFunctionIn.
382    *
383    * @param func
384    */
385   void SetSwingAnchorAlphaFunctionIn(AlphaFunction func);
386
387   /**
388    * @brief SetSwingAnchorAlphaFunctionOut.
389    * @param func
390    */
391   void SetSwingAnchorAlphaFunctionOut(AlphaFunction func);
392
393   /**
394    * @brief SetOpacityThreshold.
395    *
396    * @param thresh
397    */
398   void SetOpacityThreshold(float thresh);
399
400   /**
401    * @brief SetOpacityThreshold.
402    *
403    * @param threshIn
404    * @param threshOut
405    */
406   void SetOpacityThreshold(float threshIn, float threshOut);
407
408   /**
409    * @brief SetOpacityThresholdIn.
410    *
411    * @param thresh
412    */
413   void SetOpacityThresholdIn(float thresh);
414
415   /**
416    * @brief SetOpacityThresholdOut.
417    *
418    * @param thresh
419    */
420   void SetOpacityThresholdOut(float thresh);
421
422   /**
423    * @brief SetOpacityAlphaFunction.
424    *
425    * @param func
426    */
427   void SetOpacityAlphaFunction(AlphaFunction func);
428
429   /**
430    * @brief SetOpacityAlphaFunction.
431    *
432    * @param funcIn
433    * @param funcOut
434    */
435   void SetOpacityAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
436
437   /**
438    * @brief SetOpacityAlphaFunctionIn.
439    *
440    * @param func
441    */
442   void SetOpacityAlphaFunctionIn(AlphaFunction func);
443
444   /**
445    * @brief SetOpacityAlphaFunctionOut.
446    *
447    * @param func
448    */
449   void SetOpacityAlphaFunctionOut(AlphaFunction func);
450
451   /**
452    * @brief Applies the effect to a page.
453    *
454    * @param page the page to apply this effect to
455    * @param pageSize not needed, page size is determined by scroll view
456
457    */
458   void ApplyToPage(Actor page, Vector3 pageSize);
459
460 protected:
461
462   /**
463    * @brief This constructor is used by Dali New() methods.
464    *
465    * @param [in] impl A pointer to a newly allocated Dali resource
466    */
467   ScrollViewCustomEffect( Internal::ScrollViewCustomEffect *impl );
468
469 };
470
471 } // namespace Toolkit
472
473 } // namespace Dali
474
475 #endif // __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__