New Bouncing Effect
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / scrollable / scrollable-impl.cpp
index 451895c..555ae70 100644 (file)
@@ -1,18 +1,19 @@
-//
-// 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.
+ *
+ */
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
@@ -31,11 +32,14 @@ namespace Dali
 namespace Toolkit
 {
 
+const Property::Index Scrollable::PROPERTY_OVERSHOOT_EFFECT_COLOR( Toolkit::Internal::Control::CONTROL_PROPERTY_END_INDEX + 1 );
+
 namespace Internal
 {
 
 namespace
 {
+const Vector4 DEFAULT_OVERSHOOT_COLOUR(0.0f, 0.64f, 0.85f, 0.25f);
 
 BaseHandle Create()
 {
@@ -50,22 +54,33 @@ SignalConnectorType s2(mType, Toolkit::Scrollable::SIGNAL_SCROLL_COMPLETED, &Scr
 SignalConnectorType s3(mType, Toolkit::Scrollable::SIGNAL_SCROLL_UPDATED,   &Scrollable::DoConnectSignal);
 SignalConnectorType s4(mType, Toolkit::Scrollable::SIGNAL_SCROLL_CLAMPED,   &Scrollable::DoConnectSignal);
 
+PropertyRegistration property1( mType,
+                                "overshoot-effect-color",
+                                Toolkit::Scrollable::PROPERTY_OVERSHOOT_EFFECT_COLOR,
+                                Property::VECTOR4,
+                                &Scrollable::SetProperty,
+                                &Scrollable::GetProperty );
+
 }
 
 const std::string Scrollable::SCROLLABLE_CAN_SCROLL_VERTICAL( "scrollable-can-scroll-vertical" );
 const std::string Scrollable::SCROLLABLE_CAN_SCROLL_HORIZONTAL( "scrollable-can-scroll-horizontal" );
-const Vector4     Scrollable::DEFAULT_OVERSHOOT_COLOUR(0.0f, 0.64f, 0.85f, 0.6f);
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Scrollable
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
+// Scrollable controls are not layout containers so they dont need size negotiation..
+// we dont want size negotiation while scrolling if we can avoid it
 Scrollable::Scrollable()
-: Control(true/*requires touch*/),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | NO_SIZE_NEGOTIATION ) ),
+  mOvershootEffectColor(  DEFAULT_OVERSHOOT_COLOUR ),
   mPropertyRelativePosition(Property::INVALID_INDEX),
   mPropertyPositionMin(Property::INVALID_INDEX),
   mPropertyPositionMax(Property::INVALID_INDEX),
   mPropertyScrollDirection(Property::INVALID_INDEX),
+  mPropertyCanScrollVertical(Property::INVALID_INDEX),
+  mPropertyCanScrollHorizontal(Property::INVALID_INDEX),
   mOvershootEnabled(false)
 {
 }
@@ -146,6 +161,11 @@ void Scrollable::DisableScrollComponent(Toolkit::Scrollable::ScrollComponentType
   }
 }
 
+Vector4 Scrollable::GetOvershootEffectColor() const
+{
+  return mOvershootEffectColor;
+};
+
 Toolkit::Scrollable::ScrollStartedSignalV2& Scrollable::ScrollStartedSignal()
 {
   return mScrollStartedSignalV2;
@@ -198,6 +218,46 @@ bool Scrollable::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface
   return connected;
 }
 
+void Scrollable::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+  Toolkit::Scrollable scrollable = Toolkit::Scrollable::DownCast( Dali::BaseHandle( object ) );
+
+  if( scrollable )
+  {
+    Scrollable& scrollableImpl( GetImpl( scrollable ) );
+    switch( index )
+    {
+      case Toolkit::Scrollable::PROPERTY_OVERSHOOT_EFFECT_COLOR:
+      {
+        scrollableImpl.SetOvershootEffectColor( value.Get<Vector4>() );
+        break;
+      }
+    }
+  }
+}
+
+Property::Value Scrollable::GetProperty( BaseObject* object, Property::Index index )
+{
+  Property::Value value;
+
+  Toolkit::Scrollable scrollable = Toolkit::Scrollable::DownCast( Dali::BaseHandle( object ) );
+
+  if( scrollable )
+  {
+    Scrollable& scrollableImpl( GetImpl( scrollable ) );
+    switch( index )
+    {
+      case Toolkit::Scrollable::PROPERTY_OVERSHOOT_EFFECT_COLOR:
+      {
+        value = scrollableImpl.GetOvershootEffectColor();
+        break;
+      }
+    }
+  }
+
+  return value;
+}
+
 Toolkit::ScrollComponent Scrollable::NewScrollComponent(Toolkit::Scrollable& scrollable, Toolkit::Scrollable::ScrollComponentType type)
 {
   Toolkit::ScrollComponent instance;