Add property SHADOW to Control
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / control / control-data-impl.cpp
index 0367037..fb42012 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -36,8 +36,6 @@
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
-#include <dali-toolkit/devel-api/layouting/bin-layout.h>
-#include <dali-toolkit/devel-api/layouting/layout-item.h>
 #include <dali-toolkit/internal/styling/style-manager-impl.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
 
@@ -69,7 +67,6 @@ namespace
 
 #if defined(DEBUG_ENABLED)
 Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS");
-Debug::Filter* gLogFilterLayout = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT");
 #endif
 
 
@@ -301,8 +298,8 @@ void SetVisualsOffStage( const RegisteredVisualContainer& container, Actor paren
 
 // Properties registered without macro to use specific member variables.
 const PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "styleName",              Toolkit::Control::Property::STYLE_NAME,                   Property::STRING,  &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "backgroundColor",        Toolkit::Control::Property::BACKGROUND_COLOR,             Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-const PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "backgroundImage",        Toolkit::Control::Property::BACKGROUND_IMAGE,             Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "reservedProperty01",     Toolkit::Control::Property::RESERVED_PROPERTY_01,         Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "reservedProperty02",     Toolkit::Control::Property::RESERVED_PROPERTY_02,         Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus",          Toolkit::Control::Property::KEY_INPUT_FOCUS,              Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background",             Toolkit::Control::Property::BACKGROUND,                   Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "margin",                 Toolkit::Control::Property::MARGIN,                       Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
@@ -314,13 +311,13 @@ const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "leftFo
 const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocusableActorId",    Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID,   Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId",  Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_15( typeRegistration, "shadow",                Toolkit::DevelControl::Property::SHADOW,                  Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
 
 
 Control::Impl::Impl( Control& controlImpl )
 : mControlImpl( controlImpl ),
   mState( Toolkit::DevelControl::NORMAL ),
   mSubStateName(""),
-  mLayout( NULL ),
   mLeftFocusableActorId( -1 ),
   mRightFocusableActorId( -1 ),
   mUpFocusableActorId( -1 ),
@@ -343,8 +340,7 @@ Control::Impl::Impl( Control& controlImpl )
   mInputMethodContext(),
   mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
   mIsKeyboardNavigationSupported( false ),
-  mIsKeyboardFocusGroup( false ),
-  mIsLayoutingRequired( false )
+  mIsKeyboardFocusGroup( false )
 {
 }
 
@@ -914,29 +910,6 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons
       }
       break;
 
-      case Toolkit::Control::Property::BACKGROUND_COLOR:
-      {
-        DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
-        controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
-        break;
-      }
-
-      case Toolkit::Control::Property::BACKGROUND_IMAGE:
-      {
-        DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
-        Image image = Scripting::NewImage( value );
-        if ( image )
-        {
-          controlImpl.SetBackgroundImage( image );
-        }
-        else
-        {
-          // An empty image means the background is no longer required
-          controlImpl.ClearBackground();
-        }
-        break;
-      }
-
       case Toolkit::Control::Property::KEY_INPUT_FOCUS:
       {
         if ( value.Get< bool >() )
@@ -1011,6 +984,21 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons
         break;
       }
 
+      case Toolkit::DevelControl::Property::SHADOW:
+      {
+        const Property::Map* map = value.GetMap();
+        if( map && !map->Empty() )
+        {
+          controlImpl.SetShadow( *map );
+        }
+        else
+        {
+          // The shadow is an empty property map, so we should clear the shadow
+          controlImpl.ClearShadow();
+        }
+        break;
+      }
+
     }
   }
 }
@@ -1069,26 +1057,6 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index
         break;
       }
 
-      case Toolkit::Control::Property::BACKGROUND_COLOR:
-      {
-        DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
-        value = controlImpl.GetBackgroundColor();
-        break;
-      }
-
-      case Toolkit::Control::Property::BACKGROUND_IMAGE:
-      {
-        DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
-        Property::Map map;
-        Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
-        if( visual )
-        {
-          visual.CreatePropertyMap( map );
-        }
-        value = map;
-        break;
-      }
-
       case Toolkit::Control::Property::KEY_INPUT_FOCUS:
       {
         value = controlImpl.HasKeyInputFocus();
@@ -1130,6 +1098,19 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index
         value = map;
         break;
       }
+
+      case Toolkit::DevelControl::Property::SHADOW:
+      {
+        Property::Map map;
+        Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::DevelControl::Property::SHADOW );
+        if( visual )
+        {
+          visual.CreatePropertyMap( map );
+        }
+
+        value = map;
+        break;
+      }
     }
   }
 
@@ -1443,67 +1424,6 @@ bool Control::Impl::FilterKeyEvent( const KeyEvent& event )
   return consumed;
 }
 
-Toolkit::Internal::LayoutItemPtr Control::Impl::GetLayout() const
-{
-  return mLayout;
-}
-
-void Control::Impl::SetLayout( Toolkit::Internal::LayoutItem& layout )
-{
-  DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout control:%s  replacing existing layout:%s\n",
-                                   mControlImpl.Self().GetName().c_str(),
-                                   mLayout?"true":"false" );
-  // Check if layout already has an owner.
-  auto control = Toolkit::Control::DownCast( layout.GetOwner() );
-  if ( control )
-  {
-    // If the owner is not this control then the owning control can no longer own it.
-    Dali::Toolkit::Control handle( mControlImpl.GetOwner() );
-    if( control != handle )
-    {
-      DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout Layout already in use, %s will now have a BinLayout\n",
-                                                        control.GetName().c_str() );
-      Toolkit::BinLayout binLayout = Toolkit::BinLayout::New();
-      // Previous owner of the layout gets a BinLayout instead of the layout.
-      DevelControl::SetLayout( control, binLayout ) ;
-    }
-    else
-    {
-      return; // layout is already set to this control.
-    }
-  }
-
-  if( mLayout )
-  {
-    mLayout->Unparent();
-    mLayout.Reset();
-  }
-
-  mLayout = &layout;
-
-  auto controlHandle = Toolkit::Control::DownCast( mControlImpl.Self() ); // Get a handle of this control implementation without copying internals.
-  mLayout->Initialize( controlHandle, controlHandle.GetTypeName() ); // LayoutGroup takes ownership of existing children
-}
-
-void Control::Impl::RemoveLayout()
-{
-  DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::Impl::RemoveLayout\n");
-
-  Toolkit::BinLayout binLayout = Toolkit::BinLayout::New();
-
-  mControlImpl.mImpl->SetLayout( GetImplementation( binLayout ) ) ;
-}
-
-void Control::Impl::SetLayoutingRequired( bool layoutingRequired )
-{
-  mControlImpl.mImpl->mIsLayoutingRequired = layoutingRequired;
-}
-
-bool Control::Impl::IsLayoutingRequired()
-{
-  return mControlImpl.mImpl->mIsLayoutingRequired;
-}
-
 DevelControl::VisualEventSignalType& Control::Impl::VisualEventSignal()
 {
   return mVisualEventSignal;