043dc2c6c7a2a09e27fe209aff53a7fb7b5235ef
[platform/core/uifw/dali-toolkit.git] / capi / dali-toolkit / public-api / controls / scrollable / scroll-view / scroll-view-slide-effect.h
1 #ifndef __DALI_TOOLKIT_SCROLL_VIEW_SLIDE_EFFECT_H__
2 #define __DALI_TOOLKIT_SCROLL_VIEW_SLIDE_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 // EXTERNAL INCLUDES
27
28 // INTERNAL INCLUDES
29 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-effect.h>
30
31 namespace Dali DALI_IMPORT_API
32 {
33
34 class Actor;
35
36 namespace Toolkit
37 {
38
39 class ScrollViewEffect;
40
41 namespace Internal DALI_INTERNAL
42 {
43 class ScrollViewSlideEffect;
44 }
45
46 /**
47  * @brief ScrollView effect that uses slides for transitioning pages.
48  */
49 class ScrollViewSlideEffect : public ScrollViewEffect
50 {
51 public:
52   static const std::string EFFECT_TIME;        ///< Effect time property name
53   static const std::string EFFECT_REFERENCE;   ///< Effect reference property name
54   static const std::string EFFECT_ACTIVE;      ///< Effect active property name
55
56 public:
57
58   /**
59    * @brief Create an initialized ScrollViewSlideEffect.
60    *
61    * @return A handle to a newly allocated Dali resource.
62    */
63   static ScrollViewSlideEffect New();
64
65   /**
66    * @brief Create an uninitialized ScrollViewSlideEffect; this can be initialized with ScrollViewSlideEffect::New().
67    *
68    * Calling member functions with an uninitialized Toolkit::ScrollViewSlideEffect is not allowed.
69    */
70   ScrollViewSlideEffect();
71
72   /**
73    * @brief Downcast an Object handle to ScrollViewSlideEffect.
74    *
75    * If handle points to a ScrollViewSlideEffect the downcast produces
76    * valid handle. If not the returned handle is left uninitialized.
77    *
78    * @param[in] handle Handle to an object
79    * @return handle to a ScrollViewSlideEffect or an uninitialized handle
80    */
81   static ScrollViewSlideEffect DownCast( BaseHandle handle );
82
83   /**
84    * @brief Gets the slide direction for this effect.
85    *
86    * @return The slide direction (true = vertical, false = horizontal)
87    */
88   bool GetSlideDirection() const;
89
90   /**
91    * @brief Sets the slide direction for this effect.
92    *
93    * If the direction has been set to horizontal (false), then
94    * the user will see the Actors have a delay in horizontal movement
95    * based on the vertical distance the actor is away from the initial drag point.
96    * If the direction has been set to vertical (true), then the
97    * user will experience the opposite effect (i.e. delay in the vertical movement).
98    * @param[in] vertical The slide direction (true = vertical, false = horizontal)
99    * (default is horizontal i.e. false)
100    */
101   void SetSlideDirection(bool vertical);
102
103   /**
104    * @brief Gets the delay reference offset for this effect.
105    *
106    * @return The delay reference offset (Vector3::ZERO - indicates no offset)
107    */
108   Vector3 GetDelayReferenceOffset() const;
109
110   /**
111    * @brief Sets an offset for where the central delay point on the scroll-view should be
112    * when dragging.
113    *
114    * By default the offset is 0. Which means that the point where the user drags
115    * the scroll-view content should have no delay, and the further away from this
116    * point, the delay should increase. Adjusting this offset to for example
117    * 0.0f, -stageSize.height * 0.5f, will mean that dragging the center of the stage
118    * will result in the content at the top of the stage moving with no delay, and
119    * the further away from this point (top of stage), the delay should increase.
120    * @param[in] offset The offset in local coordinates, relative to the ScrollView.
121    */
122   void SetDelayReferenceOffset(const Vector3& offset);
123
124   /**
125    * @brief Gets the maximum duration of the effect after scrolling completes.
126    *
127    * @return The duration in seconds
128    */
129   float GetMaxDelayDuration() const;
130
131   /**
132    * @brief Sets the maximum duration of the effect after scrolling completes.
133    *
134    * @param[in] duration The duration in seconds (>= 0.0f, default is 0.25 seconds)
135    */
136   void SetMaxDelayDuration(float duration);
137
138   /**
139    * @brief Manually apply effect to an Actor.
140    *
141    * @param[in] child The child Actor to be affected by this effect.
142    * @param[in] delayMin The minimum delay coefficient for Actors at the
143    * scroll-view touch point. Set to 0 for instantaneous, and 1 for infinite delay.
144    * Default is 0.5f
145    * @param[in] delayMax The maximum delay coefficient for Actors at the
146    * scroll-view approx 1 ScrollView size from the touch point. Set to 0 for
147    * instantaneous, and 1 for infinite delay. Default is 0.99f (a noticable delay)
148    */
149   void ApplyToActor( Actor child,
150                      float delayMin = 0.5f,
151                      float delayMax = 0.95f );
152
153 protected:
154
155   /**
156    * @brief This constructor is used by Dali New() methods.
157    *
158    * @param [in] impl A pointer to a newly allocated Dali resource
159    */
160   ScrollViewSlideEffect(Internal::ScrollViewSlideEffect *impl);
161
162 };
163
164 } // namespace Toolkit
165
166 } // namespace Dali
167
168 /**
169  * @}
170  */
171 #endif // __DALI_TOOLKIT_SCROLL_VIEW_SLIDE_EFFECT_H__