Add internal api for winKeygrab and Iconified 55/122955/5
authordarkleem <cdark.lim@samsung.com>
Tue, 4 Apr 2017 05:33:37 +0000 (14:33 +0900)
committerdarkleem <cdark.lim@samsung.com>
Thu, 6 Apr 2017 08:32:23 +0000 (17:32 +0900)
Change-Id: I80b9b5ac1d5263c539846a9e4e2d8a8732b9ca25
Signed-off-by: darkleem <cdark.lim@samsung.com>
ElmSharp.Test/ElmSharp.Test.csproj
ElmSharp.Test/TC/WindowInternalTest.cs [new file with mode: 0644]
ElmSharp.Test/TestRunner.cs
ElmSharp/ElmSharp/Window.cs
ElmSharp/Interop/Interop.Elementary.Win.cs
packaging/elm-sharp.spec

index 01e4434..0bdd667 100644 (file)
     <Compile Include="TC\SliderTest1.cs" />
     <Compile Include="TC\SpinnerTest1.cs" />
     <Compile Include="TC\ToolbarTest1.cs" />
+    <Compile Include="TC\WindowInternalTest.cs" />
     <Compile Include="TestCaseBase.cs" />
     <Compile Include="TestRunner.cs" />
   </ItemGroup>
   <ProjectExtensions>
     <VisualStudio>
       <FlavorProperties GUID="{2F98DAC9-6F16-457B-AED7-D43CAC379341}" Configuration="Debug|Any CPU">
-        <ProjectCorporateFlavorCfg />
+        <ProjectCommonFlavorCfg />
       </FlavorProperties>
       <FlavorProperties GUID="{2F98DAC9-6F16-457B-AED7-D43CAC379341}" Configuration="Release|Any CPU">
-        <ProjectCorporateFlavorCfg />
+        <ProjectCommonFlavorCfg />
       </FlavorProperties>
     </VisualStudio>
   </ProjectExtensions>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/ElmSharp.Test/TC/WindowInternalTest.cs b/ElmSharp.Test/TC/WindowInternalTest.cs
new file mode 100644 (file)
index 0000000..c238b74
--- /dev/null
@@ -0,0 +1,97 @@
+using Tizen.Applications;
+/*
+ * 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.Diagnostics;
+
+namespace ElmSharp.Test
+{
+    class WindowInternalTest : TestCaseBase
+    {
+        public override string TestName => "WindowInternalTest";
+        public override string TestDescription => "Window Test";
+
+        public override void Run(Window window)
+        {
+            var firstWindow = (Application.Current as TestRunner)?._firstPageWindow;
+            firstWindow.Hide();
+            firstWindow.Unrealize();
+
+            Button button1 = new Button(window) {
+                Text = "Iconified",
+            };
+            button1.Resize(window.ScreenSize.Width, 100);
+            button1.Move(0, 0);
+            button1.Show();
+
+            button1.Clicked += (e, o) =>
+            {
+                window.Iconified = true;
+            };
+
+            Button button2 = new Button(window)
+            {
+                Text = "WinKeyGrab",
+            };
+            button2.Resize(window.ScreenSize.Width, 100);
+            button2.Move(0, 100);
+            button2.Show();
+
+            button2.Clicked += (e, o) =>
+            {
+                Debug.WriteLine("@@KeyGrab");
+                window.KeyGrab(EvasKeyEventArgs.PlatformHomeButtonName, true);
+                window.WinKeyGrab(EvasKeyEventArgs.PlatformHomeButtonName, KeyGrabMode.Exclusive);
+            };
+
+            Button button3 = new Button(window)
+            {
+                Text = "WinUnKeyGrab",
+            };
+            button3.Resize(window.ScreenSize.Width, 100);
+            button3.Move(0, 200);
+            button3.Show();
+
+            button3.Clicked += (e, o) =>
+            {
+                Debug.WriteLine("@@UnKeyGrab");
+                window.WinKeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName);
+                window.KeyUngrab(EvasKeyEventArgs.PlatformHomeButtonName);
+
+            };
+            window.KeyGrab(EvasKeyEventArgs.PlatformBackButtonName, true);
+            EventHandler<EvasKeyEventArgs> handler = (s, e) =>
+            {
+                Debug.WriteLine("@@KeyDown start" + e.KeyName);
+
+                if (e.KeyName == EvasKeyEventArgs.PlatformBackButtonName)
+                {
+                    Application.Current.Exit();
+                }
+                if (e.KeyName == EvasKeyEventArgs.PlatformHomeButtonName)
+                {
+                    Debug.WriteLine("@@KeyDown OK : " + window.Iconified);
+                    window.Iconified = !window.Iconified;
+                }
+            };
+
+            window.KeyUp += handler;
+        }
+
+    }
+}
index c472650..ebdab32 100644 (file)
@@ -26,7 +26,7 @@ namespace ElmSharp.Test
 {
     public class TestRunner : CoreUIApplication
     {
-        private Window _firstPageWindow;
+        internal Window _firstPageWindow;
         private static bool s_terminated;
 
         public static string ResourceDir { get; private set; }
index 139270c..52391de 100755 (executable)
@@ -16,6 +16,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 
 namespace ElmSharp
 {
@@ -67,6 +68,15 @@ namespace ElmSharp
         Transparent = 3,
     }
 
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public enum KeyGrabMode
+    {
+        Shared = 256,
+        Topmost = 512,
+        Exclusive = 1024,
+        OverrideExclusive = 2048,
+    }
+
     /// <summary>
     /// The Window is container that contain the graphical user interface of a program.
     /// </summary>
@@ -273,6 +283,19 @@ namespace ElmSharp
             }
         }
 
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool Iconified
+        {
+            get
+            {
+                return Interop.Elementary.elm_win_iconified_get(RealHandle);
+            }
+            set
+            {
+                Interop.Elementary.elm_win_iconified_set(RealHandle, value);
+            }
+        }
+
         /// <summary>
         /// This function sends a request to the Windows Manager to activate the Window.
         /// If honored by the WM, the window receives the keyboard focus.
@@ -303,6 +326,17 @@ namespace ElmSharp
             Interop.Elementary.elm_win_resize_object_add(Handle, obj);
         }
 
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void WinKeyGrab(string keyname, KeyGrabMode mode)
+        {
+            Interop.Elementary.elm_win_keygrab_set(RealHandle, keyname, 0, 0, 0, mode);
+        }
+
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void WinKeyUngrab(string keyname)
+        {
+            Interop.Elementary.elm_win_keygrab_unset(RealHandle, keyname, 0, 0);
+        }
 
         /// <summary>
         /// Set the keygrab of the window.
index 959f867..30871f0 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+using ElmSharp;
 using System;
 using System.Runtime.InteropServices;
 
@@ -137,6 +138,21 @@ internal static partial class Interop
         [DllImport(Libraries.Elementary)]
         internal static extern void elm_win_screen_dpi_get(IntPtr obj, out int xdpi, out int ydpi);
 
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_win_iconified_set(IntPtr obj, bool iconified);
+
+        [DllImport(Libraries.Elementary)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool elm_win_iconified_get(IntPtr obj);
+
+        [DllImport(Libraries.Elementary)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool elm_win_keygrab_set(IntPtr obj, string key, ulong  modifiers, ulong notModifiers, int proirity, KeyGrabMode grabMode);
+
+        [DllImport(Libraries.Elementary)]
+        [return: MarshalAs(UnmanagedType.U1)]
+        internal static extern bool elm_win_keygrab_unset(IntPtr obj, string key, ulong modifiers, ulong notModifiers);
+
         [DllImport(Libraries.Eext)]
         internal static extern bool eext_win_keygrab_set(IntPtr obj, string key);
 
index 2f140ee..5a8658a 100644 (file)
@@ -1,4 +1,4 @@
-%define DEV_VERSION beta-018
+%define DEV_VERSION beta-019
 
 Name:       elm-sharp
 Summary:    C# Binding for Elementary