[Issue#] N/A
[Problem] Hard to customize overshoot indicators.
[Cause] Requires changes to ItemView internals etc.
[Solution] Move the overshoot property out into ScrollConnector.
(and then implement overshoot indicators outside of ItemView)
Change-Id: I99632fd485f1f5744e4d38b5056e1dfb0ded3b67
Signed-off-by: Paul Wisbey <p.wisbey@samsung.com>
* This basically consists of:
* - A "scroll-position" property which controls which part of the scrollable content is visible
* - The minimum/maximum limits of the scroll position, which corresponds to the start & end points of the scollable list etc.
* This basically consists of:
* - A "scroll-position" property which controls which part of the scrollable content is visible
* - The minimum/maximum limits of the scroll position, which corresponds to the start & end points of the scollable list etc.
+ * - An "overshoot" property which shows any attempts to exceed the start & end points.
*
* The provider of the scrollable content is responsible for calling SetLimits(). Scroll-bar components are then expected to
* receive these values via the LIMITS_CHANGED signal.
*
* The scroll-position property is accessible via GetScrollPositionObject(). This is intended to be shared by multiple controls
* e.g. a list control may be scrolled by panning the list content, or indirectly by dragging a connected scroll-bar control.
*
* The provider of the scrollable content is responsible for calling SetLimits(). Scroll-bar components are then expected to
* receive these values via the LIMITS_CHANGED signal.
*
* The scroll-position property is accessible via GetScrollPositionObject(). This is intended to be shared by multiple controls
* e.g. a list control may be scrolled by panning the list content, or indirectly by dragging a connected scroll-bar control.
+ *
+ * The overshoot property is intended for implementing 'end of list' style indicators. This property is expected to be in the range
+ * -1 to 1, where -1 shows an attempt the scroll beyond the minimum limit, and 1 shows an attempt the scroll beyond the maximum limit.
+ * Zero indicates normal scrolling i.e. when overshoot indicators should be hidden.
*/
class ScrollConnector : public BaseHandle
{
public:
static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
*/
class ScrollConnector : public BaseHandle
{
public:
static const char* const SCROLL_POSITION_PROPERTY_NAME; ///< This float "scroll-position" property is available via GetScrollPositionObject()
+ static const char* const OVERSHOOT_PROPERTY_NAME; ///< This float "overshoot" property is available via GetScrollPositionObject()
+
static const Property::Index SCROLL_POSITION; ///< The index of the "scroll-position" property
static const Property::Index SCROLL_POSITION; ///< The index of the "scroll-position" property
+ static const Property::Index OVERSHOOT; ///< The index of the "overshoot" property
// Signals
static const char* const LIMITS_CHANGED_SIGNAL_NAME; ///< "limits-changed" signal name
// Signals
static const char* const LIMITS_CHANGED_SIGNAL_NAME; ///< "limits-changed" signal name
mPropertyMinimumLayoutPosition = self.RegisterProperty(MINIMUM_LAYOUT_POSITION_PROPERTY_NAME, 0.0f);
mPropertyPosition = self.RegisterProperty(POSITION_PROPERTY_NAME, 0.0f);
mPropertyScrollSpeed = self.RegisterProperty(SCROLL_SPEED_PROPERTY_NAME, 0.0f);
mPropertyMinimumLayoutPosition = self.RegisterProperty(MINIMUM_LAYOUT_POSITION_PROPERTY_NAME, 0.0f);
mPropertyPosition = self.RegisterProperty(POSITION_PROPERTY_NAME, 0.0f);
mPropertyScrollSpeed = self.RegisterProperty(SCROLL_SPEED_PROPERTY_NAME, 0.0f);
- mPropertyOvershoot = self.RegisterProperty(OVERSHOOT_PROPERTY_NAME, 0.0f);
ApplyOvershootOverlayConstraints();
ApplyOvershootOverlayConstraints();
{
Constraint constraint = Constraint::New<float>( Actor::SIZE_WIDTH,
ParentSource( mPropertyScrollDirection ),
{
Constraint constraint = Constraint::New<float>( Actor::SIZE_WIDTH,
ParentSource( mPropertyScrollDirection ),
- ParentSource( mPropertyOvershoot ),
+ Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
ParentSource( Actor::SIZE ),
OvershootOverlaySizeConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
ParentSource( Actor::SIZE ),
OvershootOverlaySizeConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
constraint = Constraint::New<Quaternion>( Actor::ROTATION,
ParentSource( mPropertyScrollDirection ),
constraint = Constraint::New<Quaternion>( Actor::ROTATION,
ParentSource( mPropertyScrollDirection ),
- ParentSource( mPropertyOvershoot ),
+ Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
OvershootOverlayRotationConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
constraint = Constraint::New<Vector3>( Actor::POSITION,
ParentSource( Actor::SIZE ),
ParentSource( mPropertyScrollDirection ),
OvershootOverlayRotationConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
constraint = Constraint::New<Vector3>( Actor::POSITION,
ParentSource( Actor::SIZE ),
ParentSource( mPropertyScrollDirection ),
- ParentSource( mPropertyOvershoot ),
+ Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
OvershootOverlayPositionConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
OvershootOverlayPositionConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
int effectOvershootPropertyIndex = mOvershootEffect.GetPropertyIndex(mOvershootEffect.GetOvershootPropertyName());
Actor self = Self();
constraint = Constraint::New<float>( effectOvershootPropertyIndex,
int effectOvershootPropertyIndex = mOvershootEffect.GetPropertyIndex(mOvershootEffect.GetOvershootPropertyName());
Actor self = Self();
constraint = Constraint::New<float>( effectOvershootPropertyIndex,
- Source( self, mPropertyOvershoot ),
+ Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
EqualToConstraint() );
mOvershootEffect.ApplyConstraint(constraint);
}
EqualToConstraint() );
mOvershootEffect.ApplyConstraint(constraint);
}
- float currentOvershoot = self.GetProperty<float>(mPropertyOvershoot);
+ float currentOvershoot = mScrollPositionObject.GetProperty<float>(ScrollConnector::OVERSHOOT);
float duration = DEFAULT_OVERSHOOT_ANIMATION_DURATION * (animatingOn ? (1.0f - fabsf(currentOvershoot)) : fabsf(currentOvershoot));
RemoveAnimation(mScrollOvershootAnimation);
mScrollOvershootAnimation = Animation::New(duration);
mScrollOvershootAnimation.FinishedSignal().Connect(this, &ItemView::OnOvershootOnFinished);
float duration = DEFAULT_OVERSHOOT_ANIMATION_DURATION * (animatingOn ? (1.0f - fabsf(currentOvershoot)) : fabsf(currentOvershoot));
RemoveAnimation(mScrollOvershootAnimation);
mScrollOvershootAnimation = Animation::New(duration);
mScrollOvershootAnimation.FinishedSignal().Connect(this, &ItemView::OnOvershootOnFinished);
- mScrollOvershootAnimation.AnimateTo( Property(self, mPropertyOvershoot), overshootAmount, TimePeriod(0.0f, duration) );
+ mScrollOvershootAnimation.AnimateTo( Property(mScrollPositionObject, ScrollConnector::OVERSHOOT), overshootAmount, TimePeriod(0.0f, duration) );
mScrollOvershootAnimation.Play();
mAnimatingOvershootOn = animatingOn;
mScrollOvershootAnimation.Play();
mAnimatingOvershootOn = animatingOn;
Property::Index mPropertyPosition; ///< The physical position of the first item within the layout
Property::Index mPropertyMinimumLayoutPosition; ///< The minimum valid layout position in the layout.
Property::Index mPropertyScrollSpeed; ///< The current scroll speed of item view
Property::Index mPropertyPosition; ///< The physical position of the first item within the layout
Property::Index mPropertyMinimumLayoutPosition; ///< The minimum valid layout position in the layout.
Property::Index mPropertyScrollSpeed; ///< The current scroll speed of item view
- Property::Index mPropertyOvershoot; ///< The scroll overshoot (difference of the layout position before and after clamping)
};
} // namespace Internal
};
} // namespace Internal
-const Property::Index ScrollConnector::SCROLL_POSITION = 50000000; // TODO - expose CUSTOM_PROPERTY_START from Core
+const Property::Index ScrollConnector::SCROLL_POSITION = Dali::PROPERTY_CUSTOM_START_INDEX;
+const Property::Index ScrollConnector::OVERSHOOT = Dali::PROPERTY_CUSTOM_START_INDEX + 1;
ScrollConnector* ScrollConnector::New()
{
ScrollConnector* ScrollConnector::New()
{
mScrollPositionObject = Constrainable::New();
mScrollPositionObject.RegisterProperty( Toolkit::ScrollConnector::SCROLL_POSITION_PROPERTY_NAME, 0.0f );
mScrollPositionObject = Constrainable::New();
mScrollPositionObject.RegisterProperty( Toolkit::ScrollConnector::SCROLL_POSITION_PROPERTY_NAME, 0.0f );
+ mScrollPositionObject.RegisterProperty( Toolkit::ScrollConnector::OVERSHOOT_PROPERTY_NAME, 0.0f );
}
ScrollConnector::~ScrollConnector()
}
ScrollConnector::~ScrollConnector()
typedef Toolkit::ScrollConnector::LimitsChangedSignalType LimitsChangedSignalType;
static const Property::Index SCROLL_POSITION;
typedef Toolkit::ScrollConnector::LimitsChangedSignalType LimitsChangedSignalType;
static const Property::Index SCROLL_POSITION;
+ static const Property::Index OVERSHOOT;
/**
* Create a ScrollConnector.
/**
* Create a ScrollConnector.
-const char* const ScrollConnector::SCROLL_POSITION_PROPERTY_NAME = "scroll-position";
-const Property::Index ScrollConnector::SCROLL_POSITION = Internal::ScrollConnector::SCROLL_POSITION;
-const char* const ScrollConnector::LIMITS_CHANGED_SIGNAL_NAME = "limits-changed";
+const char* const ScrollConnector::SCROLL_POSITION_PROPERTY_NAME = "scroll-position";
+const char* const ScrollConnector::OVERSHOOT_PROPERTY_NAME = "overshoot";
+
+const Property::Index ScrollConnector::SCROLL_POSITION = Internal::ScrollConnector::SCROLL_POSITION;
+const Property::Index ScrollConnector::OVERSHOOT = Internal::ScrollConnector::OVERSHOOT;
+
+const char* const ScrollConnector::LIMITS_CHANGED_SIGNAL_NAME = "limits-changed";
ScrollConnector ScrollConnector::New()
{
ScrollConnector ScrollConnector::New()
{