From ac9ec0555ae69f2283c84a1f678784bfed173586 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Mon, 5 Sep 2016 09:43:59 +0900 Subject: [PATCH] Support alpha to Background Change-Id: Icf8ad9ee5d0f052f27e5a153206a8fa174ce2b00 --- ElmSharpTest/TC/BackgroundTest2.cs | 4 ++-- src/ElmSharp/ElmSharp/Background.cs | 25 ++++++++++++++++++------- src/ElmSharp/ElmSharp/Widget.cs | 5 +++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ElmSharpTest/TC/BackgroundTest2.cs b/ElmSharpTest/TC/BackgroundTest2.cs index 9609fae..704815f 100644 --- a/ElmSharpTest/TC/BackgroundTest2.cs +++ b/ElmSharpTest/TC/BackgroundTest2.cs @@ -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(); } } } diff --git a/src/ElmSharp/ElmSharp/Background.cs b/src/ElmSharp/ElmSharp/Background.cs index 25d4446..791ec12 100644 --- a/src/ElmSharp/ElmSharp/Background.cs +++ b/src/ElmSharp/ElmSharp/Background.cs @@ -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); } } diff --git a/src/ElmSharp/ElmSharp/Widget.cs b/src/ElmSharp/ElmSharp/Widget.cs index c974114..bd42d51 100644 --- a/src/ElmSharp/ElmSharp/Widget.cs +++ b/src/ElmSharp/ElmSharp/Widget.cs @@ -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); + } } } -- 2.7.4