Merge "Use new animatable registered properties in ScrollView" into tizen
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-depth-effect-impl.cpp
index cdef6d5..0f21d0c 100644 (file)
@@ -1,19 +1,26 @@
-//
-// 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/animation/active-constraint.h>
+#include <dali/public-api/animation/constraint.h>
+#include <dali/public-api/object/property-input.h>
 
+// INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-effect-impl.h>
 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-depth-effect-impl.h>
 
@@ -86,11 +93,11 @@ struct ScrollDepthScaleConstraint
   /**
    * @param[in] current The current scale
    * @param[in] pagePositionProperty The page's position.
-   * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
-   * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
-   * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+   * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+   * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+   * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
    * @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
-   * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+   * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
    * @return The new scale of this Actor.
    */
   Vector3 operator()(const Vector3& currentScale,
@@ -115,25 +122,22 @@ struct ScrollDepthScaleConstraint
     }
 
     const Vector3& pageSize = pageSizeProperty.GetVector3();
+
     // Don't have enough parameters, to provide Wrap mode (need a way of having 'uniforms' instead of scrollWrap.GetBoolean())
-    const bool wrap = true;
 
-    if(wrap)
-    {
-      const Vector3& min = scrollPositionMin.GetVector3();
-      const Vector3& max = scrollPositionMax.GetVector3();
+    const Vector3& min = scrollPositionMin.GetVector3();
+    const Vector3& max = scrollPositionMax.GetVector3();
 
-      if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
-      {
-        // WRAP X (based on the position of the right side)
-        position.x = WrapInDomain(position.x + pageSize.x, min.x, max.x) - pageSize.x;
-      }
+    if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
+    {
+      // WRAP X (based on the position of the right side)
+      position.x = WrapInDomain(position.x + pageSize.x, min.x, max.x) - pageSize.x;
+    }
 
-      if(fabsf(min.y - max.y) > Math::MACHINE_EPSILON_1)
-      {
-        // WRAP Y (based on the position of the bottom side)
-        position.y = WrapInDomain(position.y + pageSize.y, min.y, max.y) - pageSize.y;
-      }
+    if(fabsf(min.y - max.y) > Math::MACHINE_EPSILON_1)
+    {
+      // WRAP Y (based on the position of the bottom side)
+      position.y = WrapInDomain(position.y + pageSize.y, min.y, max.y) - pageSize.y;
     }
 
     // short circuit: for pages outside of view.
@@ -214,11 +218,11 @@ struct ScrollDepthPositionConstraint
   /**
    * @param[in] current The current position
    * @param[in] pagePositionProperty The page's position.
-   * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
-   * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
-   * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+   * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+   * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+   * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
    * @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
-   * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+   * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
    * @return The new position of this Actor.
    */
   Vector3 operator()(const Vector3& currentPosition,
@@ -332,25 +336,25 @@ void ApplyScrollDepthConstraints(Toolkit::ScrollView scrollView,
                                  float scaleExtent)
 {
   // Scale Constraint
-  Constraint constraint = Constraint::New<Vector3>( Actor::SCALE,
-                                         LocalSource(Actor::POSITION),
-                                         ParentSource(Actor::POSITION),
-                                         Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
-                                         Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
-                                         Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
-                                         Source(scrollView, Actor::SIZE ),
+  Constraint constraint = Constraint::New<Vector3>( Actor::Property::SCALE,
+                                         LocalSource(Actor::Property::POSITION),
+                                         ParentSource(Actor::Property::POSITION),
+                                         Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ),
+                                         Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+                                         Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
+                                         Source(scrollView, Actor::Property::SIZE ),
                                          ScrollDepthScaleConstraint( positionExtent, offsetExtent, positionScale, scaleExtent ) );
   constraint.SetRemoveAction( Constraint::Discard );
   child.ApplyConstraint( constraint );
 
   // Position Constraint (apply last as other constraints use Actor::POSITION as a function input)
-  constraint = Constraint::New<Vector3>( Actor::POSITION,
-                                         ParentSource(Actor::POSITION),
-                                         Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
-                                         Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
-                                         Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
-                                         Source(scrollView, Actor::SIZE ),
-                                         Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+  constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
+                                         ParentSource(Actor::Property::POSITION),
+                                         Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ),
+                                         Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+                                         Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
+                                         Source(scrollView, Actor::Property::SIZE ),
+                                         Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
                                          ScrollDepthPositionConstraint( positionExtent, offsetExtent, positionScale ) );
 
   constraint.SetRemoveAction( Constraint::Discard );