From: Paul Wisbey Date: Mon, 7 Apr 2014 15:56:43 +0000 (+0100) Subject: Allow overshoot indicators to be implemented outside of ItemView X-Git-Tag: dali-2014-wk16-release~13 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=7c48d81eb1f49aab3c852ab83c9f688cfdfadd0d Allow overshoot indicators to be implemented outside of ItemView [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 --- diff --git a/capi/dali-toolkit/public-api/controls/scrollable/scroll-connector.h b/capi/dali-toolkit/public-api/controls/scrollable/scroll-connector.h index fad7fb2..c03da89 100644 --- a/capi/dali-toolkit/public-api/controls/scrollable/scroll-connector.h +++ b/capi/dali-toolkit/public-api/controls/scrollable/scroll-connector.h @@ -37,19 +37,27 @@ class ScrollConnector; * 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 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() + 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 OVERSHOOT; ///< The index of the "overshoot" property // Signals static const char* const LIMITS_CHANGED_SIGNAL_NAME; ///< "limits-changed" signal name diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index 5ab0e2f..5f1f7b8 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -439,7 +439,6 @@ void ItemView::OnInitialize() 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(); @@ -1645,7 +1644,7 @@ void ItemView::ApplyOvershootOverlayConstraints() { Constraint constraint = Constraint::New( Actor::SIZE_WIDTH, ParentSource( mPropertyScrollDirection ), - ParentSource( mPropertyOvershoot ), + Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ), ParentSource( Actor::SIZE ), OvershootOverlaySizeConstraint() ); mOvershootOverlay.ApplyConstraint(constraint); @@ -1653,14 +1652,14 @@ void ItemView::ApplyOvershootOverlayConstraints() constraint = Constraint::New( Actor::ROTATION, ParentSource( mPropertyScrollDirection ), - ParentSource( mPropertyOvershoot ), + Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ), OvershootOverlayRotationConstraint() ); mOvershootOverlay.ApplyConstraint(constraint); constraint = Constraint::New( Actor::POSITION, ParentSource( Actor::SIZE ), ParentSource( mPropertyScrollDirection ), - ParentSource( mPropertyOvershoot ), + Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ), OvershootOverlayPositionConstraint() ); mOvershootOverlay.ApplyConstraint(constraint); @@ -1672,7 +1671,7 @@ void ItemView::ApplyOvershootOverlayConstraints() int effectOvershootPropertyIndex = mOvershootEffect.GetPropertyIndex(mOvershootEffect.GetOvershootPropertyName()); Actor self = Self(); constraint = Constraint::New( effectOvershootPropertyIndex, - Source( self, mPropertyOvershoot ), + Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ), EqualToConstraint() ); mOvershootEffect.ApplyConstraint(constraint); } @@ -1711,13 +1710,13 @@ void ItemView::AnimateScrollOvershoot(float overshootAmount, bool animateBack) } Actor self = Self(); - float currentOvershoot = self.GetProperty(mPropertyOvershoot); + float currentOvershoot = mScrollPositionObject.GetProperty(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); - 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; diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h index de0860c..75022c7 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h @@ -544,7 +544,6 @@ private: 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 diff --git a/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp index 7983fa5..1db9119 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.cpp @@ -29,7 +29,8 @@ namespace Toolkit 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() { @@ -51,6 +52,7 @@ ScrollConnector::ScrollConnector() mScrollPositionObject = Constrainable::New(); mScrollPositionObject.RegisterProperty( Toolkit::ScrollConnector::SCROLL_POSITION_PROPERTY_NAME, 0.0f ); + mScrollPositionObject.RegisterProperty( Toolkit::ScrollConnector::OVERSHOOT_PROPERTY_NAME, 0.0f ); } ScrollConnector::~ScrollConnector() diff --git a/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h index 7545fc5..5d169b1 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scroll-connector-impl.h @@ -39,6 +39,7 @@ public: typedef Toolkit::ScrollConnector::LimitsChangedSignalType LimitsChangedSignalType; static const Property::Index SCROLL_POSITION; + static const Property::Index OVERSHOOT; /** * Create a ScrollConnector. diff --git a/dali-toolkit/public-api/controls/scrollable/scroll-connector.cpp b/dali-toolkit/public-api/controls/scrollable/scroll-connector.cpp index 30cf797..97721b2 100644 --- a/dali-toolkit/public-api/controls/scrollable/scroll-connector.cpp +++ b/dali-toolkit/public-api/controls/scrollable/scroll-connector.cpp @@ -25,9 +25,13 @@ namespace Dali namespace Toolkit { -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() {