From: joogab.yun Date: Mon, 10 Jul 2023 10:50:03 +0000 (+0900) Subject: [NUI] Register OrientationChanged for BorderWindow. X-Git-Tag: submit/tizen_7.0/20230711.151008~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c0444bcde8006f550566a41f9bd3fd95b2eada9;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Register OrientationChanged for BorderWindow. Because if the window is rotated, we need to resize the window by recalculating the border area. --- diff --git a/src/Tizen.NUI/src/public/Window/BorderWindow.cs b/src/Tizen.NUI/src/public/Window/BorderWindow.cs index f07279d..3cb9f7e 100755 --- a/src/Tizen.NUI/src/public/Window/BorderWindow.cs +++ b/src/Tizen.NUI/src/public/Window/BorderWindow.cs @@ -35,6 +35,7 @@ namespace Tizen.NUI private IBorderInterface borderInterface = null; private Layer borderWindowRootLayer = null; private Layer borderWindowBottomLayer = null; + private WindowOrientation currentOrientation; // for border area private View rootView = null; @@ -186,14 +187,14 @@ namespace Tizen.NUI SetMimimumSize(mimimumSize); minSize = borderInterface.MinSize; } - + if (maxSize != borderInterface.MaxSize || (borderInterface.MaxSize != null && isNeedResizeByLine == true)) { using Size2D maximumSize = new Size2D((borderInterface.MaxSize?.Width + (int)borderLineThickness * 2 ?? 0), (borderInterface.MaxSize?.Height ?? 0) + (int)(borderHeight + borderLineThickness * 2)); SetMaximumSize(maximumSize); maxSize = borderInterface.MaxSize; } - + if (borderResizePolicy != borderInterface.ResizePolicy) { AddAuxiliaryHint("wm.policy.win.resize_aspect_ratio", "0"); @@ -203,7 +204,7 @@ namespace Tizen.NUI AddAuxiliaryHint("wm.policy.win.resize_aspect_ratio", "1"); } } - + } } /// @@ -261,6 +262,10 @@ namespace Tizen.NUI if (CreateBorder() == true) { + Tizen.Log.Info("NUI", $"currentOrientation {currentOrientation}\n"); + currentOrientation = GetCurrentOrientation(); + currentOrientation = (currentOrientation == WindowOrientation.Portrait || currentOrientation == WindowOrientation.PortraitInverse) ? WindowOrientation.Portrait : WindowOrientation.Landscape; + using var realWindowSize = new Size2D(WindowSize.Width, WindowSize.Height); isBorderWindow = true; @@ -269,6 +274,8 @@ namespace Tizen.NUI Moved += OnBorderWindowMoved; + OrientationChanged += OnBorderWindowOrientationChanged; + borderInterface.OnCreated(borderView); // Increase the window size as much as the border area. @@ -536,6 +543,22 @@ namespace Tizen.NUI borderInterface.OnMoved(e.WindowPosition.X, e.WindowPosition.X); } + private void OnBorderWindowOrientationChanged(object sender, WindowOrientationChangedEventArgs e) + { + WindowOrientation orientation = e.WindowOrientation; + orientation = (orientation == WindowOrientation.Portrait || orientation == WindowOrientation.PortraitInverse) ? WindowOrientation.Portrait : WindowOrientation.Landscape; + if (currentOrientation != orientation) + { + if (isEnabledOverlayMode == false && IsFloatingModeEnabled() == false) + { + using var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true); + Tizen.Log.Info("NUI", $"OnBorderWindowOrientationChanged {e.WindowOrientation} {val.GetWidth()},{val.GetHeight()}\n"); + uint borderLine = borderLineThickness * 2; + WindowSize = new Size2D((int)(val.GetWidth() - borderHeight - borderLine), (int)(val.GetHeight() - borderLine)); + } + } + currentOrientation = orientation; + } // Called when the window size has changed. private void OnBorderWindowResized(object sender, Window.ResizedEventArgs e) @@ -625,6 +648,8 @@ namespace Tizen.NUI { Resized -= OnBorderWindowResized; FocusChanged -= OnWindowFocusChanged; + Moved -= OnBorderWindowMoved; + OrientationChanged -= OnBorderWindowOrientationChanged; borderInterface.Dispose(); GetBorderWindowBottomLayer().Dispose(); }