[NUI] Supprot border for apps launched in full size.
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 16 May 2022 08:19:54 +0000 (17:19 +0900)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Fri, 27 May 2022 06:15:42 +0000 (15:15 +0900)
IsMaximized() is false even if the app runs at full size without Maximized(true).
So, do Maximize(true) when launched in full size.

src/Tizen.NUI/src/public/Application/NUIApplication.cs
src/Tizen.NUI/src/public/Window/BorderWindow.cs
src/Tizen.NUI/src/public/Window/DefaultBorder.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/BorderWindowTest.cs

index 17e0d3d..33c7898 100755 (executable)
@@ -479,7 +479,6 @@ namespace Tizen.NUI
             if (borderEnabled)
             {
                 GetDefaultWindow().EnableBorder(borderInterface);
-                GetDefaultWindow().EnableFloatingMode(false);
             }
         }
 
index d78f91f..3b97140 100755 (executable)
@@ -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<int>("http://tizen.org/feature/screen.width", out screenWidth);
+                Information.TryGetValue<int>("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;
index cfa2b7c..d50c96b 100755 (executable)
@@ -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();
         }
 
 
index 2a98d62..1d6ed3b 100755 (executable)
@@ -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()