c6c952caf255cfa194395e94d1d2f823fdadac1d
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-custom-effect-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_CUSTOM_EFFECT_H__
2 #define __DALI_TOOLKIT_INTERNAL_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 // INTERNAL INCLUDES
21 #include <dali/public-api/animation/animation.h>
22 #include <dali/public-api/animation/alpha-functions.h>
23 #include <dali/public-api/animation/time-period.h>
24 #include <dali/public-api/object/ref-object.h>
25 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
26 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-custom-effect.h>
27 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-effect-impl.h>
28
29 namespace Dali
30 {
31
32 class Animation;
33
34 namespace Toolkit
35 {
36
37 class ScrollGroup;
38 class ScrollView;
39
40 namespace Internal
41 {
42
43 /**
44  * @copydoc Toolkit::ScrollViewCustomEffect
45  */
46 class ScrollViewCustomEffect : public ScrollViewEffect
47 {
48   static const std::string SCROLL_AMOUNT_PROPERTY_STRING;
49   static const std::string ANCHOR_POINT_PROPERTY_STRING;
50
51 public:
52
53   /**
54    * Constructor
55    */
56   ScrollViewCustomEffect();
57
58 public:
59
60   /**
61    * @brief SetPageSpacing
62    * @param spacing
63    */
64   void SetPageSpacing(const Vector2& spacing);
65
66   /**
67    * @brief SetPageTranslation sets a simple translate on/off value
68    * @param translation
69    */
70   void SetPageTranslation(const Vector3& translation);
71
72   /**
73    * @brief SetPageTranslation
74    * @param translationIn
75    * @param translationOut
76    */
77   void SetPageTranslation(const Vector3& translationIn, const Vector3& translationOut);
78
79   /**
80    * @brief SetPageTranslationIn
81    * @param translation
82    */
83   void SetPageTranslationIn(const Vector3& translation);
84
85   /**
86    * @brief SetPageTranslationOut
87    * @param translation
88    */
89   void SetPageTranslationOut(const Vector3& translation);
90
91   /**
92    * @brief SetPageTranslateAlphaFunction
93    * @param func
94    */
95   void SetPageTranslateAlphaFunction(AlphaFunction func);
96
97   /**
98    * @brief SetPageTranslateAlphaFunction
99    * @param funcIn
100    * @param funcOut
101    */
102   void SetPageTranslateAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
103
104   /**
105    * @brief SetPageTranslateAlphaFunctionIn
106    * @param func
107    */
108   void SetPageTranslateAlphaFunctionIn(AlphaFunction func);
109
110   /**
111    * @brief SetPageTranslateAlphaFunctionOut
112    * @param func
113    */
114   void SetPageTranslateAlphaFunctionOut(AlphaFunction func);
115
116   /**
117    * @brief SetGlobalPageRotation
118    * @param angle
119    * @param axis
120    */
121   void SetGlobalPageRotation(float angle, const Vector3& axis);
122
123   /**
124    * @brief SetAnglePageRotation uses the angle and page size passed in on creation to create a faked origin (inner cube needs this method)
125    * @param angle
126    */
127   void SetAngledOriginPageRotation(const Vector3& angle);
128
129   /**
130    * @brief SetGlobalPageRotation
131    * @param angleIn
132    * @param axisIn
133    * @param angleOut
134    * @param axisOut
135    */
136   void SetGlobalPageRotation(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
137
138   /**
139    * @brief SetGlobalPageRotationIn
140    * @param angle
141    * @param axis
142    */
143   void SetGlobalPageRotationIn(float angle, const Vector3& axis);
144
145   /**
146    * @brief SetGlobalPageRotationOut
147    * @param angle
148    * @param axis
149    */
150   void SetGlobalPageRotationOut(float angle, const Vector3& axis);
151
152   /**
153    * @brief SetPageRotationOrigin Set the origin to rotate all the pages around
154    *        - The default value is (0,0,0)
155    * @param origin
156    */
157   void SetGlobalPageRotationOrigin(const Vector3& origin);
158
159   /**
160    * @brief SetGlobalPageRotationOrigin
161    * @param originIn
162    * @param originOut
163    */
164   void SetGlobalPageRotationOrigin(const Vector3& originIn, const Vector3& originOut);
165
166   /**
167    * @brief SetGlobalPageRotationOriginIn
168    * @param origin
169    */
170   void SetGlobalPageRotationOriginIn(const Vector3& origin);
171
172   /**
173    * @brief SetGlobalPageRotationOriginOut
174    * @param origin
175    */
176   void SetGlobalPageRotationOriginOut(const Vector3& origin);
177
178   /**
179    * @brief SetSwingAngle
180    * @param angle
181    * @param axis
182    */
183   void SetSwingAngle(const float angle, const Vector3& axis);
184
185   /**
186    * @brief SetSwingAngle
187    * @param angleIn
188    * @param axisIn
189    * @param angleOut
190    * @param axisOut
191    */
192   void SetSwingAngle(float angleIn, const Vector3& axisIn, float angleOut, const Vector3& axisOut);
193
194   /**
195    * @brief SetSwingAngleIn
196    * @param angle
197    * @param axis
198    */
199   void SetSwingAngleIn(float angle, const Vector3& axis);
200
201   /**
202    * @brief SetSwingAngleOut
203    * @param angle
204    * @param axis
205    */
206   void SetSwingAngleOut(float angle, const Vector3& axis);
207
208   /**
209    * @brief SetSwingAngleAlphaFunction
210    * @param func
211    */
212   void SetSwingAngleAlphaFunction(AlphaFunction func);
213
214   /**
215    * @brief SetSwingAngleAlphaFunction
216    * @param funcIn
217    * @param funcOut
218    */
219   void SetSwingAngleAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
220
221   /**
222    * @brief SetSwingAngleAlphaFunctionIn
223    * @param func
224    */
225   void SetSwingAngleAlphaFunctionIn(AlphaFunction func);
226
227   /**
228    * @brief SetSwingAngleAlphaFunctionOut
229    * @param func
230    */
231   void SetSwingAngleAlphaFunctionOut(AlphaFunction func);
232
233   /**
234    * @brief SetSwingAnchor
235    * @param anchor
236    */
237   void SetSwingAnchor(const Vector3& anchor);
238
239   /**
240    * @brief SetSwingAnchor
241    * @param anchorIn
242    * @param anchorOut
243    */
244   void SetSwingAnchor(const Vector3& anchorIn, const Vector3& anchorOut);
245
246   /**
247    * @brief SetSwingAnchorIn
248    * @param anchor
249    */
250   void SetSwingAnchorIn(const Vector3& anchor);
251
252   /**
253    * @brief SetSwingAnchorOut
254    * @param anchor
255    */
256   void SetSwingAnchorOut(const Vector3& anchor);
257
258   /**
259    * @brief SetSwingAnchorAlphaFunction
260    * @param func
261    */
262   void SetSwingAnchorAlphaFunction(AlphaFunction func);
263
264   /**
265    * @brief SetSwingAnchorAlphaFunction
266    * @param funcIn
267    * @param funcOut
268    */
269   void SetSwingAnchorAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
270
271   /**
272    * @brief SetSwingAnchorAlphaFunctionIn
273    * @param func
274    */
275   void SetSwingAnchorAlphaFunctionIn(AlphaFunction func);
276
277   /**
278    * @brief SetSwingAnchorAlphaFunctionOut
279    * @param func
280    */
281   void SetSwingAnchorAlphaFunctionOut(AlphaFunction func);
282
283   /**
284    * @brief SetOpacityThreshold
285    * @param thresh
286    */
287   void SetOpacityThreshold(float thresh);
288
289   /**
290    * @brief SetOpacityThreshold
291    * @param threshIn
292    * @param threshOut
293    */
294   void SetOpacityThreshold(float threshIn, float threshOut);
295
296   /**
297    * @brief SetOpacityThresholdIn
298    * @param thresh
299    */
300   void SetOpacityThresholdIn(float thresh);
301
302   /**
303    * @brief SetOpacityThresholdOut
304    * @param thresh
305    */
306   void SetOpacityThresholdOut(float thresh);
307
308   /**
309    * @brief SetOpacityAlphaFunction
310    * @param func
311    */
312   void SetOpacityAlphaFunction(AlphaFunction func);
313
314   /**
315    * @brief SetOpacityAlphaFunction
316    * @param funcIn
317    * @param funcOut
318    */
319   void SetOpacityAlphaFunction(AlphaFunction funcIn, AlphaFunction funcOut);
320
321   /**
322    * @brief SetOpacityAlphaFunctionIn
323    * @param func
324    */
325   void SetOpacityAlphaFunctionIn(AlphaFunction func);
326
327   /**
328    * @brief SetOpacityAlphaFunctionOut
329    * @param func
330    */
331   void SetOpacityAlphaFunctionOut(AlphaFunction func);
332
333
334   /**
335    * ApplyToPage This is the full internal ApplyToPage function and ALL other ApplyToPage
336    * functions should call this one. Making this internal allows us to change this function
337    * in the future without affecting demo apps
338    * @param page
339    * @param pageSize
340    */
341   void ApplyToPage( Actor page, Vector3 pageSize);
342
343   /**
344    * @copydoc ScrollViewEffect::OnAttach
345    */
346   virtual void OnAttach( Toolkit::ScrollView& scrollView );
347
348   /**
349    * @copydoc ScrollViewEffect::OnDetach
350    */
351   virtual void OnDetach( Toolkit::ScrollView& scrollView );
352
353 protected:
354
355   /**
356    * A reference counted object may only be deleted by calling Unreference()
357    */
358   virtual ~ScrollViewCustomEffect();
359
360 private:
361
362   Vector3 mPageSize; ///< The logical page size for the 3D effect.
363
364   uint          mFlags;                         ///< flags describing functionality, set automatically depending on functions called during effect setup
365   Vector2       mPageSpacing;                   ///< space between pages... kinda obvious really
366   Vector3       mTranslateIn;                   ///< translation offset to use when scrolling a page onto the screen
367   Vector3       mTranslateOut;                  ///< translation offset to use when scrolling a page off the screen
368   Quaternion    mGlobalRotateIn;                ///< rotates the page's position around a point
369   Quaternion    mGlobalRotateOut;               ///< rotates the page's position around a point
370   Vector3       mGlobalOriginIn;                ///< the point to rotate a page around when scrolling onto screen
371   Vector3       mGlobalOriginOut;               ///< the point to rotate a page around when scrolling off screen
372   float         mSwingAngleIn;                  ///< angle to rotate a page around its anchor when scrolling onto screen
373   Vector3       mSwingAxisIn;
374   float         mSwingAngleOut;                 ///< angle to rotate a page around its anchor when scrolling off screen
375   Vector3       mSwingAxisOut;
376   Vector3       mSwingAnchorIn;                 ///< the page anchor point to use when scrolling onto screen
377   Vector3       mSwingAnchorOut;                ///< the page anchor point to use when scrolling off screen
378   float         mOpacityThresholdIn;            ///< the point at which opacity will change as page scrolls onto screen
379   float         mOpacityThresholdOut;           ///< the point at which opacity will change as page scrolls off screen
380   AlphaFunction mGlobalRotateAlphaFunctionIn;
381   AlphaFunction mGlobalRotateAlphaFunctionOut;
382   AlphaFunction mSwingAlphaFunctionIn;
383   AlphaFunction mSwingAlphaFunctionOut;
384   AlphaFunction mSwingAnchorAlphaFunctionIn;
385   AlphaFunction mSwingAnchorAlphaFunctionOut;
386   AlphaFunction mTranslateAlphaFunctionIn;
387   AlphaFunction mTranslateAlphaFunctionOut;
388   AlphaFunction mOpacityAlphaFunctionIn;
389   AlphaFunction mOpacityAlphaFunctionOut;
390 };
391
392 } // namespace Internal
393
394 // Helpers for public-api forwarding methods
395
396 inline Internal::ScrollViewCustomEffect& GetImpl(Dali::Toolkit::ScrollViewCustomEffect& obj)
397 {
398   DALI_ASSERT_ALWAYS(obj);
399
400   Dali::RefObject& handle = obj.GetBaseObject();
401
402   return static_cast<Internal::ScrollViewCustomEffect&>(handle);
403 }
404
405 inline const Internal::ScrollViewCustomEffect& GetImpl(const Dali::Toolkit::ScrollViewCustomEffect& obj)
406 {
407   DALI_ASSERT_ALWAYS(obj);
408
409   const Dali::RefObject& handle = obj.GetBaseObject();
410
411   return static_cast<const Internal::ScrollViewCustomEffect&>(handle);
412 }
413
414 } // namespace Toolkit
415
416 } // namespace Dali
417
418 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_CUSTOM_EFFECT_H__