(Control) Re-added Background enums 16/56116/4
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 4 Jan 2016 13:04:10 +0000 (13:04 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 5 Jan 2016 14:03:32 +0000 (14:03 +0000)
- Marked as deprecated

Change-Id: I1c75374a7b76b6235ac4df7166c6ae9641d73a08

automated-tests/src/dali-toolkit/utc-Dali-Control.cpp
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control.h

index de50f8c..9c92848 100644 (file)
@@ -485,6 +485,18 @@ int UtcDaliControlBackgroundProperties(void)
   control.SetProperty( Control::Property::BACKGROUND, emptyMap );
   DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND ).Get< Property::Map >().Empty() );
 
+  // Deprecated Properties
+  control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW );
+  DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >() == Color::YELLOW );
+  DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >() == control.GetBackgroundColor() );
+  control.ClearBackground();
+  control.SetProperty( Control::Property::BACKGROUND_IMAGE, imageMap );
+  propValue = control.GetProperty( Control::Property::BACKGROUND_IMAGE );
+  resultMap = propValue.GetMap();
+  DALI_TEST_CHECK( resultMap->Find( "imageUrl" )->Get< std::string >() == "TestImage" );
+  control.SetProperty( Control::Property::BACKGROUND_IMAGE, emptyMap );
+  DALI_TEST_CHECK( control.GetProperty( Control::Property::BACKGROUND_IMAGE ).Get< Property::Map >().Empty() );
+
   END_TEST;
 }
 
index b41b630..6d1a28d 100644 (file)
@@ -244,23 +244,27 @@ public:
           controlImpl.SetStyleName( value.Get< std::string >() );
           break;
         }
-        case Toolkit::Control::Property::BACKGROUND:
+
+        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 );
-            break;
           }
-          const Property::Map* map = value.GetMap();
-          if( map )
+          else
           {
-            controlImpl.SetBackground( *map );
-            break;
+            // An empty map means the background is no longer required
+            controlImpl.ClearBackground();
           }
-
-          // The background is neither a valid image nor a property map, so it is no longer required
-          controlImpl.ClearBackground();
           break;
         }
 
@@ -276,6 +280,26 @@ public:
           }
           break;
         }
+
+        case Toolkit::Control::Property::BACKGROUND:
+        {
+          Image image = Scripting::NewImage( value );
+          if ( image )
+          {
+            controlImpl.SetBackgroundImage( image );
+            break;
+          }
+          const Property::Map* map = value.GetMap();
+          if( map )
+          {
+            controlImpl.SetBackground( *map );
+            break;
+          }
+
+          // The background is neither a valid image nor a property map, so it is no longer required
+          controlImpl.ClearBackground();
+          break;
+        }
       }
     }
   }
@@ -304,14 +328,21 @@ public:
           break;
         }
 
-        case Toolkit::Control::Property::BACKGROUND:
+        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;
           if( controlImpl.mImpl->mBackgroundRenderer )
           {
-            (controlImpl.mImpl->mBackgroundRenderer).CreatePropertyMap( map );
+            controlImpl.mImpl->mBackgroundRenderer.CreatePropertyMap( map );
           }
-
           value = map;
           break;
         }
@@ -321,6 +352,19 @@ public:
           value = controlImpl.HasKeyInputFocus();
           break;
         }
+
+        case Toolkit::Control::Property::BACKGROUND:
+        {
+          Property::Map map;
+          if( controlImpl.mImpl->mBackgroundRenderer )
+          {
+            (controlImpl.mImpl->mBackgroundRenderer).CreatePropertyMap( map );
+          }
+
+          value = map;
+          break;
+        }
+
       }
     }
 
@@ -349,15 +393,19 @@ public:
   bool mAddRemoveBackgroundChild:1;        ///< Flag to know when we are adding or removing our own actor to avoid call to OnControlChildAdd
 
   // Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
-  static PropertyRegistration PROPERTY_1;
-  static PropertyRegistration PROPERTY_2;
-  static PropertyRegistration PROPERTY_3;
+  static const PropertyRegistration PROPERTY_1;
+  static const PropertyRegistration PROPERTY_2;
+  static const PropertyRegistration PROPERTY_3;
+  static const PropertyRegistration PROPERTY_4;
+  static const PropertyRegistration PROPERTY_5;
 };
 
 // Properties registered without macro to use specific member variables.
-PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "styleName",       Toolkit::Control::Property::STYLE_NAME,      Property::STRING,  &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background",      Toolkit::Control::Property::BACKGROUND,      Property::MAP,     &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "keyInputFocus",   Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+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_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 );
 
 Toolkit::Control Control::New()
 {
index 6d6ca11..76f646f 100644 (file)
@@ -88,9 +88,11 @@ public:
   {
     enum
     {
-      STYLE_NAME = PROPERTY_START_INDEX,       ///< name "styleName",        @see SetStyleName,       type std::string
-      BACKGROUND,                              ///< name "background",       @since DALi 1.1.4,       type Map
-      KEY_INPUT_FOCUS,                         ///< name "keyInputFocus",    @see SetKeyInputFocus,   type bool
+      STYLE_NAME = PROPERTY_START_INDEX, ///< name "styleName",        @see SetStyleName,                                                             type std::string
+      BACKGROUND_COLOR,                  ///< name "background-color", @deprecated DALi 1.1.3 mutually exclusive with BACKGROUND_IMAGE & BACKGROUND,  type Vector4
+      BACKGROUND_IMAGE,                  ///< name "background-image", @deprecated DALi 1.1.3 mutually exclusive with BACKGROUND_COLOR & BACKGROUND,  type Map
+      KEY_INPUT_FOCUS,                   ///< name "keyInputFocus",    @see SetKeyInputFocus,                                                         type bool
+      BACKGROUND,                        ///< name "background",       @since DALi 1.1.3 mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE, type Map
     };
   };