for( unsigned int i = 0u; i < 10; ++i )
{
- Actor child = view.GetChildAt( i );
+ Actor child = view.GetItem( i );
Actor newActor = Actor::New();
newActor.SetName("Replaced");
- replaceList.push_back( Item( view.GetItemId(child), newActor ) );
+ replaceList.push_back( Item( i, newActor ) );
}
if( !replaceList.empty() )
// Set up a scrollView...
ScrollView scrollView = ScrollView::New();
+ scrollView.SetOvershootEnabled(true);
Stage::GetCurrent().Add( scrollView );
Vector2 stageSize = Stage::GetCurrent().GetSize();
scrollView.SetSize(stageSize);
// Set up a scrollView...
ScrollView scrollView = ScrollView::New();
+ scrollView.SetOvershootEnabled(true);
Stage::GetCurrent().Add( scrollView );
Vector2 stageSize = Stage::GetCurrent().GetSize();
scrollView.SetSize(stageSize);
namespace
{
// Bouncing effect is presented by stacked three layers with same color and opacity
-const Vector3 LAYER_HEIGHTS( 1.f, 27.f/42.f, 13.f/42.f);
+const float LAYER_HEIGHTS[5] =
+{
+ 1.f,
+ 26.f * 4.f/ 130.f,
+ 26.f * 3.f / 130.f,
+ 26.f * 2.f / 130.f,
+ 26.f / 130.f
+};
#define MAKE_SHADER(A)#A
Vector3 position2;
};
// 4 vertices 2 triangles per layer. The depth interval between each layer is 0.01
- VertexPosition vertexData[12] = {
- //bottom layer
+ VertexPosition vertexData[20] = {
+ // bottom layer
{ Vector3( -0.5f, -0.5f, 0.f ), Vector3( -0.5f, -0.5f, 0.f ) },
{ Vector3( 0.5f, -0.5f, 0.f ), Vector3( 0.5f, -0.5f, 0.f ) },
{ Vector3( -0.5f, -0.5f, 0.f ), Vector3( -0.5f, -0.5f + LAYER_HEIGHTS[0], 0.f ) },
{ Vector3( 0.5f, -0.5f, 0.f ), Vector3( 0.5f, -0.5f+ LAYER_HEIGHTS[0], 0.f ) },
- // middle layer
+ // mid-bottom layer
{ Vector3( -0.5f, -0.5f, 0.01f ), Vector3( -0.5f, -0.5f, 0.01f ) },
{ Vector3( 0.5f, -0.5f, 0.01f ), Vector3( 0.5f, -0.5f, 0.01f ) },
{ Vector3( -0.5f, -0.5f, 0.01f ), Vector3( -0.5f, -0.5f + LAYER_HEIGHTS[1], 0.01f ) },
{ Vector3( 0.5f, -0.5f, 0.01f ), Vector3( 0.5f, -0.5f+ LAYER_HEIGHTS[1], 0.01f ) },
- // top layer
+ // middle layer
{ Vector3( -0.5f, -0.5f, 0.02f ), Vector3( -0.5f, -0.5f, 0.02f ) },
{ Vector3( 0.5f, -0.5f, 0.02f ), Vector3( 0.5f, -0.5f, 0.02f ) },
{ Vector3( -0.5f, -0.5f, 0.02f ), Vector3( -0.5f, -0.5f + LAYER_HEIGHTS[2], 0.02f ) },
- { Vector3( 0.5f, -0.5f, 0.02f ), Vector3( 0.5f, -0.5f+ LAYER_HEIGHTS[2], 0.02f ) }
+ { Vector3( 0.5f, -0.5f, 0.02f ), Vector3( 0.5f, -0.5f+ LAYER_HEIGHTS[2], 0.02f ) },
+ // mid-top layer
+ { Vector3( -0.5f, -0.5f, 0.03f ), Vector3( -0.5f, -0.5f, 0.03f ) },
+ { Vector3( 0.5f, -0.5f, 0.03f ), Vector3( 0.5f, -0.5f, 0.03f ) },
+ { Vector3( -0.5f, -0.5f, 0.03f ), Vector3( -0.5f, -0.5f + LAYER_HEIGHTS[3], 0.03f ) },
+ { Vector3( 0.5f, -0.5f, 0.03f ), Vector3( 0.5f, -0.5f+ LAYER_HEIGHTS[3], 0.03f ) },
+ // top layer
+ { Vector3( -0.5f, -0.5f, 0.04f ), Vector3( -0.5f, -0.5f, 0.04f ) },
+ { Vector3( 0.5f, -0.5f, 0.04f ), Vector3( 0.5f, -0.5f, 0.04f ) },
+ { Vector3( -0.5f, -0.5f, 0.04f ), Vector3( -0.5f, -0.5f + LAYER_HEIGHTS[4], 0.04f ) },
+ { Vector3( 0.5f, -0.5f, 0.04f ), Vector3( 0.5f, -0.5f+ LAYER_HEIGHTS[4], 0.04f ) }
};
Property::Map vertexFormat;
vertexFormat["aPosition1"] = Property::VECTOR3;
vertexFormat["aPosition2"] = Property::VECTOR3;
- PropertyBuffer vertices = PropertyBuffer::New( vertexFormat, 12u );
+ PropertyBuffer vertices = PropertyBuffer::New( vertexFormat, 20u );
vertices.SetData( vertexData );
- unsigned int indexData[18] = { 0,3,1,0,2,3,4,7,5,4,6,7,8,11,9,8,10,11 };
+ unsigned int indexData[30] = { 0,3,1,0,2,3,4,7,5,4,6,7,8,11,9,8,10,11,12,15,13,12,14,15,16,19,17,16,18,19};
Property::Map indexFormat;
indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat, 18u );
+ PropertyBuffer indices = PropertyBuffer::New( indexFormat, 30u );
indices.SetData( indexData );
Geometry meshGeometry = Geometry::New();
const float MILLISECONDS_PER_SECONDS = 1000.0f;
-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 DEFAULT_KEYBOARD_FOCUS_SCROLL_DURATION = 0.2f;
}
// Overshoot overlay constraints
-void OvershootOverlaySizeConstraint( Vector3& current, const PropertyInputContainer& inputs )
+struct OvershootOverlaySizeConstraint
{
- const Vector2& parentScrollDirection = inputs[0]->GetVector2();
- const Toolkit::ControlOrientation::Type& layoutOrientation = static_cast<Toolkit::ControlOrientation::Type>(inputs[1]->GetInteger());
- const Vector3& parentSize = inputs[2]->GetVector3();
-
- if(Toolkit::IsVertical(layoutOrientation))
+ OvershootOverlaySizeConstraint( float height )
+ : mOvershootHeight( height )
{
- current.width = fabsf(parentScrollDirection.y) > Math::MACHINE_EPSILON_1 ? parentSize.x : parentSize.y;
}
- else
+
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- current.width = fabsf(parentScrollDirection.x) > Math::MACHINE_EPSILON_1 ? parentSize.y : parentSize.x;
+ const Vector2& parentScrollDirection = inputs[0]->GetVector2();
+ const Toolkit::ControlOrientation::Type& layoutOrientation = static_cast<Toolkit::ControlOrientation::Type>(inputs[1]->GetInteger());
+ const Vector3& parentSize = inputs[2]->GetVector3();
+
+ if(Toolkit::IsVertical(layoutOrientation))
+ {
+ current.width = fabsf(parentScrollDirection.y) > Math::MACHINE_EPSILON_1 ? parentSize.x : parentSize.y;
+ }
+ else
+ {
+ current.width = fabsf(parentScrollDirection.x) > Math::MACHINE_EPSILON_1 ? parentSize.y : parentSize.x;
+ }
+
+ current.height = ( current.width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD ) ? mOvershootHeight : mOvershootHeight*0.5f;
}
- current.height = ( current.width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD ) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height*0.5f;
-}
+ float mOvershootHeight;
+};
void OvershootOverlayRotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
{
Actor self = Self();
- SetOvershootEnabled(true);
-
Vector2 stageSize = Stage::GetCurrent().GetSize();
mWheelScrollDistanceStep = stageSize.y * DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
mOvershootOverlay.SetDrawMode( DrawMode::OVERLAY_2D );
self.Add(mOvershootOverlay);
- Constraint constraint = Constraint::New<Vector3>( mOvershootOverlay, Actor::Property::SIZE, OvershootOverlaySizeConstraint );
+ Constraint constraint = Constraint::New<Vector3>( mOvershootOverlay, Actor::Property::SIZE, OvershootOverlaySizeConstraint(mOvershootSize.height) );
constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_DIRECTION ) );
constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_ORIENTATION ) );
constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
constraint.Apply();
- mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
+ mOvershootOverlay.SetSize(mOvershootSize.width, mOvershootSize.height);
constraint = Constraint::New<Quaternion>( mOvershootOverlay, Actor::Property::ORIENTATION, OvershootOverlayRotationConstraint );
constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_DIRECTION ) );
namespace
{
-const Vector2 OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE( 720.0f, 42.0f );
+
const float OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD = 180.0f;
// local helper function to resize the height of the bounce actor
-float GetBounceActorHeight( float width )
+float GetBounceActorHeight( float width, float defaultHeight )
{
- return (width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height * 0.5f;
+ return (width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD) ? defaultHeight : defaultHeight * 0.5f;
}
const float MAX_OVERSHOOT_NOTIFY_AMOUNT = 0.99f; // maximum amount to set notification for increased overshoot, beyond this we just wait for it to reduce again
mOvershootProperty(Property::INVALID_INDEX),
mEffectOvershootProperty(Property::INVALID_INDEX),
mOvershoot(0.0f),
+ mOvershootSize( scrollable.GetOvershootSize() ),
mAnimationStateFlags(0)
{
mOvershootOverlay = CreateBouncingEffectActor(mEffectOvershootProperty);
mOvershootProperty = IsVertical() ? Toolkit::ScrollView::Property::OVERSHOOT_Y : Toolkit::ScrollView::Property::OVERSHOOT_X;
// make sure height is set, since we only create a constraint for image width
- mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
+ mOvershootOverlay.SetSize( mOvershootSize );
mAttachedScrollView.AddOverlay(mOvershootOverlay);
if(IsVertical())
{
mOvershootOverlay.SetOrientation( Quaternion( Radian( 0.0f ), Vector3::ZAXIS ) );
- mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth);
+ mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width, mOvershootSize.height), size.depth);
}
else
{
mOvershootOverlay.SetOrientation( Quaternion( Radian( 1.5f * Math::PI ), Vector3::ZAXIS ) );
- mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height), size.depth);
+ mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height, mOvershootSize.height), size.depth);
relativeOffset = Vector3(0.0f, 1.0f, 0.0f);
}
mOvershootOverlay.SetPosition(relativeOffset * parentSize);
if(IsVertical())
{
mOvershootOverlay.SetOrientation( Quaternion( Radian( Math::PI ), Vector3::ZAXIS ) );
- mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth);
+ mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width, mOvershootSize.height), size.depth);
relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
}
else
{
mOvershootOverlay.SetOrientation( Quaternion( Radian( 0.5f * Math::PI ), Vector3::ZAXIS ) );
- mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height), size.depth);
+ mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height, mOvershootSize.height), size.depth);
relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
}
mOvershootOverlay.SetPosition(relativeOffset * parentSize);
PropertyNotification mOvershootDecreaseNotification;///< notification used to inform as overshoot decreases
Property::Index mOvershootProperty; ///< index of the overshoot property in the scrollable actor
Property::Index mEffectOvershootProperty; ///< index of the effect's overshoot property
- float mOvershoot; ///< last overshoot value as detected by notifications
- unsigned short mAnimationStateFlags; ///< contains flags indicating the current state of the overshoot animation
+ float mOvershoot; ///< last overshoot value as detected by notifications
+ Vector2 mOvershootSize; ///< The size of the overshoot effect
+ unsigned short mAnimationStateFlags; ///< contains flags indicating the current state of the overshoot animation
};
} // namespace Internal
mRulerX = ruler;
mRulerY = ruler;
- SetOvershootEnabled(true);
-
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, mCanScrollVertical);
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL, mCanScrollHorizontal);
void ScrollView::EnableScrollOvershoot(bool enable)
{
- if(enable && !mOvershootIndicator)
- {
- mOvershootIndicator = ScrollOvershootIndicator::New();
- }
- if( enable )
+ if (enable)
{
+ if (!mOvershootIndicator)
+ {
+ mOvershootIndicator = ScrollOvershootIndicator::New();
+ }
+
mOvershootIndicator->AttachToScrollable(*this);
}
else
{
mMaxOvershoot = mUserMaxOvershoot;
- mOvershootIndicator->DetachFromScrollable(*this);
+
+ if (mOvershootIndicator)
+ {
+ mOvershootIndicator->DetachFromScrollable(*this);
+ }
}
+
UpdateMainInternalConstraint();
}
DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshoot-effect-color", VECTOR4, OVERSHOOT_EFFECT_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshoot-animation-speed", FLOAT, OVERSHOOT_ANIMATION_SPEED )
+const int OVERSHOOT_SIZE = Dali::Toolkit::Scrollable::Property::OVERSHOOT_ANIMATION_SPEED + 1; // OVERSHOOT_SIZE is not public yet
+Dali::PropertyRegistration p1( typeRegistration, "overshoot-size", OVERSHOOT_SIZE, Property::VECTOR2, Dali::Toolkit::Internal::Scrollable::SetProperty, Dali::Toolkit::Internal::Scrollable::GetProperty );
DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-relative-position", VECTOR2, SCROLL_RELATIVE_POSITION)
DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scroll-position-min", VECTOR2, SCROLL_POSITION_MIN)
const Vector4 DEFAULT_OVERSHOOT_COLOUR(0.0f, 0.64f, 0.85f, 0.25f);
const float DEFAULT_OVERSHOOT_ANIMATION_SPEED(120.0f); // 120 pixels per second
+const Vector2 OVERSHOOT_DEFAULT_SIZE( 720.0f, 42.0f );
}
: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | DISABLE_SIZE_NEGOTIATION ) ),
mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ),
mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ),
- mOvershootEnabled(false)
+ mOvershootSize( OVERSHOOT_DEFAULT_SIZE ),
+ mOvershootEnabled(true)
{
}
: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | behaviourFlags ) ),
mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ),
mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ),
- mOvershootEnabled(false)
+ mOvershootSize( OVERSHOOT_DEFAULT_SIZE ),
+ mOvershootEnabled(true)
{
}
return mOvershootAnimationSpeed;
};
+const Vector2& Scrollable::GetOvershootSize() const
+{
+ return mOvershootSize;
+}
+
Toolkit::Scrollable::ScrollStartedSignalType& Scrollable::ScrollStartedSignal()
{
return mScrollStartedSignal;
scrollableImpl.SetOvershootAnimationSpeed( value.Get<float>() );
break;
}
+ case OVERSHOOT_SIZE: // OVERSHOOT_SIZE is not public yet
+ {
+ Vector2 input;
+ if( value.Get( input ) )
+ {
+ scrollableImpl.mOvershootSize = input;
+ }
+ scrollableImpl.EnableScrollOvershoot( scrollableImpl.IsOvershootEnabled() );
+ break;
+ }
}
}
}
value = scrollableImpl.GetOvershootAnimationSpeed();
break;
}
+ case OVERSHOOT_SIZE: // OVERSHOOT_SIZE is not public yet
+ {
+ value = scrollableImpl.mOvershootSize;
+ break;
+ }
}
}
*/
float GetOvershootAnimationSpeed() const;
+ /**
+ * @copydoc Dali::Toolkit::Scrollable::GetOvershootSize()
+ */
+ const Vector2& GetOvershootSize() const;
+
private:
/**
Vector4 mOvershootEffectColor; ///<The color of the overshoot bouncing effect
float mOvershootAnimationSpeed; ///<The speed of the overshoot animation (pixels per second)
+ Vector2 mOvershootSize; ///<The size of the overshoot effect
Toolkit::Scrollable::ScrollStartedSignalType mScrollStartedSignal;
Toolkit::Scrollable::ScrollUpdatedSignalType mScrollUpdatedSignal;
},
"scrollview":
{
- "overshoot-effect-color":"B018"
+ "overshoot-effect-color":"B018",
+ "overshoot-animation-speed":120.0,
+ "overshoot-size":[480.0,42.0]
+ },
+ "itemview":
+ {
+ "overshoot-effect-color":"B018",
+ "overshoot-animation-speed":120.0,
+ "overshoot-size":[480.0,42.0]
}
}
}
},
"scrollview":
{
- "overshoot-effect-color":"B018"
+ "overshoot-effect-color":"B018",
+ "overshoot-animation-speed":360.0,
+ "overshoot-size":[720.0,130.0]
+ },
+ "itemview":
+ {
+ "overshoot-effect-color":"B018",
+ "overshoot-animation-speed":360.0,
+ "overshoot-size":[720.0,130.0]
}
}
}