Added BackgroundColor property in Widget
authorJEONGHYUN YUN <jh0506.yun@samsung.com>
Thu, 24 Nov 2016 10:11:28 +0000 (19:11 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Mon, 5 Dec 2016 01:14:24 +0000 (10:14 +0900)
Change-Id: I6f8995cc2731492a905e6d2f43d6f80a9586934e
Signed-off-by: JEONGHYUN YUN <jh0506.yun@samsung.com>
src/ElmSharp/ElmSharp/Button.cs
src/ElmSharp/ElmSharp/Widget.cs
src/ElmSharp/Interop/Interop.Elementary.cs [changed mode: 0644->0755]
test/ElmSharp.Test/TC/ButtonTest1.cs

index 1d69347..9d13db3 100644 (file)
@@ -102,6 +102,15 @@ namespace ElmSharp
             Interop.Elementary.edje_object_color_class_del(Handle, part);
         }
 
+        public override Color BackgroundColor
+        {
+            set
+            {
+                SetPartColor("bg", value);
+                SetPartColor("bg_pressed", value);
+            }
+        }
+
         protected override IntPtr CreateHandle(EvasObject parent)
         {
             return Interop.Elementary.elm_button_add(parent.Handle);
index fabf249..f7a7833 100644 (file)
@@ -87,6 +87,20 @@ namespace ElmSharp
             }
         }
 
+        public virtual Color BackgroundColor
+        {
+            get
+            {
+                int r, g, b, a;
+                Interop.Elementary.elm_object_color_class_color_get(Handle, "bg", out r, out g, out b, out a);
+                return new Color((int)(r/(a/255.0)), (int)(g/(a/255.0)), (int)(b/(a/255.0)), a);
+            }
+            set
+            {
+                SetPartColor("bg", value);
+            }
+        }
+
         public void SetFocus(bool isFocus)
         {
             Interop.Elementary.elm_object_focus_set(Handle, isFocus);
old mode 100644 (file)
new mode 100755 (executable)
index 5a0b7bd..c96a471
@@ -152,6 +152,9 @@ internal static partial class Interop
         }
 
         [DllImport(Libraries.Elementary)]
+        internal static extern void elm_object_color_class_color_get(IntPtr obj, string colorClass, out int r, out int g, out int b, out int a);
+
+        [DllImport(Libraries.Elementary)]
         internal static extern void elm_object_color_class_color_set(IntPtr obj, string colorClass, int r, int g, int b, int a);
 
         [DllImport(Libraries.Elementary)]
index 3f99a50..ab39a61 100644 (file)
@@ -24,40 +24,68 @@ namespace ElmSharp.Test
         public override string TestName => "ButtonTest1";
         public override string TestDescription => "To test basic operation of Button";
 
-        public override void Run(Window window)
+        void SetButtonEventHandler(Button button)
         {
-            Button button1 = new Button(window) {
-                Text = "Button 1",
-            };
-
-            button1.SetPartColor("bg", Color.Red);
-
-            button1.Clicked += (s, e) =>
+            button.Clicked += (s, e) =>
             {
-                Console.WriteLine("Button1 Clicked! : {0}", button1.ClassName);
-                Console.WriteLine("Button1 Clicked! : {0}", button1.ClassName.ToLower());
-                Console.WriteLine("Button1 Clicked! : {0}", button1.ClassName.ToLower().Replace("elm_",""));
-                Console.WriteLine("Button1 Clicked! : {0}", button1.ClassName.ToLower().Replace("elm_", "")+ "/" + "bg");
+                Console.WriteLine("{0} Clicked! : {1}", button.Text, button.BackgroundColor);
+                Console.WriteLine("{0} Clicked! : {1}", button.Text, button.ClassName);
+                Console.WriteLine("{0} Clicked! : {1}", button.Text, button.ClassName.ToLower());
+                Console.WriteLine("{0} Clicked! : {1}", button.Text, button.ClassName.ToLower().Replace("elm_", ""));
+                Console.WriteLine("{0} Clicked! : {1}", button.Text, button.ClassName.ToLower().Replace("elm_", "") + "/" + "bg");
             };
 
-            button1.Pressed += (s, e) =>
+            button.Pressed += (s, e) =>
             {
-                Console.WriteLine("Button1 Pressed!");
+                Console.WriteLine("{0} Pressed!", button.Text);
             };
 
-            button1.Released += (s, e) =>
+            button.Released += (s, e) =>
             {
-                Console.WriteLine("Button1 Released!");
+                Console.WriteLine("{0} Released!", button.Text);
             };
 
-            button1.Repeated += (s, e) =>
+            button.Repeated += (s, e) =>
             {
-                Console.WriteLine("Button1 Repeated!");
+                Console.WriteLine("{0} Repeated!", button.Text);
             };
 
-            button1.Show();
+            button.Show();
+        }
+
+        public override void Run(Window window)
+        {
+            Button button1 = new Button(window) {
+                Text = "Button 1",
+            };
+            button1.SetPartColor("bg", Color.Red);
+            SetButtonEventHandler(button1);
             button1.Resize(500, 100);
             button1.Move(0, 0);
+
+            Button button2 = new Button(window) {
+                Text = "Button 2",
+                BackgroundColor = Color.Red,
+            };
+            SetButtonEventHandler(button2);
+            button2.Resize(500, 100);
+            button2.Move(0, 200);
+
+            Button button3 = new Button(window) {
+                Text = "Button 3",
+                BackgroundColor = new Color(125,200,255, 150)
+            };
+            SetButtonEventHandler(button3);
+            button3.Resize(500, 100);
+            button3.Move(0, 400);
+
+            Button button4 = new Button(window) {
+                Text = "Button 4",
+                BackgroundColor = new Color(125, 200, 255, 10)
+            };
+            SetButtonEventHandler(button4);
+            button4.Resize(500, 100);
+            button4.Move(0, 600);
         }
 
     }