Conversion to Apache 2.0 license
[platform/core/uifw/dali-toolkit.git] / capi / 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 /**
22  * @addtogroup CAPI_DALI_TOOLKIT_SCROLL_VIEW_MODULE
23  * @{
24  */
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
28
29 namespace Dali DALI_IMPORT_API
30 {
31
32 class Actor;
33
34 namespace Toolkit
35 {
36
37 namespace Internal DALI_INTERNAL
38 {
39 class ScrollViewCustomEffect;
40 }
41
42 /**
43  * @brief This class has many transition effects for use when scrolling pages, e.g opacity, rotation, swing, translation.
44  *
45  * It should be used on the following Actor hierarchy:
46  *
47  * ScrollView
48  * |
49  * Page (1..n)
50  *
51  * You should ensure ScrollView's default constraints have been removed,
52  * by calling ScrollView::RemoveConstraintsFromChildren() before applying
53  * this effect to ScrollView.
54  *
55  * Manual operation:
56  * ApplyToPage(...) method should be called on every page.
57  *
58  * Automatic operation:
59  * not implemented.
60  */
61 class ScrollViewCustomEffect : public ScrollViewEffect
62 {
63 public:
64   /**
65    * @brief Bitflags for effect types.
66    */
67   enum EFlag
68   {
69     FlagTranslate             = 0x0001,             ///< indicates that translation is wanted
70     FlagTranslateIn           = 0x0002,             ///< translating onto the screen is a separate value
71     FlagTranslateOut          = 0x0004,             ///< translating off the screen is a separate value
72     FlagTranslateMask         = FlagTranslate | FlagTranslateIn | FlagTranslateOut,
73     FlagRotate                = 0x0008,             ///< indicates that a positional rotation is wanted (rotate all pages around a single point like inner cube effect)
74     FlagRotateIn              = 0x0010,             ///< rotating onto the screen is a separate value
75     FlagRotateOut             = 0x0020,             ///< rotating off the screen is a separate value
76     FlagRotateAngleForcedOrigin = 0x0040,
77     FlagRotateMask            = FlagRotate | FlagRotateIn | FlagRotateOut | FlagRotateAngleForcedOrigin,
78     FlagRotateOrigin          = 0x0080,             ///< indicates to use a global origin to rotate all pages around
79     FlagRotateOriginIn        = 0x0100,             ///<
80     FlagRotateOriginOut       = 0x0200,             ///<
81     FlagRotateOriginMask      = FlagRotateOrigin | FlagRotateOriginIn | FlagRotateOriginOut,
82     FlagSwingAngle            = 0x0400,             ///< indicates that a SwingAngle is wanted (rotate all pages around a single point like inner cube effect)
83     FlagSwingAngleIn          = 0x0800,             ///< SwingAngle onto the screen is a separate value
84     FlagSwingAngleOut         = 0x1000,             ///< SwingAngle off the screen is a separate value
85     FlagSwingAngleMask        = FlagSwingAngle | FlagSwingAngleIn | FlagSwingAngleOut,
86     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)
87     FlagSwingAnchorIn         = 0x4000,             ///< Swing anchor onto the screen is a separate value
88     FlagSwingAnchorOut        = 0x8000,             ///< Swing anchor off the screen is a separate value
89     FlagSwingAnchorMask       = FlagSwingAnchor | FlagSwingAnchorIn | FlagSwingAnchorOut,
90     FlagOpacityThreshold      = 0x00010000,             ///<
91     FlagOpacityThresholdIn    = 0x00020000,       ///<
92     FlagOpacityThresholdOut   = 0x00040000,      ///<
93     FlagOpacityThresholdMask  = FlagOpacityThreshold | FlagOpacityThresholdIn | FlagOpacityThresholdOut,
94     FlagTranslationAlphaFunctionIn      = 0x00080000,
95     FlagTranslationAlphaFunctionOut     = 0x00100000,
96     FlagTranslationAlphaFunctionMask    = FlagTranslationAlphaFunctionIn | FlagTranslationAlphaFunctionOut,
97     FlagRotateAlphaFunctionIn           = 0x00200000,
98     FlagRotateAlphaFunctionOut          = 0x00400000,
99     FlagRotateAlphaFunctionMask         = FlagRotateAlphaFunctionIn | FlagRotateAlphaFunctionOut,
100     FlagRotateOriginAlphaFunctionIn     = 0x00800000,
101     FlagRotateOriginAlphaFunctionOut    = 0x01000000,
102     FlagRotateOriginAlphaFunctionMask   = FlagRotateOriginAlphaFunctionIn | FlagRotateOriginAlphaFunctionOut,
103     FlagSwingAngleAlphaFunctionIn       = 0x02000000,
104     FlagSwingAngleAlphaFunctionOut      = 0x04000000,
105     FlagSwingAngleAlphaFunctionMask     = FlagSwingAngleAlphaFunctionIn | FlagSwingAngleAlphaFunctionOut,
106     FlagSwingAnchorAlphaFunctionIn      = 0x08000000,
107     FlagSwingAnchorAlphaFunctionOut     = 0x10000000,
108     FlagSwingAnchorAlphaFunctionMask    = FlagSwingAnchorAlphaFunctionIn | FlagSwingAnchorAlphaFunctionOut,
109     FlagOpacityAlphaFunctionIn          = 0x20000000,
110     FlagOpacityAlphaFunctionOut         = 0x40000000,
111     FlagOpacityAlphaFunctionMask        = FlagOpacityAlphaFunctionIn | FlagOpacityAlphaFunctionOut
112   };
113
114   /**
115    * @brief Create an initialized ScrollViewCustomEffect.
116    *
117    * @return A handle to a newly allocated Dali resource.
118    */
119   static ScrollViewCustomEffect New();
120
121   /**
122    * @brief Create an uninitialized ScrollViewCustomEffect; this can be initialized with ScrollViewCustomEffect::New().
123    *
124    * Calling member functions with an uninitialized Toolkit::ScrollViewCustomEffect is not allowed.
125    */
126   ScrollViewCustomEffect();
127
128   /**
129    * @brief Downcast an Object handle to ScrollViewCustomEffect.
130    *
131    * If handle points to a ScrollViewCustomEffect the downcast
132    * produces valid handle. If not the returned handle is left
133    * uninitialized.
134    *
135    * @param[in] handle Handle to an object
136    * @return handle to a ScrollViewCustomEffect or an uninitialized handle
137    */
138   static ScrollViewCustomEffect DownCast( BaseHandle handle );
139
140   /**
141    * @brief SetPageSpacing.
142    *
143    * @param spacing
144    */
145   void SetPageSpacing(const Vector2& spacing);
146
147   /**
148    * @brief SetPageTranslation sets a simple translate on/off value.
149    *
150    * @param translation
151    */
152   void SetPageTranslation(const Vector3& translation);
153
154   /**
155    * @brief SetPageTranslation.
156    *
157    * @param translationIn
158    * @param translationOut
159    */
160   void SetPageTranslation(const Vector3& translationIn, const Vector3& translationOut);
161
162   /**
163    * @brief SetPageTranslationIn.
164    * @param translation
165    */
166   void SetPageTranslationIn(const Vector3& translation);
167
168   /**
169    * @brief SetPageTranslationOut.
170    *
171    * @param translation
172    */
173   void SetPageTranslationOut(const Vector3& translation);
174
175   /**
176    * @brief SetPageTranslateAlphaFunction.
177    *
178    * @param func
179    */
180   void SetPageTranslateAlphaFunction(AlphaFunction func);
181
182   /**
183    * @brief SetPageTranslateAlphaFunction.
184    *
185    * @param funcIn
186    * @param funcOut
187    */
188   void SetPageTranslateAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
189
190   /**
191    * @brief SetPageTranslateAlphaFunctionIn.
192    *
193    * @param func
194    */
195   void SetPageTranslateAlphaFunctionIn(AlphaFunction func);
196
197   /**
198    * @brief SetPageTranslateAlphaFunctionOut.
199    * @param func
200    */
201   void SetPageTranslateAlphaFunctionOut(AlphaFunction func);
202
203   /**
204    * @brief SetGlobalPageRotation.
205    *
206    * @param angle
207    * @param axis
208    */
209   void SetGlobalPageRotation(float angle, const Vector3& axis);
210
211   /**
212    * @brief SetAnglePageRotation uses the angle and page size passed in on creation to create a faked origin (inner cube needs this method).
213    *
214    * @param angle
215    */
216   void SetAngledOriginPageRotation(const Vector3& angle);
217
218   /**
219    * @brief SetGlobalPageRotation.
220    *
221    * @param angleIn
222    * @param axisIn
223    * @param angleOut
224    * @param axisOut
225    */
226   void SetGlobalPageRotation(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
227
228   /**
229    * @brief SetGlobalPageRotationIn.
230    *
231    * @param angle
232    * @param axis
233    */
234   void SetGlobalPageRotationIn(float angle, const Vector3& axis);
235
236   /**
237    * @brief SetGlobalPageRotationOut.
238    *
239    * @param angle
240    * @param axis
241    */
242   void SetGlobalPageRotationOut(float angle, const Vector3& axis);
243
244   /**
245    * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
246    *
247    *        - The default value is (0,0,0)
248    * @param origin
249    */
250   void SetGlobalPageRotationOrigin(const Vector3& origin);
251
252   /**
253    * @brief SetGlobalPageRotationOrigin.
254    *
255    * @param originIn
256    * @param originOut
257    */
258   void SetGlobalPageRotationOrigin(const Vector3& originIn, const Vector3& originOut);
259
260   /**
261    * @brief SetGlobalPageRotationOriginIn.
262    *
263    * @param origin
264    */
265   void SetGlobalPageRotationOriginIn(const Vector3& origin);
266
267   /**
268    * @brief SetGlobalPageRotationOriginOut.
269    *
270    * @param origin
271    */
272   void SetGlobalPageRotationOriginOut(const Vector3& origin);
273
274   /**
275    * @brief SetSwingAngle.
276    *
277    * @param angle
278    * @param axis
279    */
280   void SetSwingAngle(float angle, const Vector3& axis);
281
282   /**
283    * @brief SetSwingAngle.
284    *
285    * @param angleIn
286    * @param axisIn
287    * @param angleOut
288    * @param axisOut
289    */
290   void SetSwingAngle(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
291
292   /**
293    * @brief SetSwingAngleIn.
294    *
295    * @param angle
296    * @param axis
297    */
298   void SetSwingAngleIn(float angle, const Vector3& axis);
299
300   /**
301    * @brief SetSwingAngleOut.
302    *
303    * @param angle
304    * @param axis
305    */
306   void SetSwingAngleOut(float angle, const Vector3& axis);
307
308   /**
309    * @brief SetSwingAngleAlphaFunction.
310    *
311    * @param func
312    */
313   void SetSwingAngleAlphaFunction(AlphaFunction func);
314
315   /**
316    * @brief SetSwingAngleAlphaFunction.
317    *
318    * @param funcIn
319    * @param funcOut
320    */
321   void SetSwingAngleAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
322
323   /**
324    * @brief SetSwingAngleAlphaFunctionIn.
325    *
326    * @param func
327    */
328   void SetSwingAngleAlphaFunctionIn(AlphaFunction func);
329
330   /**
331    * @brief SetSwingAngleAlphaFunctionOut.
332    *
333    * @param func
334    */
335   void SetSwingAngleAlphaFunctionOut(AlphaFunction func);
336
337   /**
338    * @brief SetPageRotationOrigin Set the origin to rotate all the pages around.
339    *
340    *        - The default value is (0,0,0)
341    * @param anchor
342    */
343   void SetSwingAnchor(const Vector3& anchor);
344
345   /**
346    * @brief SetSwingAnchor.
347    *
348    * @param anchorIn
349    * @param anchorOut
350    */
351   void SetSwingAnchor(const Vector3& anchorIn, const Vector3& anchorOut);
352
353   /**
354    * @brief SetSwingAnchorIn.
355    *
356    * @param anchor
357    */
358   void SetSwingAnchorIn(const Vector3& anchor);
359
360   /**
361    * @brief SetSwingAnchorOut.
362    *
363    * @param anchor
364    */
365   void SetSwingAnchorOut(const Vector3& anchor);
366
367   /**
368    * @brief SetSwingAnchorAlphaFunction.
369    *
370    * @param func
371    */
372   void SetSwingAnchorAlphaFunction(AlphaFunction func);
373
374   /**
375    * @brief SetSwingAnchorAlphaFunction.
376    *
377    * @param funcIn
378    * @param funcOut
379    */
380   void SetSwingAnchorAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
381
382   /**
383    * @brief SetSwingAnchorAlphaFunctionIn.
384    *
385    * @param func
386    */
387   void SetSwingAnchorAlphaFunctionIn(AlphaFunction func);
388
389   /**
390    * @brief SetSwingAnchorAlphaFunctionOut.
391    * @param func
392    */
393   void SetSwingAnchorAlphaFunctionOut(AlphaFunction func);
394
395   /**
396    * @brief SetOpacityThreshold.
397    *
398    * @param thresh
399    */
400   void SetOpacityThreshold(float thresh);
401
402   /**
403    * @brief SetOpacityThreshold.
404    *
405    * @param threshIn
406    * @param threshOut
407    */
408   void SetOpacityThreshold(float threshIn, float threshOut);
409
410   /**
411    * @brief SetOpacityThresholdIn.
412    *
413    * @param thresh
414    */
415   void SetOpacityThresholdIn(float thresh);
416
417   /**
418    * @brief SetOpacityThresholdOut.
419    *
420    * @param thresh
421    */
422   void SetOpacityThresholdOut(float thresh);
423
424   /**
425    * @brief SetOpacityAlphaFunction.
426    *
427    * @param func
428    */
429   void SetOpacityAlphaFunction(AlphaFunction func);
430
431   /**
432    * @brief SetOpacityAlphaFunction.
433    *
434    * @param funcIn
435    * @param funcOut
436    */
437   void SetOpacityAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
438
439   /**
440    * @brief SetOpacityAlphaFunctionIn.
441    *
442    * @param func
443    */
444   void SetOpacityAlphaFunctionIn(AlphaFunction func);
445
446   /**
447    * @brief SetOpacityAlphaFunctionOut.
448    *
449    * @param func
450    */
451   void SetOpacityAlphaFunctionOut(AlphaFunction func);
452
453   /**
454    * @brief Applies the effect to a page.
455    *
456    * @param page the page to apply this effect to
457    * @param pageSize not needed, page size is determined by scroll view
458
459    */
460   void ApplyToPage(Actor page, Vector3 pageSize);
461
462 protected:
463
464   /**
465    * @brief This constructor is used by Dali New() methods.
466    *
467    * @param [in] impl A pointer to a newly allocated Dali resource
468    */
469   ScrollViewCustomEffect( Internal::ScrollViewCustomEffect *impl );
470
471 };
472
473 } // namespace Toolkit
474
475 } // namespace Dali
476
477 /**
478  * @}
479  */
480 #endif // __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__