From c9695a06e131368597a90fbaf59597f7e81220a0 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Mon, 5 Dec 2016 10:21:37 +0900 Subject: [PATCH 01/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 02/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 03/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 04/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 05/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 06/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 07/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 08/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 09/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 10/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 11/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 From 0bfeda35eb7923923cd323987c63df782e7c3f58 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Tue, 20 Dec 2016 08:03:09 +0900 Subject: [PATCH 12/16] Fix for setting image loading events Change-Id: I1fcda10ed92aae011bac35d62999b262d1c47ca9 --- ElmSharp/ElmSharp/Image.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ElmSharp/ElmSharp/Image.cs b/ElmSharp/ElmSharp/Image.cs index 2c99bcb..fece740 100644 --- a/ElmSharp/ElmSharp/Image.cs +++ b/ElmSharp/ElmSharp/Image.cs @@ -323,7 +323,7 @@ namespace ElmSharp } }); - SmartEvent loadReady = new SmartEvent(this, Handle, "load,ready"); + SmartEvent loadReady = new SmartEvent(this, RealHandle, "load,ready"); loadReady.On += (s, e) => { loadReady.Dispose(); @@ -334,7 +334,7 @@ namespace ElmSharp } }; - SmartEvent loadError = new SmartEvent(this, Handle, "load,error"); + SmartEvent loadError = new SmartEvent(this, RealHandle, "load,error"); loadError.On += (s, e) => { loadError.Dispose(); -- 2.7.4 From 61f9eb3847a0b33a00ef790745173d49d02bd389 Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Mon, 26 Dec 2016 13:46:44 +0900 Subject: [PATCH 13/16] Remove %ix86 from ExcludeArch and update dev version Change-Id: I827c0013f9b5fae89c3f51e13dd1224f1ee1becc --- packaging/elm-sharp.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index 078d9fd..b65451b 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -1,4 +1,4 @@ -%define DEV_VERSION beta-002 +%define DEV_VERSION beta-003 Name: elm-sharp Summary: C# Binding for Elementary @@ -11,7 +11,7 @@ Source0: %{name}-%{version}.tar.gz Source1: %{name}.manifest AutoReqProv: no -ExcludeArch: aarch64 %ix86 +ExcludeArch: aarch64 BuildRequires: dotnet-build-tools BuildRequires: edje-tools -- 2.7.4 From 25256d3af9366a33b82553a58dfb3b1da868d412 Mon Sep 17 00:00:00 2001 From: chungryeol lim Date: Fri, 16 Dec 2016 14:54:29 +0900 Subject: [PATCH 14/16] Add NaviItem.TitleBarBackgroundColor property Change-Id: Ic444c2b7fda2c03de81e341604cac9f3ff65ad21 Signed-off-by: chungryeol lim --- ElmSharp.Test/TC/NaviframeTest2.cs | 21 ++++++++++++++++++++- ElmSharp/ElmSharp/ItemObject.cs | 15 +++++++++++++++ ElmSharp/ElmSharp/NaviItem.cs | 22 ++++++++++++++++++++++ ElmSharp/Interop/Interop.Elementary.cs | 9 +++++++++ packaging/elm-sharp.spec | 2 +- 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/ElmSharp.Test/TC/NaviframeTest2.cs b/ElmSharp.Test/TC/NaviframeTest2.cs index 342fd9c..3de3e41 100644 --- a/ElmSharp.Test/TC/NaviframeTest2.cs +++ b/ElmSharp.Test/TC/NaviframeTest2.cs @@ -87,12 +87,20 @@ namespace ElmSharp.Test AlignmentX = -1, }; + Button barChange = new Button(parent) + { + Text = "TitleTextColor & BarColor", + WeightX = 1, + AlignmentX = -1, + }; + label.Show(); push.Show(); pop.Show(); insertBeforeTop.Show(); insertAfterTop.Show(); removeTop.Show(); + barChange.Show(); push.Clicked += (s, e) => { @@ -125,13 +133,24 @@ namespace ElmSharp.Test item.Delete(); Console.WriteLine("----- After Call NaviItem.Delete() {0:x} ", nativePointer); }; - + + Random rand = new Random(DateTime.Now.Millisecond); + barChange.Clicked += (s, e) => + { + int currentIndex = _navi.NavigationStack.Count - 1; + if (currentIndex >= 0) + { + _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.FromHex(string.Format("#{0:X8}", rand.Next())); + } + }; + box.PackEnd(label); box.PackEnd(push); box.PackEnd(pop); box.PackEnd(insertBeforeTop); box.PackEnd(insertAfterTop); box.PackEnd(removeTop); + box.PackEnd(barChange); return box; } diff --git a/ElmSharp/ElmSharp/ItemObject.cs b/ElmSharp/ElmSharp/ItemObject.cs index 9b9847a..b2dbd58 100644 --- a/ElmSharp/ElmSharp/ItemObject.cs +++ b/ElmSharp/ElmSharp/ItemObject.cs @@ -109,6 +109,21 @@ namespace ElmSharp return Interop.Elementary.elm_object_item_part_text_get(Handle, part); } + public void SetPartColor(string part, Color color) + { + Interop.Elementary.elm_object_item_color_class_color_set(Handle, part, color.R * color.A / 255, + color.G * color.A / 255, + color.B * color.A / 255, + color.A); + } + + public Color GetPartColor(string part) + { + int r, g, b, a; + Interop.Elementary.elm_object_item_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); + } + public static implicit operator IntPtr(ItemObject obj) { if (obj == null) diff --git a/ElmSharp/ElmSharp/NaviItem.cs b/ElmSharp/ElmSharp/NaviItem.cs index d2be412..3e92445 100644 --- a/ElmSharp/ElmSharp/NaviItem.cs +++ b/ElmSharp/ElmSharp/NaviItem.cs @@ -22,6 +22,7 @@ namespace ElmSharp { EvasObject _content; bool _isPopped; + Color _barBackgroundColor = Color.Default; Interop.Elementary.Elm_Naviframe_Item_Pop_Cb _popped; NaviItem(IntPtr handle, EvasObject content) : base(handle) @@ -56,6 +57,27 @@ namespace ElmSharp } } + public Color TitleBarBackgroundColor + { + get + { + return _barBackgroundColor; + } + set + { + if (value.IsDefault) + { + Console.WriteLine("ItemObject instance doesn't support to set TitleBarBackgroundColor to Color.Default."); + //TODO. Soon we will support the "elm_object_item_color_class_del" function in EFL. + } + else + { + SetPartColor("bg_title", value); + _barBackgroundColor = value; + } + } + } + protected override void OnInvalidate() { if (!_isPopped) diff --git a/ElmSharp/Interop/Interop.Elementary.cs b/ElmSharp/Interop/Interop.Elementary.cs index c96a471..4488d14 100755 --- a/ElmSharp/Interop/Interop.Elementary.cs +++ b/ElmSharp/Interop/Interop.Elementary.cs @@ -173,6 +173,15 @@ internal static partial class Interop } [DllImport(Libraries.Elementary)] + internal static extern void elm_object_item_color_class_color_set(IntPtr it, string part, int r, int g, int b, int a); + + [DllImport(Libraries.Elementary)] + internal static extern void elm_object_item_color_class_color_get(IntPtr obj, string part, out int r, out int g, out int b, out int a); + + [DllImport(Libraries.Elementary)] + internal static extern void elm_object_item_color_class_del(IntPtr obj, string part); + + [DllImport(Libraries.Elementary)] internal static extern void elm_object_item_part_text_set(IntPtr obj, string part, string label); [DllImport(Libraries.Elementary)] diff --git a/packaging/elm-sharp.spec b/packaging/elm-sharp.spec index b65451b..e6191ee 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -1,4 +1,4 @@ -%define DEV_VERSION beta-003 +%define DEV_VERSION beta-004 Name: elm-sharp Summary: C# Binding for Elementary -- 2.7.4 From 662a44ea670abb40844096b486d97162969ede41 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Tue, 27 Dec 2016 10:10:23 +0900 Subject: [PATCH 15/16] Fix Image.Color behavior correctly - Color.Default is now available on Image.Color - ImageTest3 which is to test Image.color has been added. Change-Id: I5ad9042e49d124b36bff3227bec007659734fc28 --- ElmSharp.Test/ElmSharp.Test.csproj | 4 +- ElmSharp.Test/TC/ImageTest2.cs | 2 +- ElmSharp.Test/TC/ImageTest3.cs | 135 +++++++++++++++++++++++++++++++++++++ ElmSharp.Test/res/btn_delete.png | Bin 0 -> 3826 bytes ElmSharp/ElmSharp/Image.cs | 21 +++--- 5 files changed, 152 insertions(+), 10 deletions(-) create mode 100644 ElmSharp.Test/TC/ImageTest3.cs create mode 100644 ElmSharp.Test/res/btn_delete.png diff --git a/ElmSharp.Test/ElmSharp.Test.csproj b/ElmSharp.Test/ElmSharp.Test.csproj index e89c87a..b874efe 100644 --- a/ElmSharp.Test/ElmSharp.Test.csproj +++ b/ElmSharp.Test/ElmSharp.Test.csproj @@ -63,6 +63,7 @@ + @@ -103,6 +104,7 @@ + PreserveNewest @@ -184,4 +186,4 @@ - + \ No newline at end of file diff --git a/ElmSharp.Test/TC/ImageTest2.cs b/ElmSharp.Test/TC/ImageTest2.cs index 3243c24..b82f357 100644 --- a/ElmSharp.Test/TC/ImageTest2.cs +++ b/ElmSharp.Test/TC/ImageTest2.cs @@ -118,7 +118,7 @@ namespace ElmSharp.Test void UpdateLabelText(string text) { - lbInfo.Text = "" + text + ""; + lbInfo.Text = " BackgroundColor => " + text + ""; } } } diff --git a/ElmSharp.Test/TC/ImageTest3.cs b/ElmSharp.Test/TC/ImageTest3.cs new file mode 100644 index 0000000..db3617b --- /dev/null +++ b/ElmSharp.Test/TC/ImageTest3.cs @@ -0,0 +1,135 @@ +/* + * 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 ImageTest3 : TestCaseBase + { + public override string TestName => "ImageTest3"; + 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(); + + Box buttonBox2 = new Box(window) { + IsHorizontal = true, + AlignmentX = -1, + AlignmentY = 0, + }; + buttonBox2.Show(); + + Button btnFile1 = new Button(window) { + Text = "Blue (BG)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + btnFile1.Show(); + + Button btnFile2 = new Button(window) { + Text = "Default (BG)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + btnFile2.Show(); + + Button btnFile3 = new Button(window) { + Text = "Blue (FG)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + btnFile3.Show(); + + Button btnFile4 = new Button(window) { + Text = "Default (FG)", + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1 + }; + btnFile4.Show(); + + buttonBox1.PackEnd(btnFile1); + buttonBox1.PackEnd(btnFile2); + buttonBox2.PackEnd(btnFile3); + buttonBox2.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, "btn_delete.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.Color = Color.Blue; UpdateLabelText(image.Color.ToString(), false); }; + btnFile4.Clicked += (s, e) => { image.Color = Color.Default; UpdateLabelText(image.Color.ToString(), false); }; + + box.PackEnd(buttonBox1); + box.PackEnd(buttonBox2); + box.PackEnd(lbInfo); + box.PackEnd(image); + } + + void UpdateLabelText(string text, bool isBackground = true) + { + if(isBackground) + lbInfo.Text = " Background Color => " + text + ""; + else + lbInfo.Text = " Foreground Color => " + text + ""; + } + } +} diff --git a/ElmSharp.Test/res/btn_delete.png b/ElmSharp.Test/res/btn_delete.png new file mode 100644 index 0000000000000000000000000000000000000000..7bafac6e1097179114779259a15ff5ec7459bcc7 GIT binary patch literal 3826 zcmVKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000CXNkl$r{V{D=(wS`)Y*xJ(ac+s=TWHP7S-JY5K z>XYov%An=EV05A?51m2-|GzA<3 zJ_7EA2`~X126j-K`VH6!{1^tn1keGrQ{4I&Xh}hI1uy{|2ewff`U7|o7>YXxRt9vI z5Ilfqfsb8`z;g43+Dz%`F;HJNj{r&F6!0dcsW|XcX{#?AfJxvh;58OB zlIcsN0yrB1yeZ%k(C;|zFz_|-yQ6ruNJ{s!NK%)=*JDZRJojyvH02;}ucR6i^9f1U zT_l?>yv33(C>s3`aR06Igm_g_r7z}NE|N{>5nc>@1FVT?URi49S+7o;b>>tS@h$^v zfrq~1&pF9Mfp|_*MZon< zl15!87XpeZkbu9*7 zW!RQXM*+dZET}t;k!#bd!1=J@rAFWwu&4l?kPm^+ES1v$P#2Xc*j0e=I)Qzbb7R0J z;GZZGiAj3O%z=#s0`C|zd(Lysfve0MSRM8V90gVbw+aAWhXvlt0R}`L&1;CVze<_FXKC!^tENL>0@Ap_Bz94Bh z3VKxT=M->5VxJv@Nv8WZoNtaecP}UoP_upAhUI~>mM8pE^L z_0X(9hEt9-jv*c@VtBurt%93gOW*YZ_ Date: Mon, 2 Jan 2017 07:59:15 +0900 Subject: [PATCH 16/16] Update version to beta-005 Change-Id: Ic3784086add008954a4c452068e30ef7dabd8447 --- 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 e6191ee..6351538 100644 --- a/packaging/elm-sharp.spec +++ b/packaging/elm-sharp.spec @@ -1,4 +1,4 @@ -%define DEV_VERSION beta-004 +%define DEV_VERSION beta-005 Name: elm-sharp Summary: C# Binding for Elementary -- 2.7.4