Support alpha to Background
authorKangho Hur <kangho.hur@samsung.com>
Mon, 5 Sep 2016 00:43:59 +0000 (09:43 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Mon, 5 Sep 2016 00:43:59 +0000 (09:43 +0900)
Change-Id: Icf8ad9ee5d0f052f27e5a153206a8fa174ce2b00

ElmSharpTest/TC/BackgroundTest2.cs
src/ElmSharp/ElmSharp/Background.cs
src/ElmSharp/ElmSharp/Widget.cs

index 9609fae..704815f 100644 (file)
@@ -17,7 +17,7 @@ namespace ElmSharp.Test
 
             Background bg2 = new Background(window)
             {
-                Color = new Color(255, 255, 255, 100)
+                Color = new Color(60, 128, 255, 100)
             };
             Show(bg1, 0, 0, 500, 500);
             Show(bg2, 100, 100, 500, 500);
@@ -28,9 +28,9 @@ namespace ElmSharp.Test
 
         void Show(Background bg, int x, int y, int w, int h)
         {
-            bg.Show();
             bg.Move(x, y);
             bg.Resize(w, h);
+            bg.Show();
         }
     }
 }
index 25d4446..791ec12 100644 (file)
@@ -6,22 +6,33 @@ namespace ElmSharp
     {
         public Background(EvasObject parent) : base(parent)
         {
+            Style = "transparent";
         }
 
         public override Color Color
         {
-            //TO-DO: Consider to support alpha to elm_bg.
             get
             {
-                int r;
-                int g;
-                int b;
-                Interop.Elementary.elm_bg_color_get(Handle, out r, out g, out b);
-                return new Color(r, g, b);
+                int r = 0;
+                int g = 0;
+                int b = 0;
+                int a = 0;
+                var swallowContent = GetPartContent("elm.swallow.rectangle");
+                if (swallowContent != IntPtr.Zero)
+                {
+                    Interop.Evas.evas_object_color_get(swallowContent, out r, out g, out b, out a);
+                }
+                return new Color(r, g, b, a);
             }
             set
             {
-                Interop.Elementary.elm_bg_color_set(Handle, value.R, value.G, value.B);
+                var swallowContent = GetPartContent("elm.swallow.rectangle");
+                if(swallowContent == IntPtr.Zero)
+                {
+                    Interop.Elementary.elm_bg_color_set(Handle, value.R, value.G, value.B);
+                    swallowContent = GetPartContent("elm.swallow.rectangle");
+                }
+                Interop.Evas.evas_object_color_set(swallowContent, value.R, value.G, value.B, value.A);
             }
         }
 
index c974114..bd42d51 100644 (file)
@@ -123,5 +123,10 @@ namespace ElmSharp
         {
             Interop.Elementary.elm_object_part_color_set(Handle, part, color.R, color.G, color.B, color.A);
         }
+
+        internal IntPtr GetPartContent(string part)
+        {
+            return Interop.Elementary.elm_object_part_content_get(Handle, part);
+        }
     }
 }