[ElmSharp] cherry-pick from API4 (#28)(#42)(#58) (#174)
authorarosis78 <35049857+arosis78@users.noreply.github.com>
Tue, 27 Mar 2018 06:52:09 +0000 (15:52 +0900)
committerGitHub <noreply@github.com>
Tue, 27 Mar 2018 06:52:09 +0000 (15:52 +0900)
* [ElmSharp] Remove layout for Background (#28)

Signed-off-by: Jeonghyun Yun <jh0506.yun@samsung.com>
* [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 <jh0506.yun@samsung.com>
src/ElmSharp/ElmSharp/Background.cs
src/ElmSharp/ElmSharp/GenItemClass.cs
src/ElmSharp/ElmSharp/GestureLayer.cs
src/ElmSharp/ElmSharp/Image.cs

index d6114b7..6b140fa 100755 (executable)
@@ -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
         /// <since_tizen> preview </since_tizen>
         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
         /// </summary>
         Tile
     }
-}
\ No newline at end of file
+}
index de05212..bf2c4ca 100755 (executable)
@@ -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)
index 6209ea6..c748fec 100644 (file)
@@ -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<object> action = _handlers[handlerIndex].Action;
+
+            var currentHandler = _handlers[handlerIndex];
+            Action<object> 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:
index da69b82..ce8aa23 100644 (file)
@@ -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;
         }