#include <dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h>
// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
#include <algorithm>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/set-wrapper.h>
}
// Overshoot overlay constraints
-
-struct OvershootOverlaySizeConstraint
+void OvershootOverlaySizeConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- Vector3 operator()(const Vector3& current,
- const PropertyInput& parentScrollDirectionProperty,
- const PropertyInput& parentOvershootProperty,
- const PropertyInput& parentSizeProperty)
- {
- const Vector3 parentScrollDirection = parentScrollDirectionProperty.GetVector3();
- const Vector3 parentSize = parentSizeProperty.GetVector3();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
-
- float overlayWidth;
-
- if(Toolkit::IsVertical(parentOrientation))
- {
- overlayWidth = fabsf(parentScrollDirection.y) > Math::MACHINE_EPSILON_1 ? parentSize.x : parentSize.y;
- }
- else
- {
- overlayWidth = fabsf(parentScrollDirection.x) > Math::MACHINE_EPSILON_1 ? parentSize.y : parentSize.x;
- }
-
- float overlayHeight = (overlayWidth > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height*0.5f;
+ const Vector3& parentScrollDirection = inputs[0]->GetVector3();
+ const Vector3& parentSize = inputs[1]->GetVector3();
+ const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
- return Vector3( overlayWidth, overlayHeight, current.depth );
+ if(Toolkit::IsVertical(parentOrientation))
+ {
+ 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;
}
-};
-struct OvershootOverlayRotationConstraint
+ current.height = ( current.width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD ) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height*0.5f;
+}
+
+void OvershootOverlayRotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
- Quaternion operator()(const Quaternion& current,
- const PropertyInput& parentScrollDirectionProperty,
- const PropertyInput& parentOvershootProperty)
- {
- const Vector3 parentScrollDirection = parentScrollDirectionProperty.GetVector3();
- const float parentOvershoot = parentOvershootProperty.GetFloat();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
+ const Vector3& parentScrollDirection = inputs[0]->GetVector3();
+ const float parentOvershoot = inputs[1]->GetFloat();
+ const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
- float multiplier = 0;
- if(Toolkit::IsVertical(parentOrientation))
+ float multiplier = 0;
+ if(Toolkit::IsVertical(parentOrientation))
+ {
+ if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
{
- if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
- {
- if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
- {
- multiplier = 0.5f;
- }
- else
- {
- multiplier = 1.5f;
- }
- }
- else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.y > Math::MACHINE_EPSILON_0)
- || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.y < Math::MACHINE_EPSILON_0) )
+ if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
- multiplier = 0.0f;
+ multiplier = 0.5f;
}
else
{
- multiplier = 1.0f;
+ multiplier = 1.5f;
}
}
+ else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.y > Math::MACHINE_EPSILON_0)
+ || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.y < Math::MACHINE_EPSILON_0) )
+ {
+ multiplier = 0.0f;
+ }
else
{
- if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
- {
- if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot > Math::MACHINE_EPSILON_0)
- ||(parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot < Math::MACHINE_EPSILON_0) )
- {
- multiplier = 1.0f;
- }
- else
- {
- multiplier = 0.0f;
- }
- }
- else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.x > Math::MACHINE_EPSILON_0)
- || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.x < Math::MACHINE_EPSILON_0) )
+ multiplier = 1.0f;
+ }
+ }
+ else
+ {
+ if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
+ {
+ if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot > Math::MACHINE_EPSILON_0)
+ ||(parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot < Math::MACHINE_EPSILON_0) )
{
- multiplier = 1.5f;
+ multiplier = 1.0f;
}
else
{
- multiplier = 0.5f;
+ multiplier = 0.0f;
}
}
-
- Quaternion rotation( Radian( multiplier * Math::PI ), Vector3::ZAXIS );
-
- return rotation;
+ else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.x > Math::MACHINE_EPSILON_0)
+ || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.x < Math::MACHINE_EPSILON_0) )
+ {
+ multiplier = 1.5f;
+ }
+ else
+ {
+ multiplier = 0.5f;
+ }
}
-};
-struct OvershootOverlayPositionConstraint
+ current = Quaternion( Radian( multiplier * Math::PI ), Vector3::ZAXIS );
+}
+
+void OvershootOverlayPositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- Vector3 operator()(const Vector3& current,
- const PropertyInput& parentSizeProperty,
- const PropertyInput& parentScrollDirectionProperty,
- const PropertyInput& parentOvershootProperty)
- {
- const Vector3 parentScrollDirection = parentScrollDirectionProperty.GetVector3();
- const float parentOvershoot = parentOvershootProperty.GetFloat();
- const Vector3 parentSize = parentSizeProperty.GetVector3();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
+ const Vector3& parentSize = inputs[0]->GetVector3();
+ const Vector3& parentScrollDirection = inputs[1]->GetVector3();
+ const float parentOvershoot = inputs[2]->GetFloat();
+ const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
- Vector3 relativeOffset;
+ Vector3 relativeOffset;
- if(Toolkit::IsVertical(parentOrientation))
+ if(Toolkit::IsVertical(parentOrientation))
+ {
+ if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
{
- if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
- {
- if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
- {
- relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
- }
- else
- {
- relativeOffset =Vector3(0.0f, 1.0f, 0.0f);
- }
- }
- else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.y > Math::MACHINE_EPSILON_0)
- || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.y < Math::MACHINE_EPSILON_0) )
+ if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
- relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
+ relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
}
else
{
- relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
+ relativeOffset =Vector3(0.0f, 1.0f, 0.0f);
}
}
+ else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.y > Math::MACHINE_EPSILON_0)
+ || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.y < Math::MACHINE_EPSILON_0) )
+ {
+ relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
+ }
else
{
- if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
- {
- if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot > Math::MACHINE_EPSILON_0) )
- {
- relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
- }
- else
- {
- relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
- }
- }
- else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.x > Math::MACHINE_EPSILON_0)
- || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.x < Math::MACHINE_EPSILON_0) )
+ relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
+ }
+ }
+ else
+ {
+ if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
+ {
+ if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
- relativeOffset = Vector3(0.0f, 1.0f, 0.0f);
+ relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
}
else
{
- relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
+ relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
}
}
-
- return relativeOffset * parentSize;
-
+ else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.x > Math::MACHINE_EPSILON_0)
+ || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.x < Math::MACHINE_EPSILON_0) )
+ {
+ relativeOffset = Vector3(0.0f, 1.0f, 0.0f);
+ }
+ else
+ {
+ relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
+ }
}
-};
-struct OvershootOverlayVisibilityConstraint
-{
- bool operator()(const bool& current,
- const PropertyInput& parentLayoutScrollableProperty)
- {
- const bool parentLayoutScrollable = parentLayoutScrollableProperty.GetBoolean();
+ current = relativeOffset * parentSize;
+}
- return parentLayoutScrollable;
- }
-};
+void OvershootOverlayVisibilityConstraint( bool& current, const PropertyInputContainer& inputs )
+{
+ current = inputs[0]->GetBoolean();
+}
/**
* Relative position Constraint
* Generates the relative position value of the item view based on the layout position,
* and it's relation to the layout domain. This is a value from 0.0f to 1.0f in each axis.
*/
-Vector3 RelativePositionConstraint(const Vector3& current,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollMinProperty,
- const PropertyInput& scrollMaxProperty,
- const PropertyInput& layoutSizeProperty)
+void RelativePositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& position = Vector3(0.0f, scrollPositionProperty.GetFloat(), 0.0f);
- const Vector3& min = scrollMinProperty.GetVector3();
- const Vector3& max = scrollMaxProperty.GetVector3();
+ const Vector3& position = Vector3(0.0f, inputs[0]->GetFloat(), 0.0f);
+ const Vector3& min = inputs[1]->GetVector3();
+ const Vector3& max = inputs[2]->GetVector3();
- Vector3 relativePosition;
Vector3 domainSize = max - min;
- relativePosition.x = fabsf(domainSize.x) > Math::MACHINE_EPSILON_1 ? ((min.x - position.x) / fabsf(domainSize.x)) : 0.0f;
- relativePosition.y = fabsf(domainSize.y) > Math::MACHINE_EPSILON_1 ? ((min.y - position.y) / fabsf(domainSize.y)) : 0.0f;
-
- return relativePosition;
+ current.x = fabsf(domainSize.x) > Math::MACHINE_EPSILON_1 ? ((min.x - position.x) / fabsf(domainSize.x)) : 0.0f;
+ current.y = fabsf(domainSize.y) > Math::MACHINE_EPSILON_1 ? ((min.y - position.y) / fabsf(domainSize.y)) : 0.0f;
+ current.z = 0.0f;
}
} // unnamed namespace
}
ItemView::ItemView(ItemFactory& factory)
-: Scrollable(),
+: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | REQUIRES_MOUSE_WHEEL_EVENTS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ),
mItemFactory(factory),
mActiveLayout(NULL),
mAnimatingOvershootOn(false),
mItemsParentOrigin( ParentOrigin::CENTER),
mItemsAnchorPoint( AnchorPoint::CENTER)
{
- SetRequiresMouseWheelEvents(true);
- SetKeyboardNavigationSupport(true);
}
void ItemView::OnInitialize()
{
- SetSizePolicy( Toolkit::Control::Fixed, Toolkit::Control::Fixed );
-
- RegisterCommonProperties();
-
Actor self = Self();
mScrollConnector = Dali::Toolkit::ScrollConnector::New();
EnableScrollComponent(Toolkit::Scrollable::OvershootIndicator);
- Constraint constraint = Constraint::New<Vector3>(mPropertyRelativePosition,
- LocalSource(mPropertyPosition),
- LocalSource(mPropertyPositionMin),
- LocalSource(mPropertyPositionMax),
- LocalSource(Actor::Property::SIZE),
- RelativePositionConstraint);
- self.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( self, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION, RelativePositionConstraint );
+ constraint.AddSource( LocalSource( mPropertyPosition ) );
+ constraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.Apply();
Vector2 stageSize = Stage::GetCurrent().GetSize();
mMouseWheelScrollDistanceStep = stageSize.y * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
// Move the items to the new layout positions...
- bool resizeAnimationNeeded(false);
for (ConstItemPoolIter iter = mItemPool.begin(); iter != mItemPool.end(); ++iter)
{
unsigned int itemId = iter->first;
Vector3 size;
if(mActiveLayout->GetItemSize(itemId, targetSize, size))
{
- if( durationSeconds > 0.0f )
- {
- // Use a size animation
- if (!resizeAnimationNeeded)
- {
- resizeAnimationNeeded = true;
- RemoveAnimation(mResizeAnimation);
- mResizeAnimation = Animation::New(durationSeconds);
- }
-
- // The layout provides its own resize animation
- mActiveLayout->GetResizeAnimation(mResizeAnimation, actor, size, durationSeconds);
- }
- else
- {
- // resize immediately
- actor.SetSize(size);
- }
+ // resize immediately
+ actor.SetSize( size.GetVectorXY() );
}
mActiveLayout->ApplyConstraints(actor, itemId, durationSeconds, mScrollPositionObject, Self() );
}
- if (resizeAnimationNeeded)
- {
- mResizeAnimation.Play();
- }
-
// Refresh the new layout
ItemRange range = GetItemRange(*mActiveLayout, targetSize, GetCurrentLayoutPosition(0), false/* don't reserve extra*/);
AddActorsWithinRange( range, durationSeconds );
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(durationSeconds);
- mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
- mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, targetSize), AlphaFunctions::EaseOut );
+ mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, targetSize), AlphaFunction::EASE_OUT );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnLayoutActivationScrollFinished);
mScrollAnimation.Play();
}
Radian scrollDirection(mActiveLayout->GetScrollDirection());
float orientation = static_cast<float>(mActiveLayout->GetOrientation());
- self.SetProperty(mPropertyScrollDirection, Vector3(sinf(scrollDirection), cosf(scrollDirection), orientation));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_DIRECTION, Vector3(sinf(scrollDirection), cosf(scrollDirection), orientation));
self.SetProperty(mPropertyScrollSpeed, mScrollSpeed);
}
}
+void ItemView::Refresh()
+{
+ for (ItemPoolIter iter = mItemPool.begin(); iter != mItemPool.end(); ++iter )
+ {
+ ReleaseActor( iter->first, iter->second );
+ }
+ mItemPool.clear();
+
+ DoRefresh(GetCurrentLayoutPosition(0), true);
+}
+
void ItemView::DoRefresh(float currentLayoutPosition, bool cacheExtra)
{
if (mActiveLayout)
Vector3 size;
if( mActiveLayout->GetItemSize( item.first, mActiveLayoutTargetSize, size ) )
{
- item.second.SetSize( size );
+ item.second.SetSize( size.GetVectorXY() );
}
mActiveLayout->ApplyConstraints( item.second, item.first, durationSeconds, mScrollPositionObject, Self() );
, DEFAULT_MINIMUM_SWIPE_DURATION, DEFAULT_MAXIMUM_SWIPE_DURATION);
mScrollAnimation = Animation::New(flickAnimationDuration);
- mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
- mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunctions::EaseOut );
- mScrollAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), 0.0f, AlphaFunctions::EaseOut );
+ mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), 0.0f, AlphaFunction::EASE_OUT );
mIsFlicking = true;
// Check whether it has already scrolled to the end
float anchorPosition = mActiveLayout->GetClosestAnchorPosition( GetCurrentLayoutPosition(0) );
anchoringAnimation = Animation::New(mAnchoringDuration);
- anchoringAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), anchorPosition, AlphaFunctions::EaseOut );
- anchoringAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(anchorPosition, self.GetCurrentSize()), AlphaFunctions::EaseOut );
- anchoringAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), 0.0f, AlphaFunctions::EaseOut );
+ anchoringAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), anchorPosition, AlphaFunction::EASE_OUT );
+ anchoringAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(anchorPosition, self.GetCurrentSize()), AlphaFunction::EASE_OUT );
+ anchoringAnimation.AnimateTo( Property(self, mPropertyScrollSpeed), 0.0f, AlphaFunction::EASE_OUT );
if(!mIsFlicking)
{
AnimateScrollOvershoot(0.0f);
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(durationSeconds);
- mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
- mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunctions::EaseOut );
+ mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunction::EASE_OUT );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnScrollFinished);
mScrollAnimation.Play();
}
if(IsHorizontal(mActiveLayout->GetOrientation()))
{
- self.SetProperty(mPropertyPositionMin, Vector3(0.0f, firstItemPosition.x, 0.0f));
- self.SetProperty(mPropertyPositionMax, Vector3(0.0f, lastItemPosition.x, 0.0f));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN, Vector3(0.0f, firstItemPosition.x, 0.0f));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector3(0.0f, lastItemPosition.x, 0.0f));
domainSize = fabs(firstItemPosition.x - lastItemPosition.x);
}
else
{
- self.SetProperty(mPropertyPositionMin, Vector3(0.0f, firstItemPosition.y, 0.0f));
- self.SetProperty(mPropertyPositionMax, Vector3(0.0f, lastItemPosition.y, 0.0f));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN, Vector3(0.0f, firstItemPosition.y, 0.0f));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector3(0.0f, lastItemPosition.y, 0.0f));
domainSize = fabs(firstItemPosition.y - lastItemPosition.y);
}
mScrollConnector.SetScrollDomain(minLayoutPosition, 0.0f, domainSize);
bool isLayoutScrollable = IsLayoutScrollable(layoutSize);
- self.SetProperty(mPropertyCanScrollVertical, isLayoutScrollable);
- self.SetProperty(mPropertyCanScrollHorizontal, false);
+ self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, isLayoutScrollable);
+ self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL, false);
}
}
{
Actor self = Self();
- float minScrollPosition = self.GetProperty<float>(mPropertyPositionMin);
- float maxScrollPosition = self.GetProperty<float>(mPropertyPositionMax);
+ float minScrollPosition = self.GetProperty<float>(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN);
+ float maxScrollPosition = self.GetProperty<float>(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX);
return Vector3(0.0f, fabs(maxScrollPosition - minScrollPosition), 0.0f);
}
{
RemoveAnimation(mScrollAnimation);
mScrollAnimation = Animation::New(duration);
- mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunctions::EaseOut );
- mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunctions::EaseOut );
+ mScrollAnimation.AnimateTo( Property( mScrollPositionObject, ScrollConnector::SCROLL_POSITION ), firstItemScrollPosition, AlphaFunction::EASE_OUT );
+ mScrollAnimation.AnimateTo( Property(self, mPropertyPosition), GetScrollPosition(firstItemScrollPosition, layoutSize), AlphaFunction::EASE_OUT );
mScrollAnimation.FinishedSignal().Connect(this, &ItemView::OnScrollFinished);
mScrollAnimation.Play();
}
mOvershootOverlay.SetDrawMode(DrawMode::OVERLAY);
self.Add(mOvershootOverlay);
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
- ParentSource( mPropertyScrollDirection ),
- Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
- ParentSource( Actor::Property::SIZE ),
- OvershootOverlaySizeConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( mOvershootOverlay, Actor::Property::SIZE, OvershootOverlaySizeConstraint );
+ constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
+
mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
- constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- ParentSource( mPropertyScrollDirection ),
- Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
- OvershootOverlayRotationConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
-
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- ParentSource( Actor::Property::SIZE ),
- ParentSource( mPropertyScrollDirection ),
- Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
- OvershootOverlayPositionConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
-
- constraint = Constraint::New<bool>( Actor::Property::VISIBLE,
- ParentSource( mPropertyCanScrollVertical ),
- OvershootOverlayVisibilityConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
-
- constraint = Constraint::New<float>( effectOvershootPropertyIndex,
- Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
- EqualToConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
+ constraint = Constraint::New<Quaternion>( mOvershootOverlay, Actor::Property::ORIENTATION, OvershootOverlayRotationConstraint );
+ constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mOvershootOverlay, Actor::Property::POSITION, OvershootOverlayPositionConstraint );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.Apply();
+
+ constraint = Constraint::New<bool>( mOvershootOverlay, Actor::Property::VISIBLE, OvershootOverlayVisibilityConstraint );
+ constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL ) );
+ constraint.Apply();
+
+ constraint = Constraint::New<float>( mOvershootOverlay, effectOvershootPropertyIndex, EqualToConstraint() );
+ constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.Apply();
}
else
{
if(mOvershootAnimationSpeed > Math::MACHINE_EPSILON_0)
{
float currentOvershoot = mScrollPositionObject.GetProperty<float>(ScrollConnector::OVERSHOOT);
- float duration = mOvershootOverlay.GetCurrentSize().height * (animatingOn ? (1.0f - fabsf(currentOvershoot)) : fabsf(currentOvershoot)) / mOvershootAnimationSpeed;
+ float duration = 0.0f;
+
+ if (mOvershootOverlay)
+ {
+ duration = mOvershootOverlay.GetCurrentSize().height * (animatingOn ? (1.0f - fabsf(currentOvershoot)) : fabsf(currentOvershoot)) / mOvershootAnimationSpeed;
+ }
RemoveAnimation(mScrollOvershootAnimation);
mScrollOvershootAnimation = Animation::New(duration);