Add NaviItem.TitleBarBackgroundColor property 36/105536/7
authorchungryeol lim <cdark.lim@samsung.com>
Fri, 16 Dec 2016 05:54:29 +0000 (14:54 +0900)
committerchungryeol lim <cdark.lim@samsung.com>
Mon, 26 Dec 2016 12:44:51 +0000 (21:44 +0900)
Change-Id: Ic444c2b7fda2c03de81e341604cac9f3ff65ad21
Signed-off-by: chungryeol lim <cdark.lim@samsung.com>
ElmSharp.Test/TC/NaviframeTest2.cs
ElmSharp/ElmSharp/ItemObject.cs
ElmSharp/ElmSharp/NaviItem.cs
ElmSharp/Interop/Interop.Elementary.cs
packaging/elm-sharp.spec

index 342fd9c..3de3e41 100644 (file)
@@ -87,12 +87,20 @@ namespace ElmSharp.Test
                 AlignmentX = -1,
             };
 
+            Button barChange = new Button(parent)
+            {
+                Text = "TitleTextColor & BarColor",
+                WeightX = 1,
+                AlignmentX = -1,
+            };
+
             label.Show();
             push.Show();
             pop.Show();
             insertBeforeTop.Show();
             insertAfterTop.Show();
             removeTop.Show();
+            barChange.Show();
 
             push.Clicked += (s, e) =>
             {
@@ -125,13 +133,24 @@ namespace ElmSharp.Test
                 item.Delete();
                 Console.WriteLine("----- After Call NaviItem.Delete() {0:x} ", nativePointer);
             };
-            
+
+            Random rand = new Random(DateTime.Now.Millisecond);
+            barChange.Clicked += (s, e) =>
+            {
+                int currentIndex = _navi.NavigationStack.Count - 1;
+                if (currentIndex >= 0)
+                {
+                    _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.FromHex(string.Format("#{0:X8}", rand.Next()));
+                }
+            };
+
             box.PackEnd(label);
             box.PackEnd(push);
             box.PackEnd(pop);
             box.PackEnd(insertBeforeTop);
             box.PackEnd(insertAfterTop);
             box.PackEnd(removeTop);
+            box.PackEnd(barChange);
 
             return box;
         }
index 9b9847a..b2dbd58 100644 (file)
@@ -109,6 +109,21 @@ namespace ElmSharp
             return Interop.Elementary.elm_object_item_part_text_get(Handle, part);
         }
 
+        public void SetPartColor(string part, Color color)
+        {
+            Interop.Elementary.elm_object_item_color_class_color_set(Handle, part, color.R * color.A / 255,
+                                                                              color.G * color.A / 255,
+                                                                              color.B * color.A / 255,
+                                                                              color.A);
+        }
+
+        public Color GetPartColor(string part)
+        {
+            int r, g, b, a;
+            Interop.Elementary.elm_object_item_color_class_color_get(Handle, part, 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);
+        }
+
         public static implicit operator IntPtr(ItemObject obj)
         {
             if (obj == null)
index d2be412..3e92445 100644 (file)
@@ -22,6 +22,7 @@ namespace ElmSharp
     {
         EvasObject _content;
         bool _isPopped;
+        Color _barBackgroundColor = Color.Default;
         Interop.Elementary.Elm_Naviframe_Item_Pop_Cb _popped;
 
         NaviItem(IntPtr handle, EvasObject content) : base(handle)
@@ -56,6 +57,27 @@ namespace ElmSharp
             }
         }
 
+        public Color TitleBarBackgroundColor
+        {
+            get
+            {
+                return _barBackgroundColor;
+            }
+            set
+            {
+                if (value.IsDefault)
+                {
+                    Console.WriteLine("ItemObject instance doesn't support to set TitleBarBackgroundColor to Color.Default.");
+                    //TODO. Soon we will support the "elm_object_item_color_class_del" function in EFL.
+                }
+                else
+                {
+                    SetPartColor("bg_title", value);
+                    _barBackgroundColor = value;
+                }
+            }
+        }
+
         protected override void OnInvalidate()
         {
             if (!_isPopped)
index c96a471..4488d14 100755 (executable)
@@ -173,6 +173,15 @@ internal static partial class Interop
         }
 
         [DllImport(Libraries.Elementary)]
+        internal static extern void elm_object_item_color_class_color_set(IntPtr it, string part, int r, int g, int b, int a);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_object_item_color_class_color_get(IntPtr obj, string part, out int r, out int g, out int b, out int a);
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_object_item_color_class_del(IntPtr obj, string part);
+
+        [DllImport(Libraries.Elementary)]
         internal static extern void elm_object_item_part_text_set(IntPtr obj, string part, string label);
 
         [DllImport(Libraries.Elementary)]
index b65451b..e6191ee 100644 (file)
@@ -1,4 +1,4 @@
-%define DEV_VERSION beta-003
+%define DEV_VERSION beta-004
 
 Name:       elm-sharp
 Summary:    C# Binding for Elementary