From c0b8890f81a5dcad50d831ddf54b12071f1b962c Mon Sep 17 00:00:00 2001 From: Sungtaek Hong Date: Wed, 31 May 2017 15:38:01 +0900 Subject: [PATCH] Add layout for button, entry, label Change-Id: Iedce850763cd41ef1140563c9f9cf32a2bdcce0b Signed-off-by: Sungtaek Hong --- src/ElmSharp/ElmSharp/Button.cs | 9 +++++++-- src/ElmSharp/ElmSharp/Entry.cs | 19 +++++++++++++++++-- src/ElmSharp/ElmSharp/Label.cs | 15 ++++++++++++--- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/ElmSharp/ElmSharp/Button.cs b/src/ElmSharp/ElmSharp/Button.cs index cf6155c..e369054 100755 --- a/src/ElmSharp/ElmSharp/Button.cs +++ b/src/ElmSharp/ElmSharp/Button.cs @@ -163,8 +163,13 @@ namespace ElmSharp protected override IntPtr CreateHandle(EvasObject parent) { - //TODO: Fix this to use layout - return Interop.Elementary.elm_button_add(parent.Handle); + IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle); + Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default"); + + RealHandle = Interop.Elementary.elm_button_add(handle); + Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); + + return handle; } } } diff --git a/src/ElmSharp/ElmSharp/Entry.cs b/src/ElmSharp/ElmSharp/Entry.cs index a274055..8413592 100755 --- a/src/ElmSharp/ElmSharp/Entry.cs +++ b/src/ElmSharp/ElmSharp/Entry.cs @@ -430,10 +430,25 @@ namespace ElmSharp Interop.Elementary.elm_entry_select_none(RealHandle); } + public override void SetPartColor(string part, Color color) + { + IntPtr handle = (part == "bg") ? Handle : RealHandle; + Interop.Elementary.elm_object_color_class_color_set(handle, part, color.R * color.A / 255, + color.G * color.A / 255, + color.B * color.A / 255, + color.A); + } + protected override IntPtr CreateHandle(EvasObject parent) { - //TODO: Fix this to use layout - return Interop.Elementary.elm_entry_add(parent.Handle); + IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle); + Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default"); + + + RealHandle = Interop.Elementary.elm_entry_add(handle); + Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); + + return handle; } } } diff --git a/src/ElmSharp/ElmSharp/Label.cs b/src/ElmSharp/ElmSharp/Label.cs index 77fa79b..48fa897 100755 --- a/src/ElmSharp/ElmSharp/Label.cs +++ b/src/ElmSharp/ElmSharp/Label.cs @@ -15,7 +15,6 @@ */ using System; - namespace ElmSharp { /// @@ -71,6 +70,11 @@ namespace ElmSharp set { Interop.Elementary.elm_label_line_wrap_set(RealHandle, (int)value); + if (value != WrapType.None) + { + Interop.Evas.evas_object_size_hint_min_get(RealHandle, IntPtr.Zero, out int h); + Interop.Evas.evas_object_size_hint_min_set(RealHandle, 0, h); + } } } @@ -154,8 +158,13 @@ namespace ElmSharp /// The new object, otherwise null if it cannot be created protected override IntPtr CreateHandle(EvasObject parent) { - //TODO: Fix this to use layout - return Interop.Elementary.elm_label_add(parent.Handle); + IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle); + Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default"); + + RealHandle = Interop.Elementary.elm_label_add(handle); + Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); + + return handle; } } -- 2.7.4