Adds Elementary.FocusAutoScrollMode
authorKangho Hur <kangho.hur@samsung.com>
Wed, 26 Jul 2017 05:08:12 +0000 (14:08 +0900)
committerKangho Hur <kangho.hur@samsung.com>
Wed, 26 Jul 2017 05:29:04 +0000 (14:29 +0900)
Change-Id: Ie9c5dd823f7baf47d15924f8fbcba49e4cded2bd

src/ElmSharp/ElmSharp.csproj
src/ElmSharp/ElmSharp/Elementary.cs
src/ElmSharp/Interop/Interop.Elementary.cs
test/ElmSharp.Test/ElmSharp.Test.csproj [changed mode: 0755->0644]
test/ElmSharp.Test/TC/FocusAutoScrollModeTest.cs [new file with mode: 0644]

index ed2b646..3016921 100644 (file)
@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <Version>1.2.2</Version>
+    <Version>1.2.3</Version>
     <Authors>Samsung Electronics</Authors>
     <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
     <Description>
index cf26c57..a83be9f 100644 (file)
@@ -21,6 +21,25 @@ using System.IO;
 namespace ElmSharp
 {
     /// <summary>
+    /// Focus Autoscroll Mode
+    /// </summary>
+    public enum FocusAutoScrollMode
+    {
+        /// <summary>
+        /// Directly show the focused region or item automatically
+        /// </summary>
+        Show,
+        /// <summary>
+        /// Do not show the focused region or item automatically
+        /// </summary>
+        None,
+        /// <summary>
+        /// Bring in the focused region or item automatically which might invole the scrolling
+        /// </summary>
+        BringIn
+    }
+
+    /// <summary>
     /// The Elementary is a General Elementary,a VERY SIMPLE toolkit.
     /// </summary>
     public static class Elementary
@@ -134,6 +153,21 @@ namespace ElmSharp
         }
 
         /// <summary>
+        /// Gets of sets focus auto scroll mode.
+        /// </summary>
+        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);
+            }
+        }
+
+        /// <summary>
         /// Initializes Elementary.
         /// </summary>
         public static void Initialize()
index 3791d11..2da2a60 100644 (file)
@@ -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)]
old mode 100755 (executable)
new mode 100644 (file)
index 0dcab8b..e044e7b
@@ -47,6 +47,7 @@
     <Compile Include="TC\BackgroundTest1.cs" />
     <Compile Include="TC\BackgroundTest2.cs" />
     <Compile Include="TC\BackgroundTest3.cs" />
+    <Compile Include="TC\FocusAutoScrollModeTest.cs" />
     <Compile Include="TC\GestureLayerTest1.cs" />
     <Compile Include="TC\ProgressBarTest2.cs" />
     <Compile Include="TC\ScrollerTest3.cs" />
diff --git a/test/ElmSharp.Test/TC/FocusAutoScrollModeTest.cs b/test/ElmSharp.Test/TC/FocusAutoScrollModeTest.cs
new file mode 100644 (file)
index 0000000..c0aa049
--- /dev/null
@@ -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);
+        }
+    }
+}