From: Eunki, Hong Date: Mon, 5 Aug 2024 03:56:51 +0000 (+0900) Subject: [NUI] Apply comments at VisualBase (phase 1) X-Git-Tag: submit/tizen/20240813.064948~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f88dc724fb21e51e71abed78b22821192b22cce;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Apply comments at VisualBase (phase 1) Apply some comments that report at PR #6079 - `Color.A` getter apply `Opacity` changeness - Make `VisualFittingMode` have no effect for `ColorVisual` and `BorderVisual` - `GetVisualProperty` return valid value after call `GetCurrentVisualProperty` - Make `VisualBase` class as abstract. Let we don't allow to call this class constructor. Signed-off-by: Eunki, Hong --- diff --git a/src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs b/src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs index 767b2eb88..2d1a31eeb 100644 --- a/src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs +++ b/src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs @@ -159,10 +159,6 @@ namespace Tizen.NUI.Visuals { Interop.BaseHandle.DeleteBaseHandle(new global::System.Runtime.InteropServices.HandleRef(this, cPtr)); } - else - { - ret = new Visuals.VisualBase(cPtr, true); - } NDalicPINVOKE.ThrowExceptionIfExists(); return ret; } diff --git a/src/Tizen.NUI/src/public/Visuals/VisualObject/VisualBase.cs b/src/Tizen.NUI/src/public/Visuals/VisualObject/VisualBase.cs index b82bcc0e2..fdb836ac8 100644 --- a/src/Tizen.NUI/src/public/Visuals/VisualObject/VisualBase.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualObject/VisualBase.cs @@ -35,7 +35,7 @@ namespace Tizen.NUI.Visuals /// animation.AnimateTo(view, "BorderlineOffset", -1.0f); /// [EditorBrowsable(EditorBrowsableState.Never)] - public class VisualBase : BaseHandle + public abstract class VisualBase : BaseHandle { #region Internal And Private internal PropertyMap cachedVisualPropertyMap = null; @@ -186,15 +186,6 @@ namespace Tizen.NUI.Visuals #endregion #region Constructor - /// - /// Creates an visual object. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public VisualBase() : this(Interop.VisualObject.VisualObjectNew(), true) - { - NDalicPINVOKE.ThrowExceptionIfExists(); - } - internal VisualBase(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn) { } @@ -237,7 +228,7 @@ namespace Tizen.NUI.Visuals /// and the visuals with larger sibling order are drawn top. /// /// It will be changed automatically when the visuals are added to the view. - /// The default value is 0. + /// It is 0 before being added to the view. /// [EditorBrowsable(EditorBrowsableState.Never)] public uint SiblingOrder @@ -337,7 +328,15 @@ namespace Tizen.NUI.Visuals { set { - UpdateVisualProperty((int)Tizen.NUI.Visual.Property.Opacity, new PropertyValue(value), false); + using Tizen.NUI.Color currentVisualColor = Color; + if (currentVisualColor.A != value) + { + using Tizen.NUI.Color visualColor = new Tizen.NUI.Color(currentVisualColor.R, currentVisualColor.G, currentVisualColor.B, value); + UpdateVisualProperty((int)Tizen.NUI.Visual.Property.MixColor, new PropertyValue(visualColor), false); + + // warning : We should set cached Opacity after set MixColor. + UpdateVisualProperty((int)Tizen.NUI.Visual.Property.Opacity, new PropertyValue(value), false); + } } get { @@ -358,20 +357,32 @@ namespace Tizen.NUI.Visuals /// The default value is VisualFittingModeType.DontCare. /// If user set one of Transform property, it will be set as VisualFittingModeType.DontCare automatically. /// + /// + /// Fitting mode is only available when the visual has original size. + /// For example, ImageVisual and TextVisual support FittingMode, but ColorVisual and BorderVisual don't support. + /// If visual doesn't have original size, Property set will be ignored. + /// [EditorBrowsable(EditorBrowsableState.Never)] public VisualFittingModeType FittingMode { set { - if (value != VisualFittingModeType.DontCare) + if (IsFittingModeAvailable()) { - visualFittingModeApplied = true; + if (value != VisualFittingModeType.DontCare) + { + visualFittingModeApplied = true; + } + else + { + visualFittingModeApplied = false; + } + UpdateVisualProperty((int)Tizen.NUI.Visual.Property.VisualFittingMode, new PropertyValue((int)value)); } else { - visualFittingModeApplied = false; + Tizen.Log.Error("NUI", $"Fitting mode is not supported by this visual type:{Type}. Set as DontCare\n"); } - UpdateVisualProperty((int)Tizen.NUI.Visual.Property.VisualFittingMode, new PropertyValue((int)value)); } get { @@ -1017,7 +1028,17 @@ namespace Tizen.NUI.Visuals if (ret == null) { // If we cannot find result from cached map, Get value from native engine. - GetCurrentVisualProperty(key); + ret = GetCurrentVisualProperty(key); + + // Update cached value here + if (ret != null) + { + if (cachedVisualPropertyMap == null) + { + cachedVisualPropertyMap = new PropertyMap(); + } + cachedVisualPropertyMap[key] = ret; + } } return ret; } @@ -1070,6 +1091,30 @@ namespace Tizen.NUI.Visuals } } + /// + /// Check whether given visual object is available to be use fitting mode or not. + /// + internal bool IsFittingModeAvailable() + { + switch (internalType) + { + case (int)Tizen.NUI.Visual.Type.Image: + case (int)Tizen.NUI.Visual.Type.NPatch: + case (int)Tizen.NUI.Visual.Type.AnimatedImage: + case (int)Tizen.NUI.Visual.Type.Text: + { + return true; + } + case (int)Tizen.NUI.Visual.Type.Invalid: + case (int)Tizen.NUI.Visual.Type.Border: + case (int)Tizen.NUI.Visual.Type.Color: + { + return false; + } + } + return false; + } + /// /// Dispose for VisualObject ///