From 4a42c47fa5df9d3066c59f948fb5dd20a1c2215a Mon Sep 17 00:00:00 2001 From: InHong Han Date: Mon, 5 Jul 2021 11:44:06 +0900 Subject: [PATCH] Supports window rotation Change-Id: I58812302fe67511695c50a8742d95e27e89a6a27 --- ISEDefaultNUI/ISEDefaultNUI.cs | 6 ++++++ ISEDefaultNUI/Interop/Interop.SclNui.cs | 3 +++ ISEDefaultNUI/SCLNUI.cs | 13 +++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ISEDefaultNUI/ISEDefaultNUI.cs b/ISEDefaultNUI/ISEDefaultNUI.cs index 5f87f62..44c6c1d 100644 --- a/ISEDefaultNUI/ISEDefaultNUI.cs +++ b/ISEDefaultNUI/ISEDefaultNUI.cs @@ -28,6 +28,11 @@ namespace ISEDefaultNUI void Initialize() { + Window.Instance.AddAvailableOrientation(Window.WindowOrientation.Portrait); + Window.Instance.AddAvailableOrientation(Window.WindowOrientation.PortraitInverse); + Window.Instance.AddAvailableOrientation(Window.WindowOrientation.Landscape); + Window.Instance.AddAvailableOrientation(Window.WindowOrientation.LandscapeInverse); + Window window = NUIApplication.GetDefaultWindow(); Navigator navigator = new Navigator() { @@ -44,6 +49,7 @@ namespace ISEDefaultNUI IseConfig.Instance.ReadIseConfig(); LanguageManager.Instance.SetEnabledLanguages(IseConfig.Instance.EnabledLanguages); + SclNuiSetRotation((int)Window.Instance.GetCurrentOrientation()); LanguageInfo currentLanguage = LanguageManager.Instance.GetLanguageInfo(IseConfig.Instance.SelectedLanguage); SCLNUI SclNui = new SCLNUI(navigator, DirectoryInfo.Resource + "main_entry.xml"); SclNui.SetUpdatePending(true); diff --git a/ISEDefaultNUI/Interop/Interop.SclNui.cs b/ISEDefaultNUI/Interop/Interop.SclNui.cs index 5ff8b40..4cfca8b 100644 --- a/ISEDefaultNUI/Interop/Interop.SclNui.cs +++ b/ISEDefaultNUI/Interop/Interop.SclNui.cs @@ -198,6 +198,9 @@ internal static partial class Interop [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_update_pending")] internal static extern int SclNuiSetUpdatePending(bool pend); + [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_rotation")] + internal static extern int SclNuiSetRotation(int degree); + [DllImport(Libraries.SclNui, EntryPoint = "scl_nui_set_cur_sublayout")] internal static extern int SclNuiSetCurrentSublayout(string SublayoutName); diff --git a/ISEDefaultNUI/SCLNUI.cs b/ISEDefaultNUI/SCLNUI.cs index dd3913d..44145b3 100644 --- a/ISEDefaultNUI/SCLNUI.cs +++ b/ISEDefaultNUI/SCLNUI.cs @@ -135,10 +135,8 @@ namespace ISEDefaultNUI Log.Info("NUIIME", "rectangle: x=" + pos_x + ", y=" + pos_y + ", w=" + width + ", h=" + height); Log.Info("NUIIME", "fill: " + fill + ", r=" + fill_color_r + ", g=" + fill_color_g + ", b=" + fill_color_b + ", a=" + fill_color_a); - if (width == 720) { - rectView = draw_rectangle(pos_x, pos_y, width, height, fill, fill_color_r, fill_color_g, fill_color_b, fill_color_a); - Add(rectView); - } + rectView = draw_rectangle(pos_x, pos_y, width, height, fill, fill_color_r, fill_color_g, fill_color_b, fill_color_a); + Add(rectView); }; SclNuiSetDrawRectangleCb(_draw_rectangle_cb, (IntPtr)null); @@ -212,6 +210,7 @@ namespace ISEDefaultNUI SclNuiDragStateChangedCb(_onDragStateChangedEvent); Window.Instance.TouchEvent += OnWindowTouched; + Window.Instance.Resized += OnResized; BackKeyPressed += (object source, EventArgs args) => { @@ -236,6 +235,12 @@ namespace ISEDefaultNUI SclNuiUpdateWindowPositionCb(_updateWindowPositionChangedEvent, (IntPtr)null); } + //FIXME: This should use RotationChanged of the Inputmethod. + private void OnResized(object sender, Window.ResizedEventArgs e) + { + SclNuiSetRotation((int)Window.Instance.GetCurrentOrientation()); + } + private void PreviewModeChanged(object sender, PreferenceChangedEventArgs e) { IseConfig.Instance.ReadIsePreviewOn(); -- 2.7.4