Patch 1: Add API CreateBouncingEffectActor to creates a Dali::Actor to display the bouncing effect for overshoot
Patch 5: Integrate with ScrollView, ItemView
Patch 7: Add PROPERTY_OVERSHOOT_EFFECT_COLOR to allow the StyleManager to apply the theme color
Reduce the height of the effect when the width of scrollable is less than 180px
patch 9: Add the script for overshoot-effect-color
patch 14: fix the size bug
Change-Id: I2f979ff59ab78b4ce8931b36d0bc2dff48dc7901
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/actors/mesh-actor.h>
+#include <dali/public-api/geometry/animatable-mesh.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/shader-effects/shader-effect.h>
+#include <dali/public-api/math/vector3.h>
+
+// EXTERNAL INCLUDES
+#include <math.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+// Bouncing effect is presented by stacked three layers with same color and opacity
+const size_t NUM_LAYERS( 3 );
+const Vector3 LAYER_HEIGHTS( 1.f, 27.f/42.f, 13.f/42.f);
+
+// use the actor color to paint every layer
+const char* MESH_FRAGMENT_SHADER =
+"void main()\n"
+"{\n"
+" gl_FragColor = uColor;\n"
+"}\n";
+
+// Constraint to move the vertices vertically
+struct VertexPositionConstraint
+{
+ VertexPositionConstraint( float initialY, float range )
+ : mInitialY( initialY ),
+ mRange( range )
+ {
+ }
+
+ Vector3 operator()( const Vector3& current, const PropertyInput& bounceCoef )
+ {
+ float positionY = mInitialY + mRange * fabsf(bounceCoef.GetFloat());
+ return Vector3( current.x, positionY, current.z );
+ }
+
+ float mInitialY;
+ float mRange;
+};
+
+} // namespace Anon
+
+Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex )
+{
+ Dali::AnimatableMesh mesh;
+ Dali::MeshActor meshActor;
+
+ Dali::AnimatableMesh::Faces faces;
+ faces.reserve( NUM_LAYERS * 6 ); // 2 triangles per layer
+ for( size_t i=0; i<NUM_LAYERS; i++ )
+ {
+ size_t j=i*4;
+ faces.push_back(j); faces.push_back(j+3); faces.push_back(j+1);
+ faces.push_back(j); faces.push_back(j+2); faces.push_back(j+3);
+ }
+
+ mesh = Dali::AnimatableMesh::New(NUM_LAYERS*4, faces); // 4 vertices per layer
+ for( size_t i=0;i<NUM_LAYERS;i++ )
+ {
+ size_t j=i*4;
+ float positionZ = 0.01f*static_cast<float>( i ); // the interval between each layer is 0.01
+ mesh[j ].SetPosition( Vector3( -0.5f, -0.5f, positionZ ) );
+ mesh[j+1].SetPosition( Vector3( 0.5f, -0.5f, positionZ ) );
+ mesh[j+2].SetPosition( Vector3( -0.5f, -0.5f, positionZ ) );
+ mesh[j+3].SetPosition( Vector3( 0.5f, -0.5f, positionZ ) );
+ }
+
+ meshActor = Dali::MeshActor::New(mesh);
+ meshActor.SetAffectedByLighting(false);
+
+ Dali::ShaderEffect shaderEffect = Dali::ShaderEffect::New( "", MESH_FRAGMENT_SHADER,
+ GEOMETRY_TYPE_MESH,
+ Dali::ShaderEffect::HINT_BLENDING );
+ meshActor.SetShaderEffect(shaderEffect);
+
+ // To control the movement of all vertices with one custom property
+ bouncePropertyIndex = meshActor.RegisterProperty("BounceCoeffcient", 0.f);
+ for( size_t i=0;i<NUM_LAYERS;i++ )
+ {
+ size_t j=i*4;
+ mesh.ApplyConstraint( Constraint::New<Vector3>( mesh.GetPropertyIndex(j+2, AnimatableVertex::POSITION ),
+ Source(meshActor, bouncePropertyIndex),
+ VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) ) );
+ mesh.ApplyConstraint( Constraint::New<Vector3>( mesh.GetPropertyIndex(j+3, AnimatableVertex::POSITION),
+ Source(meshActor, bouncePropertyIndex),
+ VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) ) );
+ }
+
+ return meshActor;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_BOUNCING_EFFECT_ACTOR_H__
+#define __DALI_TOOLKIT_INTERNAL_BOUNCING_EFFECT_ACTOR_H__
+
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/object/property.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+/**
+ * @brief Creates a Dali::Actor to display the bouncing effect for overshoot
+ *
+ * Usage example:
+ * @code
+ * // create the actor and get the property index for animation
+ * Property::Index bouncePropertyIndex = Property::INVALID_INDEX;
+ * Actor bounceActor = CreateBouncingEffectActor( bouncePropertyIndex );
+
+ * // set size and color
+ * bounceActor.SetSize(720.f, 42.f );
+ * bounceActor.SetColor( Vector4( 0.0,0.64f,0.85f,0.25f ) );
+ *
+ * // add to stage
+ * bounceActor.SetParentOrigin(ParentOrigin::CENTER);
+ * Stage::GetCurrent().Add(bounceActor);
+
+ * // start the bouncing animation
+ * Animation anim = Animation::New(2.0f);
+ * anim.AnimateTo( Property( bounceActor, bouncePropertyIndex ), 1.f, AlphaFunctions::Sin );
+ * anim.Play();
+ * @endcode
+ *
+ * @param[out] bouncePropertyIndex The property index which controls the bouncing
+ * @return The actor which displays the bouncing effect
+ */
+Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex);
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+
+#endif /* __DALI_TOOLKIT_INTERNAL_BOUNCING_EFFECT_ACTOR_H__ */
#include <dali/public-api/events/mouse-wheel-event.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-factory.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h>
-#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
+#include <dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h>
using namespace std;
using namespace Dali;
const float MILLISECONDS_PER_SECONDS = 1000.0f;
-const Rect<int> OVERSHOOT_BOUNCE_IMAGE_1_PIXEL_AREA( 0, 0, 720, 58 );
+const Vector2 OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE( 720.0f, 42.0f );
+const float OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD = 180.0f;
const Vector4 OVERSHOOT_OVERLAY_NINE_PATCH_BORDER(0.0f, 0.0f, 1.0f, 12.0f);
const float MAXIMUM_OVERSHOOT_HEIGHT = 36.0f; // 36 pixels
const float DEFAULT_OVERSHOOT_ANIMATION_DURATION = 0.5f; // 0.5 second
struct OvershootOverlaySizeConstraint
{
- float operator()(const float& current,
+ Vector3 operator()(const Vector3& current,
const PropertyInput& parentScrollDirectionProperty,
const PropertyInput& parentOvershootProperty,
const PropertyInput& parentSizeProperty)
overlayWidth = fabsf(parentScrollDirection.x) > Math::MACHINE_EPSILON_1 ? parentSize.y : parentSize.x;
}
- return overlayWidth;
+ float overlayHeight = (overlayWidth > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height*0.5f;
+
+ return Vector3( overlayWidth, overlayHeight, current.depth );
}
};
mScrollStartedSignalV2.Emit(GetCurrentScrollPosition());
}
+void ItemView::SetOvershootEffectColor( const Vector4& color )
+{
+ mOvershootEffectColor = color;
+ if( mOvershootOverlay )
+ {
+ mOvershootOverlay.SetColor( color );
+ }
+}
+
void ItemView::SetOvershootEnabled( bool enable )
{
Actor self = Self();
if( enable )
{
- mOvershootEffect = BouncingEffect::New(Scrollable::DEFAULT_OVERSHOOT_COLOUR);
- mOvershootOverlay = CreateSolidColorActor(Vector4::ONE);
+ Property::Index effectOvershootPropertyIndex = Property::INVALID_INDEX;
+ mOvershootOverlay = CreateBouncingEffectActor( effectOvershootPropertyIndex );
+ mOvershootOverlay.SetColor(mOvershootEffectColor);
mOvershootOverlay.SetParentOrigin(ParentOrigin::TOP_LEFT);
mOvershootOverlay.SetAnchorPoint(AnchorPoint::TOP_LEFT);
mOvershootOverlay.SetDrawMode(DrawMode::OVERLAY);
- mOvershootOverlay.SetShaderEffect(mOvershootEffect);
self.Add(mOvershootOverlay);
- Constraint constraint = Constraint::New<float>( Actor::SIZE_WIDTH,
+
+ Constraint constraint = Constraint::New<Vector3>( Actor::SIZE,
ParentSource( mPropertyScrollDirection ),
Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
ParentSource( Actor::SIZE ),
OvershootOverlaySizeConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
- mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_IMAGE_1_PIXEL_AREA.width, OVERSHOOT_BOUNCE_IMAGE_1_PIXEL_AREA.height);
+ mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
constraint = Constraint::New<Quaternion>( Actor::ROTATION,
ParentSource( mPropertyScrollDirection ),
OvershootOverlayVisibilityConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
- int effectOvershootPropertyIndex = mOvershootEffect.GetPropertyIndex(mOvershootEffect.GetProgressRatePropertyName());
Actor self = Self();
constraint = Constraint::New<float>( effectOvershootPropertyIndex,
Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
EqualToConstraint() );
- mOvershootEffect.ApplyConstraint(constraint);
+ mOvershootOverlay.ApplyConstraint(constraint);
}
else
{
self.Remove(mOvershootOverlay);
mOvershootOverlay.Reset();
}
- mOvershootEffect.Reset();
}
}
#include <dali-toolkit/public-api/controls/scrollable/scroll-connector.h>
#include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
-#include <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
namespace Dali
{
void ScrollTo(const Vector3& position, float duration);
/**
+ * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor
+ */
+ void SetOvershootEffectColor( const Vector4& color );
+
+ /**
* @brief Set whether to enable automatic refresh or not. When refresh is disabled,
* ItemView will not automatically refresh the cache in the given interval when the
* layout position is changed. This is useful in some cases, for example, automatic
Dali::Gesture::State mGestureState;
- ImageActor mOvershootOverlay; ///< The overlay actor for overshoot effect
- BouncingEffect mOvershootEffect; ///< The vertex/fragment shader used to display the overshoot ripple effect
+ Actor mOvershootOverlay; ///< The overlay actor for overshoot effect
Dali::Toolkit::ScrollConnector mScrollConnector; ///< Connects ItemView with scrollable components e.g. scroll bars
Constrainable mScrollPositionObject; ///< From mScrollConnector
#include <boost/bind.hpp>
#include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
+#include <dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
-#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
using namespace Dali;
-namespace Dali
-{
-
-namespace Toolkit
+namespace
{
+const float DEFAULT_MAX_OVERSHOOT_HEIGHT = 36.0f; // 36 pixels
+const Vector2 OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE( 720.0f, 42.0f );
+const float OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD = 180.0f;
-namespace Internal
+// local helper function to resize the height of the bounce actor
+float GetBounceActorHeight( float width )
{
+ return (width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height * 0.5f;
+}
-const float DEFAULT_MAX_OVERSHOOT_HEIGHT = 36.0f; // 36 pixels
-const Rect<int> OVERSHOOT_RIPPLE_IMAGE_1_PIXEL_AREA( 0, 0, 720, 58 );
const float DEFAULT_OVERSHOOT_ANIMATION_DURATION = 0.35f; // time in seconds
const float MAX_OVERSHOOT_NOTIFY_AMOUNT = 0.9f; // maximum amount to set notification for increased overshoot, beyond this we just wait for it to reduce again
const float MIN_OVERSHOOT_NOTIFY_AMOUNT = Math::MACHINE_EPSILON_1; // minimum amount to set notification for reduced overshoot, beyond this we just wait for it to increase again
const float OVERSHOOT_NOTIFY_STEP = 0.1f; // amount to set notifications beyond current overshoot value
+}
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
ScrollOvershootIndicator::ScrollOvershootIndicator() :
mEffectX(NULL),
mEffectY(NULL)
mEffectY->Reset();
}
+void ScrollOvershootIndicator::SetOvershootEffectColor( const Vector4& color )
+{
+ if(mEffectX)
+ {
+ mEffectX->SetOvershootEffectColor(color);
+ }
+ if(mEffectY)
+ {
+ mEffectY->SetOvershootEffectColor(color);
+ }
+}
+
+void ScrollOvershootIndicator::ClearOvershoot()
+{
+ if(mEffectX)
+ {
+ mEffectX->SetOvershoot(0.0f);
+ }
+ if(mEffectY)
+ {
+ mEffectY->SetOvershoot(0.0f);
+ }
+}
+
ScrollOvershootEffect::ScrollOvershootEffect( bool vertical ) :
mVertical(vertical)
{
mOvershoot(0.0f),
mAnimationStateFlags(0)
{
- mRippleEffect = BouncingEffect::New(Scrollable::DEFAULT_OVERSHOOT_COLOUR);
- mOvershootImage = CreateSolidColorActor(Vector4::ONE);
- mOvershootImage.SetParentOrigin(ParentOrigin::TOP_LEFT);
- mOvershootImage.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- mOvershootImage.SetDrawMode(DrawMode::OVERLAY);
- mOvershootImage.SetShaderEffect(mRippleEffect);
- mOvershootImage.SetVisible(false);
+ mOvershootOverlay = CreateBouncingEffectActor(mEffectOvershootProperty);
+ mOvershootOverlay.SetColor(mAttachedScrollView.GetOvershootEffectColor());
+ mOvershootOverlay.SetParentOrigin(ParentOrigin::TOP_LEFT);
+ mOvershootOverlay.SetAnchorPoint(AnchorPoint::TOP_LEFT);
+ mOvershootOverlay.SetDrawMode(DrawMode::OVERLAY);
+ mOvershootOverlay.SetVisible(false);
+
}
void ScrollOvershootEffectRipple::Apply()
Actor self = mAttachedScrollView.Self();
mOvershootProperty = self.GetPropertyIndex(IsVertical() ? Toolkit::ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME : Toolkit::ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
mCanScrollPropertyIndex = self.GetPropertyIndex(IsVertical() ? Scrollable::SCROLLABLE_CAN_SCROLL_VERTICAL : Scrollable::SCROLLABLE_CAN_SCROLL_HORIZONTAL);
- mEffectOvershootProperty = mRippleEffect.GetPropertyIndex(mRippleEffect.GetProgressRatePropertyName());
// make sure height is set, since we only create a constraint for image width
- mOvershootImage.SetSize(OVERSHOOT_RIPPLE_IMAGE_1_PIXEL_AREA.width, OVERSHOOT_RIPPLE_IMAGE_1_PIXEL_AREA.height);
+ mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
- mAttachedScrollView.AddOverlay(mOvershootImage);
+ mAttachedScrollView.AddOverlay(mOvershootOverlay);
UpdatePropertyNotifications();
}
void ScrollOvershootEffectRipple::Remove( Scrollable& scrollable )
{
- if(mOvershootImage)
+ if(mOvershootOverlay)
{
if(mOvershootIncreaseNotification)
{
scrollable.Self().RemovePropertyNotification(mOvershootDecreaseNotification);
mOvershootDecreaseNotification.Reset();
}
- scrollable.RemoveOverlay(mOvershootImage);
+ scrollable.RemoveOverlay(mOvershootOverlay);
}
}
void ScrollOvershootEffectRipple::Reset()
{
- mOvershootImage.SetVisible(false);
- mRippleEffect.SetUniform(mRippleEffect.GetProgressRatePropertyName(), 0.0f);
+ mOvershootOverlay.SetVisible(false);
+ mOvershootOverlay.SetProperty( mEffectOvershootProperty, 0.f);
}
void ScrollOvershootEffectRipple::UpdatePropertyNotifications()
}
}
+void ScrollOvershootEffectRipple::SetOvershootEffectColor( const Vector4& color )
+{
+ if(mOvershootOverlay)
+ {
+ mOvershootOverlay.SetColor(color);
+ }
+}
+
void ScrollOvershootEffectRipple::UpdateVisibility( bool visible )
{
- mOvershootImage.SetVisible(visible);
+ mOvershootOverlay.SetVisible(visible);
// make sure overshoot image is correctly placed
if( visible )
{
if(mOvershoot > 0.0f)
{
// positive overshoot
- const Vector3 imageSize = mOvershootImage.GetCurrentSize();
+ const Vector3 size = mOvershootOverlay.GetCurrentSize();
Vector3 relativeOffset;
const Vector3 parentSize = self.GetCurrentSize();
if(IsVertical())
{
- mOvershootImage.SetRotation(Quaternion(0.0f, Vector3::ZAXIS));
- mOvershootImage.SetSize(parentSize.width, imageSize.height, imageSize.depth);
+ mOvershootOverlay.SetRotation(Quaternion(0.0f, Vector3::ZAXIS));
+ mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth);
}
else
{
- mOvershootImage.SetRotation(Quaternion(1.5f * Math::PI, Vector3::ZAXIS));
- mOvershootImage.SetSize(parentSize.height, imageSize.height, imageSize.depth);
+ mOvershootOverlay.SetRotation(Quaternion(1.5f * Math::PI, Vector3::ZAXIS));
+ mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height), size.depth);
relativeOffset = Vector3(0.0f, 1.0f, 0.0f);
}
- mOvershootImage.SetPosition(relativeOffset * parentSize);
+ mOvershootOverlay.SetPosition(relativeOffset * parentSize);
}
else
{
// negative overshoot
- const Vector3 imageSize = mOvershootImage.GetCurrentSize();
+ const Vector3 size = mOvershootOverlay.GetCurrentSize();
Vector3 relativeOffset;
const Vector3 parentSize = self.GetCurrentSize();
if(IsVertical())
{
- mOvershootImage.SetRotation(Quaternion(Math::PI, Vector3::ZAXIS));
- mOvershootImage.SetSize(parentSize.width, imageSize.height, imageSize.depth);
+ mOvershootOverlay.SetRotation(Quaternion(Math::PI, Vector3::ZAXIS));
+ mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth);
relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
}
else
{
- mOvershootImage.SetRotation(Quaternion(0.5f * Math::PI, Vector3::ZAXIS));
- mOvershootImage.SetSize(parentSize.height, imageSize.height, imageSize.depth);
+ mOvershootOverlay.SetRotation(Quaternion(0.5f * Math::PI, Vector3::ZAXIS));
+ mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height), size.depth);
relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
}
- mOvershootImage.SetPosition(relativeOffset * parentSize);
+ mOvershootOverlay.SetPosition(relativeOffset * parentSize);
}
}
}
if( mOvershootAnimationDuration > Math::MACHINE_EPSILON_1 )
{
// setup the new overshoot to 0 animation
- float currentOvershoot = fabsf( mRippleEffect.GetProperty<float>( mEffectOvershootProperty ) );
+ float currentOvershoot = fabsf( mOvershootOverlay.GetProperty( mEffectOvershootProperty ).Get<float>() );
float duration = mOvershootAnimationDuration * (animatingOn ? (1.0f - currentOvershoot) : currentOvershoot);
if( duration > Math::MACHINE_EPSILON_0 )
}
mScrollOvershootAnimation = Animation::New(duration);
mScrollOvershootAnimation.FinishedSignal().Connect( this, &ScrollOvershootEffectRipple::OnOvershootAnimFinished );
- mScrollOvershootAnimation.AnimateTo( Property(mRippleEffect, mEffectOvershootProperty), amount, TimePeriod(0.0f, duration) );
+ mScrollOvershootAnimation.AnimateTo( Property(mOvershootOverlay, mEffectOvershootProperty), amount, TimePeriod(duration) );
mScrollOvershootAnimation.Play();
mAnimationStateFlags = animatingOn ? AnimatingIn : AnimatingOut;
}
}
else
{
- mRippleEffect.SetProgressRate(amount);
+ mOvershootOverlay.SetProperty( mEffectOvershootProperty, amount);
}
if( absAmount > Math::MACHINE_EPSILON_1 )
{
if( mAnimationStateFlags & AnimatingOut )
{
// should now be offscreen
- mOvershootImage.SetVisible(false);
+ mOvershootOverlay.SetVisible(false);
}
if( (mAnimationStateFlags & AnimateBack) )
{
*/
#include <dali/dali.h>
-#include <dali-toolkit/public-api/shader-effects/bouncing-effect.h>
namespace Dali
{
void Reset();
/**
+ * Clears the overshoot
+ */
+ void ClearOvershoot();
+
+ /**
* Create an initialized ScrollOvershootIndicator
*
* @return A pointer to the created ScrollOvershootIndicator.
*/
static ScrollOvershootIndicator* New();
+ /**
+ * Set the color of the overshoot effect.
+ * @parm[in] color The color of the overshoot effect
+ */
+ void SetOvershootEffectColor( const Vector4& color );
+
private:
ScrollOvershootEffectPtr mEffectX; ///< effect used for x-axis/horizontal display
ScrollOvershootEffectPtr mEffectY; ///< effect used for y-axis/vertical display
*/
virtual void UpdatePropertyNotifications() {}
+ /**
+ * @copydoc ScrollOvershootIndicator::SetOvershootEffectColor()
+ */
+ virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
+
+ /**
+ * Sets shader overshoot value, either immediately of by animating over time
+ *
+ * @param[in] amount The amount to set overshoot to [-1.0f,1.0f]
+ * @param[in] animate Whether to animate or set immediately
+ */
+ virtual void SetOvershoot(float amount, bool animate = true) = 0;
+
private:
bool mVertical; ///< whether this is a vertical/horizontal effect
};
void UpdatePropertyNotifications();
/**
+ * @copydoc ScrollOvershootEffect::SetOvershootEffectColor()
+ */
+ void SetOvershootEffectColor( const Vector4& color );
+
+ /**
* Updates the vibility of the overshoot image as well as updating its size, position and rotation
* This function is called when animation starts and finishes
*
void OnOvershootNotification(PropertyNotification& source);
/**
- * Sets shader overshoot value, either immediately of by animating over time
- *
- * @param[in] amount The amount to set overshoot to [-1.0f,1.0f]
- * @param[in] animate Whether to animate or set immediately
+ * @copydoc ScrollOvershootEffect::SetOvershoot()
*/
void SetOvershoot(float amount, bool animate = true);
static ScrollOvershootEffectRipplePtr New( bool vertical, Scrollable& scrollable );
private:
- ImageActor mOvershootImage; ///< the overshoot image...
+ Actor mOvershootOverlay; ///< the actor which displays the overshoot effect
Scrollable& mAttachedScrollView; ///< the actor that this indicator has been attached to
- BouncingEffect mRippleEffect; ///< the ripple vertex/fragment shader effect
Animation mScrollOvershootAnimation; ///< overshoot animation
PropertyNotification mOvershootIncreaseNotification;///< notification used to inform as overshoot increases
PropertyNotification mOvershootDecreaseNotification;///< notification used to inform as overshoot decreases
mInternalActor.Remove( actor );
}
+void ScrollView::SetOvershootEffectColor( const Vector4& color )
+{
+ mOvershootEffectColor = color;
+ if( mOvershootIndicator )
+ {
+ mOvershootIndicator->SetOvershootEffectColor( color );
+ }
+}
+
void ScrollView::SetScrollingDirection( Radian direction, Radian threshold )
{
PanGestureDetector panGesture( GetPanGestureDetector() );
{
self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
}
+
+ if( mOvershootIndicator )
+ {
+ mOvershootIndicator->ClearOvershoot();
+ }
}
else
{
*/
void RemoveOverlay(Actor actor);
+ /**
+ * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor
+ */
+ void SetOvershootEffectColor( const Vector4& color );
+
public: //Signals
/**
namespace Toolkit
{
+const Property::Index Scrollable::PROPERTY_OVERSHOOT_EFFECT_COLOR( Toolkit::Internal::Control::CONTROL_PROPERTY_END_INDEX + 1 );
+
namespace Internal
{
namespace
{
+const Vector4 DEFAULT_OVERSHOOT_COLOUR(0.0f, 0.64f, 0.85f, 0.25f);
BaseHandle Create()
{
SignalConnectorType s3(mType, Toolkit::Scrollable::SIGNAL_SCROLL_UPDATED, &Scrollable::DoConnectSignal);
SignalConnectorType s4(mType, Toolkit::Scrollable::SIGNAL_SCROLL_CLAMPED, &Scrollable::DoConnectSignal);
+PropertyRegistration property1( mType,
+ "overshoot-effect-color",
+ Toolkit::Scrollable::PROPERTY_OVERSHOOT_EFFECT_COLOR,
+ Property::VECTOR4,
+ &Scrollable::SetProperty,
+ &Scrollable::GetProperty );
+
}
const std::string Scrollable::SCROLLABLE_CAN_SCROLL_VERTICAL( "scrollable-can-scroll-vertical" );
const std::string Scrollable::SCROLLABLE_CAN_SCROLL_HORIZONTAL( "scrollable-can-scroll-horizontal" );
-const Vector4 Scrollable::DEFAULT_OVERSHOOT_COLOUR(0.0f, 0.64f, 0.85f, 0.6f);
///////////////////////////////////////////////////////////////////////////////////////////////////
// Scrollable
// we dont want size negotiation while scrolling if we can avoid it
Scrollable::Scrollable()
: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | NO_SIZE_NEGOTIATION ) ),
+ mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ),
mPropertyRelativePosition(Property::INVALID_INDEX),
mPropertyPositionMin(Property::INVALID_INDEX),
mPropertyPositionMax(Property::INVALID_INDEX),
}
}
+Vector4 Scrollable::GetOvershootEffectColor() const
+{
+ return mOvershootEffectColor;
+};
+
Toolkit::Scrollable::ScrollStartedSignalV2& Scrollable::ScrollStartedSignal()
{
return mScrollStartedSignalV2;
return connected;
}
+void Scrollable::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::Scrollable scrollable = Toolkit::Scrollable::DownCast( Dali::BaseHandle( object ) );
+
+ if( scrollable )
+ {
+ Scrollable& scrollableImpl( GetImpl( scrollable ) );
+ switch( index )
+ {
+ case Toolkit::Scrollable::PROPERTY_OVERSHOOT_EFFECT_COLOR:
+ {
+ scrollableImpl.SetOvershootEffectColor( value.Get<Vector4>() );
+ break;
+ }
+ }
+ }
+}
+
+Property::Value Scrollable::GetProperty( BaseObject* object, Property::Index index )
+{
+ Property::Value value;
+
+ Toolkit::Scrollable scrollable = Toolkit::Scrollable::DownCast( Dali::BaseHandle( object ) );
+
+ if( scrollable )
+ {
+ Scrollable& scrollableImpl( GetImpl( scrollable ) );
+ switch( index )
+ {
+ case Toolkit::Scrollable::PROPERTY_OVERSHOOT_EFFECT_COLOR:
+ {
+ value = scrollableImpl.GetOvershootEffectColor();
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
Toolkit::ScrollComponent Scrollable::NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type)
{
Toolkit::ScrollComponent instance;
public:
static const std::string SCROLLABLE_CAN_SCROLL_VERTICAL;
static const std::string SCROLLABLE_CAN_SCROLL_HORIZONTAL;
- static const Vector4 DEFAULT_OVERSHOOT_COLOUR;
/**
* Create a new Scrollable.
*/
virtual void ScrollTo(const Vector3 &position, float duration) = 0;
+ /**
+ * Set the color of the overshoot effect.
+ * @parm[in] color The color of the overshoot effect
+ */
+ virtual void SetOvershootEffectColor( const Vector4& color ) = 0;
+
+ /**
+ * Retrieve the color of the overshoot effect.
+ * @return The color of the overshoot effect.
+ */
+ Vector4 GetOvershootEffectColor() const;
+
private:
/**
*/
static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+ //properties
+
+ /**
+ * Called when a property of an object of this type is set.
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+ /**
+ * Called to retrieve a property of an object of this type.
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Property::Value GetProperty( BaseObject* object, Property::Index index );
+
protected:
/**
protected:
+ Vector4 mOvershootEffectColor; ///<The color of the overshoot bouncing effect
+
Property::Index mPropertyRelativePosition;///< Scroll Relative Position ("scroll-relative-position") [range from 0.0f - 1.0f in each axes]
Property::Index mPropertyPositionMin; ///< Scroll Domain Minimum ("position-min")
Property::Index mPropertyPositionMax; ///< Scroll Domain Maximum ("position-max")
$(toolkit_base_src_dir)/controls/scroll-component/scroll-bar-internal-impl.cpp \
$(toolkit_base_src_dir)/controls/scroll-component/scroll-bar-internal.cpp \
$(toolkit_base_src_dir)/controls/scrollable/item-view/item-view-impl.cpp \
+ $(toolkit_base_src_dir)/controls/scrollable/bouncing-effect-actor.cpp \
$(toolkit_base_src_dir)/controls/scrollable/scrollable-impl.cpp \
$(toolkit_base_src_dir)/controls/scrollable/scroll-connector-impl.cpp \
$(toolkit_base_src_dir)/controls/scrollable/scroll-view/scroll-base-impl.cpp \
GetImpl(*this).DisableScrollComponent(indicator);
}
+void Scrollable::SetOvershootEffectColor( const Vector4& color )
+{
+ GetImpl(*this).SetOvershootEffectColor(color);
+}
+
+Vector4 Scrollable::GetOvershootEffectColor() const
+{
+ return GetImpl(*this).GetOvershootEffectColor();
+}
+
} // namespace Toolkit
} // namespace Dali
"select-button-position-priority":1,
"select-all-button-position-priority":2,
"clipboard-button-position-priority":6
+ },
+ "scrollview":
+ {
+ "overshoot-effect-color":"B018"
}
}
}
static const std::string SCROLL_POSITION_MAX_PROPERTY_NAME; ///< Property, name "scroll-position-max", type VECTOR3
static const std::string SCROLL_DIRECTION_PROPERTY_NAME; ///< Property, name "scroll-direction", type VECTOR2
- //Signal Names
+ /// @name Properties
+ /** @{ */
+ static const Property::Index PROPERTY_OVERSHOOT_EFFECT_COLOR; ///< Property, name "overshoot-effect-color", @see SetOvershootEffectColor(), type VECTOR4
+ /** @} */
+
+ /// @name Signals
+ /** @{ */
static const char* const SIGNAL_SCROLL_STARTED; ///< "scroll-started";
static const char* const SIGNAL_SCROLL_COMPLETED; ///< "scroll-completed";
static const char* const SIGNAL_SCROLL_UPDATED; ///< "scroll-updated";
static const char* const SIGNAL_SCROLL_CLAMPED; ///< "scroll-clamped";
+ /** @} */
public:
*/
void DisableScrollComponent(Scrollable::ScrollComponentType type);
+ /**
+ * @brief Set the color of the overshoot effect.
+ *
+ * @param[in] color The color of the overshoot effect.
+ */
+ void SetOvershootEffectColor( const Vector4& color );
+
+ /**
+ * @brief Get the color of the overshoot effect.
+ * @return The color of the overshoot effect.
+ */
+ Vector4 GetOvershootEffectColor() const;
+
public: // Not intended for application developers
/**