X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=base%2Fdali-toolkit%2Fpublic-api%2Fcontrols%2Fscrollable%2Fscroll-view%2Fscroll-view.cpp;h=03f9d3829e364f7a05439dc02649f3d705887b12;hp=69db853c282b7374cc5fe1e65efd020b86c69b66;hb=ca4705cf3cfb2ad6be0a8c7c672381b69055c821;hpb=63106d0a9407c87ff624f4b93e2627a0c7cc1e2a diff --git a/base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp b/base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp index 69db853..03f9d38 100644 --- a/base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp +++ b/base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp @@ -15,8 +15,14 @@ * */ -#include +// CLASS HEADER #include + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include #include using namespace Dali; @@ -182,6 +188,11 @@ unsigned int DefaultRuler::GetTotalPages() const FixedRuler::FixedRuler(float spacing) : mSpacing(spacing) { + if(fabsf(mSpacing) <= Math::MACHINE_EPSILON_1) + { + DALI_LOG_ERROR( "Page spacing too small (%f).", double(spacing) ); + mSpacing = spacing >= 0.0f ? Math::MACHINE_EPSILON_1 : -Math::MACHINE_EPSILON_1; + } mType = Fixed; } @@ -197,7 +208,7 @@ float FixedRuler::GetPositionFromPage(unsigned int page, unsigned int &volume, b volume = 0; // spacing must be present. - if(mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1) + if( mEnabled ) { unsigned int column = page; @@ -231,13 +242,23 @@ unsigned int FixedRuler::GetPageFromPosition(float position, bool wrap) const unsigned int page = 0; // spacing must be present. - if(mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1) + if( mEnabled ) { + if( wrap ) + { + position = WrapInDomain(position, mDomain.min, mDomain.max); + } page = floor((position - mDomain.min) / mSpacing + 0.5f); if(wrap) { unsigned int pagesPerVolume = mDomain.GetSize() / mSpacing; + // Defensive check to avoid a divide by zero below when the ruler is in an invalid state (entire domain smaller than spacing between pages of it): + if(pagesPerVolume < 1u) + { + pagesPerVolume = 1u; + DALI_LOG_ERROR("Ruler domain(%f) is smaller than its spacing(%f).", mDomain.GetSize() * 1.0, mSpacing * 1.0 ); + } page %= pagesPerVolume; } } @@ -250,7 +271,7 @@ unsigned int FixedRuler::GetTotalPages() const unsigned int pagesPerVolume = 1; // spacing must be present. - if(mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1) + if( mEnabled ) { pagesPerVolume = mDomain.GetSize() / mSpacing; } @@ -269,8 +290,6 @@ const std::string ScrollView::SCROLL_PRE_POSITION_PROPERTY_NAME( "scroll-pre-pos const std::string ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME( "scroll-overshoot-x" ); const std::string ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME( "scroll-overshoot-y" ); const std::string ScrollView::SCROLL_FINAL_PROPERTY_NAME( "scroll-final" ); -const std::string ScrollView::SCROLL_X_PROPERTY_NAME( "scroll-x" ); -const std::string ScrollView::SCROLL_Y_PROPERTY_NAME( "scroll-y" ); const std::string ScrollView::SCROLL_SCALE_PROPERTY_NAME( "scroll-scale" ); const std::string ScrollView::SCROLL_WRAP_PROPERTY_NAME( "scroll-wrap" ); const std::string ScrollView::SCROLL_PANNING_PROPERTY_NAME( "scroll-panning" ); @@ -383,16 +402,6 @@ void ScrollView::SetRulerY(RulerPtr ruler) GetImpl(*this).SetRulerY(ruler); } -void ScrollView::SetRulerScaleX(RulerPtr ruler) -{ - GetImpl(*this).SetRulerScaleX(ruler); -} - -void ScrollView::SetRulerScaleY(RulerPtr ruler) -{ - GetImpl(*this).SetRulerScaleY(ruler); -} - void ScrollView::SetScrollSensitive(bool sensitive) { GetImpl(*this).SetScrollSensitive(sensitive); @@ -428,14 +437,14 @@ void ScrollView::SetWrapMode(bool enable) GetImpl(*this).SetWrapMode(enable); } -int ScrollView::GetRefreshInterval() const +int ScrollView::GetScrollUpdateDistance() const { - return GetImpl(*this).GetRefreshInterval(); + return GetImpl(*this).GetScrollUpdateDistance(); } -void ScrollView::SetRefreshInterval(int milliseconds) +void ScrollView::SetScrollUpdateDistance(int distance) { - GetImpl(*this).SetRefreshInterval(milliseconds); + GetImpl(*this).SetScrollUpdateDistance(distance); } bool ScrollView::GetAxisAutoLock() const @@ -478,6 +487,26 @@ void ScrollView::SetFlickSpeedCoefficient(float speed) GetImpl(*this).SetFlickSpeedCoefficient(speed); } +Vector2 ScrollView::GetMinimumDistanceForFlick() const +{ + return GetImpl(*this).GetMinimumDistanceForFlick(); +} + +void ScrollView::SetMinimumDistanceForFlick( const Vector2& distance ) +{ + GetImpl(*this).SetMinimumDistanceForFlick(distance); +} + +float ScrollView::GetMinimumSpeedForFlick() const +{ + return GetImpl(*this).GetMinimumSpeedForFlick(); +} + +void ScrollView::SetMinimumSpeedForFlick( float speed ) +{ + GetImpl(*this).SetMinimumSpeedForFlick(speed); +} + float ScrollView::GetMaxFlickSpeed() const { return GetImpl(*this).GetMaxFlickSpeed(); @@ -508,26 +537,11 @@ void ScrollView::SetScrollPosition(const Vector3& position) GetImpl(*this).SetScrollPosition(position); } -Vector3 ScrollView::GetCurrentScrollScale() const -{ - return GetImpl(*this).GetCurrentScrollScale(); -} - unsigned int ScrollView::GetCurrentPage() const { return GetImpl(*this).GetCurrentPage(); } -void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation) -{ - GetImpl(*this).TransformTo(position, scale, rotation); -} - -void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation, float duration) -{ - GetImpl(*this).TransformTo(position, scale, rotation, duration); -} - void ScrollView::ScrollTo(const Vector3 &position) { GetImpl(*this).ScrollTo(position); @@ -538,12 +552,23 @@ void ScrollView::ScrollTo(const Vector3 &position, float duration) GetImpl(*this).ScrollTo(position, duration); } +void ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha) +{ + GetImpl(*this).ScrollTo(position, duration, alpha); +} + void ScrollView::ScrollTo(const Vector3 &position, float duration, DirectionBias horizontalBias, DirectionBias verticalBias) { GetImpl(*this).ScrollTo(position, duration, horizontalBias, verticalBias); } +void ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha, + DirectionBias horizontalBias, DirectionBias verticalBias) +{ + GetImpl(*this).ScrollTo(position, duration, alpha, horizontalBias, verticalBias); +} + void ScrollView::ScrollTo(unsigned int page) { GetImpl(*this).ScrollTo(page); @@ -574,16 +599,6 @@ bool ScrollView::ScrollToSnapPoint() return GetImpl(*this).ScrollToSnapPoint(); } -void ScrollView::ScaleTo(const Vector3 &scale) -{ - GetImpl(*this).ScaleTo(scale); -} - -void ScrollView::ScaleTo(const Vector3 &scale, float duration) -{ - GetImpl(*this).ScaleTo(scale, duration); -} - void ScrollView::ApplyConstraintToChildren(Constraint constraint) { GetImpl(*this).ApplyConstraintToChildren(constraint);