From 39a12ab38abc6c17c02ebb3b7a0a77131f97b6e1 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Wed, 26 Jul 2017 14:08:12 +0900 Subject: [PATCH] Adds Elementary.FocusAutoScrollMode Change-Id: Ie9c5dd823f7baf47d15924f8fbcba49e4cded2bd --- src/ElmSharp/ElmSharp.csproj | 2 +- src/ElmSharp/ElmSharp/Elementary.cs | 34 ++++ src/ElmSharp/Interop/Interop.Elementary.cs | 12 ++ test/ElmSharp.Test/ElmSharp.Test.csproj | 1 + test/ElmSharp.Test/TC/FocusAutoScrollModeTest.cs | 203 +++++++++++++++++++++++ 5 files changed, 251 insertions(+), 1 deletion(-) mode change 100755 => 100644 test/ElmSharp.Test/ElmSharp.Test.csproj create mode 100644 test/ElmSharp.Test/TC/FocusAutoScrollModeTest.cs diff --git a/src/ElmSharp/ElmSharp.csproj b/src/ElmSharp/ElmSharp.csproj index ed2b646..3016921 100644 --- a/src/ElmSharp/ElmSharp.csproj +++ b/src/ElmSharp/ElmSharp.csproj @@ -1,7 +1,7 @@  - 1.2.2 + 1.2.3 Samsung Electronics © Samsung Electronics Co., Ltd All Rights Reserved diff --git a/src/ElmSharp/ElmSharp/Elementary.cs b/src/ElmSharp/ElmSharp/Elementary.cs index cf26c57..a83be9f 100644 --- a/src/ElmSharp/ElmSharp/Elementary.cs +++ b/src/ElmSharp/ElmSharp/Elementary.cs @@ -21,6 +21,25 @@ using System.IO; namespace ElmSharp { /// + /// Focus Autoscroll Mode + /// + public enum FocusAutoScrollMode + { + /// + /// Directly show the focused region or item automatically + /// + Show, + /// + /// Do not show the focused region or item automatically + /// + None, + /// + /// Bring in the focused region or item automatically which might invole the scrolling + /// + BringIn + } + + /// /// The Elementary is a General Elementary,a VERY SIMPLE toolkit. /// public static class Elementary @@ -134,6 +153,21 @@ namespace ElmSharp } /// + /// Gets of sets focus auto scroll mode. + /// + public static FocusAutoScrollMode FocusAutoScrollMode + { + get + { + return (FocusAutoScrollMode)Interop.Elementary.elm_config_focus_autoscroll_mode_get(); + } + set + { + Interop.Elementary.elm_config_focus_autoscroll_mode_set((Interop.Elementary.Elm_Focus_Autoscroll_Mode)value); + } + } + + /// /// Initializes Elementary. /// public static void Initialize() diff --git a/src/ElmSharp/Interop/Interop.Elementary.cs b/src/ElmSharp/Interop/Interop.Elementary.cs index 3791d11..2da2a60 100644 --- a/src/ElmSharp/Interop/Interop.Elementary.cs +++ b/src/ElmSharp/Interop/Interop.Elementary.cs @@ -55,6 +55,12 @@ internal static partial class Interop // A message with a struct containing a string and list of floating point numbers as value. Use #Edje_Message_String_Float_Set structs as message body, for this type. EDJE_MESSAGE_STRING_FLOAT_SET = 11 } + internal enum Elm_Focus_Autoscroll_Mode + { + ELM_FOCUS_AUTOSCROLL_MODE_SHOW, + ELM_FOCUS_AUTOSCROLL_MODE_NONE, + ELM_FOCUS_AUTOSCROLL_MODE_BRING_IN + } [DllImport(Libraries.Elementary)] internal static extern void elm_config_scroll_bring_in_scroll_friction_set(double time); @@ -63,6 +69,12 @@ internal static partial class Interop internal static extern double elm_config_scroll_bring_in_scroll_friction_get(); [DllImport(Libraries.Elementary)] + internal static extern void elm_config_focus_autoscroll_mode_set(Elm_Focus_Autoscroll_Mode mode); + + [DllImport(Libraries.Elementary)] + internal static extern Elm_Focus_Autoscroll_Mode elm_config_focus_autoscroll_mode_get(); + + [DllImport(Libraries.Elementary)] internal static extern IntPtr elm_config_accel_preference_set(string preference); [DllImport(Libraries.Elementary)] diff --git a/test/ElmSharp.Test/ElmSharp.Test.csproj b/test/ElmSharp.Test/ElmSharp.Test.csproj old mode 100755 new mode 100644 index 0dcab8b..e044e7b --- a/test/ElmSharp.Test/ElmSharp.Test.csproj +++ b/test/ElmSharp.Test/ElmSharp.Test.csproj @@ -47,6 +47,7 @@ + diff --git a/test/ElmSharp.Test/TC/FocusAutoScrollModeTest.cs b/test/ElmSharp.Test/TC/FocusAutoScrollModeTest.cs new file mode 100644 index 0000000..c0aa049 --- /dev/null +++ b/test/ElmSharp.Test/TC/FocusAutoScrollModeTest.cs @@ -0,0 +1,203 @@ +/* + * 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 FocusAutoScrollModeTest : TestCaseBase + { + public override string TestName => "FocusAutoScrollModeTest"; + public override string TestDescription => "To test basic operation of Elementary.FocusAutoScrollMode"; + + public override void Run(Window window) + { + Conformant conformant = new Conformant(window); + conformant.Show(); + GenGrid grid = new GenGrid(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + ItemAlignmentX = -1, + ItemAlignmentY = -1, + ItemWidth = window.ScreenSize.Width / 3, + ItemHeight = window.ScreenSize.Width / 3, + }; + + GenItemClass defaultClass = new GenItemClass("default") + { + GetTextHandler = (obj, part) => + { + Color item = (Color)obj; + return String.Format("#{0:X}{1:X}{2:X}", item.R, item.G, item.B); + }, + GetContentHandler = (obj, part) => + { + Color item = (Color)obj; + if (part == "elm.swallow.icon") + { + var colorbox = new Rectangle(window) + { + Color = item + }; + return colorbox; + } + return null; + } + + }; + + GenGridItem firstitem = null; + GenGridItem lastitem = null; + + var rnd = new Random(); + for (int i = 0; i < 102; i++) + { + int r = rnd.Next(255); + int g = rnd.Next(255); + int b = rnd.Next(255); + Color color = Color.FromRgb(r, g, b); + var item = grid.Append(defaultClass, color); + if (i == 0) + firstitem = item; + if (i == 101) + lastitem = item; + } + grid.Show(); + Box box = new Box(window) + { + AlignmentX = -1, + AlignmentY = -1, + WeightX = 1, + WeightY = 1, + }; + box.Show(); + conformant.SetContent(box); + + box.PackEnd(grid); + + Button show = new Button(window) + { + Text = "Show", + AlignmentX = -1, + WeightX = 1, + }; + Button none = new Button(window) + { + Text = "None", + AlignmentX = -1, + WeightX = 1, + }; + Button bringIn = new Button(window) + { + Text = "BringIn", + AlignmentX = -1, + WeightX = 1, + }; + + show.Clicked += (s, e) => + { + Elementary.FocusAutoScrollMode = FocusAutoScrollMode.Show; + Console.WriteLine("FocusAutoScrollMode : {0}", Elementary.FocusAutoScrollMode); + }; + none.Clicked += (s, e) => + { + Elementary.FocusAutoScrollMode = FocusAutoScrollMode.None; + Console.WriteLine("FocusAutoScrollMode : {0}", Elementary.FocusAutoScrollMode); + }; + bringIn.Clicked += (s, e) => + { + Elementary.FocusAutoScrollMode = FocusAutoScrollMode.BringIn; + Console.WriteLine("FocusAutoScrollMode : {0}", Elementary.FocusAutoScrollMode); + }; + + show.Show(); + none.Show(); + bringIn.Show(); + + box.PackEnd(show); + box.PackEnd(none); + box.PackEnd(bringIn); + + grid.ItemActivated += Grid_ItemActivated; + grid.ItemSelected += Grid_ItemSelected; + grid.ItemUnselected += Grid_ItemUnselected; + grid.ItemRealized += Grid_ItemRealized; + grid.ItemUnrealized += Grid_ItemUnrealized; + grid.ItemPressed += Grid_ItemPressed; + grid.ItemReleased += Grid_ItemReleased; + grid.ItemLongPressed += Grid_ItemLongPressed; + grid.ItemDoubleClicked += Grid_ItemDoubleClicked; + } + + private void Grid_ItemDoubleClicked(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is Double clicked", color.R, color.G, color.B); + } + + private void Grid_ItemLongPressed(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is LongPressed", color.R, color.G, color.B); + } + + private void Grid_ItemReleased(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is Released", color.R, color.G, color.B); + } + + private void Grid_ItemPressed(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is Pressed", color.R, color.G, color.B); + } + + private void Grid_ItemUnselected(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is Unselected", color.R, color.G, color.B); + } + + private void Grid_ItemRealized(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is Realized", color.R, color.G, color.B); + } + + private void Grid_ItemUnrealized(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is Unrealized", color.R, color.G, color.B); + } + + private void Grid_ItemSelected(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is Selected", color.R, color.G, color.B); + } + + private void Grid_ItemActivated(object sender, GenGridItemEventArgs e) + { + Color color = (Color)e.Item.Data; + Console.WriteLine("#{0:X}{1:X}{2:X} is Activated", color.R, color.G, color.B); + } + } +} -- 2.7.4