[NUI] Change Window.Instance to NUIApplication.GetDefaultWindow() (#1523)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Wed, 8 Apr 2020 06:38:41 +0000 (15:38 +0900)
committerGitHub <noreply@github.com>
Wed, 8 Apr 2020 06:38:41 +0000 (15:38 +0900)
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
12 files changed:
src/Tizen.NUI/src/internal/Application.cs
src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs
src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs
src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
src/Tizen.NUI/src/public/GraphicsTypeConverter.cs
src/Tizen.NUI/src/public/Layer.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs
src/Tizen.NUI/src/public/Layouting/LayoutItem.cs
src/Tizen.NUI/src/public/NUIApplication.cs
src/Tizen.NUI/src/public/WindowEvent.cs
src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs

index accce45..9f70268 100755 (executable)
@@ -706,9 +706,11 @@ namespace Tizen.NUI
                 e.Application = this;
                 _applicationTerminateEventHandler.Invoke(this, e);
             }
-            if (Window.Instance)
+
+            List<Window> windows = GetWindowList();
+            foreach (Window window in windows)
             {
-                Window.Instance.DisconnectNativeSignals();
+                window?.DisconnectNativeSignals();
             }
         }
 
index 97f71f2..4988c79 100755 (executable)
@@ -238,8 +238,8 @@ namespace Tizen.NUI.Xaml
             string resource = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
 
             Tizen.Log.Fatal("NUI", "the resource path: " + resource);
-            int windowWidth = Window.Instance.Size.Width;
-            int windowHeight = Window.Instance.Size.Height;
+            int windowWidth = NUIApplication.GetDefaultWindow().Size.Width;
+            int windowHeight = NUIApplication.GetDefaultWindow().Size.Height;
 
             string likelyResourcePath = resource + "layout/" + windowWidth.ToString() + "x" + windowHeight.ToString() + "/" + resourceName;
             Tizen.Log.Fatal("NUI", "the resource path: " + likelyResourcePath);
@@ -437,8 +437,8 @@ namespace Tizen.NUI.Xaml
 
             NUILog.Debug($"resource=({resource})");
 
-            int windowWidth = Window.Instance.Size.Width;
-            int windowHeight = Window.Instance.Size.Height;
+            int windowWidth = NUIApplication.GetDefaultWindow().Size.Width;
+            int windowHeight = NUIApplication.GetDefaultWindow().Size.Height;
 
             string likelyResourcePath = resource + "layout/" + windowWidth.ToString() + "x" + windowHeight.ToString() + "/" + resourceName;
 
index a0958fc..f1442e4 100755 (executable)
@@ -222,7 +222,7 @@ namespace Tizen.NUI.BaseComponents
         /// <code>
         /// LottieAnimationView myLottie = new LottieAnimationView();
         /// myLottie.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "myLottie.json"; //myLottie.json's total frame is 100 (frame: 0~99)
-        /// Window.Instance.GetDefaultLayer().Add(myLottie);
+        /// NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(myLottie);
         /// myLottie.CurrentFrame = 200; //display 99 frame
         /// myLottie.SetMinMaxFrame(10, 20);
         /// myLottie.CurrentFrame = 15; //display 15 frame
@@ -312,7 +312,7 @@ namespace Tizen.NUI.BaseComponents
         /// <code>
         /// LottieAnimationView myLottie = new LottieAnimationView();
         /// myLottie.URL = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "myLottie.json"; //myLottie.json's total frame is 100 (frame: 0~99)
-        /// Window.Instance.GetDefaultLayer().Add(myLottie);
+        /// NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(myLottie);
         /// myLottie.LoopCount = -1; //infinite loop
         /// myLottie.Play();
         /// myLottie.Stop(); //it plays continuously unless Stop() is called
index e91067d..4680cd3 100755 (executable)
@@ -58,7 +58,7 @@ namespace Tizen.NUI.BaseComponents
 
         private void SendViewAddedEventToWindow(IntPtr data)
         {
-            Window.Instance?.SendViewAdded(this);
+            NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
         }
 
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
@@ -294,7 +294,7 @@ namespace Tizen.NUI.BaseComponents
 
                 if (WindowWheelEventHandler == null)
                 {
-                    Window.Instance.WheelEvent += OnWindowWheelEvent;
+                    NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
                 }
                 WindowWheelEventHandler += value;
             }
@@ -310,7 +310,7 @@ namespace Tizen.NUI.BaseComponents
                 WindowWheelEventHandler -= value;
                 if (WindowWheelEventHandler == null)
                 {
-                    Window.Instance.WheelEvent -= OnWindowWheelEvent;
+                    NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
                 }
             }
         }
index d308481..92ff630 100755 (executable)
@@ -1087,7 +1087,7 @@ namespace Tizen.NUI.BaseComponents
 
             if (WindowWheelEventHandler != null)
             {
-                Window.Instance.WheelEvent -= OnWindowWheelEvent;
+                NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
             }
 
             if (_hoverEventCallback != null)
index 7dec52e..be726cd 100755 (executable)
@@ -68,7 +68,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual float ConvertToPixel(float value)
         {
-            return value * (Window.Instance.Dpi.X / defaultDpi);
+            return value * (NUIApplication.GetDefaultWindow().Dpi.X / defaultDpi);
         }
 
         /// <summary>
@@ -79,7 +79,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public virtual float ConvertFromPixel(float value)
         {
-            return value * (defaultDpi / Window.Instance.Dpi.X);
+            return value * (defaultDpi / NUIApplication.GetDefaultWindow().Dpi.X);
         }
     }
 }
index f378117..e788546 100755 (executable)
@@ -36,11 +36,8 @@ namespace Tizen.NUI
         public Layer() : this(Interop.Layer.Layer_New(), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            if (Window.Instance != null)
-            {
-                this.SetAnchorPoint(Tizen.NUI.PivotPoint.TopLeft);
-                this.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
-            }
+            this.SetAnchorPoint(Tizen.NUI.PivotPoint.TopLeft);
+            this.SetResizePolicy(ResizePolicyType.FillToParent, DimensionType.AllDimensions);
         }
 
         internal Layer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Layer.Layer_SWIGUpcast(cPtr), cMemoryOwn)
index 1e53bb6..2d9daf8 100755 (executable)
@@ -95,12 +95,12 @@ namespace Tizen.NUI
                     {
                         if (!childLayout.IsReplaceFlag())
                         {
-                            Window.Instance.LayoutController.AddToRemovalStack(childLayout);
+                            NUIApplication.GetDefaultWindow().LayoutController.AddToRemovalStack(childLayout);
                         }
 
                         childLayout.ConditionForAnimation = childLayout.ConditionForAnimation | TransitionCondition.Remove;
                         // Add LayoutItem to the transition stack so can animate it out.
-                        Window.Instance.LayoutController.AddTransitionDataEntry(new LayoutData(layoutItem, ConditionForAnimation, 0, 0, 0, 0));
+                        NUIApplication.GetDefaultWindow().LayoutController.AddTransitionDataEntry(new LayoutData(layoutItem, ConditionForAnimation, 0, 0, 0, 0));
                     }
                     else
                     {
index fa42224..7d3bb53 100755 (executable)
@@ -536,7 +536,7 @@ namespace Tizen.NUI
 
                 if (Owner.Parent != null && Owner.Parent.Layout != null && Owner.Parent.Layout.LayoutWithTransition)
                 {
-                    Window.Instance.LayoutController.AddTransitionDataEntry(_layoutPositionData);
+                    NUIApplication.GetDefaultWindow().LayoutController.AddTransitionDataEntry(_layoutPositionData);
                 }
                 else
                 {
index a2582bd..d3e8365 100755 (executable)
@@ -196,7 +196,7 @@ namespace Tizen.NUI
         {
             get
             {
-                return Window.Instance;
+                return GetDefaultWindow();
             }
         }
 
index 6a0b8b6..feb9840 100755 (executable)
@@ -211,7 +211,7 @@ namespace Tizen.NUI
         /// Instead please use FocusChanged.
         [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
             "Like: " +
-            "Window.Instance.FocusChanged = OnFocusChanged; " +
+            "NUIApplication.GetDefaultWindow().FocusChanged = OnFocusChanged; " +
             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
         [EditorBrowsable(EditorBrowsableState.Never)]
         public event EventHandler<FocusChangedEventArgs> WindowFocusChanged
@@ -815,7 +815,7 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
             "Like: " +
-            "Window.Instance.FocusChanged = OnFocusChanged; " +
+            "NUIApplication.GetDefaultWindow().FocusChanged = OnFocusChanged; " +
             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
         [EditorBrowsable(EditorBrowsableState.Never)]
         public class WindowFocusChangedEventArgs : EventArgs
@@ -843,7 +843,7 @@ namespace Tizen.NUI
             /// <since_tizen> 4 </since_tizen>
             public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
             {
-                SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
+                SetHandle(NUIApplication.GetDefaultWindow().GetNativeWindowHandler());
             }
             /// <summary>
             /// Null check if the handle is valid or not.
index 64441d6..7437e80 100755 (executable)
@@ -154,7 +154,7 @@ namespace Tizen.NUI
             //because the execution order of Finalizes is non-deterministic.
             if(Root != null) 
             {
-                Window.Instance.Remove(Root);
+                Root.Unparent();
                 Root.Dispose();
                 Root = null;
             }
@@ -184,7 +184,7 @@ namespace Tizen.NUI
             if ( Root != null )
             {
                 //Remove it from the window
-                Window.Instance.Remove(Root);
+                Root.Unparent();
                 Root.Dispose();
                 Root = null;
 
@@ -192,7 +192,7 @@ namespace Tizen.NUI
                 Root = new View();
                 Root.WidthResizePolicy = ResizePolicyType.FillToParent;
                 Root.HeightResizePolicy = ResizePolicyType.FillToParent;
-                Window.Instance.Add(Root);
+                NUIApplication.GetDefaultWindow().Add(Root);
 
                 ClearHandler();
             }