From 46053ff213ba5f875cbd466b1f5a30dbdc7b13d8 Mon Sep 17 00:00:00 2001 From: arosis78 <35049857+arosis78@users.noreply.github.com> Date: Tue, 27 Mar 2018 15:52:09 +0900 Subject: [PATCH] [ElmSharp] cherry-pick from API4 (#28)(#42)(#58) (#174) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * [ElmSharp] Remove layout for Background (#28) Signed-off-by: Jeonghyun Yun * [ElmSharp] fix svace issue (#42) Add an optional extended description… * [ElmSharp] Changed Background Color property internal implementation to Widget BackgroundColor property (#58) Signed-off-by: Jeonghyun Yun --- src/ElmSharp/ElmSharp/Background.cs | 29 ++++------------------------- src/ElmSharp/ElmSharp/GenItemClass.cs | 4 ++-- src/ElmSharp/ElmSharp/GestureLayer.cs | 7 +++++-- src/ElmSharp/ElmSharp/Image.cs | 22 +++++++++++----------- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/ElmSharp/ElmSharp/Background.cs b/src/ElmSharp/ElmSharp/Background.cs index d6114b7..6b140fa 100755 --- a/src/ElmSharp/ElmSharp/Background.cs +++ b/src/ElmSharp/ElmSharp/Background.cs @@ -43,26 +43,11 @@ namespace ElmSharp { get { - int r = 0; - int g = 0; - int b = 0; - int a = 0; - var swallowContent = GetPartContent("elm.swallow.rectangle"); - if (swallowContent != IntPtr.Zero) - { - Interop.Evas.evas_object_color_get(swallowContent, out r, out g, out b, out a); - } - return new Color(r, g, b, a); + return BackgroundColor; } set { - var swallowContent = GetPartContent("elm.swallow.rectangle"); - if (swallowContent == IntPtr.Zero) - { - Interop.Elementary.elm_bg_color_set(RealHandle, value.R, value.G, value.B); - swallowContent = GetPartContent("elm.swallow.rectangle"); - } - Interop.Evas.evas_object_color_set(swallowContent, value.R, value.G, value.B, value.A); + BackgroundColor = value; } } @@ -132,13 +117,7 @@ namespace ElmSharp /// preview protected override IntPtr CreateHandle(EvasObject parent) { - IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle); - Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default"); - - RealHandle = Interop.Elementary.elm_bg_add(handle); - Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); - - return handle; + return Interop.Elementary.elm_bg_add(parent.Handle); } } @@ -168,4 +147,4 @@ namespace ElmSharp /// Tile } -} \ No newline at end of file +} diff --git a/src/ElmSharp/ElmSharp/GenItemClass.cs b/src/ElmSharp/ElmSharp/GenItemClass.cs index de05212..bf2c4ca 100755 --- a/src/ElmSharp/ElmSharp/GenItemClass.cs +++ b/src/ElmSharp/ElmSharp/GenItemClass.cs @@ -217,8 +217,8 @@ namespace ElmSharp void EvasObjectDeleted(object sender, EventArgs e) { - IntPtr handle = (sender as EvasObject).Handle; - s_HandleToEvasObject.Remove(handle); + if(sender is EvasObject evasObject) + s_HandleToEvasObject.Remove(evasObject); } IntPtr GetReusableContentCallback(IntPtr data, IntPtr obj, IntPtr part, IntPtr old) diff --git a/src/ElmSharp/ElmSharp/GestureLayer.cs b/src/ElmSharp/ElmSharp/GestureLayer.cs index 6209ea6..c748fec 100644 --- a/src/ElmSharp/ElmSharp/GestureLayer.cs +++ b/src/ElmSharp/ElmSharp/GestureLayer.cs @@ -559,11 +559,14 @@ namespace ElmSharp // thanks to the fact that we never remove item from _handlers, we don't need a lock here if (handlerIndex < 0 || handlerIndex >= _handlers.Count) return; - Action action = _handlers[handlerIndex].Action; + + var currentHandler = _handlers[handlerIndex]; + Action action = currentHandler.Action; if (action == null) return; + // the interpretation of the event_info struct pointer depends on the GestureType - switch (_handlers[handlerIndex].Type) + switch (currentHandler.Type) { case GestureType.Tap: case GestureType.LongTap: diff --git a/src/ElmSharp/ElmSharp/Image.cs b/src/ElmSharp/ElmSharp/Image.cs index da69b82..ce8aa23 100644 --- a/src/ElmSharp/ElmSharp/Image.cs +++ b/src/ElmSharp/ElmSharp/Image.cs @@ -618,24 +618,24 @@ namespace ElmSharp } }; - MemoryStream memstream = new MemoryStream(); - await stream.CopyToAsync(memstream); - - unsafe + using (MemoryStream memstream = new MemoryStream()) { - byte[] dataArr = memstream.ToArray(); - fixed (byte* data = &dataArr[0]) + await stream.CopyToAsync(memstream); + + unsafe { - bool ret = Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero); - if (!ret) + byte[] dataArr = memstream.ToArray(); + fixed (byte* data = &dataArr[0]) { - return false; + bool ret = Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero); + if (!ret) + { + return false; + } } } } - memstream.Dispose(); - return await tcs.Task; } -- 2.7.4