Enhance Background Widget 69/129569/2
authorSeunghyun Choi <sh4682.choi@samsung.com>
Wed, 17 May 2017 04:26:12 +0000 (13:26 +0900)
committerSeunghyun Choi <sh4682.choi@samsung.com>
Wed, 7 Jun 2017 11:49:08 +0000 (20:49 +0900)
Change-Id: I199e612365e21b889c22de1ffec80a4b865cdfea
Signed-off-by: Seunghyun Choi <sh4682.choi@samsung.com>
ElmSharp.Test/TC/BackgroundTest1.cs
ElmSharp/ElmSharp/Background.cs [changed mode: 0755->0644]
ElmSharp/Interop/Interop.Elementary.Bg.cs

index a9514d5..ed2a447 100644 (file)
@@ -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
old mode 100755 (executable)
new mode 100644 (file)
index c463ce8..e5348b0
@@ -98,6 +98,26 @@ namespace ElmSharp
             }
         }
 
+        /// <summary>
+        /// 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.
+        /// </summary>
+        /// <param name="w">The new width of the image pixmap representation.</param>
+        /// <param name="h">The new height of the image pixmap representation.</param>
+        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
         /// </summary>
         Center,
+
         /// <summary>
         /// Scales the background image, retaining the aspect ratio
         /// </summary>
         Scale,
+
         /// <summary>
         /// Stretches the background image to fill the UI component's area.
         /// </summary>
         Stretch,
+
         /// <summary>
         /// Tiles the background image at its original size
         /// </summary>
         Tile
     }
-}
+}
\ No newline at end of file
index d598425..2f6f732 100644 (file)
@@ -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