From ed48b7b7d174fd6ded3a4a858e6fc947f665b8aa Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Mon, 16 May 2022 17:19:54 +0900 Subject: [PATCH] [NUI] Supprot border for apps launched in full size. IsMaximized() is false even if the app runs at full size without Maximized(true). So, do Maximize(true) when launched in full size. --- .../src/public/Application/NUIApplication.cs | 1 - src/Tizen.NUI/src/public/Window/BorderWindow.cs | 50 +++++++++++++++++++--- src/Tizen.NUI/src/public/Window/DefaultBorder.cs | 6 +++ .../Tizen.NUI.Samples/Samples/BorderWindowTest.cs | 19 +++++++- 4 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/Tizen.NUI/src/public/Application/NUIApplication.cs b/src/Tizen.NUI/src/public/Application/NUIApplication.cs index 17e0d3d..33c7898 100755 --- a/src/Tizen.NUI/src/public/Application/NUIApplication.cs +++ b/src/Tizen.NUI/src/public/Application/NUIApplication.cs @@ -479,7 +479,6 @@ namespace Tizen.NUI if (borderEnabled) { GetDefaultWindow().EnableBorder(borderInterface); - GetDefaultWindow().EnableFloatingMode(false); } } diff --git a/src/Tizen.NUI/src/public/Window/BorderWindow.cs b/src/Tizen.NUI/src/public/Window/BorderWindow.cs index d78f91f..3b97140 100755 --- a/src/Tizen.NUI/src/public/Window/BorderWindow.cs +++ b/src/Tizen.NUI/src/public/Window/BorderWindow.cs @@ -14,6 +14,8 @@ * limitations under the License. * */ +extern alias TizenSystemInformation; +using TizenSystemInformation.Tizen.System; using System; using System.Collections.Generic; @@ -47,7 +49,9 @@ namespace Tizen.NUI private View bottomView = null; private bool isTop = false; private bool isBottom = false; - uint borderHeight = 0; + private uint borderHeight = 0; + private int screenWidth = 0; + private int screenHeight = 0; #endregion //Fields #region Constructors @@ -113,6 +117,16 @@ namespace Tizen.NUI return false; } + try + { + Information.TryGetValue("http://tizen.org/feature/screen.width", out screenWidth); + Information.TryGetValue("http://tizen.org/feature/screen.height", out screenHeight); + } + catch (DllNotFoundException e) + { + Tizen.Log.Fatal("NUI", $"{e}\n"); + } + if (borderInterface == null) { borderInterface = new DefaultBorder(); @@ -130,7 +144,21 @@ namespace Tizen.NUI // Increase the window size as much as the border area. if (isTop) borderHeight += borderInterface.BorderHeight; if (isBottom) borderHeight += borderInterface.BorderHeight; - WindowSize += new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderHeight + borderInterface.BorderLineThickness * 2)); + + // When running the app for the first time, if it runs in full size, do Maximize(true). + if (screenWidth != 0 && screenHeight != 0 && + Size.Width >= screenWidth && Size.Height >= screenHeight && + IsMaximized() == false) + { + Maximize(true); + ResizedEventArgs e = new ResizedEventArgs(); + e.WindowSize = WindowSize; + OnBorderWindowResized(this, e); + } + else + { + WindowSize += new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderHeight + borderInterface.BorderLineThickness * 2)); + } if (borderInterface.OverlayMode == true) { @@ -144,10 +172,16 @@ namespace Tizen.NUI BackgroundColor = Color.Transparent; borderInterface.BorderWindow = this; - EnableFloatingMode(true); - borderInterface.OnCreated(borderView); + InterceptTouchEvent += (s, e) => + { + if (e.Touch.GetState(0) == PointStateType.Down && IsMaximized() == false) + { + Raise(); + } + return false; + }; return true; } @@ -282,9 +316,12 @@ namespace Tizen.NUI private bool OverlayInterceptTouch(object sender, View.TouchEventArgs e) { - if (isInterceptTouch == true && overlayTimer != null) + if (e.Touch.GetState(0) == PointStateType.Down) { - overlayTimer.Start(); + if (isInterceptTouch == true && overlayTimer != null) + { + overlayTimer.Start(); + } } return false; } @@ -366,6 +403,7 @@ namespace Tizen.NUI Tizen.Log.Info("NUI", $"OnBorderWindowResized {e.WindowSize.Width},{e.WindowSize.Height}\n"); int resizeWidth = e.WindowSize.Width; int resizeHeight = e.WindowSize.Height; + if (borderInterface.MinSize != null) { resizeWidth = borderInterface.MinSize.Width > resizeWidth ? (int)borderInterface.MinSize.Width : resizeWidth; diff --git a/src/Tizen.NUI/src/public/Window/DefaultBorder.cs b/src/Tizen.NUI/src/public/Window/DefaultBorder.cs index cfa2b7c..d50c96b 100755 --- a/src/Tizen.NUI/src/public/Window/DefaultBorder.cs +++ b/src/Tizen.NUI/src/public/Window/DefaultBorder.cs @@ -533,6 +533,10 @@ namespace Tizen.NUI { if (e.Touch.GetState(0) == PointStateType.Started) { + if (BorderWindow.IsMaximized() == false) + { + BorderWindow.Raise(); + } backgroundColor = new Color(borderView.BackgroundColor); borderView.BackgroundColor = DefaultClickedBackgroundColor; } @@ -550,6 +554,8 @@ namespace Tizen.NUI borderPinchGestureDetector.Detected += OnPinchGestureDetected; AddInterceptGesture(); + + UpdateIcons(); } diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/BorderWindowTest.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/BorderWindowTest.cs index 2a98d62..1d6ed3b 100755 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/BorderWindowTest.cs +++ b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/BorderWindowTest.cs @@ -52,12 +52,27 @@ namespace Tizen.NUI.Samples { return false; } + topView.Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + LinearAlignment = LinearLayout.Alignment.CenterVertical, + CellPadding = new Size2D(20, 20), + }; title = new TextLabel() { Text = "CustomBorder", - Position = new Position(20, 0), + }; + + var button = new Button() + { + Text = "AlwaysOnTop", + }; + button.Clicked += (s, e) => + { + BorderWindow.EnableFloatingMode(true); }; topView.Add(title); + topView.Add(button); return true; } @@ -131,6 +146,7 @@ namespace Tizen.NUI.Samples public override void OnCreated(View borderView) { base.OnCreated(borderView); + UpdateIcons(); } public override bool OnCloseIconTouched(object sender, View.TouchEventArgs e) @@ -246,6 +262,7 @@ namespace Tizen.NUI.Samples { IBorderInterface customBorder = new CustomBorder(); subWindowTwo = new Window("subwin1", customBorder, new Rectangle(60, 20, 800, 800), false); + subWindowTwo.EnableFloatingMode(true); var root = new View(){ Layout = new LinearLayout() -- 2.7.4