1 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_OVERSHOOT_INDICATOR_H__
2 #define __DALI_TOOLKIT_INTERNAL_SCROLL_OVERSHOOT_INDICATOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
20 #include <dali/dali.h>
21 #include <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
32 class ScrollOvershootEffect;
33 class ScrollOvershootEffectGradient;
34 class ScrollOvershootEffectRipple;
35 typedef IntrusivePtr<ScrollOvershootEffect> ScrollOvershootEffectPtr;
36 typedef IntrusivePtr<ScrollOvershootEffectGradient> ScrollOvershootEffectGradientPtr;
37 typedef IntrusivePtr<ScrollOvershootEffectRipple> ScrollOvershootEffectRipplePtr;
39 struct ScrollOvershootIndicator : public Dali::RefObject
44 * ScrollOvershootIndicator constructor.
45 * @param[in] scrollView reference to ScrollView implementation
46 * or horizontally (false)
48 ScrollOvershootIndicator( Scrollable& scrollable);
53 virtual ~ScrollOvershootIndicator();
56 * Enables and disables the indicator
57 * ¶m[in] enable true to enable, false to disable
59 void Enable(bool enable);
62 * Resets the indicator
67 * Create an initialized ScrollOvershootIndicator
68 * @param[in] scrollView reference to ScrollView implementation
69 * or horizontally (false)
70 * @return A pointer to the created ScrollOvershootIndicator.
72 static ScrollOvershootIndicator* New( Scrollable& scrollable);
75 Scrollable& mScrollable; ///< Internal::Scrollable object
76 ScrollOvershootEffectPtr mEffectX; ///< effect used for x-axis/horizontal display
77 ScrollOvershootEffectPtr mEffectY; ///< effect used for y-axis/vertical display
81 * ScrollOvershootEffect is a derivable class, designed to allow the application programmer to create their own
82 * overshoot effect and apply it with minimal implementation required
84 struct ScrollOvershootEffect : public Dali::RefObject
88 * Create a new overshoot effect, passing in whether it is vertical or horizontal
90 * @param[in] vertical whether this effect is a vertical or horizontal one
92 ScrollOvershootEffect(bool vertical);
97 virtual ~ScrollOvershootEffect() {}
100 * Returns if this is a vertical or horizontal overhoot effect
102 * @return true or false
104 inline bool IsVertical() { return mVertical; }
107 * Applies the indicator effect, all derived effects must implement this function
109 * @param[in] scrollable the scrollable object to apply this effect to
111 virtual void Apply(Scrollable& scrollable) = 0;
114 * Removes the indicator effect, all derived effects must implement this function
116 * @param[in] scrollable the scrollable object to remove this effect from
118 virtual void Remove(Scrollable& scrollable) = 0;
121 * Resets this overshoot effect
123 virtual void Reset() = 0;
126 * Updates the constraints used for the overshoot effect
128 * @param[in] scrollable the container for the overshoot effect
130 virtual void UpdateConstraints(Actor& scrollable) {}
133 * Sets up property notifications for overshoot values
135 * @param[in] scrollable the container for the overshoot effect
137 virtual void SetPropertyNotifications(Actor& scrollable) {}
140 bool mVertical; ///< whether this is a vertical/horizontal effect
144 * ScrollOvershootEffectRipple creates an animated bounce effect at the end of the scrollable area if the user
145 * attempts to scroll past it
147 struct ScrollOvershootEffectRipple : public ScrollOvershootEffect, public ConnectionTracker
151 * Create a new gradient overshoot effect, passing in whether it is vertical or horizontal
153 ScrollOvershootEffectRipple(bool vertical);
156 * @copydoc ScrollOvershootEffect::Apply
158 virtual void Apply(Scrollable& scrollable);
161 * @copydoc ScrollOvershootEffect::Remove
163 virtual void Remove(Scrollable& scrollable);
166 * @copydoc ScrollOvershootEffect::Reset
168 virtual void Reset();
171 * @copydoc ScrollOvershootEffect::UpdateConstraints(Actor& scrollable)
173 virtual void UpdateConstraints(Actor& scrollable);
176 * @copydoc ScrollOvershootEffect::SetPropertyNotification
178 virtual void SetPropertyNotifications(Actor& scrollable);
181 * Constrains the size of the gradient image
182 * @param[in] current current position of the image actor
183 * @param[in] parentSizeProperty size of the scrollable area so we can position image on the edge of it
184 * @param[in] overshootProperty current overshoot amount for this indicator's axis
185 * @return new position of the gradient image actor
187 Vector3 PositionConstraint(const Vector3& current, const PropertyInput& parentSizeProperty, const PropertyInput& overshootProperty);
190 * Informs overshoot effect to update image position and to animate effect overshoot value for a
191 * positive overshoot value from scrollview
193 * @param[in] source the property notification that triggered this callback
195 void OnPositiveOvershootNotification(PropertyNotification& source);
198 * Informs overshoot effect to update image position and to animate effect overshoot value for a
199 * negative overshoot value from scrollview
201 * @param[in] source the property notification that triggered this callback
203 void OnNegativeOvershootNotification(PropertyNotification& source);
206 * Function to animate effect overshoot value either to -1.0f/1.0f or 0.0f
208 * @param[in] overshootAmount the amount to animate overshoot to [-1.0f,0.0f,1.0f]
210 void AnimateScrollOvershoot(float overshootAmount);
213 * Connects to the animation finished signal of our overshoot animation
215 * @param[in] animation the animation instance that has finished
217 void OnOvershootAnimFinished(Animation& animation);
220 * Creates a new ScrollOvershootEffectGradient objects and returns a pointer to it
221 * @param[in] vertical whether to create a vertical(true) or horizontal effect
222 * @return a pointer to the new effect
224 static ScrollOvershootEffectRipplePtr New( bool vertical );
228 float mMaxOvershootImageSize; ///< maximum size of the image when overshoot value is 1.0f
229 ImageActor mOvershootImage; ///< the overshoot image...
230 Animation mScrollOvershootAnimation; ///< animation
231 bool mAnimatingOvershootOn; ///< whether we are currently animating overshoot to 1.0f/-1.0f (on) or to 0.0f (off)
232 bool mAnimateOvershootOff; ///< whether we are currently animating overshoot to 1.0f/-1.0f (on) or to 0.0f (off)
233 int mCanScrollPropertyIndex; ///< property index to a property that informs indicator if it is needed
234 BouncingEffect mRippleEffect; // the ripple vertex/fragment shader effect
235 PropertyNotification mOvershootPositiveNotification; // stores the property notification used for positive overshoot values
236 PropertyNotification mOvershootNegativeNotification; // stores the property notification used for negative overshoot values
237 ActiveConstraint mSizeConstraint; // active constraint handle used to store the image width constraint
238 ActiveConstraint mPositionConstraint; // active constraint handle used to store the image position constraint
241 } // namespace Internal
243 } // namespace Toolkit
247 #endif // __DALI_TOOLKIT_INTERNAL_SCROLL_OVERSHOOT_INDICATOR_H__