Skip to content

Commit

Permalink
[NUI] Register OrientationChanged for BorderWindow.
Browse files Browse the repository at this point in the history
Because if the window is rotated, we need to resize the window by recalculating the border area.
  • Loading branch information
JoogabYun committed Jul 11, 2023
1 parent 36a9e8a commit fa7d77f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Tizen.NUI/src/public/Window/BorderWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public partial class Window
private IBorderInterface borderInterface = null;
private Layer borderWindowRootLayer = null;
private Layer borderWindowBottomLayer = null;
private WindowOrientation currentOrientation;

// for border area
private View rootView = null;
Expand All @@ -52,6 +53,7 @@ public partial class Window
private bool isEnabledOverlayMode = false;
private bool isMaximized = false;


// for config
private Size2D minSize = null;
private Size2D maxSize = null;
Expand Down Expand Up @@ -261,6 +263,9 @@ internal bool EnableBorder(IBorderInterface borderInterface, BorderCloseDelegate

if (CreateBorder() == true)
{
currentOrientation = GetCurrentOrientation();
currentOrientation = (currentOrientation == WindowOrientation.Portrait || currentOrientation == WindowOrientation.PortraitInverse) ? WindowOrientation.Portrait : WindowOrientation.Landscape;

using var realWindowSize = new Size2D(WindowSize.Width, WindowSize.Height);

isBorderWindow = true;
Expand All @@ -273,6 +278,8 @@ internal bool EnableBorder(IBorderInterface borderInterface, BorderCloseDelegate

ResizeCompleted += OnBorderWindowResizeCompleted;

OrientationChanged += OnBorderWindowOrientationChanged;

borderInterface.OnCreated(borderView);

// Increase the window size as much as the border area.
Expand Down Expand Up @@ -552,6 +559,21 @@ private void OnBorderWindowResizeCompleted(object sender, WindowResizeCompletedE
borderInterface.OnResizeCompleted(e.WindowCompletedSize.Width, e.WindowCompletedSize.Height);
}

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 (IsFloatingModeEnabled() == false)
{
using var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
Tizen.Log.Info("NUI", $"OnBorderWindowOrientationChanged {e.WindowOrientation} {val.GetWidth()},{val.GetHeight()}\n");
WindowSize = new Size2D((int)(val.GetWidth() - borderHeight), (int)(val.GetHeight()));
}
}
currentOrientation = orientation;
}

// Called when the window size has changed.
private void OnBorderWindowResized(object sender, Window.ResizedEventArgs e)
Expand Down Expand Up @@ -641,6 +663,10 @@ internal void DisposeBorder()
{
Resized -= OnBorderWindowResized;
FocusChanged -= OnWindowFocusChanged;
Moved -= OnBorderWindowMoved;
MoveCompleted -= OnBorderWindowMoveCompleted;
ResizeCompleted -= OnBorderWindowResizeCompleted;
OrientationChanged -= OnBorderWindowOrientationChanged;
borderInterface.Dispose();
GetBorderWindowBottomLayer().Dispose();
}
Expand Down

0 comments on commit fa7d77f

Please sign in to comment.