From: Paul Wisbey
Date: Tue, 3 May 2016 18:15:17 +0000 (+0100)
Subject: Add ItemView stopScrolling action
X-Git-Tag: dali_1.1.34~2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F51%2F68351%2F10;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git
Add ItemView stopScrolling action
+ Added a property for choosing one of the built-in alpha functions,
for scroll-to animations
Change-Id: I536672d27d6aec1ad06a3051f4b76cb63bad7b5c
---
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 9403c8a..ba2000b 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
@@ -260,6 +260,8 @@ DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ItemView, "scrollContentSize",
DALI_SIGNAL_REGISTRATION( Toolkit, ItemView, "layoutActivated", LAYOUT_ACTIVATED_SIGNAL )
+DALI_ACTION_REGISTRATION( Toolkit, ItemView, "stopScrolling", ACTION_STOP_SCROLLING )
+
DALI_TYPE_REGISTRATION_END()
bool FindById( const ItemContainer& items, ItemId id )
@@ -1378,7 +1380,7 @@ void ItemView::ScrollToItem(unsigned int itemId, float durationSeconds)
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(durationSeconds);
- mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION), firstItemScrollPosition, AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION), firstItemScrollPosition, mScrollToAlphaFunction );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnScrollFinished);
mScrollAnimation.Play();
}
@@ -1492,7 +1494,7 @@ void ItemView::ScrollTo(const Vector2& position, float duration)
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(duration);
- mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION), firstItemScrollPosition, AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, Toolkit::ItemView::Property::LAYOUT_POSITION), firstItemScrollPosition, mScrollToAlphaFunction );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnScrollFinished);
mScrollAnimation.Play();
}
@@ -1778,6 +1780,31 @@ Property::Value ItemView::GetProperty( BaseObject* object, Property::Index index
return value;
}
+bool ItemView::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
+{
+ Dali::BaseHandle handle( object );
+
+ Toolkit::ItemView itemView = Toolkit::ItemView::DownCast( handle );
+
+ DALI_ASSERT_ALWAYS( itemView );
+
+ if( 0 == strcmp( actionName.c_str(), ACTION_STOP_SCROLLING ) )
+ {
+ GetImpl( itemView ).DoStopScrolling();
+ }
+
+ return true;
+}
+
+void ItemView::DoStopScrolling()
+{
+ if( mScrollAnimation )
+ {
+ mScrollAnimation.Stop();
+ mScrollAnimation.Reset();
+ }
+}
+
} // namespace Internal
} // namespace Toolkit
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 2b3a52f..3d31e1c 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
@@ -326,6 +326,20 @@ public:
*/
static Property::Value GetProperty( BaseObject* object, Property::Index index );
+ /**
+ * Performs actions as requested using the action name.
+ * @param[in] object The object on which to perform the action.
+ * @param[in] actionName The action to perform.
+ * @param[in] attributes The attributes with which to perfrom this action.
+ * @return true if action has been accepted by this control
+ */
+ static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
+
+ /**
+ * Helper for DoAction( ACTION_STOP_SCROLLING ).
+ */
+ void DoStopScrolling();
+
private:
/**
diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp
index 3a4ad99..70e5c11 100644
--- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp
+++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.cpp
@@ -50,6 +50,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshootEffectColor", VE
DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshootAnimationSpeed", FLOAT, OVERSHOOT_ANIMATION_SPEED )
DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshootEnabled", BOOLEAN, OVERSHOOT_ENABLED )
DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "overshootSize", VECTOR2, OVERSHOOT_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scrollToAlphaFunction", INTEGER, SCROLL_TO_ALPHA_FUNCTION )
DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scrollRelativePosition", VECTOR2, SCROLL_RELATIVE_POSITION)
DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, Scrollable, "scrollPositionMin", VECTOR2, SCROLL_POSITION_MIN)
@@ -84,6 +85,7 @@ Scrollable::Scrollable()
mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ),
mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ),
mOvershootSize( OVERSHOOT_DEFAULT_SIZE ),
+ mScrollToAlphaFunction( AlphaFunction::EASE_OUT ),
mOvershootEnabled(true)
{
}
@@ -93,6 +95,7 @@ Scrollable::Scrollable( ControlBehaviour behaviourFlags )
mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ),
mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ),
mOvershootSize( OVERSHOOT_DEFAULT_SIZE ),
+ mScrollToAlphaFunction( AlphaFunction::EASE_OUT ),
mOvershootEnabled(true)
{
}
@@ -209,6 +212,17 @@ void Scrollable::SetProperty( BaseObject* object, Property::Index index, const P
scrollableImpl.EnableScrollOvershoot( scrollableImpl.IsOvershootEnabled() );
break;
}
+ case Toolkit::Scrollable::Property::SCROLL_TO_ALPHA_FUNCTION:
+ {
+ int alphaFunction = value.Get();
+
+ if( alphaFunction >= AlphaFunction::DEFAULT &&
+ alphaFunction < AlphaFunction::COUNT )
+ {
+ scrollableImpl.mScrollToAlphaFunction = static_cast< AlphaFunction::BuiltinFunction >( alphaFunction );
+ }
+ break;
+ }
}
}
}
@@ -244,6 +258,11 @@ Property::Value Scrollable::GetProperty( BaseObject* object, Property::Index ind
value = scrollableImpl.mOvershootSize;
break;
}
+ case Toolkit::Scrollable::Property::SCROLL_TO_ALPHA_FUNCTION:
+ {
+ value = static_cast( scrollableImpl.mScrollToAlphaFunction );
+ break;
+ }
}
}
diff --git a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h
index 97b3107..0d5d045 100644
--- a/dali-toolkit/internal/controls/scrollable/scrollable-impl.h
+++ b/dali-toolkit/internal/controls/scrollable/scrollable-impl.h
@@ -18,6 +18,9 @@
*
*/
+// EXTERNAL INCLUDES
+#include
+
// INTERNAL INCLUDES
#include
#include
@@ -212,6 +215,8 @@ protected:
float mOvershootAnimationSpeed; /// ItemLayoutPtr;
* |---------------------------------|--------------------------------------------|
* | layoutActivated | @ref LayoutActivatedSignal() |
* @SINCE_1_0.0
+ *
+ * Actions
+ * | %Action Name | Attributes | Description |
+ * |---------------|-------------------------|-------------------------------------------------|
+ * | stopScrolling | Doesn't have attributes | Stops the scroll animation. See @ref DoAction() |
+ * @SINCE_1_1.33
*/
class DALI_IMPORT_API ItemView : public Scrollable
diff --git a/dali-toolkit/public-api/controls/scrollable/scrollable.h b/dali-toolkit/public-api/controls/scrollable/scrollable.h
index e8af489..0df8a58 100644
--- a/dali-toolkit/public-api/controls/scrollable/scrollable.h
+++ b/dali-toolkit/public-api/controls/scrollable/scrollable.h
@@ -46,8 +46,8 @@ class Scrollable;
* | %Signal Name | Method |
* |------------------|------------------------------|
* | scrollStarted | @ref ScrollStartedSignal() |
- * | scrollCompleted | @ref ScrollUpdatedSignal() |
- * | scrollUpdated | @ref ScrollCompletedSignal() |
+ * | scrollCompleted | @ref ScrollCompletedSignal() |
+ * | scrollUpdated | @ref ScrollUpdatedSignal() |
* @SINCE_1_0.0
*/
class DALI_IMPORT_API Scrollable : public Control
@@ -80,6 +80,7 @@ public:
OVERSHOOT_ANIMATION_SPEED, ///< Property, name "overshootAnimationSpeed", @see SetOvershootAnimationSpeed(), type float @SINCE_1_0.0
OVERSHOOT_ENABLED, ///< Property, name "overshootEnabled", @see SetOvershootEnabled(), type bool, @SINCE_1_1.18
OVERSHOOT_SIZE, ///< Property, name "overshootSize", type Vector2, @SINCE_1_1.31
+ SCROLL_TO_ALPHA_FUNCTION, ///< Property, name "scrollToAlphaFunction", type int, @SINCE_1_1.33
// Animatable properties
SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scrollRelativePosition", type Vector2 @SINCE_1_0.0
diff --git a/docs/content/shared-javascript-and-cpp-documentation/item-view.md b/docs/content/shared-javascript-and-cpp-documentation/item-view.md
index 93c4816..0242d19 100644
--- a/docs/content/shared-javascript-and-cpp-documentation/item-view.md
+++ b/docs/content/shared-javascript-and-cpp-documentation/item-view.md
@@ -69,4 +69,13 @@ itemView.ActivateLayout(
Dali::Stage::GetCurrent().Add( itemView );
~~~
+## Actions
+The item-view provides an action to stop the scroll animation if desired.
+
+~~~{.cpp}
+Property::Map attributes;
+itemView.DoAction( "stopScrolling", attributes );
+~~~
+
+
*/
\ No newline at end of file