From 24175cc7e70bb04bc76132929ccdac10f3f7e46d Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Fri, 3 Jun 2022 14:30:11 +0900 Subject: [PATCH] [NUI] Add BorderCloseDelegate for closing the application by the border. When closing, it is necessary to distinguish between the application case and the window case. So, in the case of Application, we add a delegate so that it can be properly closed through the delegate. --- .../src/public/Application/NUIApplication.cs | 2 +- src/Tizen.NUI/src/public/Window/BorderWindow.cs | 32 ++++++++++++++++++---- src/Tizen.NUI/src/public/Window/DefaultBorder.cs | 27 ++++++++---------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/Tizen.NUI/src/public/Application/NUIApplication.cs b/src/Tizen.NUI/src/public/Application/NUIApplication.cs index f4e655d..5f4ef88 100755 --- a/src/Tizen.NUI/src/public/Application/NUIApplication.cs +++ b/src/Tizen.NUI/src/public/Application/NUIApplication.cs @@ -480,7 +480,7 @@ namespace Tizen.NUI if (borderEnabled) { - GetDefaultWindow().EnableBorder(borderInterface); + GetDefaultWindow().EnableBorder(borderInterface, new Window.BorderCloseDelegate(Exit)); } Tizen.Tracer.End(); diff --git a/src/Tizen.NUI/src/public/Window/BorderWindow.cs b/src/Tizen.NUI/src/public/Window/BorderWindow.cs index 8222e6f..f5b0d06 100755 --- a/src/Tizen.NUI/src/public/Window/BorderWindow.cs +++ b/src/Tizen.NUI/src/public/Window/BorderWindow.cs @@ -59,6 +59,9 @@ namespace Tizen.NUI #endregion //Distructors #region Delegates + internal delegate void BorderCloseDelegate(); + private BorderCloseDelegate borderCloseDelegate = null; + #endregion //Delegates #region Events @@ -84,7 +87,7 @@ namespace Tizen.NUI } /// - /// This enum is the policy when resizing the border window. + /// This enum is the policy when resizing the border window. /// [EditorBrowsable(EditorBrowsableState.Never)] public enum BorderResizePolicyType @@ -120,14 +123,30 @@ namespace Tizen.NUI #region Methods /// + /// Called when the border is closed. + /// If the delegate is declared, the delegate is called, otherwise window is destroyed. + /// + internal void BorderDestroy() + { + if (borderCloseDelegate != null) + { + borderCloseDelegate(); + } + else + { + Destroy(); + } + } + /// /// Enable the border window with IBorderInterface. /// This adds a border area to the Window. /// The border's UI is configured using IBorderInterface. /// Users can reisze and move by touching the border area. /// /// The IBorderInterface. + /// The BorderCloseDelegate. When close, this delegate is called. /// Whether the border window is enabled - internal bool EnableBorder(IBorderInterface borderInterface = null) + internal bool EnableBorder(IBorderInterface borderInterface, BorderCloseDelegate borderCloseDelegate = null) { if (isBorderWindow == true) { @@ -150,6 +169,7 @@ namespace Tizen.NUI borderInterface = new DefaultBorder(); } this.borderInterface = borderInterface; + this.borderCloseDelegate = borderCloseDelegate; GetDefaultLayer().Name = "OriginalRootLayer"; @@ -172,8 +192,8 @@ namespace Tizen.NUI if (isBottom) borderHeight += borderInterface.BorderHeight; // When running the app for the first time, if it runs in full size, do Maximize(true). - if (screenWidth != 0 && screenHeight != 0 && - realWindowSize.Width >= screenWidth && realWindowSize.Height >= screenHeight && + if (screenWidth != 0 && screenHeight != 0 && + realWindowSize.Width >= screenWidth && realWindowSize.Height >= screenHeight && IsMaximized() == false) { Maximize(true); @@ -196,7 +216,7 @@ namespace Tizen.NUI // Add a view to the border layer. GetBorderWindowBottomLayer().Add(rootView); - InterceptTouchEvent += (s, e) => + InterceptTouchEvent += (s, e) => { if (e.Touch.GetState(0) == PointStateType.Down && IsMaximized() == false) { @@ -232,7 +252,7 @@ namespace Tizen.NUI HeightResizePolicy = ResizePolicyType.FillToParent, BackgroundColor = Color.Transparent, Layout = new LinearLayout() { - LinearOrientation = LinearLayout.Orientation.Vertical, + LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.Top }, Padding = new Extents(padding, padding, padding, padding), diff --git a/src/Tizen.NUI/src/public/Window/DefaultBorder.cs b/src/Tizen.NUI/src/public/Window/DefaultBorder.cs index ce39b6e..d0477c9 100755 --- a/src/Tizen.NUI/src/public/Window/DefaultBorder.cs +++ b/src/Tizen.NUI/src/public/Window/DefaultBorder.cs @@ -390,7 +390,7 @@ namespace Tizen.NUI BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopLeft); } } - return false; + return true; } /// @@ -408,7 +408,7 @@ namespace Tizen.NUI BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopRight); } } - return false; + return true; } @@ -427,7 +427,7 @@ namespace Tizen.NUI BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomLeft); } } - return false; + return true; } /// @@ -445,7 +445,7 @@ namespace Tizen.NUI BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomRight); } } - return false; + return true; } @@ -470,7 +470,7 @@ namespace Tizen.NUI { MinimizeBorderWindow(); } - return false; + return true; } /// @@ -502,7 +502,7 @@ namespace Tizen.NUI { MaximizeBorderWindow(); } - return false; + return true; } /// @@ -511,8 +511,7 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] protected void CloseBorderWindow() { - BorderWindow.Destroy(); - BorderWindow = null; + BorderWindow.BorderDestroy(); } /// @@ -521,15 +520,11 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public virtual bool OnCloseIconTouched(object sender, View.TouchEventArgs e) { - if (e == null) - { - return false; - } if (e != null && e.Touch.GetState(0) == PointStateType.Up) { CloseBorderWindow(); } - return false; + return true; } @@ -801,7 +796,7 @@ namespace Tizen.NUI /// /// If window is maximized or unmaximized. [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void OnMaximize(bool isMaximized) + public virtual void OnMaximize(bool isMaximized) { UpdateIcons(); } @@ -882,6 +877,8 @@ namespace Tizen.NUI BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch; } + borderView?.Dispose(); + windowView?.Dispose(); borderPanGestureDetector?.Dispose(); borderPinchGestureDetector?.Dispose(); backgroundColor?.Dispose(); @@ -892,8 +889,6 @@ namespace Tizen.NUI rightCornerIcon?.Dispose(); timer?.Dispose(); overlayTimer?.Dispose(); - windowView?.Dispose(); - borderView?.Dispose(); } disposed = true; } -- 2.7.4