Modified to get IME size from libscl-ui-nui 45/262145/1
authorInHong Han <inhong1.han@samsung.com>
Thu, 29 Jul 2021 05:31:03 +0000 (14:31 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 3 Aug 2021 05:37:11 +0000 (14:37 +0900)
Change-Id: Ib007851f8d9ed32d450728eb89bf019ace16b46c

ISEDefaultNUI/ISEDefaultNUI.cs
ISEDefaultNUI/Interop/Interop.SclNui.cs
ISEDefaultNUI/SCLNUI.cs
ISEDefaultNUI/WindowAttribute.cs

index 9f561ee..5f452ba 100644 (file)
@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
+using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 using System.Xml;
 using Tizen;
 using Tizen.Applications;
 using Tizen.NUI;
-using Tizen.NUI.BaseComponents;
 using Tizen.NUI.Components;
 using Tizen.Uix.InputMethod;
 using static Interop.SclNuiCSharp;
@@ -108,6 +108,13 @@ namespace ISEDefaultNUI
             Window.Instance.AddAvailableOrientation(Window.WindowOrientation.Landscape);
             Window.Instance.AddAvailableOrientation(Window.WindowOrientation.LandscapeInverse);
 
+            List<Window.WindowOrientation> availableList = new List<Window.WindowOrientation>();
+            availableList.Add(Window.WindowOrientation.Portrait);
+            availableList.Add(Window.WindowOrientation.Landscape);
+            availableList.Add(Window.WindowOrientation.PortraitInverse);
+            availableList.Add(Window.WindowOrientation.LandscapeInverse);
+            Window.Instance.SetAvailableOrientations(availableList);
+
             Window window = NUIApplication.GetDefaultWindow();
             navigator = new Navigator()
             {
@@ -186,6 +193,7 @@ namespace ISEDefaultNUI
                     break;
             }
             UpdateCursorPosition(b.CursorPosition);
+            SetIMESize();
 
             SclNui = new SCLNUI(navigator);
             LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(IseConfig.Instance.SelectedLanguage);
@@ -446,11 +454,29 @@ namespace ISEDefaultNUI
             SclDbusFocusIn();
         }
 
+        private static void SetIMESize()
+        {
+            IntPtr inputModePtr;
+            SclNuiGetInputMode(out inputModePtr);
+            string inputMode = Marshal.PtrToStringAnsi(inputModePtr);
+
+            int portraitWidth, portraitHeight, landscapeWidth, landscapeHeight;
+            SclNuiGetInputModeSize(inputMode, (int)WindowAttribute.DisplayMode.Portrait, out portraitWidth, out portraitHeight);
+            SclNuiGetInputModeSize(inputMode, (int)WindowAttribute.DisplayMode.Landscape, out landscapeWidth, out landscapeHeight);
+
+            Rectangle portraitRectangle = new Rectangle(0, 0, portraitWidth, portraitHeight);
+            Rectangle landscapeRectangle = new Rectangle(0, 0, landscapeHeight, landscapeWidth);
+            Window.Instance.SetPositionSizeWithOrientation(portraitRectangle, Window.WindowOrientation.Portrait);
+            Window.Instance.SetPositionSizeWithOrientation(landscapeRectangle, Window.WindowOrientation.Landscape);
+            Window.Instance.SetPositionSizeWithOrientation(portraitRectangle, Window.WindowOrientation.PortraitInverse);
+            Window.Instance.SetPositionSizeWithOrientation(landscapeRectangle, Window.WindowOrientation.LandscapeInverse);
+        }
+
         static void Main(string[] args)
         {
             InputMethodEditor.Run(Create, Terminate, Show, Hide);
 
-            Size2D initSize = new Size2D(720, 442);
+            Size2D initSize = new Size2D(0, 0);
             Position2D initPosition = new Position2D(0, 0);
 
             var app = new Program("", WindowMode.Opaque, initSize, initPosition, WindowType.Ime);
index e6ef9fc..503c5a3 100644 (file)
@@ -180,6 +180,9 @@ internal static partial class Interop
         [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_get_input_mode")]
         internal static extern int SclNuiGetInputMode(out IntPtr mode);
 
+        [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_get_input_mode_size")]
+        internal static extern int SclNuiGetInputModeSize(string mode, int display_mode, out int width, out int height);
+
         [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_input_mode")]
         internal static extern int SclNuiSetInputMode(string mode);
 
index e6b575f..778d7e7 100644 (file)
@@ -119,7 +119,7 @@ namespace ISEDefaultNUI
                             {
                                 int dimOrder = DimView.Instance.GetDimView().SiblingOrder;
                                 keyText.SiblingOrder = dimOrder - 1;
-                            }                            
+                            }
                             break;
                         }
                     case WindowAttribute.WindowType.Magnifier:
@@ -474,7 +474,6 @@ namespace ISEDefaultNUI
             return true;
         }
 
-        //FIXME: This should use RotationChanged of the Inputmethod.
         private void OnResized(object sender, Window.ResizedEventArgs e)
         {
             SclNuiSetRotation((int)Window.Instance.GetCurrentOrientation());
index 5a18503..9828fa4 100644 (file)
@@ -17,6 +17,12 @@ namespace ISEDefaultNUI
             AutoPopup,
         }
 
+        public enum DisplayMode
+        {
+            Portrait = 0,
+            Landscape,
+        }
+
         public class BackgroundColor
         {
             public int Red;