[NUI] Bind SynchronousSizing for ImageView / ImageVisual
authorEunki Hong <eunkiki.hong@samsung.com>
Mon, 29 Jul 2024 15:06:37 +0000 (00:06 +0900)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Tue, 13 Aug 2024 06:45:22 +0000 (15:45 +0900)
Add SynchrousSizing property - reload as size of visual.

It will be useful when we want to load image as specific size of view,
so the memory is reduced.

Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs
src/Tizen.NUI/src/public/Visuals/VisualConstants.cs
src/Tizen.NUI/src/public/Visuals/VisualObject/ImageVisual.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/VisualTest.cs

index f8b1626..dd8fbde 100755 (executable)
@@ -52,7 +52,7 @@ namespace Tizen.NUI.BaseComponents
                 SynchronousLoadingProperty = BindableProperty.Create(nameof(SynchronousLoading), typeof(bool), typeof(ImageView), false, propertyChanged: SetInternalSynchronousLoadingProperty, defaultValueCreator: GetInternalSynchronousLoadingProperty);
 
                 OrientationCorrectionProperty = BindableProperty.Create(nameof(OrientationCorrection), typeof(bool), typeof(ImageView), false, propertyChanged: SetInternalOrientationCorrectionProperty, defaultValueCreator: GetInternalOrientationCorrectionProperty);
-                        
+
                 MaskingModeProperty = BindableProperty.Create(nameof(MaskingMode), typeof(MaskingModeType), typeof(ImageView), default(MaskingModeType), propertyChanged: SetInternalMaskingModeProperty, defaultValueCreator: GetInternalMaskingModeProperty);
 
                 FastTrackUploadingProperty = BindableProperty.Create(nameof(FastTrackUploading), typeof(bool), typeof(ImageView), false, propertyChanged: SetInternalFastTrackUploadingProperty, defaultValueCreator: GetInternalFastTrackUploadingProperty);
@@ -136,6 +136,7 @@ namespace Tizen.NUI.BaseComponents
             Visual.Property.PremultipliedAlpha,
             ImageVisualProperty.OrientationCorrection,
             ImageVisualProperty.FastTrackUploading,
+            ImageVisualProperty.SynchronousSizing,
             NpatchImageVisualProperty.Border,
             NpatchImageVisualProperty.BorderOnly,
         };
@@ -774,6 +775,27 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Gets or sets whether to automatically reload the image as the view size<br />
+        /// If we set this value as true, view size will be works as desired size of image.<br />
+        /// </summary>
+        /// <remarks>
+        /// If we set this value as true, <see cref="DesiredWidth"/> and <see cref="DesiredHeight"/> will be invalidated.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool SynchronousSizing
+        {
+            get
+            {
+                return (bool)GetInternalSynchronousSizingProperty(this);
+            }
+            set
+            {
+                SetInternalSynchronousSizingProperty(this, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        /// <summary>
         /// Gets or sets whether to apply mask on GPU or not.<br />
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
index 14b121f..852d1e0 100755 (executable)
@@ -361,6 +361,23 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// SynchronousSizingProperty
+        /// </summary>
+        internal static void SetInternalSynchronousSizingProperty(ImageView imageView, bool newValue)
+        {
+            imageView.UpdateImage(ImageVisualProperty.SynchronousSizing, new PropertyValue(newValue));
+        }
+
+        internal static object GetInternalSynchronousSizingProperty(ImageView imageView)
+        {
+            bool ret = false;
+
+            imageView.GetCachedImageVisualProperty(ImageVisualProperty.SynchronousSizing)?.Get(out ret);
+
+            return ret;
+        }
+
+        /// <summary>
         /// MaskingModeProperty
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
index c72f453..5b758d4 100755 (executable)
@@ -1023,6 +1023,15 @@ namespace Tizen.NUI
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly int NotifyAfterRasterization = NDalic.ImageVisualOrientationCorrection + 17;
+
+        /// <summary>
+        /// @brief Whether to synchronize image texture size to visual size.
+        /// @details Name "synchronousSizing", type Property::BOOLEAN.
+        /// If this property is true, ImageVisual ignores mDesiredSize.
+        /// @note Used by the ImageVisual. The default is false.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly int SynchronousSizing = NDalic.ImageVisualOrientationCorrection + 18;
     }
 
     /// <summary>
index e31665a..c1f6083 100644 (file)
@@ -175,6 +175,29 @@ namespace Tizen.NUI.Visuals
         }
 
         /// <summary>
+        /// Gets or sets whether to automatically reload the image as the visual size.<br />
+        /// If we set this value as true, Visual size will be works as desired size of image.<br />
+        /// </summary>
+        /// <remarks>
+        /// If this value is true, <see cref="DesiredWidth"/> and <see cref="DesiredHeight"/> will be invalidated.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool SynchronousSizing
+        {
+            set
+            {
+                UpdateVisualProperty((int)Tizen.NUI.ImageVisualProperty.SynchronousSizing, new PropertyValue(value), true);
+            }
+            get
+            {
+                bool ret = false;
+                var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.ImageVisualProperty.SynchronousSizing);
+                propertyValue?.Get(out ret);
+                return ret;
+            }
+        }
+
+        /// <summary>
         /// Gets or sets the URL of the alpha mask.<br />
         /// Optional.
         /// </summary>
index 2f24312..54dbea7 100755 (executable)
@@ -312,8 +312,7 @@ namespace Tizen.NUI.Samples
                 Width = thumbnailSize,
                 Height = thumbnailSize,
 
-                DesiredWidth = (int)thumbnailSize,
-                DesiredHeight = (int)thumbnailSize,
+                SynchronousSizing = true,
 
                 OffsetXPolicy = VisualTransformPolicyType.Absolute,
                 OffsetYPolicy = VisualTransformPolicyType.Absolute,