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