[NUI] Border lines make the window invisible when maximized.
authorjoogab.yun <joogab.yun@samsung.com>
Fri, 26 Aug 2022 06:35:32 +0000 (15:35 +0900)
committerSangHyeon Jade Lee <dltkdgus1764@gmail.com>
Tue, 30 Aug 2022 07:41:27 +0000 (16:41 +0900)
When the window is full size, the content area should be full size. So it makes the border line disappear.
When it becomes partial size again, the border line is visible.

src/Tizen.NUI/src/public/Window/BorderWindow.cs
src/Tizen.NUI/src/public/Window/DefaultBorder.cs

index 87a0f2a..93d0bd6 100755 (executable)
@@ -35,7 +35,6 @@ namespace Tizen.NUI
         private IBorderInterface borderInterface = null;
         private Layer borderWindowRootLayer = null;
         private Layer borderWindowBottomLayer = null;
-        private bool isBorderWindow = false;
 
         // for border area
         private View rootView = null;
@@ -43,12 +42,16 @@ namespace Tizen.NUI
         private View topView = null;
         private View contentsView = null;
         private View bottomView = null;
-        private bool isTop = false;
-        private bool isBottom = false;
         private float borderHeight = 0;
         private int screenWidth = 0;
         private int screenHeight = 0;
 
+        private bool isBorderWindow = false;
+        private bool hasTopView = false;
+        private bool hasBottomView = false;
+        private bool isEnabledOverlayMode = false;
+        private bool isMaximized = false;
+
         // for config
         private Size2D minSize = null;
         private Size2D maxSize = null;
@@ -134,8 +137,8 @@ namespace Tizen.NUI
             if (borderInterface != null)
             {
                 float height = 0;
-                if (isTop) height += topView.SizeHeight;
-                if (isBottom) height += bottomView.SizeHeight;
+                if (hasTopView) height += topView.SizeHeight;
+                if (hasBottomView) height += bottomView.SizeHeight;
 
                 if (height != borderHeight)
                 {
@@ -236,8 +239,8 @@ namespace Tizen.NUI
 
                 // Increase the window size as much as the border area.
                 borderHeight = 0;
-                if (isTop) borderHeight += topView.SizeHeight;
-                if (isBottom) borderHeight += bottomView.SizeHeight;
+                if (hasTopView) borderHeight += topView.SizeHeight;
+                if (hasBottomView) borderHeight += bottomView.SizeHeight;
 
                 // Sets the minimum / maximum size to be resized by RequestResizeToServer.
                 if (borderInterface.MinSize != null)
@@ -345,17 +348,17 @@ namespace Tizen.NUI
             if (borderInterface.CreateTopBorderView(topView) == true && topView != null)
             {
                 borderView.Add(topView);
-                isTop = true;
+                hasTopView = true;
             }
             borderView.Add(contentsView);
             if (borderInterface.CreateBottomBorderView(bottomView) == true && bottomView != null)
             {
                 borderView.Add(bottomView);
-                isBottom = true;
+                hasBottomView = true;
             }
             rootView.Add(borderView);
 
-            return isTop || isBottom;
+            return hasTopView || hasBottomView;
         }
 
         /// <summary>
@@ -410,7 +413,7 @@ namespace Tizen.NUI
                 direction = BorderDirection.Top;
             }
             // check move
-            else if ((yPosition > WindowSize.Height) || (isTop == true && yPosition < topView.SizeHeight))
+            else if ((yPosition > WindowSize.Height) || (hasTopView == true && yPosition < topView.SizeHeight))
             {
                 direction = BorderDirection.Move;
             }
@@ -422,19 +425,33 @@ namespace Tizen.NUI
         {
             if (borderInterface.OverlayMode == true)
             {
-                borderInterface.OnOverlayMode(enable);
-                borderView?.OverlayMode(enable);
-                if (enable == true)
-                {
-                    GetBorderWindowBottomLayer().RaiseToTop();
-                }
-                else
+                if (isEnabledOverlayMode != enable)
                 {
-                    GetBorderWindowBottomLayer().LowerToBottom();
+                    borderView?.OverlayMode(enable);
+                    borderInterface.OnOverlayMode(enable);
+                    if (enable == true)
+                    {
+                        GetBorderWindowBottomLayer().RaiseToTop();
+                    }
+                    else
+                    {
+                        GetBorderWindowBottomLayer().LowerToBottom();
+                    }
+                    isEnabledOverlayMode = enable;
                 }
             }
         }
 
+        private void DoMaximize(bool isMaximized)
+        {
+            if (this.isMaximized != isMaximized)
+            {
+                borderView?.OnMaximize(isMaximized);
+                borderInterface.OnMaximize(isMaximized);
+            }
+            this.isMaximized = isMaximized;
+        }
+
         // Called when the window position has changed.
         private void OnBorderWindowMoved(object sender, WindowMovedEventArgs e)
         {
@@ -454,32 +471,34 @@ namespace Tizen.NUI
 
              // reset borderHeight
             borderHeight = 0;
-            if (isTop) borderHeight += topView.SizeHeight;
-            if (isBottom) borderHeight += bottomView.SizeHeight;
+            if (hasTopView) borderHeight += topView.SizeHeight;
+            if (hasBottomView) borderHeight += bottomView.SizeHeight;
 
-            if (borderInterface.OverlayMode == true && IsMaximized() == true)
+            bool isMaximized = IsMaximized();
+            bool isEnabledOverlay = (borderInterface.OverlayMode == true && isMaximized == true);
+
+            float width = 0;
+            float height = isEnabledOverlay ? 0 : borderHeight;
+            float y = isEnabledOverlay ? 0 : ((hasTopView == true) ? topView.SizeHeight : 0);
+
+            if (isMaximized == false)
             {
-                Interop.ActorInternal.SetSize(GetBorderWindowRootLayer().SwigCPtr, resizeWidth, resizeHeight);
-                Interop.ActorInternal.SetSize(GetBorderWindowBottomLayer().SwigCPtr, resizeWidth, resizeHeight);
-                Interop.ActorInternal.SetPosition(GetBorderWindowRootLayer().SwigCPtr, 0, 0);
-                if (contentsView != null)
-                {
-                    contentsView.SizeHeight = resizeHeight - borderHeight - (float)(borderInterface.BorderLineThickness * 2);
-                }
-                DoOverlayMode(true);
+                width = (float)(borderInterface.BorderLineThickness * 2);
+                height += (float)(borderInterface.BorderLineThickness * 2);
+                y += borderInterface.BorderLineThickness;
             }
-            else
+
+            Interop.ActorInternal.SetSize(GetBorderWindowRootLayer().SwigCPtr, resizeWidth, resizeHeight);
+            Interop.ActorInternal.SetSize(GetBorderWindowBottomLayer().SwigCPtr, resizeWidth + width, resizeHeight + height);
+            Interop.ActorInternal.SetPosition(GetBorderWindowRootLayer().SwigCPtr, 0, y);
+
+            if (contentsView != null)
             {
-                float height = (isTop == true) ? topView.SizeHeight : 0;
-                Interop.ActorInternal.SetSize(GetBorderWindowRootLayer().SwigCPtr, resizeWidth, resizeHeight);
-                Interop.ActorInternal.SetSize(GetBorderWindowBottomLayer().SwigCPtr, resizeWidth + (float)(borderInterface.BorderLineThickness * 2), resizeHeight + borderHeight + (float)(borderInterface.BorderLineThickness * 2));
-                Interop.ActorInternal.SetPosition(GetBorderWindowRootLayer().SwigCPtr, 0, height + borderInterface.BorderLineThickness);
-                if (contentsView != null)
-                {
-                    contentsView.SizeHeight = resizeHeight;
-                }
-                DoOverlayMode(false);
+                contentsView.SizeHeight = resizeHeight - (isEnabledOverlay ? borderHeight : 0);
             }
+            DoMaximize(isMaximized);
+
+            DoOverlayMode(isEnabledOverlay);
 
             if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
         }
@@ -514,7 +533,7 @@ namespace Tizen.NUI
                 Interop.Actor.SetAnchorPoint(borderWindowRootLayer.SwigCPtr, topCentor.SwigCPtr);
                 Interop.Actor.Add(rootLayer.SwigCPtr, borderWindowRootLayer.SwigCPtr);
                 Interop.ActorInternal.SetSize(borderWindowRootLayer.SwigCPtr, WindowSize.Width, WindowSize.Height - borderHeight - borderInterface.BorderLineThickness * 2);
-                float height = (isTop == true) ? topView.SizeHeight : 0;
+                float height = (hasTopView == true) ? topView.SizeHeight : 0;
                 Interop.ActorInternal.SetPosition(borderWindowRootLayer.SwigCPtr, 0, height + borderInterface.BorderLineThickness);
                 using PropertyValue propertyValue = new Tizen.NUI.PropertyValue((int)Tizen.NUI.ClippingModeType.ClipToBoundingBox);
                 Tizen.NUI.Object.SetProperty(borderWindowRootLayer.SwigCPtr, Tizen.NUI.BaseComponents.View.Property.ClippingMode, propertyValue);
@@ -563,7 +582,8 @@ namespace Tizen.NUI
         // View class for border view.
         private class BorderView : View
         {
-            private bool overlayEnabled = false;
+            private bool isEnabledOverlay = false;
+            private Extents prePadding = new Extents(0, 0, 0, 0);
 
             /// <summary>
             /// Set whether or not it is in overlay mode.
@@ -574,17 +594,33 @@ namespace Tizen.NUI
             [EditorBrowsable(EditorBrowsableState.Never)]
             public void OverlayMode(bool enabled)
             {
-                overlayEnabled = enabled;
+                isEnabledOverlay = enabled;
             }
 
-            protected override bool HitTest(Touch touch)
+            /// <summary>
+            /// Called when the window is maximized.
+            /// </summary>
+            /// <param name="isMaximized">If window is maximized or unmaximized.</param>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public void OnMaximize(bool isMaximized)
             {
-                // If borderView is in overlay mode, pass the hittest.
-                if (overlayEnabled == true)
+                // When maximized, it is displayed in full without border lines.
+                if (isMaximized == true)
                 {
-                    return false;
+                    prePadding = Padding;
+                    Padding = new Extents(0, 0, 0, 0);
                 }
-                return true;
+                else
+                {
+                    Padding = prePadding;
+                }
+                
+            }
+
+            protected override bool HitTest(Touch touch)
+            {
+                // If borderView is in overlay mode, pass the hittest.
+                return (isEnabledOverlay == false);
             }
         }
         #endregion //Classes
index f7776a7..0033cea 100755 (executable)
@@ -75,6 +75,7 @@ namespace Tizen.NUI
         private Size2D minSize;
         private Size2D maxSize;
         private Window.BorderResizePolicyType resizePolicy;
+
         #endregion //Fields
 
         #region Events
@@ -391,7 +392,6 @@ namespace Tizen.NUI
                     if (BorderWindow.IsMaximized())
                     {
                         BorderWindow.Maximize(false);
-                        OnMaximize(false);
                     }
                     else
                     {
@@ -402,7 +402,6 @@ namespace Tizen.NUI
                 else
                 {
                     BorderWindow.Maximize(true);
-                    OnMaximize(true);
                 }
             }
         }
@@ -425,7 +424,6 @@ namespace Tizen.NUI
                     if (BorderWindow.IsMaximized() == true)
                     {
                         BorderWindow.Maximize(false);
-                        OnMaximize(false);
                     }
                     else
                     {
@@ -554,12 +552,10 @@ namespace Tizen.NUI
             if (BorderWindow.IsMaximized())
             {
               BorderWindow.Maximize(false);
-              OnMaximize(false);
             }
             else
             {
               BorderWindow.Maximize(true);
-              OnMaximize(true);
             }
         }
 
@@ -758,12 +754,10 @@ namespace Tizen.NUI
                   if (BorderWindow.IsMaximized() == false)
                   {
                     BorderWindow.Maximize(true);
-                    OnMaximize(true);
                   }
                   else
                   {
                     BorderWindow.Maximize(false);
-                    OnMaximize(false);
                   }
               }
               else
@@ -786,7 +780,6 @@ namespace Tizen.NUI
                     if (BorderWindow.IsMaximized() == true)
                     {
                         BorderWindow.Maximize(false);
-                        OnMaximize(false);
                     }
                     else
                     {
@@ -862,6 +855,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual void OnMaximize(bool isMaximized)
         {
+            Tizen.Log.Info("NUI", $"OnMaximize {isMaximized}\n");
             UpdateIcons();
         }
 
@@ -884,6 +878,7 @@ namespace Tizen.NUI
         {
             if (borderView != null && OverlayMode == true)
             {
+                Tizen.Log.Info("NUI", $"OnOverlayMode {enabled}\n");
                 if (enabled == true)
                 {
                     backgroundColor = new Color(borderView.BackgroundColor);