summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangho Hur <kangho.hur@samsung.com>2016-12-12 21:06:08 +0900
committerKangho Hur <kangho.hur@samsung.com>2016-12-13 10:38:05 +0900
commita206b44f4245d63d29d048b2897d17d442a0e3e5 (patch)
tree660e4720b7a442ba6cf8641c9ba31e663d65ca04
parente31d4d977df743249eb3fb986672a0f5eb3ee252 (diff)
downloadelm-sharp-a206b44f4245d63d29d048b2897d17d442a0e3e5.tar.gz
elm-sharp-a206b44f4245d63d29d048b2897d17d442a0e3e5.tar.bz2
elm-sharp-a206b44f4245d63d29d048b2897d17d442a0e3e5.zip
Support Image.BackgroundColor
Change-Id: I4cd5296f2849bf6f4abeeea7997ce2703d835547
-rw-r--r--ElmSharp.Test/ElmSharp.Test.csproj1
-rw-r--r--ElmSharp.Test/TC/ImageTest2.cs124
-rw-r--r--ElmSharp/ElmSharp/Image.cs108
3 files changed, 190 insertions, 43 deletions
diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj
index a532bdc..e89c87a 100644
--- a/ElmSharp.Test/ElmSharp.Test.csproj
+++ b/ElmSharp.Test/ElmSharp.Test.csproj
@@ -63,6 +63,7 @@
<Compile Include="TC\GenListTest3.cs" />
<Compile Include="TC\GenListTest4.cs" />
<Compile Include="TC\GenListTest6.cs" />
+ <Compile Include="TC\ImageTest2.cs" />
<Compile Include="TC\TableTest1.cs" />
<Compile Include="TC\GenListTest8.cs" />
<Compile Include="TC\PerformanceTest.cs" />
diff --git a/ElmSharp.Test/TC/ImageTest2.cs b/ElmSharp.Test/TC/ImageTest2.cs
new file mode 100644
index 0000000..3243c24
--- /dev/null
+++ b/ElmSharp.Test/TC/ImageTest2.cs
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+
+namespace ElmSharp.Test
+{
+ public class ImageTest2 : TestCaseBase
+ {
+ public override string TestName => "ImageTest2";
+ public override string TestDescription => "To test basic operation of Image";
+
+ Image image;
+ Label lbInfo;
+
+ public override void Run(Window window)
+ {
+ Conformant conformant = new Conformant(window);
+ conformant.Show();
+ Box box = new Box(window);
+ conformant.SetContent(box);
+ box.Show();
+
+ Box buttonBox1 = new Box(window) {
+ IsHorizontal = true,
+ AlignmentX = -1,
+ AlignmentY = 0,
+ };
+ buttonBox1.Show();
+
+ Button btnFile1 = new Button(window) {
+ Text = "Blue",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile1.Show();
+
+ Button btnFile2 = new Button(window) {
+ Text = "Default",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile2.Show();
+
+ Button btnFile3 = new Button(window) {
+ Text = "Aspect",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile3.Show();
+
+ Button btnFile4 = new Button(window) {
+ Text = "Rotate",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile4.Show();
+
+ buttonBox1.PackEnd(btnFile1);
+ buttonBox1.PackEnd(btnFile2);
+ buttonBox1.PackEnd(btnFile3);
+ buttonBox1.PackEnd(btnFile4);
+
+ lbInfo = new Label(window) {
+ Color = Color.White,
+ AlignmentX = -1,
+ AlignmentY = 0,
+ WeightX = 1
+ };
+ lbInfo.Show();
+
+ image = new Image(window) {
+ IsFixedAspect = true,
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ image.Show();
+ image.Load(Path.Combine(TestRunner.ResourceDir, "picture.png"));
+ image.Clicked += (s, e) =>
+ {
+ Console.WriteLine("Image has been clicked. (IsFixedAspect = {0}", image.IsFixedAspect);
+ image.IsFixedAspect = image.IsFixedAspect == true ? false : true;
+ };
+
+ btnFile1.Clicked += (s, e) => { image.BackgroundColor = Color.Blue; UpdateLabelText(image.BackgroundColor.ToString()); };
+ btnFile2.Clicked += (s, e) => { image.BackgroundColor = Color.Default; UpdateLabelText(image.BackgroundColor.ToString()); };
+ btnFile3.Clicked += (s, e) => { image.IsFixedAspect = image.IsFixedAspect == true ? false : true; };
+ btnFile4.Clicked += (s, e) => { image.Orientation = image.Orientation == ImageOrientation.None ? ImageOrientation.Rotate270 : ImageOrientation.None; };
+
+ box.PackEnd(buttonBox1);
+ box.PackEnd(lbInfo);
+ box.PackEnd(image);
+ }
+
+ void UpdateLabelText(string text)
+ {
+ lbInfo.Text = "<span color=#ffffff font_size=20>" + text + "</span>";
+ }
+ }
+}
diff --git a/ElmSharp/ElmSharp/Image.cs b/ElmSharp/ElmSharp/Image.cs
index 9268c1b..2c99bcb 100644
--- a/ElmSharp/ElmSharp/Image.cs
+++ b/ElmSharp/ElmSharp/Image.cs
@@ -41,7 +41,7 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_file_get(Handle);
+ return Interop.Elementary.elm_image_file_get(RealHandle);
}
}
@@ -49,11 +49,11 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_smooth_get(Handle);
+ return Interop.Elementary.elm_image_smooth_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_smooth_set(Handle, value);
+ Interop.Elementary.elm_image_smooth_set(RealHandle, value);
}
}
@@ -61,11 +61,11 @@ namespace ElmSharp
{
get
{
- return !Interop.Elementary.elm_image_no_scale_get(Handle);
+ return !Interop.Elementary.elm_image_no_scale_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_no_scale_set(Handle, !value);
+ Interop.Elementary.elm_image_no_scale_set(RealHandle, !value);
}
}
@@ -78,7 +78,7 @@ namespace ElmSharp
set
{
_canScaleDown = value;
- Interop.Elementary.elm_image_resizable_set(Handle, _canScaleUp, _canScaleDown);
+ Interop.Elementary.elm_image_resizable_set(RealHandle, _canScaleUp, _canScaleDown);
}
}
@@ -91,7 +91,7 @@ namespace ElmSharp
set
{
_canScaleUp = value;
- Interop.Elementary.elm_image_resizable_set(Handle, _canScaleUp, _canScaleDown);
+ Interop.Elementary.elm_image_resizable_set(RealHandle, _canScaleUp, _canScaleDown);
}
}
@@ -99,11 +99,11 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_fill_outside_get(Handle);
+ return Interop.Elementary.elm_image_fill_outside_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_fill_outside_set(Handle, value);
+ Interop.Elementary.elm_image_fill_outside_set(RealHandle, value);
}
}
@@ -111,11 +111,11 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_prescale_get(Handle);
+ return Interop.Elementary.elm_image_prescale_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_prescale_set(Handle, value);
+ Interop.Elementary.elm_image_prescale_set(RealHandle, value);
}
}
@@ -123,11 +123,11 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_aspect_fixed_get(Handle);
+ return Interop.Elementary.elm_image_aspect_fixed_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_aspect_fixed_set(Handle, value);
+ Interop.Elementary.elm_image_aspect_fixed_set(RealHandle, value);
}
}
@@ -135,11 +135,11 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_animated_get(Handle);
+ return Interop.Elementary.elm_image_animated_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_animated_set(Handle, value);
+ Interop.Elementary.elm_image_animated_set(RealHandle, value);
}
}
@@ -147,7 +147,7 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_animated_available_get(Handle);
+ return Interop.Elementary.elm_image_animated_available_get(RealHandle);
}
}
@@ -155,11 +155,11 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_animated_play_get(Handle);
+ return Interop.Elementary.elm_image_animated_play_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_animated_play_set(Handle, value);
+ Interop.Elementary.elm_image_animated_play_set(RealHandle, value);
}
}
@@ -167,11 +167,11 @@ namespace ElmSharp
{
get
{
- return Interop.Elementary.elm_image_editable_get(Handle);
+ return Interop.Elementary.elm_image_editable_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_editable_set(Handle, value);
+ Interop.Elementary.elm_image_editable_set(RealHandle, value);
}
}
@@ -180,7 +180,7 @@ namespace ElmSharp
get
{
int w, h;
- Interop.Elementary.elm_image_object_size_get(Handle, out w, out h);
+ Interop.Elementary.elm_image_object_size_get(RealHandle, out w, out h);
return new Size(w, h);
}
}
@@ -189,7 +189,7 @@ namespace ElmSharp
{
get
{
- IntPtr evasObj = Interop.Elementary.elm_image_object_get(Handle);
+ IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
if (evasObj != IntPtr.Zero)
{
return !Interop.Evas.evas_object_image_alpha_get(evasObj);
@@ -198,7 +198,7 @@ namespace ElmSharp
}
set
{
- IntPtr evasObj = Interop.Elementary.elm_image_object_get(Handle);
+ IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
if (evasObj != IntPtr.Zero)
{
Interop.Evas.evas_object_image_alpha_set(evasObj, !value);
@@ -210,11 +210,11 @@ namespace ElmSharp
{
get
{
- return (ImageOrientation)Interop.Elementary.elm_image_orient_get(Handle);
+ return (ImageOrientation)Interop.Elementary.elm_image_orient_get(RealHandle);
}
set
{
- Interop.Elementary.elm_image_orient_set(Handle, (int)value);
+ Interop.Elementary.elm_image_orient_set(RealHandle, (int)value);
}
}
@@ -223,7 +223,7 @@ namespace ElmSharp
get
{
int r = 255, g = 255, b = 255, a = 255;
- IntPtr evasObj = Interop.Elementary.elm_image_object_get(Handle);
+ IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
if (evasObj != IntPtr.Zero)
{
Interop.Evas.evas_object_color_get(evasObj, out r, out g, out b, out a);
@@ -232,7 +232,7 @@ namespace ElmSharp
}
set
{
- IntPtr evasObj = Interop.Elementary.elm_image_object_get(Handle);
+ IntPtr evasObj = Interop.Elementary.elm_image_object_get(RealHandle);
if (evasObj != IntPtr.Zero)
{
Interop.Evas.evas_object_color_set(evasObj, value.R, value.G, value.B, value.A);
@@ -240,14 +240,30 @@ namespace ElmSharp
}
}
+ public override Color BackgroundColor
+ {
+ set
+ {
+ if (value.IsDefault)
+ {
+ SetPartColor("bg", Color.Transparent);
+ }
+ else
+ {
+ SetPartColor("bg", value);
+ }
+ _backgroundColor = value;
+ }
+ }
+
public bool Load(string file)
{
if (file == null)
throw new ArgumentNullException("file");
- Interop.Elementary.elm_image_async_open_set(Handle, false);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, true);
- return Interop.Elementary.elm_image_file_set(Handle, file, null);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, false);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, true);
+ return Interop.Elementary.elm_image_file_set(RealHandle, file, null);
}
public bool Load(Uri uri)
@@ -265,9 +281,9 @@ namespace ElmSharp
if (img == null)
throw new ArgumentNullException("img");
- Interop.Elementary.elm_image_async_open_set(Handle, false);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, true);
- return Interop.Elementary.elm_image_memfile_set(Handle, img, size, IntPtr.Zero, IntPtr.Zero);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, false);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, true);
+ return Interop.Elementary.elm_image_memfile_set(RealHandle, img, size, IntPtr.Zero, IntPtr.Zero);
}
public bool Load(Stream stream)
@@ -275,8 +291,8 @@ namespace ElmSharp
if (stream == null)
throw new ArgumentNullException("stream");
- Interop.Elementary.elm_image_async_open_set(Handle, false);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, true);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, false);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, true);
MemoryStream memstream = new MemoryStream();
stream.CopyTo(memstream);
unsafe
@@ -284,7 +300,7 @@ namespace ElmSharp
byte[] dataArr = memstream.ToArray();
fixed (byte* data = &dataArr[0])
{
- return Interop.Elementary.elm_image_memfile_set(Handle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
+ return Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
}
}
}
@@ -294,8 +310,8 @@ namespace ElmSharp
if (file == null)
throw new ArgumentNullException("file");
- Interop.Elementary.elm_image_async_open_set(Handle, true);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, false);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, true);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, false);
var tcs = new TaskCompletionSource<bool>();
@@ -329,7 +345,7 @@ namespace ElmSharp
}
};
- bool ret = Interop.Elementary.elm_image_file_set(Handle, file, null);
+ bool ret = Interop.Elementary.elm_image_file_set(RealHandle, file, null);
if (!ret)
{
throw new InvalidOperationException("Failed to set file to Image");
@@ -351,8 +367,8 @@ namespace ElmSharp
if (stream == null)
throw new ArgumentNullException("stream");
- Interop.Elementary.elm_image_async_open_set(Handle, true);
- Interop.Elementary.elm_image_preload_disabled_set(Handle, false);
+ Interop.Elementary.elm_image_async_open_set(RealHandle, true);
+ Interop.Elementary.elm_image_preload_disabled_set(RealHandle, false);
var tcs = new TaskCompletionSource<bool>();
@@ -394,7 +410,7 @@ namespace ElmSharp
byte[] dataArr = memstream.ToArray();
fixed (byte* data = &dataArr[0])
{
- bool ret = Interop.Elementary.elm_image_memfile_set(Handle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
+ bool ret = Interop.Elementary.elm_image_memfile_set(RealHandle, data, dataArr.Length, IntPtr.Zero, IntPtr.Zero);
if (!ret)
{
return false;
@@ -407,7 +423,13 @@ namespace ElmSharp
protected override IntPtr CreateHandle(EvasObject parent)
{
- return Interop.Elementary.elm_image_add(parent.Handle);
+ IntPtr handle = Interop.Elementary.elm_layout_add(parent);
+ Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
+
+ RealHandle = Interop.Elementary.elm_image_add(handle);
+ Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
+
+ return handle;
}
}