[NUI] Minimize size is set too large. and code clean
authorjoogab.yun <joogab.yun@samsung.com>
Tue, 19 Apr 2022 03:18:31 +0000 (12:18 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 20 Apr 2022 08:38:08 +0000 (17:38 +0900)
src/Tizen.NUI/src/public/Window/DefaultBorder.cs
src/Tizen.NUI/src/public/Window/IBorderInterface.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/AllAppsSample.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/BorderWindowTest.cs

index 2b9cd25..eed66b4 100755 (executable)
@@ -31,31 +31,30 @@ namespace Tizen.NUI
         private static readonly string ResourcePath = FrameworkInformation.ResourcePath;
         private static readonly string MinimalizeIcon = ResourcePath + "minimalize.png";
         private static readonly string MaximalizeIcon = ResourcePath + "maximalize.png";
-        private static readonly string PreviousIcon = ResourcePath + "smallwindow.png";
         private static readonly string CloseIcon = ResourcePath + "close.png";
         private static readonly string LeftCornerIcon = ResourcePath + "leftCorner.png";
         private static readonly string RightCornerIcon = ResourcePath + "rightCorner.png";
 
         private static readonly string DarkMinimalizeIcon = ResourcePath + "dark_minimalize.png";
-        private static readonly string DarkMaximalizeIcon = ResourcePath + "dark_maximalize.png";
         private static readonly string DarkPreviousIcon = ResourcePath + "dark_smallwindow.png";
         private static readonly string DarkCloseIcon = ResourcePath + "dark_close.png";
         private static readonly string DarkLeftCornerIcon = ResourcePath + "dark_leftCorner.png";
         private static readonly string DarkRightCornerIcon = ResourcePath + "dark_rightCorner.png";
 
 
-        private static readonly uint DefaultHeight = 50;
-        private static readonly uint DefaultLineThickness = 5;
-        private static readonly uint DefaultTouchThickness = 20;
+        private const uint DefaultHeight = 50;
+        private const uint DefaultLineThickness = 5;
+        private const uint DefaultTouchThickness = 20;
         private static readonly Color DefaultBackgroundColor = new Color(1, 1, 1, 0.3f);
         private static readonly Color DefaultClickedBackgroundColor = new Color(1, 1, 1, 0.4f);
-        private static readonly Size2D DefaultMinSize = new Size2D(500, 0);
+        private static readonly Size2D DefaultMinSize = new Size2D(100, 0);
         #endregion //Constant Fields
 
 
         #region Fields
         private Color backgroundColor;
         private View rootView;
+        private View borderView;
 
         private ImageView minimalizeIcon;
         private ImageView maximalizeIcon;
@@ -71,6 +70,7 @@ namespace Tizen.NUI
         private Timer timer;
 
         private CurrentGesture currentGesture = CurrentGesture.None;
+        private bool disposed = false;
         #endregion //Fields
 
         #region Events
@@ -154,12 +154,16 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual void CreateBorderView(View rootView)
         {
+            if (rootView == null)
+            {
+                return;
+            }
             this.rootView = rootView;
             rootView.BackgroundColor = DefaultBackgroundColor;
             rootView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
             rootView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
 
-            View borderView = new View()
+            borderView = new View()
             {
                 Layout = new LinearLayout()
                 {
@@ -227,6 +231,10 @@ namespace Tizen.NUI
         /// Determines the behavior of pinch gesture.
         private void OnPinchGestureDetected(object source, PinchGestureDetector.DetectedEventArgs e)
         {
+            if (e == null)
+            {
+                return;
+            }
             if (e.PinchGesture.State == Gesture.StateType.Started)
             {
                 preScale = e.PinchGesture.Scale;
@@ -254,6 +262,10 @@ namespace Tizen.NUI
         /// Determines the behavior of borders.
         private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
         {
+            if (e == null)
+            {
+                return;
+            }
             PanGesture panGesture = e.PanGesture;
 
             if (panGesture.State == Gesture.StateType.Started)
@@ -309,6 +321,10 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnLeftCornerIconTouched(object sender, View.TouchEventArgs e)
         {
+            if (e == null)
+            {
+                return false;
+            }
             if (e.Touch.GetState(0) == PointStateType.Down)
             {
               ClearWindowGesture();
@@ -324,6 +340,10 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnRightCornerIconTouched(object sender, View.TouchEventArgs e)
         {
+            if (e == null)
+            {
+                return false;
+            }
             if (e.Touch.GetState(0) == PointStateType.Down)
             {
               ClearWindowGesture();
@@ -340,6 +360,10 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
         {
+            if (e == null)
+            {
+                return false;
+            }
             if (e.Touch.GetState(0) == PointStateType.Up)
             {
                 ClearWindowGesture();
@@ -354,6 +378,10 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnMaximizeIconTouched(object sender, View.TouchEventArgs e)
         {
+            if (e == null)
+            {
+                return false;
+            }
             if (e.Touch.GetState(0) == PointStateType.Up)
             {
                 ClearWindowGesture();
@@ -375,6 +403,10 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
         {
+            if (e == null)
+            {
+                return false;
+            }
             if (e.Touch.GetState(0) == PointStateType.Up)
             {
                 BorderWindow.Destroy();
@@ -451,6 +483,10 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual void OnCreated(View rootView)
         {
+            if (rootView == null)
+            {
+                return;
+            }
             // Register to resize and move through pan gestures.
             borderPanGestureDetector = new PanGestureDetector();
             borderPanGestureDetector.Attach(rootView);
@@ -508,6 +544,7 @@ namespace Tizen.NUI
                 {
                     timer.Stop();
                     timer.Dispose();
+                    timer = null;
                 }
             }
             return false;
@@ -521,7 +558,7 @@ namespace Tizen.NUI
             {
                 WidthResizePolicy = ResizePolicyType.FillToParent,
                 HeightResizePolicy = ResizePolicyType.FillToParent,
-                BackgroundColor = new Vector4(1, 1, 1, 0.5f),
+                BackgroundColor = new Color(1, 1, 1, 0.5f),
             };
             windowView.TouchEvent += (s, e) =>
             {
@@ -626,24 +663,44 @@ namespace Tizen.NUI
             UpdateIcons();
         }
 
-        /// <summary>
-        /// Dispose
-        /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public virtual void Dispose()
+        protected virtual void Dispose(bool disposing)
         {
-            ClearWindowGesture();
-            BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
-            borderPanGestureDetector.Dispose();
-            borderPinchGestureDetector.Dispose();
-            if (windowView != null)
+            if (disposed)
             {
-                windowView.Dispose();
+                return;
             }
-            if (rootView != null)
+            if (disposing)
             {
-                rootView.Dispose();
+                ClearWindowGesture();
+                if (BorderWindow != null)
+                {
+                    BorderWindow.InterceptTouchEvent -= OnWinInterceptedTouch;
+                }
+                borderPanGestureDetector?.Dispose();
+                borderPinchGestureDetector?.Dispose();
+                backgroundColor?.Dispose();
+                minimalizeIcon?.Dispose();
+                maximalizeIcon?.Dispose();
+                closeIcon?.Dispose();
+                leftCornerIcon?.Dispose();
+                rightCornerIcon?.Dispose();
+                timer?.Dispose();
+                windowView?.Dispose();
+                borderView?.Dispose();
+                rootView?.Dispose();
             }
+            disposed = true;
+        }
+
+        /// <summary>
+        /// Dispose
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void Dispose()
+        {
+            Dispose(true);
+            global::System.GC.SuppressFinalize(this);
         }
         #endregion //Methods
 
index e2661ff..7abc23a 100755 (executable)
@@ -25,7 +25,7 @@ namespace Tizen.NUI
     /// This is the interface used to draw the border UI.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
-    public interface IBorderInterface
+    public interface IBorderInterface : IDisposable
     {
         /// <summary>
         /// The thickness of the border.
@@ -101,10 +101,5 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void OnResized(int width, int height);
 
-        /// <summary>
-        /// Dispose
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public void Dispose();
     }
 }
index c3b332e..953c437 100644 (file)
@@ -22,7 +22,7 @@ namespace Tizen.NUI.Samples
                                "hbo", "linkedin", "youtube"
                                };
 
-    class TestWindow : BorderWindowInterface
+    class TestWindow : DefaultBorder
     {
       public override void CreateBorderView(View rootView)
       {
@@ -70,9 +70,9 @@ namespace Tizen.NUI.Samples
         borderView.Add(closeIcon);
         rootView.Add(borderView);
 
-        minimalizeIcon.TouchEvent += OnMinTouched;
-        maximalizeIcon.TouchEvent += OnMaxTouched;
-        closeIcon.TouchEvent += OnCloseTouched;
+        minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
+        maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
+        closeIcon.TouchEvent += OnCloseIconTouched;
       }
     }
 
@@ -120,8 +120,7 @@ namespace Tizen.NUI.Samples
     {
       if (subWindowOne == null)
       {
-        subWindowOne = new Window("subwin1", new Rectangle(1300, 250, 550, 500), false);
-        subWindowOne.EnableBorderWindow();
+        subWindowOne = new Window("subwin1", null, new Rectangle(1300, 250, 550, 500), false);
 
         var mainView = new View()
         {
@@ -175,8 +174,7 @@ namespace Tizen.NUI.Samples
     {
       if (subWindowTwo == null)
       {
-        subWindowTwo = new Window("subwin1", new Rectangle(60, 600, 600, 250), false);
-        subWindowTwo.EnableBorderWindow();
+        subWindowTwo = new Window("subwin1", null, new Rectangle(60, 600, 600, 250), false);
 
         var mainView = new View()
         {
index 800556d..ef42430 100755 (executable)
@@ -149,11 +149,6 @@ namespace Tizen.NUI.Samples
         }
       }
 
-      public override void Dispose()
-      {
-        base.Dispose();
-      }
-
     }
 
     void CreateSubWindowOne()