Formatting API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scrollable / scroll-view / scroll-view.cpp
index 398939e..fead0d2 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 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
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -51,11 +49,11 @@ float RulerDomain::Clamp(float x, float length, float scale) const
   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, ClampStateclamped) const
 {
   if(!enabled)
   {
-    clamped = NotClamped;
+    clamped = NOT_CLAMPED;
     return x;
   }
 
@@ -63,22 +61,22 @@ float RulerDomain::Clamp(float x, float length, float scale, ClampState &clamped
   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;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -86,9 +84,9 @@ float RulerDomain::GetSize() const
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 Ruler::Ruler()
-: mType(Free),
+: mType(FREE),
   mEnabled(true),
-  mDomain(RulerDomain(0.0f,1.0f,false))
+  mDomain(RulerDomain(0.0f, 1.0f, false))
 {
 }
 
@@ -121,14 +119,14 @@ void Ruler::SetDomain(RulerDomain domain)
   mDomain = domain;
 }
 
-const RulerDomain &Ruler::GetDomain() const
+const RulerDomainRuler::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
@@ -136,7 +134,7 @@ 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, ClampStateclamped) const
 {
   return mDomain.Clamp(x, length, scale, clamped);
 }
@@ -146,7 +144,7 @@ float Ruler::SnapAndClamp(float x, float bias, float length, float scale) const
   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, ClampStateclamped) const
 {
   return Clamp(Snap(x, bias), length, scale, clamped);
 }
@@ -157,7 +155,7 @@ float Ruler::SnapAndClamp(float x, float bias, float length, float scale, ClampS
 
 DefaultRuler::DefaultRuler()
 {
-  mType = Free;
+  mType = FREE;
 }
 
 float DefaultRuler::Snap(float x, float bias) const
@@ -165,7 +163,7 @@ 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 intvolume, bool wrap) const
 {
   volume = 0;
   return 0.0f;
@@ -190,10 +188,10 @@ FixedRuler::FixedRuler(float spacing)
 {
   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
@@ -201,14 +199,14 @@ 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 intvolume, bool wrap) const
 {
   float position = mDomain.min;
 
   volume = 0;
 
   // spacing must be present.
-  if( mEnabled )
+  if(mEnabled)
   {
     unsigned int column = page;
 
@@ -216,17 +214,17 @@ float FixedRuler::GetPositionFromPage(unsigned int page, unsigned int &volume, b
     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)
     {
@@ -242,13 +240,13 @@ unsigned int FixedRuler::GetPageFromPosition(float position, bool wrap) const
   unsigned int page = 0;
 
   // spacing must be present.
-  if( mEnabled )
+  if(mEnabled)
   {
-    if( wrap )
+    if(wrap)
     {
       position = WrapInDomain(position, mDomain.min, mDomain.max);
     }
-    page = std::max(static_cast<double>(0.0f), 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)
     {
@@ -257,7 +255,7 @@ unsigned int FixedRuler::GetPageFromPosition(float position, bool wrap) const
       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;
     }
@@ -271,7 +269,7 @@ unsigned int FixedRuler::GetTotalPages() const
   unsigned int pagesPerVolume = 1;
 
   // spacing must be present.
-  if( mEnabled )
+  if(mEnabled)
   {
     pagesPerVolume = mDomain.GetSize() / mSpacing;
   }
@@ -292,25 +290,19 @@ ScrollView::ScrollView(Internal::ScrollView& implementation)
 {
 }
 
-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) = default;
+
+ScrollView& ScrollView::operator=(const ScrollView& handle) = default;
+
+ScrollView& ScrollView::operator=(ScrollView&& rhs) = default;
 
 ScrollView ScrollView::New()
 {
@@ -321,7 +313,7 @@ ScrollView::~ScrollView()
 {
 }
 
-ScrollView ScrollView::DownCast( BaseHandle handle )
+ScrollView ScrollView::DownCast(BaseHandle handle)
 {
   return Control::DownCast<ScrollView, Internal::ScrollView>(handle);
 }
@@ -461,7 +453,7 @@ Vector2 ScrollView::GetMinimumDistanceForFlick() const
   return GetImpl(*this).GetMinimumDistanceForFlick();
 }
 
-void ScrollView::SetMinimumDistanceForFlick( const Vector2& distance )
+void ScrollView::SetMinimumDistanceForFlick(const Vector2& distance)
 {
   GetImpl(*this).SetMinimumDistanceForFlick(distance);
 }
@@ -471,7 +463,7 @@ float ScrollView::GetMinimumSpeedForFlick() const
   return GetImpl(*this).GetMinimumSpeedForFlick();
 }
 
-void ScrollView::SetMinimumSpeedForFlick( float speed )
+void ScrollView::SetMinimumSpeedForFlick(float speed)
 {
   GetImpl(*this).SetMinimumSpeedForFlick(speed);
 }
@@ -506,29 +498,27 @@ unsigned int ScrollView::GetCurrentPage() const
   return GetImpl(*this).GetCurrentPage();
 }
 
-void ScrollView::ScrollTo(const Vector2 &position)
+void ScrollView::ScrollTo(const Vector2position)
 {
   GetImpl(*this).ScrollTo(position);
 }
 
-void ScrollView::ScrollTo(const Vector2 &position, float duration)
+void ScrollView::ScrollTo(const Vector2position, float duration)
 {
   GetImpl(*this).ScrollTo(position, duration);
 }
 
-void ScrollView::ScrollTo(const Vector2 &position, float duration, AlphaFunction alpha)
+void ScrollView::ScrollTo(const Vector2position, float duration, AlphaFunction alpha)
 {
   GetImpl(*this).ScrollTo(position, duration, alpha);
 }
 
-void ScrollView::ScrollTo(const Vector2 &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 Vector2 &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);
 }
@@ -548,12 +538,12 @@ void ScrollView::ScrollTo(unsigned int page, float duration, DirectionBias bias)
   GetImpl(*this).ScrollTo(page, duration, bias);
 }
 
-void ScrollView::ScrollTo(Actor &actor)
+void ScrollView::ScrollTo(Actoractor)
 {
   GetImpl(*this).ScrollTo(actor);
 }
 
-void ScrollView::ScrollTo(Actor &actor, float duration)
+void ScrollView::ScrollTo(Actoractor, float duration)
 {
   GetImpl(*this).ScrollTo(actor, duration);
 }
@@ -603,14 +593,14 @@ ScrollView::SnapStartedSignalType& ScrollView::SnapStartedSignal()
   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