X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscroll-bar%2Fscroll-bar-impl.cpp;h=2bcca2f5daec6cdd40fd337420114625c493ee49;hp=bae2b78e0f86f4c57e5773ba63e206061738a488;hb=030e7c680a6eb0e8d87bfdb8ec359a0267ef7db2;hpb=2ec164cd618f93ccafe17b1d0b8ff16401ed4aef diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp index bae2b78..2bcca2f 100755 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -19,6 +19,7 @@ #include // EXTERNAL INCLUDES +#include // for strcmp #include #include #include @@ -71,24 +72,21 @@ struct IndicatorPositionConstraint /** * Constraint operator - * @param[in] current The current indicator position - * @param[in] indicatorSizeProperty The size of indicator. - * @param[in] parentSizeProperty The parent size of indicator. - * @param[in] scrollPositionProperty The scroll position of the scrollable container // (from 0.0 -> 1.0 in each axis) + * @param[in,out] current The current indicator position + * @param[in] inputs Contains the size of indicator, the size of indicator's parent, and the scroll position of the scrollable container (from 0.0 -> 1.0 in each axis) * @return The new indicator position is returned. */ - Vector3 operator()(const Vector3& current, - const PropertyInput& indicatorSizeProperty, - const PropertyInput& parentSizeProperty, - const PropertyInput& scrollPositionProperty) + void operator()( Vector3& current, const PropertyInputContainer& inputs ) { - Vector3 indicatorSize = indicatorSizeProperty.GetVector3(); - Vector3 parentSize = parentSizeProperty.GetVector3(); - float scrollPosition = scrollPositionProperty.GetFloat(); + const Vector3& indicatorSize = inputs[0]->GetVector3(); + const Vector3& parentSize = inputs[1]->GetVector3(); + float scrollPosition = inputs[2]->GetFloat(); const float domainSize = fabs(mMaxPosition - mMinPosition); float relativePosition = (mMaxPosition - scrollPosition) / domainSize; - return Vector3(current.x, relativePosition * (parentSize.height - indicatorSize.height), DEFAULT_SLIDER_DEPTH); + + current.y = relativePosition * ( parentSize.height - indicatorSize.height ); + current.z = DEFAULT_SLIDER_DEPTH; } float mMinPosition; ///< The minimum scroll position @@ -119,12 +117,12 @@ BaseHandle Create() // Setup properties, signals and actions using the type-registry. DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollBar, Toolkit::ScrollComponent, Create ); -DALI_PROPERTY_REGISTRATION( ScrollBar, "indicator-height-policy", STRING, INDICATOR_HEIGHT_POLICY ) -DALI_PROPERTY_REGISTRATION( ScrollBar, "indicator-fixed-height", FLOAT, INDICATOR_FIXED_HEIGHT ) -DALI_PROPERTY_REGISTRATION( ScrollBar, "indicator-show-duration", FLOAT, INDICATOR_SHOW_DURATION ) -DALI_PROPERTY_REGISTRATION( ScrollBar, "indicator-hide-duration", FLOAT, INDICATOR_HIDE_DURATION ) +DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-height-policy", STRING, INDICATOR_HEIGHT_POLICY ) +DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-fixed-height", FLOAT, INDICATOR_FIXED_HEIGHT ) +DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-show-duration", FLOAT, INDICATOR_SHOW_DURATION ) +DALI_PROPERTY_REGISTRATION( Toolkit, ScrollBar, "indicator-hide-duration", FLOAT, INDICATOR_HIDE_DURATION ) -DALI_SIGNAL_REGISTRATION( ScrollBar, "scroll-position-notified", SCROLL_POSITION_NOTIFIED_SIGNAL ) +DALI_SIGNAL_REGISTRATION( Toolkit, ScrollBar, "scroll-position-notified", SCROLL_POSITION_NOTIFIED_SIGNAL ) DALI_TYPE_REGISTRATION_END() @@ -198,13 +196,6 @@ void ScrollBar::ApplyConstraints() { if( mScrollConnector ) { - Constraint constraint; - - if(mIndicatorSizeConstraint) - { - mIndicator.RemoveConstraint(mIndicatorSizeConstraint); - } - // Set indicator height according to the indicator's height policy if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed) { @@ -217,15 +208,14 @@ void ScrollBar::ApplyConstraints() if(mIndicatorPositionConstraint) { - mIndicator.RemoveConstraint(mIndicatorPositionConstraint); + mIndicatorPositionConstraint.Remove(); } - constraint = Constraint::New( Actor::Property::POSITION, - LocalSource( Actor::Property::SIZE ), - ParentSource( Actor::Property::SIZE ), - Source( mScrollPositionObject, Toolkit::ScrollConnector::SCROLL_POSITION ), - IndicatorPositionConstraint( mScrollConnector.GetMinLimit(), mScrollConnector.GetMaxLimit() ) ); - mIndicatorPositionConstraint = mIndicator.ApplyConstraint( constraint ); + mIndicatorPositionConstraint = Constraint::New( mIndicator, Actor::Property::POSITION, IndicatorPositionConstraint( mScrollConnector.GetMinLimit(), mScrollConnector.GetMaxLimit() ) ); + mIndicatorPositionConstraint.AddSource( LocalSource( Actor::Property::SIZE ) ); + mIndicatorPositionConstraint.AddSource( ParentSource( Actor::Property::SIZE ) ); + mIndicatorPositionConstraint.AddSource( Source( mScrollPositionObject, Toolkit::ScrollConnector::SCROLL_POSITION ) ); + mIndicatorPositionConstraint.Apply(); } } @@ -250,6 +240,8 @@ void ScrollBar::OnScrollPositionNotified(PropertyNotification& source) void ScrollBar::Show() { + Actor self = Self(); + // Cancel any animation if(mAnimation) { @@ -260,17 +252,19 @@ void ScrollBar::Show() if(mIndicatorShowDuration > 0.0f) { mAnimation = Animation::New( mIndicatorShowDuration ); - mAnimation.OpacityTo( Self(), 1.0f, AlphaFunctions::EaseIn ); + mAnimation.AnimateTo( Property( self, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::EASE_IN ); mAnimation.Play(); } else { - Self().SetOpacity(1.0f); + self.SetOpacity(1.0f); } } void ScrollBar::Hide() { + Actor self = Self(); + // Cancel any animation if(mAnimation) { @@ -281,12 +275,12 @@ void ScrollBar::Hide() if(mIndicatorHideDuration > 0.0f) { mAnimation = Animation::New( mIndicatorHideDuration ); - mAnimation.OpacityTo( Self(), 0.0f, AlphaFunctions::EaseIn ); + mAnimation.AnimateTo( Property( self, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunction::EASE_IN ); mAnimation.Play(); } else { - Self().SetOpacity(0.0f); + self.SetOpacity(0.0f); } }