From 1902ae88068129e1c3614178543373b5b54969fc Mon Sep 17 00:00:00 2001 From: huiyueun <35286162+huiyueun@users.noreply.github.com> Date: Wed, 8 Apr 2020 15:38:41 +0900 Subject: [PATCH] [NUI] Change Window.Instance to NUIApplication.GetDefaultWindow() (#1523) Signed-off-by: huiyu.eun --- src/Tizen.NUI/src/internal/Application.cs | 6 ++++-- src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs | 8 ++++---- src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs | 4 ++-- src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs | 6 +++--- src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs | 2 +- src/Tizen.NUI/src/public/GraphicsTypeConverter.cs | 4 ++-- src/Tizen.NUI/src/public/Layer.cs | 7 ++----- src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs | 4 ++-- src/Tizen.NUI/src/public/Layouting/LayoutItem.cs | 2 +- src/Tizen.NUI/src/public/NUIApplication.cs | 2 +- src/Tizen.NUI/src/public/WindowEvent.cs | 6 +++--- src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs | 6 +++--- 12 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Application.cs b/src/Tizen.NUI/src/internal/Application.cs index accce45..9f70268 100755 --- a/src/Tizen.NUI/src/internal/Application.cs +++ b/src/Tizen.NUI/src/internal/Application.cs @@ -706,9 +706,11 @@ namespace Tizen.NUI e.Application = this; _applicationTerminateEventHandler.Invoke(this, e); } - if (Window.Instance) + + List windows = GetWindowList(); + foreach (Window window in windows) { - Window.Instance.DisconnectNativeSignals(); + window?.DisconnectNativeSignals(); } } diff --git a/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs b/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs index 97f71f2..4988c79 100755 --- a/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs +++ b/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs @@ -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; diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index a0958fc..f1442e4 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -222,7 +222,7 @@ namespace Tizen.NUI.BaseComponents /// /// 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 /// /// 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 diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index e91067d..4680cd3 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -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; } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index d308481..92ff630 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -1087,7 +1087,7 @@ namespace Tizen.NUI.BaseComponents if (WindowWheelEventHandler != null) { - Window.Instance.WheelEvent -= OnWindowWheelEvent; + NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent; } if (_hoverEventCallback != null) diff --git a/src/Tizen.NUI/src/public/GraphicsTypeConverter.cs b/src/Tizen.NUI/src/public/GraphicsTypeConverter.cs index 7dec52e..be726cd 100755 --- a/src/Tizen.NUI/src/public/GraphicsTypeConverter.cs +++ b/src/Tizen.NUI/src/public/GraphicsTypeConverter.cs @@ -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); } /// @@ -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); } } } diff --git a/src/Tizen.NUI/src/public/Layer.cs b/src/Tizen.NUI/src/public/Layer.cs index f378117..e788546 100755 --- a/src/Tizen.NUI/src/public/Layer.cs +++ b/src/Tizen.NUI/src/public/Layer.cs @@ -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) diff --git a/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs b/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs index 1e53bb6..2d9daf8 100755 --- a/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs +++ b/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs @@ -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 { diff --git a/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs b/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs index fa42224..7d3bb53 100755 --- a/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs +++ b/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs @@ -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 { diff --git a/src/Tizen.NUI/src/public/NUIApplication.cs b/src/Tizen.NUI/src/public/NUIApplication.cs index a2582bd..d3e8365 100755 --- a/src/Tizen.NUI/src/public/NUIApplication.cs +++ b/src/Tizen.NUI/src/public/NUIApplication.cs @@ -196,7 +196,7 @@ namespace Tizen.NUI { get { - return Window.Instance; + return GetDefaultWindow(); } } diff --git a/src/Tizen.NUI/src/public/WindowEvent.cs b/src/Tizen.NUI/src/public/WindowEvent.cs index 6a0b8b6..feb9840 100755 --- a/src/Tizen.NUI/src/public/WindowEvent.cs +++ b/src/Tizen.NUI/src/public/WindowEvent.cs @@ -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 WindowFocusChanged @@ -815,7 +815,7 @@ namespace Tizen.NUI /// 3 [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 /// 4 public SafeNativeWindowHandle() : base(IntPtr.Zero, false) { - SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler()); + SetHandle(NUIApplication.GetDefaultWindow().GetNativeWindowHandler()); } /// /// Null check if the handle is valid or not. diff --git a/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs b/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs index 64441d6..7437e80 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/ContentPage.cs @@ -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(); } -- 2.7.4