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