9201fa7a4a5e5238db0a7c800164f41033a450d2
[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 Flora License, Version 1.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://floralicense.org/license/
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  * @addtogroup CAPI_DALI_FRAMEWORK
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
27
28 namespace Dali DALI_IMPORT_API
29 {
30
31 class Actor;
32
33 namespace Toolkit
34 {
35
36 namespace Internal DALI_INTERNAL
37 {
38 class ScrollViewCustomEffect;
39 }
40
41 /**
42  * ScrollView Inner Cube-Effect.
43  *
44  * This effect cause each page in a scroll-view to rotate round an inner 3D cube.
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   static const std::string ANCHOR_POINT_PROPERTY_NAME;
64   static const std::string SCROLL_AMOUNT_PROPERTY_NAME;               ///< Property, name "scroll-amount",           type VECTOR3
65
66 public:
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    * Create an initialized ScrollViewPageCubeEffect.
116    * @return A handle to a newly allocated Dali resource.
117    */
118   static ScrollViewCustomEffect New();
119
120   /**
121    * Create an uninitialized ScrollViewPageCubeEffect; this can be initialized with ScrollViewPageCubeEffect::New()
122    * Calling member functions with an uninitialized Toolkit::ScrollViewPageCubeEffect is not allowed.
123    */
124   ScrollViewCustomEffect();
125
126   /**
127    * Downcast an Object handle to ScrollViewCustomEffect. If handle points to a ScrollViewCustomEffect the
128    * downcast produces valid handle. If not the returned handle is left uninitialized.
129    * @param[in] handle Handle to an object
130    * @return handle to a ScrollViewCustomEffect or an uninitialized handle
131    */
132   static ScrollViewCustomEffect DownCast( BaseHandle handle );
133
134   /**
135    * @brief SetPageSpacing
136    * @param spacing
137    */
138   void SetPageSpacing(const Vector2& spacing);
139
140   /**
141    * @brief SetPageTranslation sets a simple translate on/off value
142    * @param translation
143    */
144   void SetPageTranslation(const Vector3& translation);
145
146   /**
147    * @brief SetPageTranslation
148    * @param translationIn
149    * @param translationOut
150    */
151   void SetPageTranslation(const Vector3& translationIn, const Vector3& translationOut);
152
153   /**
154    * @brief SetPageTranslationIn
155    * @param translation
156    */
157   void SetPageTranslationIn(const Vector3& translation);
158
159   /**
160    * @brief SetPageTranslationOut
161    * @param translation
162    */
163   void SetPageTranslationOut(const Vector3& translation);
164
165   /**
166    * @brief SetPageTranslateAlphaFunction
167    * @param func
168    */
169   void SetPageTranslateAlphaFunction(AlphaFunction func);
170
171   /**
172    * @brief SetPageTranslateAlphaFunction
173    * @param funcIn
174    * @param funcOut
175    */
176   void SetPageTranslateAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
177
178   /**
179    * @brief SetPageTranslateAlphaFunctionIn
180    * @param func
181    */
182   void SetPageTranslateAlphaFunctionIn(AlphaFunction func);
183
184   /**
185    * @brief SetPageTranslateAlphaFunctionOut
186    * @param func
187    */
188   void SetPageTranslateAlphaFunctionOut(AlphaFunction func);
189
190   /**
191    * @brief SetGlobalPageRotation
192    * @param angle
193    * @param axis
194    */
195   void SetGlobalPageRotation(float angle, const Vector3& axis);
196
197   /**
198    * @brief SetAnglePageRotation uses the angle and page size passed in on creation to create a faked origin (inner cube needs this method)
199    * @param angle
200    */
201   void SetAngledOriginPageRotation(const Vector3& angle);
202
203   /**
204    * @brief SetGlobalPageRotation
205    * @param angleIn
206    * @param axisIn
207    * @param angleOut
208    * @param axisOut
209    */
210   void SetGlobalPageRotation(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
211
212   /**
213    * @brief SetGlobalPageRotationIn
214    * @param angle
215    * @param axis
216    */
217   void SetGlobalPageRotationIn(float angle, const Vector3& axis);
218
219   /**
220    * @brief SetGlobalPageRotationOut
221    * @param angle
222    * @param axis
223    */
224   void SetGlobalPageRotationOut(float angle, const Vector3& axis);
225
226   /**
227    * @brief SetPageRotationOrigin Set the origin to rotate all the pages around
228    *        - The default value is (0,0,0)
229    * @param origin
230    */
231   void SetGlobalPageRotationOrigin(const Vector3& origin);
232
233   /**
234    * @brief SetGlobalPageRotationOrigin
235    * @param originIn
236    * @param originOut
237    */
238   void SetGlobalPageRotationOrigin(const Vector3& originIn, const Vector3& originOut);
239
240   /**
241    * @brief SetGlobalPageRotationOriginIn
242    * @param origin
243    */
244   void SetGlobalPageRotationOriginIn(const Vector3& origin);
245
246   /**
247    * @brief SetGlobalPageRotationOriginOut
248    * @param origin
249    */
250   void SetGlobalPageRotationOriginOut(const Vector3& origin);
251
252   /**
253    * @brief SetSwingAngle
254    * @param angle
255    * @param axis
256    */
257   void SetSwingAngle(float angle, const Vector3& axis);
258
259   /**
260    * @brief SetSwingAngle
261    * @param angleIn
262    * @param axisIn
263    * @param angleOut
264    * @param axisOut
265    */
266   void SetSwingAngle(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
267
268   /**
269    * @brief SetSwingAngleIn
270    * @param angle
271    * @param axis
272    */
273   void SetSwingAngleIn(float angle, const Vector3& axis);
274
275   /**
276    * @brief SetSwingAngleOut
277    * @param angle
278    * @param axis
279    */
280   void SetSwingAngleOut(float angle, const Vector3& axis);
281
282   /**
283    * @brief SetSwingAngleAlphaFunction
284    * @param func
285    */
286   void SetSwingAngleAlphaFunction(AlphaFunction func);
287
288   /**
289    * @brief SetSwingAngleAlphaFunction
290    * @param funcIn
291    * @param funcOut
292    */
293   void SetSwingAngleAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
294
295   /**
296    * @brief SetSwingAngleAlphaFunctionIn
297    * @param func
298    */
299   void SetSwingAngleAlphaFunctionIn(AlphaFunction func);
300
301   /**
302    * @brief SetSwingAngleAlphaFunctionOut
303    * @param func
304    */
305   void SetSwingAngleAlphaFunctionOut(AlphaFunction func);
306
307   /**
308    * @brief SetPageRotationOrigin Set the origin to rotate all the pages around
309    *        - The default value is (0,0,0)
310    * @param anchor
311    */
312   void SetSwingAnchor(const Vector3& anchor);
313
314   /**
315    * @brief SetSwingAnchor
316    * @param anchorIn
317    * @param anchorOut
318    */
319   void SetSwingAnchor(const Vector3& anchorIn, const Vector3& anchorOut);
320
321   /**
322    * @brief SetSwingAnchorIn
323    * @param anchor
324    */
325   void SetSwingAnchorIn(const Vector3& anchor);
326
327   /**
328    * @brief SetSwingAnchorOut
329    * @param anchor
330    */
331   void SetSwingAnchorOut(const Vector3& anchor);
332
333   /**
334    * @brief SetSwingAnchorAlphaFunction
335    * @param func
336    */
337   void SetSwingAnchorAlphaFunction(AlphaFunction func);
338
339   /**
340    * @brief SetSwingAnchorAlphaFunction
341    * @param funcIn
342    * @param funcOut
343    */
344   void SetSwingAnchorAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
345
346   /**
347    * @brief SetSwingAnchorAlphaFunctionIn
348    * @param func
349    */
350   void SetSwingAnchorAlphaFunctionIn(AlphaFunction func);
351
352   /**
353    * @brief SetSwingAnchorAlphaFunctionOut
354    * @param func
355    */
356   void SetSwingAnchorAlphaFunctionOut(AlphaFunction func);
357
358   /**
359    * @brief SetOpacityThreshold
360    * @param thresh
361    */
362   void SetOpacityThreshold(float thresh);
363
364   /**
365    * @brief SetOpacityThreshold
366    * @param threshIn
367    * @param threshOut
368    */
369   void SetOpacityThreshold(float threshIn, float threshOut);
370
371   /**
372    * @brief SetOpacityThresholdIn
373    * @param thresh
374    */
375   void SetOpacityThresholdIn(float thresh);
376
377   /**
378    * @brief SetOpacityThresholdOut
379    * @param thresh
380    */
381   void SetOpacityThresholdOut(float thresh);
382
383   /**
384    * @brief SetOpacityAlphaFunction
385    * @param func
386    */
387   void SetOpacityAlphaFunction(AlphaFunction func);
388
389   /**
390    * @brief SetOpacityAlphaFunction
391    * @param funcIn
392    * @param funcOut
393    */
394   void SetOpacityAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
395
396   /**
397    * @brief SetOpacityAlphaFunctionIn
398    * @param func
399    */
400   void SetOpacityAlphaFunctionIn(AlphaFunction func);
401
402   /**
403    * @brief SetOpacityAlphaFunctionOut
404    * @param func
405    */
406   void SetOpacityAlphaFunctionOut(AlphaFunction func);
407
408   /**
409    * Applies the effect to a page
410    * @param page the page to apply this effect to
411    * @param pageSize not needed, page size is determined by scroll view
412
413    */
414   void ApplyToPage(Actor page, Vector3 pageSize);
415
416 protected:
417
418   /**
419    * This constructor is used by Dali New() methods.
420    * @param [in] impl A pointer to a newly allocated Dali resource
421    */
422   ScrollViewCustomEffect( Internal::ScrollViewCustomEffect *impl );
423
424 };
425
426 } // namespace Toolkit
427
428 } // namespace Dali
429
430 /**
431  * @}
432  */
433 #endif // __DALI_TOOLKIT_SCROLL_VIEW_CUSTOM_EFFECT_H__