From b7212cecf53eb96613cf15d830ff67a92fc88352 Mon Sep 17 00:00:00 2001 From: Sidharth Gupta Date: Thu, 1 Dec 2016 11:43:49 +0900 Subject: [PATCH 01/16] Mark StopPluse Obsolete and add StopPulse in ProgressBar Minor version updated as well. Signed-off-by: Sidharth Gupta Change-Id: I27b455afd71a03be8e388381a0cf8626ac344ea9 --- ElmSharp/ElmSharp/ProgressBar.cs | 6 ++++++ packaging/elm-sharp.spec | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ElmSharp/ElmSharp/ProgressBar.cs b/ElmSharp/ElmSharp/ProgressBar.cs index de66329..f72c6ef 100644 --- a/ElmSharp/ElmSharp/ProgressBar.cs +++ b/ElmSharp/ElmSharp/ProgressBar.cs @@ -110,11 +110,17 @@ namespace ElmSharp Interop.Elementary.elm_progressbar_pulse(Handle, true); } + [Obsolete("use StopPulse instead")] public void StopPluse() { Interop.Elementary.elm_progressbar_pulse(Handle, false); } + public void StopPulse() + { + Interop.Elementary.elm_progressbar_pulse(Handle, false); + } + protected override IntPtr CreateHandle(EvasObject parent) { return Interop.Elementary.elm_progressbar_add(parent); diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index 5adc61d..60f9ed8 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -8,7 +8,7 @@ Name: elm-sharp Summary: C# Binding for Elementary -Version: 1.0.15 +Version: 1.1.0 Release: 1 Group: Development/Libraries License: Apache-2.0 -- 2.7.4 From 04db1f96a7a37953f23c56632c7caf6175808538 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Thu, 1 Dec 2016 19:55:19 +0900 Subject: [PATCH 02/16] Update package/nuget version to 1.1.0-beta-001 Change-Id: I833158ee716091948862c4ad34922a8873b8945e --- packaging/elm-sharp.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index 60f9ed8..1d43d81 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -6,6 +6,8 @@ %define BUILDCONF Release %endif +%define DEV_VERSION beta-001 + Name: elm-sharp Summary: C# Binding for Elementary Version: 1.1.0 @@ -40,7 +42,7 @@ find $ASM/*.project.json -exec nuget restore {} \; # Build find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \; # NuGet Pack -nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF} +nuget pack $ASM/$ASM.nuspec -Version %{version}%{?DEV_VERSION:-%{DEV_VERSION}} -Properties Configuration=%{BUILDCONF} done edje_cc -id ElmSharp/theme/%{profile}/HD/images/ \ -- 2.7.4 From 9bba3fa733eed84630f45146d36392945fd0e6c6 Mon Sep 17 00:00:00 2001 From: "jh5.cho" Date: Fri, 2 Dec 2016 11:04:35 +0900 Subject: [PATCH 03/16] Add EvasMapTest1 as TC Change-Id: I5c28989396652538f911b6a76465cf7f8a9c3519 --- ElmSharp.Test/ElmSharp.Test.csproj | 1 + ElmSharp.Test/TC/EvasMapTest1.cs | 113 +++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100755 ElmSharp.Test/TC/EvasMapTest1.cs diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj index f703a51..22fb426 100755 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -52,6 +52,7 @@ + diff --git a/ElmSharp.Test/TC/EvasMapTest1.cs b/ElmSharp.Test/TC/EvasMapTest1.cs new file mode 100755 index 0000000..498dd16 --- /dev/null +++ b/ElmSharp.Test/TC/EvasMapTest1.cs @@ -0,0 +1,113 @@ +using System; +using ElmSharp; + +namespace ElmSharp.Test +{ + class EvasMapTest1 : TestCaseBase + { + public override string TestName => "EvasMapTest1"; + public override string TestDescription => "Test EvasMap on different levels of hierarchy"; + + public override void Run(Window window) + { + var box = new Box(window) + { + IsHorizontal = false, + }; + box.SetAlignment(-1.0, -1.0); + box.SetWeight(1.0, 1.0); + box.Show(); + + var text = new Label(box) + { + Text = "Target", + AlignmentX = -1.0, + AlignmentY = -1.0, + WeightX = 1.0, + WeightY = 1.0, + }; + text.Show(); + + var textBox = new Box(box) + { + AlignmentX = -1.0, + WeightX = 1.0, + WeightY = 0.7, + }; + textBox.PackEnd(text); + textBox.Show(); + + double angle = 0.0; + + var reset = new Button(box) + { + Text = "Reset", + AlignmentX = -1.0, + WeightX = 1.0, + WeightY = 0.1, + }; + reset.Show(); + + double zx = 1.0; + double zy = 1.0; + reset.Clicked += (object sender, EventArgs e) => + { + text.IsMapEnabled = false; + angle = 0.0; + zx = 1.0; + zy = 1.0; + }; + + var zoom = new Button(box) + { + Text = "Zoom Target", + AlignmentX = -1.0, + WeightX = 1.0, + WeightY = 0.1, + }; + zoom.Show(); + + zoom.Clicked += (object sender, EventArgs e) => + { + zx += 0.1; + zy += 0.1; + var map = new EvasMap(4); + var g = text.Geometry; + map.PopulatePoints(g, 0); + map.Rotate3D(0, 0, angle, g.X + g.Width / 2, g.Y + g.Height / 2, 0); + map.Zoom(zx, zy, g.X, g.Y); + text.EvasMap = map; + text.IsMapEnabled = true; + }; + + var rotate = new Button(box) + { + Text = "Rotate Target", + AlignmentX = -1.0, + WeightX = 1.0, + WeightY = 0.1, + }; + rotate.Show(); + + rotate.Clicked += (object sender, EventArgs e) => + { + angle += 5.0; + var map = new EvasMap(4); + var g = text.Geometry; + map.PopulatePoints(g, 0); + map.Rotate3D(0, 0, angle, g.X + g.Width / 2, g.Y + g.Height / 2, 0); + map.Zoom(zx, zy, g.X, g.Y); + text.EvasMap = map; + text.IsMapEnabled = true; + }; + + box.PackEnd(textBox); + box.PackEnd(reset); + box.PackEnd(zoom); + box.PackEnd(rotate); + + box.Resize(window.ScreenSize.Width, window.ScreenSize.Height); + box.Move(0, 0); + } + } +} \ No newline at end of file -- 2.7.4 From 10906f24247778391508603f6646640f90faf970 Mon Sep 17 00:00:00 2001 From: JEONGHYUN YUN Date: Thu, 24 Nov 2016 19:11:28 +0900 Subject: [PATCH 04/16] Added BackgroundColor property in Widget Change-Id: I6f8995cc2731492a905e6d2f43d6f80a9586934e Signed-off-by: JEONGHYUN YUN --- ElmSharp.Test/TC/ButtonTest1.cs | 66 ++++++++++++++++++++++++---------- ElmSharp/ElmSharp/Button.cs | 9 +++++ ElmSharp/ElmSharp/Widget.cs | 14 ++++++++ ElmSharp/Interop/Interop.Elementary.cs | 3 ++ 4 files changed, 73 insertions(+), 19 deletions(-) mode change 100644 => 100755 ElmSharp/Interop/Interop.Elementary.cs diff --git a/ElmSharp.Test/TC/ButtonTest1.cs b/ElmSharp.Test/TC/ButtonTest1.cs index 3f99a50..ab39a61 100644 --- a/ElmSharp.Test/TC/ButtonTest1.cs +++ b/ElmSharp.Test/TC/ButtonTest1.cs @@ -24,40 +24,68 @@ namespace ElmSharp.Test public override string TestName => "ButtonTest1"; public override string TestDescription => "To test basic operation of Button"; - public override void Run(Window window) + void SetButtonEventHandler(Button button) { - Button button1 = new Button(window) { - Text = "Button 1", - }; - - button1.SetPartColor("bg", Color.Red); - - button1.Clicked += (s, e) => + button.Clicked += (s, e) => { - Console.WriteLine("Button1 Clicked! : {0}", button1.ClassName); - Console.WriteLine("Button1 Clicked! : {0}", button1.ClassName.ToLower()); - Console.WriteLine("Button1 Clicked! : {0}", button1.ClassName.ToLower().Replace("elm_","")); - Console.WriteLine("Button1 Clicked! : {0}", button1.ClassName.ToLower().Replace("elm_", "")+ "/" + "bg"); + Console.WriteLine("{0} Clicked! : {1}", button.Text, button.BackgroundColor); + Console.WriteLine("{0} Clicked! : {1}", button.Text, button.ClassName); + Console.WriteLine("{0} Clicked! : {1}", button.Text, button.ClassName.ToLower()); + Console.WriteLine("{0} Clicked! : {1}", button.Text, button.ClassName.ToLower().Replace("elm_", "")); + Console.WriteLine("{0} Clicked! : {1}", button.Text, button.ClassName.ToLower().Replace("elm_", "") + "/" + "bg"); }; - button1.Pressed += (s, e) => + button.Pressed += (s, e) => { - Console.WriteLine("Button1 Pressed!"); + Console.WriteLine("{0} Pressed!", button.Text); }; - button1.Released += (s, e) => + button.Released += (s, e) => { - Console.WriteLine("Button1 Released!"); + Console.WriteLine("{0} Released!", button.Text); }; - button1.Repeated += (s, e) => + button.Repeated += (s, e) => { - Console.WriteLine("Button1 Repeated!"); + Console.WriteLine("{0} Repeated!", button.Text); }; - button1.Show(); + button.Show(); + } + + public override void Run(Window window) + { + Button button1 = new Button(window) { + Text = "Button 1", + }; + button1.SetPartColor("bg", Color.Red); + SetButtonEventHandler(button1); button1.Resize(500, 100); button1.Move(0, 0); + + Button button2 = new Button(window) { + Text = "Button 2", + BackgroundColor = Color.Red, + }; + SetButtonEventHandler(button2); + button2.Resize(500, 100); + button2.Move(0, 200); + + Button button3 = new Button(window) { + Text = "Button 3", + BackgroundColor = new Color(125,200,255, 150) + }; + SetButtonEventHandler(button3); + button3.Resize(500, 100); + button3.Move(0, 400); + + Button button4 = new Button(window) { + Text = "Button 4", + BackgroundColor = new Color(125, 200, 255, 10) + }; + SetButtonEventHandler(button4); + button4.Resize(500, 100); + button4.Move(0, 600); } } diff --git a/ElmSharp/ElmSharp/Button.cs b/ElmSharp/ElmSharp/Button.cs index 1d69347..9d13db3 100644 --- a/ElmSharp/ElmSharp/Button.cs +++ b/ElmSharp/ElmSharp/Button.cs @@ -102,6 +102,15 @@ namespace ElmSharp Interop.Elementary.edje_object_color_class_del(Handle, part); } + public override Color BackgroundColor + { + set + { + SetPartColor("bg", value); + SetPartColor("bg_pressed", value); + } + } + protected override IntPtr CreateHandle(EvasObject parent) { return Interop.Elementary.elm_button_add(parent.Handle); diff --git a/ElmSharp/ElmSharp/Widget.cs b/ElmSharp/ElmSharp/Widget.cs index fabf249..f7a7833 100644 --- a/ElmSharp/ElmSharp/Widget.cs +++ b/ElmSharp/ElmSharp/Widget.cs @@ -87,6 +87,20 @@ namespace ElmSharp } } + public virtual Color BackgroundColor + { + get + { + int r, g, b, a; + Interop.Elementary.elm_object_color_class_color_get(Handle, "bg", out r, out g, out b, out a); + return new Color((int)(r/(a/255.0)), (int)(g/(a/255.0)), (int)(b/(a/255.0)), a); + } + set + { + SetPartColor("bg", value); + } + } + public void SetFocus(bool isFocus) { Interop.Elementary.elm_object_focus_set(Handle, isFocus); diff --git a/ElmSharp/Interop/Interop.Elementary.cs b/ElmSharp/Interop/Interop.Elementary.cs old mode 100644 new mode 100755 index 5a0b7bd..c96a471 --- a/ElmSharp/Interop/Interop.Elementary.cs +++ b/ElmSharp/Interop/Interop.Elementary.cs @@ -152,6 +152,9 @@ internal static partial class Interop } [DllImport(Libraries.Elementary)] + internal static extern void elm_object_color_class_color_get(IntPtr obj, string colorClass, out int r, out int g, out int b, out int a); + + [DllImport(Libraries.Elementary)] internal static extern void elm_object_color_class_color_set(IntPtr obj, string colorClass, int r, int g, int b, int a); [DllImport(Libraries.Elementary)] -- 2.7.4 From 29ae5e9ea7a958ad411922275f23bd01e71adcd1 Mon Sep 17 00:00:00 2001 From: JEONGHYUN YUN Date: Mon, 31 Oct 2016 13:24:38 +0900 Subject: [PATCH 05/16] Added background color set API for Box Change-Id: Ife6df16fb8bf03bef9c11a06a30bf55ad2541dd1 Signed-off-by: JEONGHYUN YUN --- ElmSharp.Test/TC/BoxTest1.cs | 13 +++++--- ElmSharp/ElmSharp/Box.cs | 29 +++++++++++------ ElmSharp/ElmSharp/Container.cs | 5 +++ ElmSharp/theme/mobile/color_classes.edc | 7 +++++ ElmSharp/theme/mobile/elm-sharp-theme-mobile.edc | 1 + ElmSharp/theme/mobile/widgets/layout.edc | 40 ++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 14 deletions(-) create mode 100644 ElmSharp/theme/mobile/widgets/layout.edc diff --git a/ElmSharp.Test/TC/BoxTest1.cs b/ElmSharp.Test/TC/BoxTest1.cs index f640d93..e927724 100644 --- a/ElmSharp.Test/TC/BoxTest1.cs +++ b/ElmSharp.Test/TC/BoxTest1.cs @@ -24,11 +24,14 @@ namespace ElmSharp.Test public override string TestName => "BoxTest1"; public override string TestDescription => "To test basic operation of Box"; + Box box; + public override void Run(Window window) { Conformant conformant = new Conformant(window); conformant.Show(); - Box box = new Box(window); + box = new Box(window); + box.BackgroundColor = Color.Orange; conformant.SetContent(box); box.Show(); @@ -44,14 +47,16 @@ namespace ElmSharp.Test AlignmentX = -1, AlignmentY = -1, WeightX = 1, - WeightY = 1 + WeightY = 1, + BackgroundColor = new Color(50,100,200,75) }; Button button3 = new Button(window) { Text = "Button 3", AlignmentX = -1, AlignmentY = -1, WeightX = 1, - WeightY = 1 + WeightY = 1, + BackgroundColor = Color.Olive }; box.PackEnd(button1); @@ -69,7 +74,7 @@ namespace ElmSharp.Test private void Button1_Clicked(object sender, EventArgs e) { - Console.WriteLine("{0} Clicked!", ((Button)sender).Text); + Console.WriteLine("{0} Clicked! - Button's BG Color : {1}, Box's BG Color : {2}", ((Button)sender).Text, ((Button)sender).BackgroundColor, box.BackgroundColor); } } } diff --git a/ElmSharp/ElmSharp/Box.cs b/ElmSharp/ElmSharp/Box.cs index 02ed3ad..f67d30d 100644 --- a/ElmSharp/ElmSharp/Box.cs +++ b/ElmSharp/ElmSharp/Box.cs @@ -22,46 +22,49 @@ namespace ElmSharp { private Interop.Elementary.BoxLayoutCallback _layoutCallback; - public Box(EvasObject parent) : base(parent) { } + public Box(EvasObject parent) : base(parent) + { + } + public bool IsHorizontal { get { - return Interop.Elementary.elm_box_horizontal_get(Handle); + return Interop.Elementary.elm_box_horizontal_get(GetRealHandle(Handle)); } set { - Interop.Elementary.elm_box_horizontal_set(Handle, value); + Interop.Elementary.elm_box_horizontal_set(GetRealHandle(Handle), value); } } public void PackEnd(EvasObject content) { - Interop.Elementary.elm_box_pack_end(Handle, content); + Interop.Elementary.elm_box_pack_end(GetRealHandle(Handle), content); AddChild(content); } public void PackStart(EvasObject content) { - Interop.Elementary.elm_box_pack_start(Handle, content); + Interop.Elementary.elm_box_pack_start(GetRealHandle(Handle), content); AddChild(content); } public void PackAfter(EvasObject content, EvasObject after) { - Interop.Elementary.elm_box_pack_after(Handle, content, after); + Interop.Elementary.elm_box_pack_after(GetRealHandle(Handle), content, after); AddChild(content); } public void UnPack(EvasObject content) { - Interop.Elementary.elm_box_unpack(Handle, content); + Interop.Elementary.elm_box_unpack(GetRealHandle(Handle), content); RemoveChild(content); } public void UnPackAll() { - Interop.Elementary.elm_box_unpack_all(Handle); + Interop.Elementary.elm_box_unpack_all(GetRealHandle(Handle)); ClearChildren(); } @@ -71,12 +74,18 @@ namespace ElmSharp { action(); }; - Interop.Elementary.elm_box_layout_set(Handle, _layoutCallback, IntPtr.Zero, null); + Interop.Elementary.elm_box_layout_set(GetRealHandle(Handle), _layoutCallback, IntPtr.Zero, null); } protected override IntPtr CreateHandle(EvasObject parent) { - return Interop.Elementary.elm_box_add(parent); + IntPtr handle = Interop.Elementary.elm_layout_add(parent); + Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default"); + + IntPtr realHandle = Interop.Elementary.elm_box_add(handle); + Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", realHandle); + + return handle; } } } diff --git a/ElmSharp/ElmSharp/Container.cs b/ElmSharp/ElmSharp/Container.cs index 086f187..0cd27c0 100644 --- a/ElmSharp/ElmSharp/Container.cs +++ b/ElmSharp/ElmSharp/Container.cs @@ -27,6 +27,11 @@ namespace ElmSharp { } + protected virtual IntPtr GetRealHandle(IntPtr handle) + { + return Interop.Elementary.elm_object_part_content_get(handle, "elm.swallow.content"); + } + internal void AddChild(EvasObject obj) { _children.Add(obj); diff --git a/ElmSharp/theme/mobile/color_classes.edc b/ElmSharp/theme/mobile/color_classes.edc index f71991c..d10c93b 100644 --- a/ElmSharp/theme/mobile/color_classes.edc +++ b/ElmSharp/theme/mobile/color_classes.edc @@ -1,5 +1,12 @@ color_classes { /* + * Layout + */ + color_class { + name: "layout/background/bg"; + color: 0 0 0 0; + } + /* * Colorselector */ color_class { diff --git a/ElmSharp/theme/mobile/elm-sharp-theme-mobile.edc b/ElmSharp/theme/mobile/elm-sharp-theme-mobile.edc index 2a95234..d9baad4 100644 --- a/ElmSharp/theme/mobile/elm-sharp-theme-mobile.edc +++ b/ElmSharp/theme/mobile/elm-sharp-theme-mobile.edc @@ -87,6 +87,7 @@ collections { #include "widgets/entry.edc" #include "widgets/label.edc" #include "widgets/radio.edc" +#include "widgets/layout.edc" } diff --git a/ElmSharp/theme/mobile/widgets/layout.edc b/ElmSharp/theme/mobile/widgets/layout.edc new file mode 100644 index 0000000..4268a9f --- /dev/null +++ b/ElmSharp/theme/mobile/widgets/layout.edc @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2010 Samsung Electronics Co., Ltd All Rights Reserved + * + * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +group { "elm/layout/background/default"; + parts { + rect { "bg"; + scale; + desc { "default"; + color_class: "layout/background/bg"; + } + } + swallow { "elm.swallow.content"; + scale; + desc { "default"; } + } + } +} -- 2.7.4 From c9695a06e131368597a90fbaf59597f7e81220a0 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Mon, 5 Dec 2016 10:21:37 +0900 Subject: [PATCH 06/16] Deprecate the Button.DeleteColorClass() - please use EdjeObject.DeleteColorClass(string) Change-Id: Ifbf9a1e92bb0869edd8762f5d0013f6d5edf27cd --- ElmSharp/ElmSharp/Button.cs | 1 + ElmSharp/ElmSharp/EdjeObject.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ElmSharp/ElmSharp/Button.cs b/ElmSharp/ElmSharp/Button.cs index 9d13db3..2292074 100644 --- a/ElmSharp/ElmSharp/Button.cs +++ b/ElmSharp/ElmSharp/Button.cs @@ -97,6 +97,7 @@ namespace ElmSharp } } + [Obsolete("DeleteColorClass is obsolete, please use EdjeObject.DeleteColorClass(string)")] public void DeleteColorClass(string part) { Interop.Elementary.edje_object_color_class_del(Handle, part); diff --git a/ElmSharp/ElmSharp/EdjeObject.cs b/ElmSharp/ElmSharp/EdjeObject.cs index bd40244..4dc7e28 100644 --- a/ElmSharp/ElmSharp/EdjeObject.cs +++ b/ElmSharp/ElmSharp/EdjeObject.cs @@ -43,6 +43,11 @@ namespace ElmSharp { Interop.Elementary.edje_object_signal_emit(_edjeHandle, emission, source); } + + public void DeleteColorClass(string part) + { + Interop.Elementary.edje_object_color_class_del(_edjeHandle, part); + } } public class EdjeTextPartObject -- 2.7.4 From 6f01d7a3aa7d564bc186a9d5e132d3b9eca79503 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Tue, 6 Dec 2016 19:03:53 +0900 Subject: [PATCH 07/16] Support to Color.Default - This change allow to set color as Color.Defalut. - Change-Id: Ieae82112b0609cac17808d8fc41a9d2db0d102ed --- ElmSharp.Test/ElmSharp.Test.csproj | 1 + ElmSharp.Test/TC/BackgroundColorTest1.cs | 101 +++++++++++++++++++++++++++++++ ElmSharp/ElmSharp/Button.cs | 13 +++- ElmSharp/ElmSharp/Color.cs | 42 +++++++++++-- ElmSharp/ElmSharp/Layout.cs | 17 ++++++ ElmSharp/ElmSharp/Widget.cs | 27 +++++++-- 6 files changed, 190 insertions(+), 11 deletions(-) mode change 100755 => 100644 ElmSharp.Test/ElmSharp.Test.csproj create mode 100644 ElmSharp.Test/TC/BackgroundColorTest1.cs diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj old mode 100755 new mode 100644 index 22fb426..832a052 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -45,6 +45,7 @@ + diff --git a/ElmSharp.Test/TC/BackgroundColorTest1.cs b/ElmSharp.Test/TC/BackgroundColorTest1.cs new file mode 100644 index 0000000..c8073f3 --- /dev/null +++ b/ElmSharp.Test/TC/BackgroundColorTest1.cs @@ -0,0 +1,101 @@ +/* + * 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 ElmSharp; + +namespace ElmSharp.Test +{ + class BackgroundColorTest1 : TestCaseBase + { + public override string TestName => "BackgroundColorTest1"; + public override string TestDescription => "To test basic operation of Widget's background Color"; + + + + public override void Run(Window window) + { + Button button1 = new Button(window) { + Text = "Target Button", + }; + button1.Resize(window.ScreenSize.Width, 100); + button1.Move(0, 0); + button1.Show(); + + Label label1 = new Label(window) { + Text = button1.BackgroundColor.ToString(), + BackgroundColor = Color.Black, + Color = Color.White + }; + label1.Resize(window.ScreenSize.Width, 100); + label1.Move(0, 100); + label1.Show(); + + Button button2 = new Button(window) { + Text = "Set Color.Red", + BackgroundColor = Color.Red, + }; + button2.Clicked += (e, o) => + { + button1.BackgroundColor = Color.Red; + label1.Text = button1.BackgroundColor.ToString(); + }; + button2.Resize(window.ScreenSize.Width, 100); + button2.Move(0, 400); + button2.Show(); + + Button button3 = new Button(window) { + Text = "Set Color(125,200,255, 150)", + BackgroundColor = new Color(125,200,255, 150) + }; + button3.Clicked += (e, o) => + { + button1.BackgroundColor = button3.BackgroundColor; + label1.Text = button1.BackgroundColor.ToString(); + }; + button3.Resize(window.ScreenSize.Width, 100); + button3.Move(0, 500); + button3.Show(); + + Button button4 = new Button(window) { + Text = "Set Color(125, 200, 255, 10)", + BackgroundColor = new Color(125, 200, 255, 10) + }; + button4.Clicked += (e,o) => + { + button1.BackgroundColor = button4.BackgroundColor; + label1.Text = button1.BackgroundColor.ToString(); + }; + button4.Resize(window.ScreenSize.Width, 100); + button4.Move(0, 600); + button4.Show(); + + Button button5 = new Button(window) { + Text = "Set Color.Default", + BackgroundColor = Color.Default + }; + button5.Clicked += (e, o) => + { + button1.BackgroundColor = button5.BackgroundColor; + label1.Text = button1.BackgroundColor.ToString(); + }; + button5.Resize(window.ScreenSize.Width, 100); + button5.Move(0, 700); + button5.Show(); + } + + } +} diff --git a/ElmSharp/ElmSharp/Button.cs b/ElmSharp/ElmSharp/Button.cs index 2292074..0b8edec 100644 --- a/ElmSharp/ElmSharp/Button.cs +++ b/ElmSharp/ElmSharp/Button.cs @@ -107,8 +107,17 @@ namespace ElmSharp { set { - SetPartColor("bg", value); - SetPartColor("bg_pressed", value); + if (value.IsDefault) + { + EdjeObject.DeleteColorClass("button/bg"); + EdjeObject.DeleteColorClass("button/bg_pressed"); + } + else + { + SetPartColor("bg", value); + SetPartColor("bg_pressed", value); + } + _backgroundColor = value; } } diff --git a/ElmSharp/ElmSharp/Color.cs b/ElmSharp/ElmSharp/Color.cs index aba4410..f1730a3 100644 --- a/ElmSharp/ElmSharp/Color.cs +++ b/ElmSharp/ElmSharp/Color.cs @@ -26,6 +26,24 @@ namespace ElmSharp readonly int _g; readonly int _b; + readonly Mode _mode; + + enum Mode + { + Default, + Rgb + } + + public static Color Default + { + get { return new Color(-1, -1, -1, -1, Mode.Default); } + } + + public bool IsDefault + { + get { return _mode == Mode.Default; } + } + public int A { get { return _a; } @@ -50,12 +68,24 @@ namespace ElmSharp { } - public Color(int r, int g, int b, int a) + public Color(int r, int g, int b, int a) : this(r,g,b,a, Mode.Rgb) + { + } + + Color(int r, int g, int b, int a, Mode mode) { - _r = Clamp(r, 0, 255); - _g = Clamp(g, 0, 255); - _b = Clamp(b, 0, 255); - _a = Clamp(a, 0, 255); + _mode = mode; + if (mode == Mode.Rgb) + { + _r = Clamp(r, 0, 255); + _g = Clamp(g, 0, 255); + _b = Clamp(b, 0, 255); + _a = Clamp(a, 0, 255); + } + else // Default + { + _r = _g = _b = _a = -1; + } } public override int GetHashCode() @@ -78,6 +108,8 @@ namespace ElmSharp static bool EqualsInner(Color color1, Color color2) { + if (color1._mode == Mode.Default && color2._mode == Mode.Default) + return true; return color1._r == color2._r && color1._g == color2._g && color1._b == color2._b && color1._a == color2._a; } diff --git a/ElmSharp/ElmSharp/Layout.cs b/ElmSharp/ElmSharp/Layout.cs index c1678d9..4ae1fa6 100644 --- a/ElmSharp/ElmSharp/Layout.cs +++ b/ElmSharp/ElmSharp/Layout.cs @@ -63,6 +63,23 @@ namespace ElmSharp Interop.Elementary.elm_layout_file_set(Handle, file, group); } + public override Color BackgroundColor + { + set + { + if(value.IsDefault) + { + string part = ClassName.ToLower().Replace("elm_", "") + "/" + "bg"; + EdjeObject.DeleteColorClass(part); + } + else + { + SetPartColor("bg", value); + } + _backgroundColor = value; + } + } + protected override IntPtr CreateHandle(EvasObject parent) { return Interop.Elementary.elm_layout_add(parent.Handle); diff --git a/ElmSharp/ElmSharp/Widget.cs b/ElmSharp/ElmSharp/Widget.cs index f7a7833..d258145 100644 --- a/ElmSharp/ElmSharp/Widget.cs +++ b/ElmSharp/ElmSharp/Widget.cs @@ -26,6 +26,8 @@ namespace ElmSharp SmartEvent _focused; SmartEvent _unfocused; + internal Color _backgroundColor = Color.Default; + protected Widget() { } @@ -91,13 +93,23 @@ namespace ElmSharp { get { - int r, g, b, a; - Interop.Elementary.elm_object_color_class_color_get(Handle, "bg", out r, out g, out b, out a); - return new Color((int)(r/(a/255.0)), (int)(g/(a/255.0)), (int)(b/(a/255.0)), a); + if(!_backgroundColor.IsDefault) + { + _backgroundColor = GetPartColor("bg"); + } + return _backgroundColor; } set { - SetPartColor("bg", value); + if (value.IsDefault) + { + Console.WriteLine("Widget instance doesn't support to set BackgroundColor to Color.Default."); + } + else + { + SetPartColor("bg", value); + _backgroundColor = value; + } } } @@ -156,6 +168,13 @@ namespace ElmSharp color.A); } + public Color GetPartColor(string part) + { + int r, g, b, a; + Interop.Elementary.elm_object_color_class_color_get(Handle, part, out r, out g, out b, out a); + return new Color((int)(r / (a / 255.0)), (int)(g / (a / 255.0)), (int)(b / (a / 255.0)), a); + } + internal IntPtr GetPartContent(string part) { return Interop.Elementary.elm_object_part_content_get(Handle, part); -- 2.7.4 From 7a171bc04279c2820cdf782eefe63e68769cf423 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Tue, 6 Dec 2016 20:56:45 +0900 Subject: [PATCH 08/16] Support BackgroundColor API for Table - this change enable containers (box and table) to use Color.Default Change-Id: I6b9d1c65e08e2c3692fb881b4217b7397b2a488c --- ElmSharp.Test/ElmSharp.Test.csproj | 1 + ElmSharp.Test/TC/TableTest1.cs | 73 ++++++++++++++++++++++++++++++++++++++ ElmSharp/ElmSharp/Container.cs | 16 +++++++++ ElmSharp/ElmSharp/Table.cs | 22 +++++++----- 4 files changed, 104 insertions(+), 8 deletions(-) create mode 100644 ElmSharp.Test/TC/TableTest1.cs diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj index 832a052..b019daa 100644 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -63,6 +63,7 @@ + diff --git a/ElmSharp.Test/TC/TableTest1.cs b/ElmSharp.Test/TC/TableTest1.cs new file mode 100644 index 0000000..24ca0d6 --- /dev/null +++ b/ElmSharp.Test/TC/TableTest1.cs @@ -0,0 +1,73 @@ +/* + * 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 ElmSharp; + +namespace ElmSharp.Test +{ + public class TableTest1 : TestCaseBase + { + public override string TestName => "TableTest1"; + public override string TestDescription => "To test basic operation of Table"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + Table table = new Table(window) { + PaddingX = 10, + PaddingY = 10 + }; + // table.BackgroundColor = Color.Orange; + conformant.SetContent(table); + table.Show(); + + Button button1 = new Button(window) { + Text = "Button (set Color.Oranage)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + button1.Clicked += (e,o) => + { + table.BackgroundColor = Color.Orange; + Console.WriteLine("{0} Clicked! - Button's BG Color : {1}, Table's BG Color : {2}", ((Button)e).Text, ((Button)e).BackgroundColor, table.BackgroundColor); + }; + + Button button2 = new Button(window) { + Text = "Button 2 (set Color.Defalut)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + BackgroundColor = new Color(50, 100, 200, 75) + }; + button2.Clicked += (e, o) => + { + table.BackgroundColor = Color.Default; + Console.WriteLine("{0} Clicked! - Button's BG Color : {1}, Table's BG Color : {2}", ((Button)e).Text, ((Button)e).BackgroundColor, table.BackgroundColor); + }; + + table.Pack(button1,0,0,3,3); + table.Pack(button2,3,1,1,1); + + button1.Show(); + button2.Show(); + } + } +} diff --git a/ElmSharp/ElmSharp/Container.cs b/ElmSharp/ElmSharp/Container.cs index 0cd27c0..75a1f5c 100644 --- a/ElmSharp/ElmSharp/Container.cs +++ b/ElmSharp/ElmSharp/Container.cs @@ -27,6 +27,22 @@ namespace ElmSharp { } + public override Color BackgroundColor + { + set + { + if(value.IsDefault) + { + SetPartColor("bg", Color.Transparent); + } + else + { + SetPartColor("bg", value); + } + _backgroundColor = value; + } + } + protected virtual IntPtr GetRealHandle(IntPtr handle) { return Interop.Elementary.elm_object_part_content_get(handle, "elm.swallow.content"); diff --git a/ElmSharp/ElmSharp/Table.cs b/ElmSharp/ElmSharp/Table.cs index 742cfaf..252e6d0 100644 --- a/ElmSharp/ElmSharp/Table.cs +++ b/ElmSharp/ElmSharp/Table.cs @@ -31,11 +31,11 @@ namespace ElmSharp { get { - return Interop.Elementary.elm_table_homogeneous_get(Handle); + return Interop.Elementary.elm_table_homogeneous_get(GetRealHandle(Handle)); } set { - Interop.Elementary.elm_table_homogeneous_set(Handle, value); + Interop.Elementary.elm_table_homogeneous_set(GetRealHandle(Handle), value); } } @@ -48,7 +48,7 @@ namespace ElmSharp set { _paddingX = value; - Interop.Elementary.elm_table_padding_set(Handle, _paddingX, _paddingY); + Interop.Elementary.elm_table_padding_set(GetRealHandle(Handle), _paddingX, _paddingY); } } @@ -61,7 +61,7 @@ namespace ElmSharp set { _paddingY = value; - Interop.Elementary.elm_table_padding_set(Handle, _paddingX, _paddingY); + Interop.Elementary.elm_table_padding_set(GetRealHandle(Handle), _paddingX, _paddingY); } } @@ -69,7 +69,7 @@ namespace ElmSharp { if (obj == null) throw new ArgumentNullException("obj"); - Interop.Elementary.elm_table_pack(Handle, obj, col, row, colspan, rowspan); + Interop.Elementary.elm_table_pack(GetRealHandle(Handle), obj, col, row, colspan, rowspan); AddChild(obj); } @@ -77,19 +77,25 @@ namespace ElmSharp { if (obj == null) throw new ArgumentNullException("obj"); - Interop.Elementary.elm_table_unpack(Handle, obj); + Interop.Elementary.elm_table_unpack(GetRealHandle(Handle), obj); RemoveChild(obj); } public void Clear() { - Interop.Elementary.elm_table_clear(Handle, false); + Interop.Elementary.elm_table_clear(GetRealHandle(Handle), false); ClearChildren(); } protected override IntPtr CreateHandle(EvasObject parent) { - return Interop.Elementary.elm_table_add(parent); + IntPtr handle = Interop.Elementary.elm_layout_add(parent); + Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default"); + + IntPtr realHandle = Interop.Elementary.elm_table_add(handle); + Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", realHandle); + + return handle; } } } -- 2.7.4 From 943fca8089996ce2f156b0fc06492ea652c8dd73 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Wed, 7 Dec 2016 20:56:26 +0900 Subject: [PATCH 09/16] Update version to beta-002 Change-Id: Ie536fd31d6cbd1d22b5bbfb285699d67bdc6da27 --- packaging/elm-sharp.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index 1d43d81..01a1c14 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -6,7 +6,7 @@ %define BUILDCONF Release %endif -%define DEV_VERSION beta-001 +%define DEV_VERSION beta-002 Name: elm-sharp Summary: C# Binding for Elementary -- 2.7.4 From 0c899d228367d57e7413d41b5db33697c3aa78dc Mon Sep 17 00:00:00 2001 From: JEONGHYUN YUN Date: Mon, 12 Dec 2016 13:50:03 +0900 Subject: [PATCH 10/16] Added TV theme Change-Id: I0b9c409e0a15f5e91c7057928d1c973cf7774f25 Signed-off-by: JEONGHYUN YUN --- ElmSharp/theme/tv/HD-inc.edc | 41 ++++++++++++++ ElmSharp/theme/tv/color_classes.edc | 9 ++++ ElmSharp/theme/tv/elm-sharp-theme-tv.edc | 93 ++++++++++++++++++++++++++++++++ ElmSharp/theme/tv/widgets/layout.edc | 40 ++++++++++++++ 4 files changed, 183 insertions(+) create mode 100644 ElmSharp/theme/tv/HD-inc.edc create mode 100644 ElmSharp/theme/tv/color_classes.edc create mode 100644 ElmSharp/theme/tv/elm-sharp-theme-tv.edc create mode 100644 ElmSharp/theme/tv/widgets/layout.edc diff --git a/ElmSharp/theme/tv/HD-inc.edc b/ElmSharp/theme/tv/HD-inc.edc new file mode 100644 index 0000000..d7817dd --- /dev/null +++ b/ElmSharp/theme/tv/HD-inc.edc @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +//****************************************************************************// +// This file defines the width, height (not color!) for each widgets +// We can define different INC file by Resolution (HD, qHD, WVGA, HVGA) +// +// ************* Naming Rule ************ // +// {WIDGET}_{GROUP}_{PART}_{STATE}_{TYPE} +// WIDGET: NAVIFRAME, LIST, DATETIME, POPUP, etc. +// GROUP: INDEX +// PART: TEXT, ICON, BG, PADDING, DIVIDER, ICON, etc. +// STATE: LEFT, RIGHT, TOP, BOTTOM, MIN, MAX, +// TYPE: HEIGHT, WIDTH, SIZE +// e.g. LIST_PADDING_LEFT_HEIGHT +//****************************************************************************// + +#define BASE_SCALE_INC 2.6 diff --git a/ElmSharp/theme/tv/color_classes.edc b/ElmSharp/theme/tv/color_classes.edc new file mode 100644 index 0000000..c3ad645 --- /dev/null +++ b/ElmSharp/theme/tv/color_classes.edc @@ -0,0 +1,9 @@ +color_classes { + /* + * Layout + */ + color_class { + name: "layout/background/bg"; + color: 0 0 0 0; + } +} diff --git a/ElmSharp/theme/tv/elm-sharp-theme-tv.edc b/ElmSharp/theme/tv/elm-sharp-theme-tv.edc new file mode 100644 index 0000000..854cb80 --- /dev/null +++ b/ElmSharp/theme/tv/elm-sharp-theme-tv.edc @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// LICENSE NOTE: +// This file (and only this one) is licenses under public-domain. The reason +// is that this is meant to serve as a template for making your own themes and +// Elementary's LGPL license is not intended to follow. The images used do come +// under LGPL, but this file specifically for the structure of your theme is +// public-domain. This means you can take, use, re-license and otherwise +// have zero restrictions on using this file as a base for your theme. + +//****************************************************************************************// +// This is theme body including all widget bodys +// Define shared descriptions (e.g. sound samples, color classes, textblock styles) in here +// Do not define size(width, height) in here!!!! +//****************************************************************************************// + +// Include INC (e.g. HD-inc.edc, HVGA-inc.edc for each resolution) file +#include "HD-inc.edc" + +externals { + external: "elm"; +} + +// BUILD_FIX: Add version to edc as 110. +data.item: "version" "110"; +// + +collections { + base_scale: BASE_SCALE_INC; + /*plugins { + plugin { + name: "touch_sound"; + source: "feedback"; + param: "FEEDBACK_TYPE_SOUND FEEDBACK_PATTERN_TAP"; // FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TOUCH_TAP + + /* 2014.06.11 updated from libsvi(feedback) + Above plugin will run below external function: + int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern); + + param1: feedback_type_e + FEEDBACK_TYPE_NONE = 0, + FEEDBACK_TYPE_SOUND = 1, + FEEDBACK_TYPE_VIBRATION, + FEEDBACK_TYPE_LED, + FEEDBACK_TYPE_END + + * param2 enumeration: + FEEDBACK_PATTERN_TAP = 0, + FEEDBACK_PATTERN_SIP, + FEEDBACK_PATTERN_SIP_BACKSPACE, + FEEDBACK_PATTERN_SIP_FUNCTION, + FEEDBACK_PATTERN_SIP_FJKEY, + ... + + * For more information please refer libsvi. + */ + } + }*/ + +#include "color_classes.edc" + +//#include "widgets/colorselector.edc" +//#include "widgets/entry.edc" +//#include "widgets/label.edc" +//#include "widgets/radio.edc" +#include "widgets/layout.edc" + +} + diff --git a/ElmSharp/theme/tv/widgets/layout.edc b/ElmSharp/theme/tv/widgets/layout.edc new file mode 100644 index 0000000..4268a9f --- /dev/null +++ b/ElmSharp/theme/tv/widgets/layout.edc @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2010 Samsung Electronics Co., Ltd All Rights Reserved + * + * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +group { "elm/layout/background/default"; + parts { + rect { "bg"; + scale; + desc { "default"; + color_class: "layout/background/bg"; + } + } + swallow { "elm.swallow.content"; + scale; + desc { "default"; } + } + } +} -- 2.7.4 From e3806597c76d942f045cdb584a267ef8a3c47dff Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Mon, 12 Dec 2016 15:34:10 +0900 Subject: [PATCH 11/16] Fix Box.MinimumHeight issue - Box has fake handle, and it is a layout - When setting a MinimunHeight of Box, it does not apply to box, is set in the layout - Introduce new internal property "RealHandle" - It is normally same with Handle - It used for some internal APIs, to get inner handle (RealHandle) Change-Id: I0608b14e700f2adb21566b05a06982c43bbfb067 --- ElmSharp/ElmSharp/Box.cs | 20 ++++++++++---------- ElmSharp/ElmSharp/Container.cs | 5 ----- ElmSharp/ElmSharp/EvasObject.cs | 34 +++++++++++++++++++++++----------- ElmSharp/ElmSharp/Table.cs | 18 +++++++++--------- 4 files changed, 42 insertions(+), 35 deletions(-) diff --git a/ElmSharp/ElmSharp/Box.cs b/ElmSharp/ElmSharp/Box.cs index f67d30d..8bec6c3 100644 --- a/ElmSharp/ElmSharp/Box.cs +++ b/ElmSharp/ElmSharp/Box.cs @@ -30,41 +30,41 @@ namespace ElmSharp { get { - return Interop.Elementary.elm_box_horizontal_get(GetRealHandle(Handle)); + return Interop.Elementary.elm_box_horizontal_get(RealHandle); } set { - Interop.Elementary.elm_box_horizontal_set(GetRealHandle(Handle), value); + Interop.Elementary.elm_box_horizontal_set(RealHandle, value); } } public void PackEnd(EvasObject content) { - Interop.Elementary.elm_box_pack_end(GetRealHandle(Handle), content); + Interop.Elementary.elm_box_pack_end(RealHandle, content); AddChild(content); } public void PackStart(EvasObject content) { - Interop.Elementary.elm_box_pack_start(GetRealHandle(Handle), content); + Interop.Elementary.elm_box_pack_start(RealHandle, content); AddChild(content); } public void PackAfter(EvasObject content, EvasObject after) { - Interop.Elementary.elm_box_pack_after(GetRealHandle(Handle), content, after); + Interop.Elementary.elm_box_pack_after(RealHandle, content, after); AddChild(content); } public void UnPack(EvasObject content) { - Interop.Elementary.elm_box_unpack(GetRealHandle(Handle), content); + Interop.Elementary.elm_box_unpack(RealHandle, content); RemoveChild(content); } public void UnPackAll() { - Interop.Elementary.elm_box_unpack_all(GetRealHandle(Handle)); + Interop.Elementary.elm_box_unpack_all(RealHandle); ClearChildren(); } @@ -74,7 +74,7 @@ namespace ElmSharp { action(); }; - Interop.Elementary.elm_box_layout_set(GetRealHandle(Handle), _layoutCallback, IntPtr.Zero, null); + Interop.Elementary.elm_box_layout_set(RealHandle, _layoutCallback, IntPtr.Zero, null); } protected override IntPtr CreateHandle(EvasObject parent) @@ -82,8 +82,8 @@ namespace ElmSharp IntPtr handle = Interop.Elementary.elm_layout_add(parent); Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default"); - IntPtr realHandle = Interop.Elementary.elm_box_add(handle); - Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", realHandle); + RealHandle = Interop.Elementary.elm_box_add(handle); + Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); return handle; } diff --git a/ElmSharp/ElmSharp/Container.cs b/ElmSharp/ElmSharp/Container.cs index 75a1f5c..2842629 100644 --- a/ElmSharp/ElmSharp/Container.cs +++ b/ElmSharp/ElmSharp/Container.cs @@ -43,11 +43,6 @@ namespace ElmSharp } } - protected virtual IntPtr GetRealHandle(IntPtr handle) - { - return Interop.Elementary.elm_object_part_content_get(handle, "elm.swallow.content"); - } - internal void AddChild(EvasObject obj) { _children.Add(obj); diff --git a/ElmSharp/ElmSharp/EvasObject.cs b/ElmSharp/ElmSharp/EvasObject.cs index 87ac0eb..6b732c2 100644 --- a/ElmSharp/ElmSharp/EvasObject.cs +++ b/ElmSharp/ElmSharp/EvasObject.cs @@ -22,8 +22,20 @@ namespace ElmSharp { public abstract class EvasObject { + private IntPtr _realHandle = IntPtr.Zero; internal IntPtr Handle { get; set; } internal EvasObject Parent { get; set; } + internal IntPtr RealHandle + { + get + { + return _realHandle == IntPtr.Zero ? Handle : _realHandle; + } + set + { + _realHandle = value; + } + } EvasObjectEvent _deleted; EvasObjectEvent _keyup; @@ -136,13 +148,13 @@ namespace ElmSharp get { int w, h; - Interop.Evas.evas_object_size_hint_min_get(Handle, out w, out h); + Interop.Evas.evas_object_size_hint_min_get(RealHandle, out w, out h); return w; } set { int h = MinimumHeight; - Interop.Evas.evas_object_size_hint_min_set(Handle, value, h); + Interop.Evas.evas_object_size_hint_min_set(RealHandle, value, h); } } @@ -151,13 +163,13 @@ namespace ElmSharp get { int w, h; - Interop.Evas.evas_object_size_hint_min_get(Handle, out w, out h); + Interop.Evas.evas_object_size_hint_min_get(RealHandle, out w, out h); return h; } set { int w = MinimumWidth; - Interop.Evas.evas_object_size_hint_min_set(Handle, w, value); + Interop.Evas.evas_object_size_hint_min_set(RealHandle, w, value); } } @@ -227,11 +239,11 @@ namespace ElmSharp { get { - return Interop.Evas.evas_object_repeat_events_get(Handle); + return Interop.Evas.evas_object_repeat_events_get(RealHandle); } set { - Interop.Evas.evas_object_repeat_events_set(Handle, value); + Interop.Evas.evas_object_repeat_events_set(RealHandle, value); } } @@ -239,11 +251,11 @@ namespace ElmSharp { get { - return Interop.Evas.evas_object_propagate_events_get(Handle); + return Interop.Evas.evas_object_propagate_events_get(RealHandle); } set { - Interop.Evas.evas_object_propagate_events_set(Handle, value); + Interop.Evas.evas_object_propagate_events_set(RealHandle, value); } } @@ -251,11 +263,11 @@ namespace ElmSharp { get { - return Interop.Evas.evas_object_pass_events_get(Handle); + return Interop.Evas.evas_object_pass_events_get(RealHandle); } set { - Interop.Evas.evas_object_pass_events_set(Handle, value); + Interop.Evas.evas_object_pass_events_set(RealHandle, value); } } @@ -318,7 +330,7 @@ namespace ElmSharp public void MarkChanged() { - Interop.Evas.evas_object_smart_changed(Handle); + Interop.Evas.evas_object_smart_changed(RealHandle); } protected virtual void OnInvalidate() diff --git a/ElmSharp/ElmSharp/Table.cs b/ElmSharp/ElmSharp/Table.cs index 252e6d0..7b1792c 100644 --- a/ElmSharp/ElmSharp/Table.cs +++ b/ElmSharp/ElmSharp/Table.cs @@ -31,11 +31,11 @@ namespace ElmSharp { get { - return Interop.Elementary.elm_table_homogeneous_get(GetRealHandle(Handle)); + return Interop.Elementary.elm_table_homogeneous_get(RealHandle); } set { - Interop.Elementary.elm_table_homogeneous_set(GetRealHandle(Handle), value); + Interop.Elementary.elm_table_homogeneous_set(RealHandle, value); } } @@ -48,7 +48,7 @@ namespace ElmSharp set { _paddingX = value; - Interop.Elementary.elm_table_padding_set(GetRealHandle(Handle), _paddingX, _paddingY); + Interop.Elementary.elm_table_padding_set(RealHandle, _paddingX, _paddingY); } } @@ -61,7 +61,7 @@ namespace ElmSharp set { _paddingY = value; - Interop.Elementary.elm_table_padding_set(GetRealHandle(Handle), _paddingX, _paddingY); + Interop.Elementary.elm_table_padding_set(RealHandle, _paddingX, _paddingY); } } @@ -69,7 +69,7 @@ namespace ElmSharp { if (obj == null) throw new ArgumentNullException("obj"); - Interop.Elementary.elm_table_pack(GetRealHandle(Handle), obj, col, row, colspan, rowspan); + Interop.Elementary.elm_table_pack(RealHandle, obj, col, row, colspan, rowspan); AddChild(obj); } @@ -77,13 +77,13 @@ namespace ElmSharp { if (obj == null) throw new ArgumentNullException("obj"); - Interop.Elementary.elm_table_unpack(GetRealHandle(Handle), obj); + Interop.Elementary.elm_table_unpack(RealHandle, obj); RemoveChild(obj); } public void Clear() { - Interop.Elementary.elm_table_clear(GetRealHandle(Handle), false); + Interop.Elementary.elm_table_clear(RealHandle, false); ClearChildren(); } @@ -92,8 +92,8 @@ namespace ElmSharp IntPtr handle = Interop.Elementary.elm_layout_add(parent); Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default"); - IntPtr realHandle = Interop.Elementary.elm_table_add(handle); - Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", realHandle); + RealHandle = Interop.Elementary.elm_table_add(handle); + Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle); return handle; } -- 2.7.4 From 5b3b8dedcde3b1cfe858ce23e8a04240c8247f9b Mon Sep 17 00:00:00 2001 From: JEONGHYUN YUN Date: Mon, 12 Dec 2016 16:46:13 +0900 Subject: [PATCH 12/16] Modified TV theme for fixing build error Change-Id: Id1ee95b4dc7dca5350d3ebfa47f1ad487d5a825d Signed-off-by: JEONGHYUN YUN --- ElmSharp/theme/tv/elm-sharp-theme-tv.edc | 33 -------------------------------- 1 file changed, 33 deletions(-) diff --git a/ElmSharp/theme/tv/elm-sharp-theme-tv.edc b/ElmSharp/theme/tv/elm-sharp-theme-tv.edc index 854cb80..8233fbe 100644 --- a/ElmSharp/theme/tv/elm-sharp-theme-tv.edc +++ b/ElmSharp/theme/tv/elm-sharp-theme-tv.edc @@ -51,42 +51,9 @@ data.item: "version" "110"; collections { base_scale: BASE_SCALE_INC; - /*plugins { - plugin { - name: "touch_sound"; - source: "feedback"; - param: "FEEDBACK_TYPE_SOUND FEEDBACK_PATTERN_TAP"; // FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TOUCH_TAP - - /* 2014.06.11 updated from libsvi(feedback) - Above plugin will run below external function: - int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern); - - param1: feedback_type_e - FEEDBACK_TYPE_NONE = 0, - FEEDBACK_TYPE_SOUND = 1, - FEEDBACK_TYPE_VIBRATION, - FEEDBACK_TYPE_LED, - FEEDBACK_TYPE_END - - * param2 enumeration: - FEEDBACK_PATTERN_TAP = 0, - FEEDBACK_PATTERN_SIP, - FEEDBACK_PATTERN_SIP_BACKSPACE, - FEEDBACK_PATTERN_SIP_FUNCTION, - FEEDBACK_PATTERN_SIP_FJKEY, - ... - - * For more information please refer libsvi. - */ - } - }*/ #include "color_classes.edc" -//#include "widgets/colorselector.edc" -//#include "widgets/entry.edc" -//#include "widgets/label.edc" -//#include "widgets/radio.edc" #include "widgets/layout.edc" } -- 2.7.4 From e31d4d977df743249eb3fb986672a0f5eb3ee252 Mon Sep 17 00:00:00 2001 From: Seungkeun Lee Date: Tue, 29 Nov 2016 13:32:35 +0900 Subject: [PATCH 13/16] Add recycle cache feature in genlist Change-Id: I9da339419dbfadb81ae991f9c97f59d6f1f8ba3a --- ElmSharp.Test/ElmSharp.Test.csproj | 3 +- ElmSharp.Test/TC/GenListTest8.cs | 111 +++++++++++++++++++++++++++++++++++++ ElmSharp/ElmSharp/GenItemClass.cs | 53 ++++++++++++++---- 3 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 ElmSharp.Test/TC/GenListTest8.cs diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj index b019daa..a532bdc 100644 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -64,6 +64,7 @@ + @@ -182,4 +183,4 @@ - \ No newline at end of file + diff --git a/ElmSharp.Test/TC/GenListTest8.cs b/ElmSharp.Test/TC/GenListTest8.cs new file mode 100644 index 0000000..6316235 --- /dev/null +++ b/ElmSharp.Test/TC/GenListTest8.cs @@ -0,0 +1,111 @@ +/* + * 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 ElmSharp; +using System.Collections.Generic; + +namespace ElmSharp.Test +{ + class GenListTest8 : TestCaseBase + { + + Dictionary _cacheMap = new Dictionary(); + public override string TestName => "GenListTest8"; + public override string TestDescription => "To test group operation of GenList"; + + public override void Run(Window window) + { + Background bg = new Background(window) + { + Color = Color.White, + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + bg.Show(); + bg.Lower(); + + window.AddResizeObject(bg); + Conformant conformant = new Conformant(window); + conformant.Show(); + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + Check check = new Check(window); + check.Show(); + check.IsChecked = true; + check.Text = "Reuse?"; + + GenList list = new GenList(window) + { + Homogeneous = false, + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + + GenItemClass fullyCustomizeClass = new GenItemClass("full") + { + GetContentHandler = (obj, part) => + { + Console.WriteLine("{0} part create requested", part); + var btn = new Button(window) + { + AlignmentX = -1, + WeightX = 1, + Text = (string)obj + }; + return btn; + }, + ReusableContentHandler = (object data, string part, EvasObject old) => + { + Console.WriteLine("{0} part reuse requested", part); + if (!check.IsChecked) + { + return null; + } + var btn = old as Button; + btn.Text = (string)data; + return old; + } + }; + + for (int i = 0; i < 100; i++) + { + list.Append(fullyCustomizeClass, string.Format("{0} Item", i), GenListItemType.Normal); + } + + list.Show(); + list.ItemSelected += List_ItemSelected; ; + box.Show(); + box.PackEnd(check); + box.PackEnd(list); + conformant.SetContent(box); + } + + private void List_ItemSelected(object sender, GenListItemEventArgs e) + { + Console.WriteLine("{0} Item was selected", (string)(e.Item.Data)); + } + } +} diff --git a/ElmSharp/ElmSharp/GenItemClass.cs b/ElmSharp/ElmSharp/GenItemClass.cs index 944b700..0ece261 100644 --- a/ElmSharp/ElmSharp/GenItemClass.cs +++ b/ElmSharp/ElmSharp/GenItemClass.cs @@ -15,15 +15,18 @@ */ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; namespace ElmSharp { public class GenItemClass : IDisposable { + private static Dictionary s_HandleToEvasObject = new Dictionary(); public delegate string GetTextDelegate(object data, string part); public delegate EvasObject GetContentDelegate(object data, string part); public delegate void DeleteDelegate(object data); + public delegate EvasObject GetReusableContentDelegate(object data, string part, EvasObject old); private ItemClass _itemClass; private IntPtr _unmanagedPtr = IntPtr.Zero; @@ -32,16 +35,16 @@ namespace ElmSharp public GenItemClass(string style) { _style = style; - _itemClass = new ItemClass() - { - refCount = 1, - deleteMe = 0, - itemStyle = style, - textCallback = GetTextCallback, - contentCallback = GetContentCallback, - stateCallback = null, - delCallback = DelCallback, - }; + IntPtr unmanaged = Interop.Elementary.elm_genlist_item_class_new(); + _itemClass = Marshal.PtrToStructure(unmanaged); + _itemClass.itemStyle = style; + _itemClass.textCallback = GetTextCallback; + _itemClass.contentCallback = GetContentCallback; + _itemClass.stateCallback = null; + _itemClass.delCallback = DelCallback; + _itemClass.reusableContentCallback = GetReusableContentCallback; + + Interop.Elementary.elm_genlist_item_class_free(unmanaged); } ~GenItemClass() @@ -53,6 +56,7 @@ namespace ElmSharp public GetTextDelegate GetTextHandler { get; set; } public GetContentDelegate GetContentHandler { get; set; } public DeleteDelegate DeleteHandler { get; set; } + public GetReusableContentDelegate ReusableContentHandler { get; set; } internal IntPtr UnmanagedPtr { @@ -99,7 +103,30 @@ namespace ElmSharp private IntPtr GetContentCallback(IntPtr data, IntPtr obj, IntPtr part) { GenItem item = ItemObject.GetItemById((int)data) as GenItem; - return GetContentHandler?.Invoke(item?.Data, Marshal.PtrToStringAnsi(part)); + EvasObject evasObject = GetContentHandler?.Invoke(item?.Data, Marshal.PtrToStringAnsi(part)); + if (evasObject != null) + { + s_HandleToEvasObject[evasObject.Handle] = evasObject; + evasObject.Deleted += EvasObjectDeleted; + } + return evasObject; + } + + private void EvasObjectDeleted(object sender, EventArgs e) + { + IntPtr handle = (sender as EvasObject).Handle; + s_HandleToEvasObject.Remove(handle); + } + + private IntPtr GetReusableContentCallback(IntPtr data, IntPtr obj, IntPtr part, IntPtr old) + { + IntPtr reusedHandle = IntPtr.Zero; + GenItem item = ItemObject.GetItemById((int)data) as GenItem; + if (s_HandleToEvasObject.ContainsKey(old)) + { + reusedHandle = ReusableContentHandler?.Invoke(item?.Data, Marshal.PtrToStringAnsi(part), s_HandleToEvasObject[old]); + } + return reusedHandle; } private void DelCallback(IntPtr data, IntPtr obj) { @@ -120,8 +147,9 @@ namespace ElmSharp public delegate int GetStateCallback(IntPtr data, IntPtr obj, IntPtr part); public delegate void DelCallback(IntPtr data, IntPtr obj); public delegate int FilterCallback(IntPtr data, IntPtr obj, IntPtr key); + public delegate IntPtr GetReusableContentCallback(IntPtr data, IntPtr obj, IntPtr part, IntPtr old); - public readonly int version; + public int version; public uint refCount; public int deleteMe; public string itemStyle; @@ -132,6 +160,7 @@ namespace ElmSharp public GetStateCallback stateCallback; public DelCallback delCallback; public FilterCallback filterCallback; + public GetReusableContentCallback reusableContentCallback; } } -- 2.7.4 From a206b44f4245d63d29d048b2897d17d442a0e3e5 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Mon, 12 Dec 2016 21:06:08 +0900 Subject: [PATCH 14/16] Support Image.BackgroundColor Change-Id: I4cd5296f2849bf6f4abeeea7997ce2703d835547 --- ElmSharp.Test/ElmSharp.Test.csproj | 1 + ElmSharp.Test/TC/ImageTest2.cs | 124 +++++++++++++++++++++++++++++++++++++ ElmSharp/ElmSharp/Image.cs | 108 +++++++++++++++++++------------- 3 files changed, 190 insertions(+), 43 deletions(-) create mode 100644 ElmSharp.Test/TC/ImageTest2.cs 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 @@ + 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 = "" + text + ""; + } + } +} 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(); @@ -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(); @@ -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; } } -- 2.7.4 From 15b1479b837ef0e558bcb870679c0ae322a127ac Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Wed, 14 Dec 2016 14:26:53 +0900 Subject: [PATCH 15/16] Add ExcludeArch for aarch64 and %ix86 Change-Id: Ib4f210fda30d8b3f9c72b1eac15feff66298a9df --- packaging/elm-sharp.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index 01a1c14..4ff9645 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -19,6 +19,7 @@ Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest AutoReqProv: no +ExcludeArch: aarch64 %ix86 BuildRequires: mono-compiler BuildRequires: mono-devel -- 2.7.4 From 8994c6cb67c5badb66755d82b78564d9fe3044f1 Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Mon, 19 Dec 2016 18:47:19 +0900 Subject: [PATCH 16/16] Apply dotnet RPM macros Change-Id: Icd1c12d0b16e67c6767a4cbee63aa458db8c1332 Signed-off-by: WonYoung Choi --- packaging/elm-sharp.spec | 52 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 42 deletions(-) diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index 4ff9645..078d9fd 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -1,11 +1,3 @@ -%{!?dotnet_assembly_path: %define dotnet_assembly_path /opt/usr/share/dotnet.tizen/framework} - -%if 0%{?tizen_build_devel_mode} -%define BUILDCONF Debug -%else -%define BUILDCONF Release -%endif - %define DEV_VERSION beta-002 Name: elm-sharp @@ -21,29 +13,24 @@ Source1: %{name}.manifest AutoReqProv: no ExcludeArch: aarch64 %ix86 -BuildRequires: mono-compiler -BuildRequires: mono-devel - BuildRequires: dotnet-build-tools BuildRequires: edje-tools +%define Assemblies ElmSharp + %description -C# Binding for Elementary +%{summary} + +%dotnet_import_sub_packages %prep %setup -q cp %{SOURCE1} . -%define Assemblies ElmSharp - %build for ASM in %{Assemblies}; do -# NuGet Restore -find $ASM/*.project.json -exec nuget restore {} \; -# Build -find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \; -# NuGet Pack -nuget pack $ASM/$ASM.nuspec -Version %{version}%{?DEV_VERSION:-%{DEV_VERSION}} -Properties Configuration=%{BUILDCONF} +%dotnet_build $ASM +%dotnet_pack $ASM/$ASM.nuspec %{version}%{?DEV_VERSION:-%{DEV_VERSION}} done edje_cc -id ElmSharp/theme/%{profile}/HD/images/ \ @@ -51,34 +38,15 @@ edje_cc -id ElmSharp/theme/%{profile}/HD/images/ \ ElmSharp/theme/%{profile}/elm-sharp-theme-%{profile}.edc ElmSharp/theme/elm-sharp-theme.edj %install -# Runtime Binary -mkdir -p %{buildroot}%{dotnet_assembly_path} for ASM in %{Assemblies}; do -%if 0%{?_with_corefx} - install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path} -%else - install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path} -%endif +%dotnet_install $ASM done -# NuGet -mkdir -p %{buildroot}/nuget -install -p -m 644 *.nupkg %{buildroot}/nuget -# Theme + mkdir %{buildroot}%{_datadir}/edje/elm-sharp -p install -m 644 ElmSharp/theme/elm-sharp-theme.edj %{buildroot}%{_datadir}/edje/elm-sharp/ %files %manifest %{name}.manifest %license LICENSE -%attr(644,root,root) %{dotnet_assembly_path}/*.dll +%attr(644,root,root) %{dotnet_assembly_files} %attr(644,root,root) %{_datadir}/edje/elm-sharp/*.edj - -%package nuget -Summary: NuGet package for %{name} -Group: Development/Libraries - -%description nuget -NuGet package for %{name} - -%files nuget -/nuget/*.nupkg -- 2.7.4