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