Merge "Fix BackgroundImage and BackgroudColor properties in C# View" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Wed, 8 Mar 2017 18:10:59 +0000 (10:10 -0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 8 Mar 2017 18:10:59 +0000 (10:10 -0800)
automated-tests/src/dali-toolkit/utc-Dali-Control.cpp
dali-toolkit/public-api/controls/control-impl.cpp
dali-toolkit/public-api/controls/control.h
plugins/dali-swig/examples/dali-test.cs
plugins/dali-swig/manual/csharp/View.cs

index 376ad0d..9de7101 100644 (file)
@@ -486,6 +486,13 @@ int UtcDaliControlBackgroundProperties(void)
   DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::IMAGE, TEST_LOCATION );
   DALI_TEST_EQUALS( resultMap->Find( ImageVisual::Property::URL )->Get<std::string>(), "Foobar.png", TEST_LOCATION );
 
+  // set as Color
+  control.SetProperty( Control::Property::BACKGROUND, Color::RED );
+  propValue = control.GetProperty( Control::Property::BACKGROUND );
+  resultMap = propValue.GetMap();
+  DALI_TEST_EQUALS( resultMap->Find( Visual::Property::TYPE )->Get<int>(), (int)Visual::COLOR, TEST_LOCATION );
+  DALI_TEST_EQUALS( resultMap->Find( ColorVisual::Property::MIX_COLOR )->Get<Vector4>(), Color::RED, TEST_LOCATION );
+
   // Deprecated Properties
   control.SetProperty( Control::Property::BACKGROUND_COLOR, Color::YELLOW );
   DALI_TEST_EQUALS( control.GetProperty( Control::Property::BACKGROUND_COLOR ).Get< Vector4 >(), Color::YELLOW, TEST_LOCATION );
index c89ae0c..d45c8dd 100644 (file)
@@ -409,6 +409,7 @@ public:
         case Toolkit::Control::Property::BACKGROUND:
         {
           std::string url;
+          Vector4 color;
           const Property::Map* map = value.GetMap();
           if( map && !map->Empty() )
           {
@@ -424,6 +425,10 @@ public:
               visual.SetDepthIndex( DepthIndex::BACKGROUND );
             }
           }
+          else if( value.Get( color ) )
+          {
+            controlImpl.SetBackgroundColor(color);
+          }
           else
           {
             // The background is an empty property map, so we should clear the background
index 3f2f169..cd72a0f 100644 (file)
@@ -121,7 +121,7 @@ public:
        */
       KEY_INPUT_FOCUS,
       /**
-       * @brief name "background", mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE, type Map or std::string for URL.
+       * @brief name "background", mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE, type Map or std::string for URL or Vector4 for Color.
        * @SINCE_1_1.3
        */
       BACKGROUND,
index 856a4dd..73b7fb3 100644 (file)
@@ -445,7 +445,7 @@ namespace MyCSharpExample
             // Background property
             Property.Map background = new Property.Map();
             background.Add( Dali.Constants.Visual.Property.Type, new Property.Value((int)Dali.Constants.Visual.Type.Color) )
-                .Add( Dali.Constants.ColorVisualProperty.MixColor, new Property.Value(Color.Red) );
+                      .Add( Dali.Constants.ColorVisualProperty.MixColor, new Property.Value(Color.Red) );
             spin.Background = background;
 
             background = spin.Background;
@@ -471,6 +471,17 @@ namespace MyCSharpExample
                 Console.WriteLine ("Custom View BackgroundColor property : test failed");
             }
 
+            // BackgroundImage property
+            spin.BackgroundImage = "background-image.jpg";
+            if(spin.BackgroundImage == "background-image.jpg")
+            {
+                Console.WriteLine ("Custom View BackgroundImage property : test passed");
+            }
+            else
+            {
+                Console.WriteLine ("Custom View BackgroundImage property : test failed");
+            }
+
             // StyleName property
             spin.StyleName = "MyCustomStyle";
             if(spin.StyleName == "MyCustomStyle")
index b48f779..1b4fbec 100644 (file)
@@ -1110,27 +1110,43 @@ public class View : CustomActor {
   {
     get
     {
-      Vector4 temp = new Vector4(0.0f,0.0f,0.0f,0.0f);
-      GetProperty( View.Property.BACKGROUND_COLOR).Get(  temp );
-      return temp;
+      Vector4 backgroundColor = new Vector4(0.0f,0.0f,0.0f,0.0f);
+
+      Dali.Property.Map background = Background;
+      int visualType = 0;
+      background.Find( Dali.Constants.Visual.Property.Type ).Get( ref visualType );
+      if(visualType == (int)Dali.Constants.Visual.Type.Color)
+      {
+        background.Find( Dali.Constants.ColorVisualProperty.MixColor ).Get( backgroundColor );
+      }
+
+      return backgroundColor;
     }
     set
     {
-      SetProperty( View.Property.BACKGROUND_COLOR, new Dali.Property.Value( value ) );
+      SetProperty( View.Property.BACKGROUND, new Dali.Property.Value( value ) );
     }
   }
 
-  public Dali.Property.Map BackgroundImage
+  public string BackgroundImage
   {
     get
     {
-      Dali.Property.Map temp = new Dali.Property.Map();
-      GetProperty( View.Property.BACKGROUND_IMAGE).Get(  temp );
-      return temp;
+      string backgroundImage = "";
+
+      Dali.Property.Map background = Background;
+      int visualType = 0;
+      background.Find( Dali.Constants.Visual.Property.Type ).Get( ref visualType );
+      if(visualType == (int)Dali.Constants.Visual.Type.Image)
+      {
+        background.Find( Dali.Constants.ImageVisualProperty.URL ).Get( out backgroundImage );
+      }
+
+      return backgroundImage;
     }
     set
     {
-      SetProperty( View.Property.BACKGROUND_IMAGE, new Dali.Property.Value( value ) );
+      SetProperty( View.Property.BACKGROUND, new Dali.Property.Value( value ) );
     }
   }