From 29ae5e9ea7a958ad411922275f23bd01e71adcd1 Mon Sep 17 00:00:00 2001 From: JEONGHYUN YUN Date: Mon, 31 Oct 2016 13:24:38 +0900 Subject: 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,4 +1,11 @@ color_classes { + /* + * Layout + */ + color_class { + name: "layout/background/bg"; + color: 0 0 0 0; + } /* * Colorselector */ 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"; } + } + } +} -- cgit v1.2.3