From: Ferran Sole Date: Thu, 19 Jan 2017 11:58:46 +0000 (+0000) Subject: Fix for ItemView OVERSHOOT_SIZE X-Git-Tag: dali_1.2.24~9^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=2059450020d10987f079a7a14062a86045337e8a Fix for ItemView OVERSHOOT_SIZE Setting overshoot size after overshoot was enabled was not working Change-Id: Ibb7cc6268f85aa68aa5476b8a99222abab6f6525 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index 3e3e303..040fb1c 100755 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -1011,6 +1011,12 @@ int UtcDaliItemViewSetGetProperty(void) view.SetProperty( Scrollable::Property::OVERSHOOT_ENABLED, false ); DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_ENABLED).Get(), false, TEST_LOCATION ); + // Test "overshootSize" property + DALI_TEST_CHECK( view.GetPropertyIndex("overshootSize") == Scrollable::Property::OVERSHOOT_SIZE ); + Vector2 overshootSize = Vector2(100.0f,100.0f); + view.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize ); + DALI_TEST_EQUALS( view.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get(), overshootSize, TEST_LOCATION ); + // Animatable properties // Test "layoutPosition" property diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index 883aacc..fdd32b5 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -1198,6 +1198,11 @@ int UtcDaliToolkitScrollViewOvershoot(void) // Set up a scrollView... ScrollView scrollView = ScrollView::New(); scrollView.SetOvershootEnabled(true); + + Vector2 overshootSize = Vector2(100.0f,100.0f); + scrollView.SetProperty( Scrollable::Property::OVERSHOOT_SIZE, overshootSize ); + DALI_TEST_EQUALS( scrollView.GetProperty(Scrollable::Property::OVERSHOOT_SIZE).Get(), overshootSize, TEST_LOCATION ); + Stage::GetCurrent().Add( scrollView ); Vector2 stageSize = Stage::GetCurrent().GetSize(); scrollView.SetSize(stageSize); 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 1724f83..8b84088 100755 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -69,6 +69,8 @@ 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; +const unsigned int OVERSHOOT_SIZE_CONSTRAINT_TAG(42); + /** * Local helper to convert pan distance (in actor coordinates) to the layout-specific scrolling direction */ @@ -291,6 +293,21 @@ bool FindById( const ItemContainer& items, ItemId id ) return false; } +/** + * Helper to apply size constraint to mOvershootOverlay + * @param[in] overshootOverlay The overshootOverlay actor + * @param[in] The required height + */ +void ApplyOvershootSizeConstraint( Actor overshootOverlay, float height ) +{ + Constraint constraint = Constraint::New( overshootOverlay, Actor::Property::SIZE, OvershootOverlaySizeConstraint( height ) ); + constraint.AddSource( ParentSource( Dali::Toolkit::ItemView::Property::SCROLL_DIRECTION ) ); + constraint.AddSource( ParentSource( Dali::Toolkit::ItemView::Property::LAYOUT_ORIENTATION ) ); + constraint.AddSource( ParentSource( Dali::Actor::Property::SIZE ) ); + constraint.SetTag( OVERSHOOT_SIZE_CONSTRAINT_TAG ); + constraint.Apply(); +} + } // unnamed namespace Dali::Toolkit::ItemView ItemView::New(ItemFactory& factory) @@ -1519,6 +1536,18 @@ void ItemView::ScrollTo(const Vector2& position, float duration) mRefreshEnabled = true; } +void ItemView::SetOvershootSize( const Vector2& size ) +{ + mOvershootSize = size; + + if( mOvershootOverlay ) + { + // Remove old & add new size constraint + mOvershootOverlay.RemoveConstraints( OVERSHOOT_SIZE_CONSTRAINT_TAG ); + ApplyOvershootSizeConstraint( mOvershootOverlay, mOvershootSize.height ); + } +} + void ItemView::SetOvershootEffectColor( const Vector4& color ) { mOvershootEffectColor = color; @@ -1543,15 +1572,9 @@ void ItemView::EnableScrollOvershoot( bool enable ) mOvershootOverlay.SetDrawMode( DrawMode::OVERLAY_2D ); self.Add(mOvershootOverlay); - Constraint constraint = Constraint::New( 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(mOvershootSize.width, mOvershootSize.height); + ApplyOvershootSizeConstraint( mOvershootOverlay, mOvershootSize.height ); - constraint = Constraint::New( mOvershootOverlay, Actor::Property::ORIENTATION, OvershootOverlayRotationConstraint ); + Constraint constraint = Constraint::New( mOvershootOverlay, Actor::Property::ORIENTATION, OvershootOverlayRotationConstraint ); constraint.AddSource( ParentSource( Toolkit::ItemView::Property::SCROLL_DIRECTION ) ); constraint.AddSource( ParentSource( Toolkit::ItemView::Property::LAYOUT_ORIENTATION ) ); constraint.AddSource( ParentSource( Toolkit::ItemView::Property::OVERSHOOT ) ); 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 f49ee81..d0a2bf1 100755 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h @@ -239,6 +239,11 @@ public: void ScrollTo(const Vector2& position, float duration); /** + * @copydoc Toolkit::Internal::Scrollable::SetOvershootSize + */ + void SetOvershootSize( const Vector2& size ); + + /** * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor */ void SetOvershootEffectColor( const Vector4& color ); diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 0da1660..3330f13 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -1781,6 +1781,15 @@ void ScrollView::RemoveOverlay(Actor actor) mInternalActor.Remove( actor ); } +void ScrollView::SetOvershootSize( const Vector2& size ) +{ + mOvershootSize = size; + if( IsOvershootEnabled() && mOvershootIndicator ) + { + mOvershootIndicator->AttachToScrollable(*this); + } +} + void ScrollView::SetOvershootEffectColor( const Vector4& color ) { mOvershootEffectColor = color; diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h index b288720..9a16624 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h @@ -494,6 +494,11 @@ public: void RemoveOverlay(Actor actor); /** + * @copydoc Toolkit::Internal::Scrollable::SetOvershootSize + */ + void SetOvershootSize( const Vector2& size ); + + /** * @copydoc Toolkit::Internal::Scrollable::SetOvershootEffectColor */ void SetOvershootEffectColor( const Vector4& color ); diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp index 20da41c..31201ee 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp @@ -204,12 +204,7 @@ void Scrollable::SetProperty( BaseObject* object, Property::Index index, const P } case Toolkit::Scrollable::Property::OVERSHOOT_SIZE: { - Vector2 input; - if( value.Get( input ) ) - { - scrollableImpl.mOvershootSize = input; - } - scrollableImpl.EnableScrollOvershoot( scrollableImpl.IsOvershootEnabled() ); + scrollableImpl.SetOvershootSize( value.Get() ); break; } case Toolkit::Scrollable::Property::SCROLL_TO_ALPHA_FUNCTION: diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h index 660606c..bf6fa98 100644 --- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h @@ -112,6 +112,12 @@ public: */ const Vector2& GetOvershootSize() const; + /** + * Set the size of the overshoot effect. + * @parm[in] size The size of the overshoot effect + */ + virtual void SetOvershootSize( const Vector2& size ) = 0; + private: /**