Added background color set API for Box
authorJEONGHYUN YUN <jh0506.yun@samsung.com>
Mon, 31 Oct 2016 04:24:38 +0000 (13:24 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Mon, 5 Dec 2016 09:35:25 +0000 (18:35 +0900)
Change-Id: Ife6df16fb8bf03bef9c11a06a30bf55ad2541dd1
Signed-off-by: JEONGHYUN YUN <jh0506.yun@samsung.com>
src/ElmSharp/ElmSharp/Box.cs
src/ElmSharp/ElmSharp/Container.cs
src/ElmSharp/theme/mobile/color_classes.edc
src/ElmSharp/theme/mobile/elm-sharp-theme-mobile.edc
src/ElmSharp/theme/mobile/widgets/layout.edc [new file with mode: 0644]
test/ElmSharp.Test/TC/BoxTest1.cs

index 02ed3ad..f67d30d 100644 (file)
@@ -22,46 +22,49 @@ namespace ElmSharp
     {
         private Interop.Elementary.BoxLayoutCallback _layoutCallback;
 
-        public Box(EvasObject parent) : base(parent) { }
+        public Box(EvasObject parent) : base(parent)
+        {
+        }
+
         public bool IsHorizontal
         {
             get
             {
-                return Interop.Elementary.elm_box_horizontal_get(Handle);
+                return Interop.Elementary.elm_box_horizontal_get(GetRealHandle(Handle));
             }
             set
             {
-                Interop.Elementary.elm_box_horizontal_set(Handle, value);
+                Interop.Elementary.elm_box_horizontal_set(GetRealHandle(Handle), value);
             }
         }
 
         public void PackEnd(EvasObject content)
         {
-            Interop.Elementary.elm_box_pack_end(Handle, content);
+            Interop.Elementary.elm_box_pack_end(GetRealHandle(Handle), content);
             AddChild(content);
         }
 
         public void PackStart(EvasObject content)
         {
-            Interop.Elementary.elm_box_pack_start(Handle, content);
+            Interop.Elementary.elm_box_pack_start(GetRealHandle(Handle), content);
             AddChild(content);
         }
 
         public void PackAfter(EvasObject content, EvasObject after)
         {
-            Interop.Elementary.elm_box_pack_after(Handle, content, after);
+            Interop.Elementary.elm_box_pack_after(GetRealHandle(Handle), content, after);
             AddChild(content);
         }
 
         public void UnPack(EvasObject content)
         {
-            Interop.Elementary.elm_box_unpack(Handle, content);
+            Interop.Elementary.elm_box_unpack(GetRealHandle(Handle), content);
             RemoveChild(content);
         }
 
         public void UnPackAll()
         {
-            Interop.Elementary.elm_box_unpack_all(Handle);
+            Interop.Elementary.elm_box_unpack_all(GetRealHandle(Handle));
             ClearChildren();
         }
 
@@ -71,12 +74,18 @@ namespace ElmSharp
             {
                 action();
             };
-            Interop.Elementary.elm_box_layout_set(Handle, _layoutCallback, IntPtr.Zero, null);
+            Interop.Elementary.elm_box_layout_set(GetRealHandle(Handle), _layoutCallback, IntPtr.Zero, null);
         }
 
         protected override IntPtr CreateHandle(EvasObject parent)
         {
-            return Interop.Elementary.elm_box_add(parent);
+            IntPtr handle = Interop.Elementary.elm_layout_add(parent);
+            Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
+
+            IntPtr realHandle = Interop.Elementary.elm_box_add(handle);
+            Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", realHandle);
+
+            return handle;
         }
     }
 }
index 086f187..0cd27c0 100644 (file)
@@ -27,6 +27,11 @@ namespace ElmSharp
         {
         }
 
+        protected virtual IntPtr GetRealHandle(IntPtr handle)
+        {
+            return Interop.Elementary.elm_object_part_content_get(handle, "elm.swallow.content");
+        }
+
         internal void AddChild(EvasObject obj)
         {
             _children.Add(obj);
index f71991c..d10c93b 100644 (file)
@@ -1,5 +1,12 @@
 color_classes {
    /*
+    * Layout
+    */
+   color_class {
+      name: "layout/background/bg";
+      color: 0 0 0 0;
+   }
+   /*
     * Colorselector
     */
    color_class {
index 2a95234..d9baad4 100644 (file)
@@ -87,6 +87,7 @@ collections {
 #include "widgets/entry.edc"
 #include "widgets/label.edc"
 #include "widgets/radio.edc"
+#include "widgets/layout.edc"
 
 }
 
diff --git a/src/ElmSharp/theme/mobile/widgets/layout.edc b/src/ElmSharp/theme/mobile/widgets/layout.edc
new file mode 100644 (file)
index 0000000..4268a9f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above copyright notice, this
+ *      list of conditions and the following disclaimer.
+ *   2. Redistributions in binary form must reproduce the above copyright notice,
+ *      this list of conditions and the following disclaimer in the documentation
+ *      and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+group { "elm/layout/background/default";
+   parts {
+      rect { "bg";
+         scale;
+         desc { "default";
+            color_class: "layout/background/bg";
+         }
+      }
+      swallow { "elm.swallow.content";
+         scale;
+         desc { "default"; }
+      }
+   }
+}
index f640d93..e927724 100644 (file)
@@ -24,11 +24,14 @@ namespace ElmSharp.Test
         public override string TestName => "BoxTest1";
         public override string TestDescription => "To test basic operation of Box";
 
+        Box box;
+
         public override void Run(Window window)
         {
             Conformant conformant = new Conformant(window);
             conformant.Show();
-            Box box = new Box(window);
+            box = new Box(window);
+            box.BackgroundColor = Color.Orange;
             conformant.SetContent(box);
             box.Show();
 
@@ -44,14 +47,16 @@ namespace ElmSharp.Test
                 AlignmentX = -1,
                 AlignmentY = -1,
                 WeightX = 1,
-                WeightY = 1
+                WeightY = 1,
+                BackgroundColor = new Color(50,100,200,75)
             };
             Button button3 = new Button(window) {
                 Text = "Button 3",
                 AlignmentX = -1,
                 AlignmentY = -1,
                 WeightX = 1,
-                WeightY = 1
+                WeightY = 1,
+                BackgroundColor = Color.Olive
             };
 
             box.PackEnd(button1);
@@ -69,7 +74,7 @@ namespace ElmSharp.Test
 
         private void Button1_Clicked(object sender, EventArgs e)
         {
-            Console.WriteLine("{0} Clicked!", ((Button)sender).Text);
+            Console.WriteLine("{0} Clicked! - Button's BG Color : {1}, Box's BG Color : {2}", ((Button)sender).Text, ((Button)sender).BackgroundColor, box.BackgroundColor);
         }
     }
 }