Cleaned up Degree, Radian, AngleAxis and Quaternion classes
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / scrollable / item-view / grid-layout.cpp
index eb3bfd8..35d5ab6 100644 (file)
@@ -1,26 +1,29 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/public-api/controls/scrollable/item-view/grid-layout.h>
 
+// EXTERNAL INCLUDES
 #include <algorithm>
-
-#include <dali-toolkit/public-api/controls/scrollable/item-view/grid-layout.h>
+#include <dali/public-api/animation/animation.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
-using namespace std;
 
 namespace // unnamed namespace
 {
@@ -190,7 +193,7 @@ struct GridRotationConstraint0
 {
   Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
   {
-    return Quaternion(0.0f, Vector3::ZAXIS);
+    return Quaternion( Radian( 0.0f ), Vector3::ZAXIS);
   }
 };
 
@@ -198,7 +201,7 @@ struct GridRotationConstraint90
 {
   Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
   {
-    return Quaternion(1.5f * Math::PI, Vector3::ZAXIS);
+    return Quaternion( Radian( 1.5f * Math::PI ), Vector3::ZAXIS);
   }
 };
 
@@ -206,7 +209,7 @@ struct GridRotationConstraint180
 {
   Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
   {
-    return Quaternion(Math::PI, Vector3::ZAXIS);
+    return Quaternion( Radian( Math::PI ), Vector3::ZAXIS);
   }
 };
 
@@ -214,7 +217,7 @@ struct GridRotationConstraint270
 {
   Quaternion operator()(const Quaternion& current, const float& layoutPosition, const float& scrollSpeed, const Vector3& layoutSize)
   {
-    return Quaternion(0.5f * Math::PI, Vector3::ZAXIS);
+    return Quaternion( Radian( 0.5f * Math::PI ), Vector3::ZAXIS);
   }
 };
 
@@ -307,6 +310,7 @@ struct GridLayout::Impl
     mTopMargin(DEFAULT_TOP_MARGIN),
     mBottomMargin(DEFAULT_BOTTOM_MARGIN),
     mSideMargin(DEFAULT_SIDE_MARGIN),
+    mZGap(0.f),
     mScrollSpeedFactor(DEFAULT_SCROLL_SPEED_FACTOR),
     mMaximumSwipeSpeed(DEFAULT_MAXIMUM_SWIPE_SPEED),
     mItemFlickAnimationDuration(DEFAULT_ITEM_FLICK_ANIMATION_DURATION),
@@ -615,14 +619,13 @@ void GridLayout::GetResizeAnimation(Animation& animation, Actor actor, Vector3 s
     Vector3 currentSize( actor.GetCurrentSize() );
     Vector3 shrink( currentSize );
 
-    shrink.width = min(size.width, currentSize.width);
-    shrink.height = min(size.height, currentSize.height);
+    shrink.width = std::min(size.width, currentSize.width);
+    shrink.height = std::min(size.height, currentSize.height);
 
     // Do a nonlinear size animation to shrink the actor first when the actor size changes,
     // so that we can avoid the actors overlapping during orientation change.
-    animation.Resize( actor, shrink, AlphaFunctions::EaseOut, 0.0f, durationSeconds * 0.5f );
-    animation.Resize( actor, size, AlphaFunctions::EaseIn, 0.0f, durationSeconds );
-    animation.SetDestroyAction( Animation::Bake );
+    animation.AnimateTo( Property( actor, Actor::Property::SIZE ), shrink, AlphaFunctions::EaseOut, TimePeriod( 0.0f, durationSeconds * 0.5f ) );
+    animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size, AlphaFunctions::EaseIn, TimePeriod( 0.0f, durationSeconds ) );
   }
 }
 
@@ -689,19 +692,19 @@ Degree GridLayout::GetScrollDirection() const
 
   if (mOrientation == ControlOrientation::Up)
   {
-    scrollDirection = 0.0f;
+    scrollDirection = Degree( 0.0f );
   }
   else if (mOrientation == ControlOrientation::Left)
   {
-    scrollDirection = 90.0f;
+    scrollDirection = Degree( 90.0f );
   }
   else if (mOrientation == ControlOrientation::Down)
   {
-    scrollDirection = 180.0f;
+    scrollDirection = Degree( 180.0f );
   }
   else // mOrientation == ControlOrientation::Right
   {
-    scrollDirection = 270.0f;
+    scrollDirection = Degree( 270.0f );
   }
 
   return scrollDirection;