From 1f8829ccebc487f9f82dfd3c00a14c1ae158e40d Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Mon, 22 Nov 2021 15:57:59 +0900 Subject: [PATCH] Revert "[NUI] Change for Size2D property to own internalSize2D which is cashed to prevent making repeated Size2D instance" This reverts commit 1d7d93845e15839fdf18ef36fb7a795392f64e5c. --- src/Tizen.NUI/Tizen.NUI.csproj | 7 --- src/Tizen.NUI/Tizen.NUI.sln | 6 --- src/Tizen.NUI/src/public/BaseComponents/View.cs | 13 +++-- .../public/BaseComponents/ViewBindableProperty.cs | 61 ++++++++-------------- .../src/public/BaseComponents/ViewEvent.cs | 13 ++--- .../src/public/BaseComponents/ViewInternal.cs | 2 - src/Tizen.NUI/src/public/Common/PropertyValue.cs | 38 -------------- src/Tizen.NUI/src/public/Common/Size2D.cs | 36 ------------- 8 files changed, 35 insertions(+), 141 deletions(-) diff --git a/src/Tizen.NUI/Tizen.NUI.csproj b/src/Tizen.NUI/Tizen.NUI.csproj index 7ff82e1..55bd751 100755 --- a/src/Tizen.NUI/Tizen.NUI.csproj +++ b/src/Tizen.NUI/Tizen.NUI.csproj @@ -42,11 +42,4 @@ - - - - - diff --git a/src/Tizen.NUI/Tizen.NUI.sln b/src/Tizen.NUI/Tizen.NUI.sln index e094980..382d9c5 100755 --- a/src/Tizen.NUI/Tizen.NUI.sln +++ b/src/Tizen.NUI/Tizen.NUI.sln @@ -17,8 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Componen EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.Information", "..\Tizen.System.Information\Tizen.System.Information.csproj", "{AD4B56C0-01B2-4ED0-9DBD-6CF233D16FF4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ThemeManager", "..\Tizen.Applications.ThemeManager\Tizen.Applications.ThemeManager.csproj", "{F57F6911-C581-49CA-80A5-9B5DDDAE3D40}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -53,10 +51,6 @@ Global {AD4B56C0-01B2-4ED0-9DBD-6CF233D16FF4}.Debug|Any CPU.Build.0 = Debug|Any CPU {AD4B56C0-01B2-4ED0-9DBD-6CF233D16FF4}.Release|Any CPU.ActiveCfg = Release|Any CPU {AD4B56C0-01B2-4ED0-9DBD-6CF233D16FF4}.Release|Any CPU.Build.0 = Release|Any CPU - {F57F6911-C581-49CA-80A5-9B5DDDAE3D40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F57F6911-C581-49CA-80A5-9B5DDDAE3D40}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F57F6911-C581-49CA-80A5-9B5DDDAE3D40}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F57F6911-C581-49CA-80A5-9B5DDDAE3D40}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 67091da..f00d363 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -51,9 +51,6 @@ namespace Tizen.NUI.BaseComponents // List of constraints private Constraint widthConstraint = null; private Constraint heightConstraint = null; - - private Size2D internalSize2D = null; - static View() { RegisterPropertyGroup(PositionProperty, positionPropertyGroup); @@ -992,15 +989,17 @@ namespace Tizen.NUI.BaseComponents { get { - var temp = (Size2D)GetValue(Size2DProperty); + Size2D temp = (Size2D)GetValue(Size2DProperty); + int width = temp.Width; + int height = temp.Height; if (this.Layout == null) { - if (temp.Width < 0) { temp.Width = 0; } - if (temp.Height < 0) { temp.Height = 0; } + if (width < 0) { width = 0; } + if (height < 0) { height = 0; } } - return temp; + return new Size2D(OnSize2DChanged, width, height); } set { diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index 38be66e..755a331 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -607,43 +607,26 @@ namespace Tizen.NUI.BaseComponents /// Size2DProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty Size2DProperty = BindableProperty.Create(nameof(Size2D), typeof(Size2D), typeof(View), null, - propertyChanged: ((bindable, oldValue, newValue) => - { - View view = (View)bindable; - if (newValue != null) - { - view.SetSize(((Size2D)newValue).Width, ((Size2D)newValue).Height, 0); - - view.widthPolicy = ((Size2D)newValue).Width; - view.heightPolicy = ((Size2D)newValue).Height; - - view.layout?.RequestLayout(); - } - }), - defaultValueCreator: ((bindable) => + public static readonly BindableProperty Size2DProperty = BindableProperty.Create(nameof(Size2D), typeof(Size2D), typeof(View), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => + { + var view = (View)bindable; + if (newValue != null) { - View view = (View)bindable; - var tmp = new Size(0, 0, 0); - Object.GetProperty(view.SwigCPtr, Property.SIZE).Get(tmp); - - int tmpWidth = (int)tmp?.Width; - int tmpHeight = (int)tmp?.Height; - tmp?.Dispose(); - tmp = null; + Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)view.SwigCPtr, View.Property.SIZE, new Tizen.NUI.PropertyValue(new Size((Size2D)newValue))); + view.widthPolicy = ((Size2D)newValue).Width; + view.heightPolicy = ((Size2D)newValue).Height; - if (view.internalSize2D == null) - { - view.internalSize2D = new Size2D(view.OnSize2DChanged, tmpWidth, tmpHeight); - } - else - { - if (view.internalSize2D.Width != tmpWidth) { view.internalSize2D.Width = tmpWidth; } - if (view.internalSize2D.Height != tmpHeight) { view.internalSize2D.Height = tmpHeight; } - } - return view.internalSize2D; - }) - ); + view.layout?.RequestLayout(); + } + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => + { + var view = (View)bindable; + Size temp = new Size(0.0f, 0.0f, 0.0f); + Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)view.SwigCPtr, View.Property.SIZE).Get(temp); + Size2D size = new Size2D((int)temp.Width, (int)temp.Height); + return size; + })); /// /// OpacityProperty @@ -1177,9 +1160,9 @@ namespace Tizen.NUI.BaseComponents var view = (View)bindable; if (newValue != null) { - if ((ResizePolicyType)newValue == ResizePolicyType.KeepSizeFollowingParent) + if((ResizePolicyType)newValue == ResizePolicyType.KeepSizeFollowingParent) { - if (view.widthConstraint == null) + if(view.widthConstraint == null) { view.widthConstraint = new EqualConstraintWithParentFloat((System.Runtime.InteropServices.HandleRef)view.SwigCPtr, View.Property.SizeWidth, View.Property.SizeWidth); view.widthConstraint.Apply(); @@ -1237,9 +1220,9 @@ namespace Tizen.NUI.BaseComponents var view = (View)bindable; if (newValue != null) { - if ((ResizePolicyType)newValue == ResizePolicyType.KeepSizeFollowingParent) + if((ResizePolicyType)newValue == ResizePolicyType.KeepSizeFollowingParent) { - if (view.heightConstraint == null) + if(view.heightConstraint == null) { view.heightConstraint = new EqualConstraintWithParentFloat((System.Runtime.InteropServices.HandleRef)view.SwigCPtr, View.Property.SizeHeight, View.Property.SizeHeight); view.heightConstraint.Apply(); diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index 37371cb..7d95722 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -722,18 +722,19 @@ namespace Tizen.NUI.BaseComponents private void OnSize2DChanged(int? width, int? height) { - PropertyValue temp = null; + PropertyValue temp; if (width != null) { - temp = new PropertyValue((float)width); - Object.SetProperty(SwigCPtr, Property.SizeWidth, temp); + temp = new Tizen.NUI.PropertyValue((float)width); + Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp); + temp.Dispose(); } if (height != null) { - temp = new PropertyValue((float)height); - Object.SetProperty(SwigCPtr, Property.SizeHeight, temp); + temp = new Tizen.NUI.PropertyValue((float)height); + Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp); + temp.Dispose(); } - temp?.Dispose(); } private void OnMinimumSizeChanged(int? width, int? height) diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index ff4cf4d..6a90172 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -1136,8 +1136,6 @@ namespace Tizen.NUI.BaseComponents } //_mergedStyle = null; - - internalSize2D?.Dispose(); if (type == DisposeTypes.Explicit) { diff --git a/src/Tizen.NUI/src/public/Common/PropertyValue.cs b/src/Tizen.NUI/src/public/Common/PropertyValue.cs index 1de77d9..78499e3 100755 --- a/src/Tizen.NUI/src/public/Common/PropertyValue.cs +++ b/src/Tizen.NUI/src/public/Common/PropertyValue.cs @@ -15,7 +15,6 @@ * */ -using System; using System.ComponentModel; namespace Tizen.NUI @@ -244,43 +243,6 @@ namespace Tizen.NUI if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - - /// - /// Hidden API (Inhouse API). - /// Dispose. - /// - /// - /// Following the guide of https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose. - /// This will replace "protected virtual void Dispose(DisposeTypes type)" which is exactly same in functionality. - /// - /// true in order to free managed objects - // Protected implementation of Dispose pattern. - [EditorBrowsable(EditorBrowsableState.Never)] - protected override void Dispose(bool disposing) - { - if (disposed) - { - return; - } - - //perform dipose here without being added to DisposeQueue. - if (SwigCMemOwn && SwigCPtr.Handle != IntPtr.Zero) - { - if (disposing) - { - base.Dispose(DisposeTypes.Explicit); - } - else - { - base.Dispose(DisposeTypes.Implicit); - } - } - - base.Dispose(disposing); - } - - - /// /// An extension to the property value class that allows us to create a /// Property value from a C# object, for example, integer, float, or string.
diff --git a/src/Tizen.NUI/src/public/Common/Size2D.cs b/src/Tizen.NUI/src/public/Common/Size2D.cs index d50854f..782e112 100755 --- a/src/Tizen.NUI/src/public/Common/Size2D.cs +++ b/src/Tizen.NUI/src/public/Common/Size2D.cs @@ -69,42 +69,6 @@ namespace Tizen.NUI internal delegate void Size2DChangedCallback(int? width, int? height); /// - /// Hidden API (Inhouse API). - /// Dispose. - /// - /// - /// Following the guide of https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose. - /// This will replace "protected virtual void Dispose(DisposeTypes type)" which is exactly same in functionality. - /// - /// true in order to free managed objects - // Protected implementation of Dispose pattern. - [EditorBrowsable(EditorBrowsableState.Never)] - protected override void Dispose(bool disposing) - { - if (disposed) - { - return; - } - - callback = null; - - //perform dipose here without being added to DisposeQueue. - if (SwigCMemOwn && SwigCPtr.Handle != IntPtr.Zero) - { - if (disposing) - { - base.Dispose(DisposeTypes.Explicit); - } - else - { - base.Dispose(DisposeTypes.Implicit); - } - } - - base.Dispose(disposing); - } - - /// /// The property for the width component of a size. /// /// -- 2.7.4