From 25256d3af9366a33b82553a58dfb3b1da868d412 Mon Sep 17 00:00:00 2001 From: chungryeol lim Date: Fri, 16 Dec 2016 14:54:29 +0900 Subject: Add NaviItem.TitleBarBackgroundColor property Change-Id: Ic444c2b7fda2c03de81e341604cac9f3ff65ad21 Signed-off-by: chungryeol lim --- ElmSharp.Test/TC/NaviframeTest2.cs | 21 ++++++++++++++++++++- ElmSharp/ElmSharp/ItemObject.cs | 15 +++++++++++++++ ElmSharp/ElmSharp/NaviItem.cs | 22 ++++++++++++++++++++++ ElmSharp/Interop/Interop.Elementary.cs | 9 +++++++++ packaging/elm-sharp.spec | 2 +- 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/ElmSharp.Test/TC/NaviframeTest2.cs b/ElmSharp.Test/TC/NaviframeTest2.cs index 342fd9c..3de3e41 100644 --- a/ElmSharp.Test/TC/NaviframeTest2.cs +++ b/ElmSharp.Test/TC/NaviframeTest2.cs @@ -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; } diff --git a/ElmSharp/ElmSharp/ItemObject.cs b/ElmSharp/ElmSharp/ItemObject.cs index 9b9847a..b2dbd58 100644 --- a/ElmSharp/ElmSharp/ItemObject.cs +++ b/ElmSharp/ElmSharp/ItemObject.cs @@ -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) diff --git a/ElmSharp/ElmSharp/NaviItem.cs b/ElmSharp/ElmSharp/NaviItem.cs index d2be412..3e92445 100644 --- a/ElmSharp/ElmSharp/NaviItem.cs +++ b/ElmSharp/ElmSharp/NaviItem.cs @@ -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) diff --git a/ElmSharp/Interop/Interop.Elementary.cs b/ElmSharp/Interop/Interop.Elementary.cs index c96a471..4488d14 100755 --- a/ElmSharp/Interop/Interop.Elementary.cs +++ b/ElmSharp/Interop/Interop.Elementary.cs @@ -172,6 +172,15 @@ internal static partial class Interop return Marshal.PtrToStringAnsi(text); } + [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); diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index b65451b..e6191ee 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -1,4 +1,4 @@ -%define DEV_VERSION beta-003 +%define DEV_VERSION beta-004 Name: elm-sharp Summary: C# Binding for Elementary -- cgit v1.2.3