/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h>
+#include <dali-toolkit/public-api/controls/scrollable/scrollable.h>
using namespace Dali;
namespace Dali
{
-
namespace Toolkit
{
-
///////////////////////////////////////////////////////////////////////////////////////////////////
// RulerDomain
///////////////////////////////////////////////////////////////////////////////////////////////////
return Clamp(x, length, scale, clamped);
}
-float RulerDomain::Clamp(float x, float length, float scale, ClampState &clamped) const
+float RulerDomain::Clamp(float x, float length, float scale, ClampState& clamped) const
{
if(!enabled)
{
- clamped = NotClamped;
+ clamped = NOT_CLAMPED;
return x;
}
const float maxExtent = max * scale - length;
if(x < minExtent)
{
- clamped = ClampedToMin;
+ clamped = CLAMPED_TO_MIN;
return minExtent;
}
else if(x > maxExtent)
{
- clamped = ClampedToMax;
+ clamped = CLAMPED_TO_MAX;
return maxExtent;
}
- clamped = NotClamped;
+ clamped = NOT_CLAMPED;
return x;
}
float RulerDomain::GetSize() const
{
- return max-min;
+ return max - min;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
Ruler::Ruler()
-: mType(Free),
+: mType(FREE),
mEnabled(true),
- mDomain(RulerDomain(0.0f,1.0f,false))
+ mDomain(RulerDomain(0.0f, 1.0f, false))
{
}
mDomain = domain;
}
-const RulerDomain &Ruler::GetDomain() const
+const RulerDomain& Ruler::GetDomain() const
{
return mDomain;
}
void Ruler::DisableDomain()
{
- mDomain = RulerDomain(0.0f,1.0f,false);
+ mDomain = RulerDomain(0.0f, 1.0f, false);
}
float Ruler::Clamp(float x, float length, float scale) const
return mDomain.Clamp(x, length, scale);
}
-float Ruler::Clamp(float x, float length, float scale, ClampState &clamped) const
+float Ruler::Clamp(float x, float length, float scale, ClampState& clamped) const
{
return mDomain.Clamp(x, length, scale, clamped);
}
return Clamp(Snap(x, bias), length, scale);
}
-float Ruler::SnapAndClamp(float x, float bias, float length, float scale, ClampState &clamped) const
+float Ruler::SnapAndClamp(float x, float bias, float length, float scale, ClampState& clamped) const
{
return Clamp(Snap(x, bias), length, scale, clamped);
}
DefaultRuler::DefaultRuler()
{
- mType = Free;
+ mType = FREE;
}
float DefaultRuler::Snap(float x, float bias) const
return x;
}
-float DefaultRuler::GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const
+float DefaultRuler::GetPositionFromPage(unsigned int page, unsigned int& volume, bool wrap) const
{
volume = 0;
return 0.0f;
{
if(fabsf(mSpacing) <= Math::MACHINE_EPSILON_1)
{
- DALI_LOG_ERROR( "Page spacing too small (%f).", double(spacing) );
+ DALI_LOG_ERROR("Page spacing too small (%f).\n", double(spacing));
mSpacing = spacing >= 0.0f ? Math::MACHINE_EPSILON_1 : -Math::MACHINE_EPSILON_1;
}
- mType = Fixed;
+ mType = FIXED;
}
float FixedRuler::Snap(float x, float bias) const
return floor(x / mSpacing + bias) * mSpacing;
}
-float FixedRuler::GetPositionFromPage(unsigned int page, unsigned int &volume, bool wrap) const
+float FixedRuler::GetPositionFromPage(unsigned int page, unsigned int& volume, bool wrap) const
{
float position = mDomain.min;
volume = 0;
// spacing must be present.
- if( mEnabled )
+ if(mEnabled)
{
unsigned int column = page;
if(wrap)
{
unsigned int pagesPerVolume = mDomain.GetSize() / mSpacing;
- if(pagesPerVolume>0)
+ if(pagesPerVolume > 0)
{
column += pagesPerVolume;
column %= pagesPerVolume;
- volume = page/pagesPerVolume;
+ volume = page / pagesPerVolume;
}
}
position = mDomain.min + column * mSpacing;
}
- else // Domain (or Spacing) is not present, carry page to volume.
+ else // Domain (or Spacing) is not present, carry page to volume.
{
if(wrap)
{
unsigned int page = 0;
// spacing must be present.
- if( mEnabled )
+ if(mEnabled)
{
- if( wrap )
+ if(wrap)
{
position = WrapInDomain(position, mDomain.min, mDomain.max);
}
- page = floor((position - mDomain.min) / mSpacing + 0.5f);
+ page = std::max(static_cast<double>(0.0f), static_cast<double>(floor((position - mDomain.min) / mSpacing + 0.5f)));
if(wrap)
{
if(pagesPerVolume < 1u)
{
pagesPerVolume = 1u;
- DALI_LOG_ERROR("Ruler domain(%f) is smaller than its spacing(%f).", mDomain.GetSize() * 1.0, mSpacing * 1.0 );
+ DALI_LOG_ERROR("Ruler domain(%f) is smaller than its spacing(%f).\n", mDomain.GetSize() * 1.0, mSpacing * 1.0);
}
page %= pagesPerVolume;
}
unsigned int pagesPerVolume = 1;
// spacing must be present.
- if( mEnabled )
+ if(mEnabled)
{
pagesPerVolume = mDomain.GetSize() / mSpacing;
}
// ScrollView
///////////////////////////////////////////////////////////////////////////////////////////////////
-const std::string ScrollView::SCROLL_PAGE_CURRENT( "scroll-page-current" );
-const std::string ScrollView::SCROLL_TIME_PROPERTY_NAME( "scroll-time" );
-const std::string ScrollView::SCROLL_POSITION_PROPERTY_NAME( "scroll-position" );
-const std::string ScrollView::SCROLL_PRE_POSITION_PROPERTY_NAME( "scroll-pre-position" );
-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_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" );
-const std::string ScrollView::SCROLL_SCROLLING_PROPERTY_NAME( "scroll-scrolling" );
-const std::string ScrollView::SCROLL_POSITION_DELTA_PROPERTY_NAME( "scroll-position-delta" );
-const std::string ScrollView::SCROLL_START_PAGE_POSITION_PROPERTY_NAME( "scroll-start-page-position" );
-
-const float ScrollView::DEFAULT_SLOW_SNAP_ANIMATION_DURATION(0.5f);
-const float ScrollView::DEFAULT_FAST_SNAP_ANIMATION_DURATION(0.25f);
-const float ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f);
-const float ScrollView::DEFAULT_MAX_OVERSHOOT(100.0f); // 100 pixels
-
-const float ScrollView::DEFAULT_AXIS_AUTO_LOCK_GRADIENT(0.36f);
-const float ScrollView::DEFAULT_FRICTION_COEFFICIENT(1.0f);
-const float ScrollView::DEFAULT_FLICK_SPEED_COEFFICIENT(1.0f);
-const float ScrollView::DEFAULT_MAX_FLICK_SPEED(3.0f);
-
ScrollView::ScrollView()
{
}
{
}
-ScrollView::ScrollView( Dali::Internal::CustomActor* internal )
-: Scrollable( internal )
+ScrollView::ScrollView(Dali::Internal::CustomActor* internal)
+: Scrollable(internal)
{
VerifyCustomActorPointer<Internal::ScrollView>(internal);
}
-ScrollView::ScrollView( const ScrollView& handle )
-: Scrollable( handle )
-{
-}
+ScrollView::ScrollView(const ScrollView& handle) = default;
-ScrollView& ScrollView::operator=( const ScrollView& handle )
-{
- if( &handle != this )
- {
- Control::operator=( handle );
- }
- return *this;
-}
+ScrollView::ScrollView(ScrollView&& rhs) noexcept = default;
+
+ScrollView& ScrollView::operator=(const ScrollView& handle) = default;
+
+ScrollView& ScrollView::operator=(ScrollView&& rhs) noexcept = default;
ScrollView ScrollView::New()
{
{
}
-ScrollView ScrollView::DownCast( BaseHandle handle )
+ScrollView ScrollView::DownCast(BaseHandle handle)
{
return Control::DownCast<ScrollView, Internal::ScrollView>(handle);
}
GetImpl(*this).SetSnapOvershootDuration(duration);
}
-void ScrollView::SetTouchesRequiredForPanning(unsigned int minTouches, unsigned int maxTouches, bool endOutside)
-{
- GetImpl(*this).SetTouchesRequiredForPanning(minTouches, maxTouches, endOutside);
-}
-
void ScrollView::SetActorAutoSnap(bool enable)
{
GetImpl(*this).SetActorAutoSnap(enable);
return GetImpl(*this).GetMinimumDistanceForFlick();
}
-void ScrollView::SetMinimumDistanceForFlick( const Vector2& distance )
+void ScrollView::SetMinimumDistanceForFlick(const Vector2& distance)
{
GetImpl(*this).SetMinimumDistanceForFlick(distance);
}
return GetImpl(*this).GetMinimumSpeedForFlick();
}
-void ScrollView::SetMinimumSpeedForFlick( float speed )
+void ScrollView::SetMinimumSpeedForFlick(float speed)
{
GetImpl(*this).SetMinimumSpeedForFlick(speed);
}
GetImpl(*this).SetMaxFlickSpeed(speed);
}
-Vector2 ScrollView::GetMouseWheelScrollDistanceStep() const
+Vector2 ScrollView::GetWheelScrollDistanceStep() const
{
- return GetImpl(*this).GetMouseWheelScrollDistanceStep();
+ return GetImpl(*this).GetWheelScrollDistanceStep();
}
-void ScrollView::SetMouseWheelScrollDistanceStep(Vector2 step)
+void ScrollView::SetWheelScrollDistanceStep(Vector2 step)
{
- GetImpl(*this).SetMouseWheelScrollDistanceStep(step);
+ GetImpl(*this).SetWheelScrollDistanceStep(step);
}
-Vector3 ScrollView::GetCurrentScrollPosition() const
+Vector2 ScrollView::GetCurrentScrollPosition() const
{
return GetImpl(*this).GetCurrentScrollPosition();
}
-void ScrollView::SetScrollPosition(const Vector3& position)
-{
- GetImpl(*this).SetScrollPosition(position);
-}
-
unsigned int ScrollView::GetCurrentPage() const
{
return GetImpl(*this).GetCurrentPage();
}
-void ScrollView::ScrollTo(const Vector3 &position)
+void ScrollView::ScrollTo(const Vector2& position)
{
GetImpl(*this).ScrollTo(position);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration)
+void ScrollView::ScrollTo(const Vector2& position, float duration)
{
GetImpl(*this).ScrollTo(position, duration);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration, AlphaFunction alpha)
+void ScrollView::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha)
{
GetImpl(*this).ScrollTo(position, duration, alpha);
}
-void ScrollView::ScrollTo(const Vector3 &position, float duration,
- DirectionBias horizontalBias, DirectionBias verticalBias)
+void ScrollView::ScrollTo(const Vector2& 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)
+void ScrollView::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha, DirectionBias horizontalBias, DirectionBias verticalBias)
{
GetImpl(*this).ScrollTo(position, duration, alpha, horizontalBias, verticalBias);
}
GetImpl(*this).ScrollTo(page, duration, bias);
}
-void ScrollView::ScrollTo(Actor &actor)
+void ScrollView::ScrollTo(Actor& actor)
{
GetImpl(*this).ScrollTo(actor);
}
-void ScrollView::ScrollTo(Actor &actor, float duration)
+void ScrollView::ScrollTo(Actor& actor, float duration)
{
GetImpl(*this).ScrollTo(actor, duration);
}
return GetImpl(*this).SnapStartedSignal();
}
-void ScrollView::SetScrollingDirection( Radian direction, Radian threshold )
+void ScrollView::SetScrollingDirection(Radian direction, Radian threshold)
{
- GetImpl(*this).SetScrollingDirection( direction, threshold );
+ GetImpl(*this).SetScrollingDirection(direction, threshold);
}
-void ScrollView::RemoveScrollingDirection( Radian direction )
+void ScrollView::RemoveScrollingDirection(Radian direction)
{
- GetImpl(*this).RemoveScrollingDirection( direction );
+ GetImpl(*this).RemoveScrollingDirection(direction);
}
} // namespace Toolkit