From: Seunghyun Choi Date: Wed, 17 May 2017 04:26:12 +0000 (+0900) Subject: Enhance Background Widget X-Git-Tag: submit/trunk/20170823.075128~110^2~70^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6623b834e03176d4a9e1488493271b7d36d69b3a;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Enhance Background Widget Change-Id: I199e612365e21b889c22de1ffec80a4b865cdfea Signed-off-by: Seunghyun Choi --- diff --git a/src/ElmSharp/ElmSharp/Background.cs b/src/ElmSharp/ElmSharp/Background.cs old mode 100755 new mode 100644 index c463ce8..e5348b0 --- a/src/ElmSharp/ElmSharp/Background.cs +++ b/src/ElmSharp/ElmSharp/Background.cs @@ -98,6 +98,26 @@ namespace ElmSharp } } + /// + /// Set the size of the pixmap representation of the image set on a given background widget. + /// This method just makes sense if an image file was set. + /// This is just a hint for the underlying system. + /// The real size of the pixmap may differ depending on the type of image being loaded, being bigger than requested. + /// + /// The new width of the image pixmap representation. + /// The new height of the image pixmap representation. + public void SetFileLoadSize(int w, int h) + { + if (File != null) + { + Interop.Elementary.elm_bg_load_size_set(RealHandle, w, h); + } + else + { + throw new Exception("This method just makes sense if an image file was set."); + } + } + protected override IntPtr CreateHandle(EvasObject parent) { IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle); @@ -119,17 +139,20 @@ namespace ElmSharp /// Centers the background image /// Center, + /// /// Scales the background image, retaining the aspect ratio /// Scale, + /// /// Stretches the background image to fill the UI component's area. /// Stretch, + /// /// Tiles the background image at its original size /// Tile } -} +} \ No newline at end of file diff --git a/src/ElmSharp/Interop/Interop.Elementary.Bg.cs b/src/ElmSharp/Interop/Interop.Elementary.Bg.cs index d598425..2f6f732 100644 --- a/src/ElmSharp/Interop/Interop.Elementary.Bg.cs +++ b/src/ElmSharp/Interop/Interop.Elementary.Bg.cs @@ -39,21 +39,22 @@ internal static partial class Interop internal static extern bool elm_bg_file_set(IntPtr obj, string file, IntPtr group); [DllImport(Libraries.Elementary)] - internal static extern void elm_bg_file_get(IntPtr obj, ref IntPtr file, IntPtr group); + internal static extern void elm_bg_file_get(IntPtr obj, out IntPtr file, IntPtr group); [DllImport(Libraries.Elementary)] internal static extern void elm_bg_option_set(IntPtr obj, BackgroundOptions option); [DllImport(Libraries.Elementary)] + internal static extern void elm_bg_load_size_set(IntPtr obj, int w, int h); + + [DllImport(Libraries.Elementary)] internal static extern BackgroundOptions elm_bg_option_get(IntPtr obj); internal static string BackgroundFileGet(IntPtr obj) { IntPtr file = IntPtr.Zero; - elm_bg_file_get(obj, ref file, IntPtr.Zero); - string r = Marshal.PtrToStringAnsi(file); - Marshal.FreeHGlobal(file); - return r; + elm_bg_file_get(obj, out file, IntPtr.Zero); + return Marshal.PtrToStringAnsi(file); } } -} +} \ No newline at end of file diff --git a/test/ElmSharp.Test/TC/BackgroundTest1.cs b/test/ElmSharp.Test/TC/BackgroundTest1.cs index a9514d5..ed2a447 100644 --- a/test/ElmSharp.Test/TC/BackgroundTest1.cs +++ b/test/ElmSharp.Test/TC/BackgroundTest1.cs @@ -31,13 +31,17 @@ namespace ElmSharp.Test Color = Color.Orange }; - Background bg2 = new Background(window) { - File = "/opt/home/owner/res/tizen.png", - BackgroundOption = BackgroundOptions.Tile + Background bg2 = new Background(window) + { + File = "/home/owner/apps_rw/ElmSharpTest/res/picture.png", + BackgroundOption = BackgroundOptions.Center, + BackgroundColor = Color.Gray }; + bg2.SetFileLoadSize(50, 50); + Show(bg1, 0, 0, 100, 100); - Show(bg2, 100, 100, 500, 500); + Show(bg2, 0, 100, 700, 700); } void Show(Background bg, int x, int y, int w, int h) @@ -47,4 +51,4 @@ namespace ElmSharp.Test bg.Resize(w, h); } } -} +} \ No newline at end of file