summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeunghyun Choi <sh4682.choi@samsung.com>2017-05-17 13:26:12 +0900
committerSeunghyun Choi <sh4682.choi@samsung.com>2017-06-07 20:49:08 +0900
commitcda61ab3d138d0887d9e9479e90201a7b903097d (patch)
tree2252aa27af83f30416d6c7ecee84906322b75e30
parent2e64ba1ee3b6ff540e792d6ac53c3fef7e35a46c (diff)
downloadelm-sharp-cda61ab3d138d0887d9e9479e90201a7b903097d.tar.gz
elm-sharp-cda61ab3d138d0887d9e9479e90201a7b903097d.tar.bz2
elm-sharp-cda61ab3d138d0887d9e9479e90201a7b903097d.zip
Enhance Background Widget
Change-Id: I199e612365e21b889c22de1ffec80a4b865cdfea Signed-off-by: Seunghyun Choi <sh4682.choi@samsung.com>
-rw-r--r--ElmSharp.Test/TC/BackgroundTest1.cs14
-rw-r--r--[-rwxr-xr-x]ElmSharp/ElmSharp/Background.cs25
-rw-r--r--ElmSharp/Interop/Interop.Elementary.Bg.cs13
3 files changed, 40 insertions, 12 deletions
diff --git a/ElmSharp.Test/TC/BackgroundTest1.cs b/ElmSharp.Test/TC/BackgroundTest1.cs
index a9514d5..ed2a447 100644
--- a/ElmSharp.Test/TC/BackgroundTest1.cs
+++ b/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
diff --git a/ElmSharp/ElmSharp/Background.cs b/ElmSharp/ElmSharp/Background.cs
index c463ce8..e5348b0 100755..100644
--- a/ElmSharp/ElmSharp/Background.cs
+++ b/ElmSharp/ElmSharp/Background.cs
@@ -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
diff --git a/ElmSharp/Interop/Interop.Elementary.Bg.cs b/ElmSharp/Interop/Interop.Elementary.Bg.cs
index d598425..2f6f732 100644
--- a/ElmSharp/Interop/Interop.Elementary.Bg.cs
+++ b/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