[NUI] Add Default Image & transition effect
authorsunghyun kim <scholb.kim@samsung.com>
Wed, 5 Apr 2023 06:23:27 +0000 (15:23 +0900)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Tue, 2 May 2023 07:43:54 +0000 (16:43 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs
test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PlaceHolderImageTest.cs [new file with mode: 0644]
test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/images/placeholder_image.png [new file with mode: 0755]
test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/images/placeholder_image_large.png [new file with mode: 0755]

index bbefd9e..692bc99 100755 (executable)
@@ -29,6 +29,12 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageView_Property_PIXEL_AREA_get")]
             public static extern int PixelAreaGet();
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageView_Property_PLACEHOLDER_IMAGE_get")]
+            public static extern int PlaceHolderImageGet();
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_ImageView_Property_TRANSITION_EFFECT_get")]
+            public static extern int TransitionEffectGet();
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_ImageView_Property")]
             public static extern global::System.IntPtr NewImageViewProperty();
 
index 7ef9663..6669f7a 100755 (executable)
@@ -1154,6 +1154,44 @@ namespace Tizen.NUI.BaseComponents
         }
         private bool adjustViewSize = false;
 
+        /// <summary>
+        /// ImageView PlaceHolderUrl, type string.
+        /// This is one of mandatory property. Even if not set or null set, it sets empty string ("") internally.
+        /// When it is set as null, it gives empty string ("") to be read.
+        /// </summary>
+        /// <since_tizen> 11 </since_tizen>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public string PlaceHolderUrl
+        {
+            get
+            {
+                return (string)GetValue(PlaceHolderUrlProperty);
+            }
+            set
+            {
+                SetValue(PlaceHolderUrlProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
+        /// <summary>
+        /// Gets or sets whether the image use TransitionEffect or not<br />
+        /// </summary>
+        /// <since_tizen> 11 </since_tizen>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool TransitionEffect
+        {
+            get
+            {
+                return (bool)GetValue(TransitionEffectProperty);
+            }
+            set
+            {
+                SetValue(TransitionEffectProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
         internal Selector<string> ResourceUrlSelector
         {
             get => GetSelector<string>(resourceUrlSelector, ImageView.ResourceUrlProperty);
@@ -1686,6 +1724,8 @@ namespace Tizen.NUI.BaseComponents
             internal static readonly int IMAGE = Interop.ImageView.ImageGet();
             internal static readonly int PreMultipliedAlpha = Interop.ImageView.PreMultipliedAlphaGet();
             internal static readonly int PixelArea = Interop.ImageView.PixelAreaGet();
+            internal static readonly int PlaceHolderUrl = Interop.ImageView.PlaceHolderImageGet();
+            internal static readonly int TransitionEffect = Interop.ImageView.TransitionEffectGet();
         }
 
         private enum ImageType
index 0f815ef..55ba7fd 100755 (executable)
@@ -525,5 +525,39 @@ namespace Tizen.NUI.BaseComponents
             var instance = (Tizen.NUI.BaseComponents.ImageView)bindable;
             return instance.adjustViewSize;
         });
+
+        /// <summary>
+        /// PlaceHolderUrlProperty
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty PlaceHolderUrlProperty = BindableProperty.Create(nameof(PlaceHolderUrl), typeof(string), typeof(ImageView), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var imageView = (Tizen.NUI.BaseComponents.ImageView)bindable;
+            if (newValue != null)
+            {
+                Object.InternalSetPropertyString(imageView.SwigCPtr, ImageView.Property.PlaceHolderUrl, (string)newValue );
+            }
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var imageView = (Tizen.NUI.BaseComponents.ImageView)bindable;
+            return Object.InternalGetPropertyString(imageView.SwigCPtr, ImageView.Property.PlaceHolderUrl);
+        });
+
+        /// Intenal used, will never be opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty TransitionEffectProperty = BindableProperty.Create(nameof(TransitionEffect), typeof(bool), typeof(ImageView), false, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var imageView = (ImageView)bindable;
+            if (newValue != null)
+            {
+                Object.InternalSetPropertyBool(imageView.SwigCPtr, ImageView.Property.TransitionEffect, (bool)newValue);
+            }
+        },
+        defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
+        {
+            var imageView = (ImageView)bindable;
+            return Object.InternalGetPropertyBool(imageView.SwigCPtr, ImageView.Property.TransitionEffect);
+        }));
     }
 }
diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PlaceHolderImageTest.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/PlaceHolderImageTest.cs
new file mode 100644 (file)
index 0000000..a8acc8c
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright(c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using Tizen.NUI.BaseComponents;
+
+namespace Tizen.NUI.Samples
+{
+    using log = Tizen.Log;
+    public class PlaceHolderImageSample : IExample
+    {
+        private const string tag = "NUITEST";
+        private Window mainWin;
+        private ImageView[] imageViews = null;
+        const int imageWidth = 500;
+        const int imageHeight = 500;
+        const int imageMax = 6;
+        Timer mTimer;
+        int image_count = 0;
+
+        private static string[] url = new string[]
+        {
+            "https://images.pexels.com/photos/16027424/pexels-photo-16027424.jpeg",
+            "https://images.pexels.com/photos/214574/pexels-photo-214574.jpeg",
+            "https://images.pexels.com/photos/39853/woman-girl-freedom-happy-39853.jpeg",
+            "https://images.pexels.com/photos/842711/pexels-photo-842711.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2",
+            "https://images.pexels.com/photos/15828302/pexels-photo-15828302.jpeg",
+            "",
+        };
+
+        public void Activate()
+        {
+            Initialize();
+        }
+
+        public void Deactivate()
+        {
+        }
+
+        private void Initialize()
+        {
+            mainWin = NUIApplication.GetDefaultWindow();
+            mainWin.BackgroundColor = Color.White;
+            mainWin.WindowSize = new Size2D(1920,1080);
+            Size2D windowSize = new Size2D(mainWin.Size.Width,mainWin.Size.Height);
+
+            imageViews = new ImageView[imageMax];
+            for(int i=0; i<imageMax; i++)
+            {
+                int width = (i%(imageMax/2))*imageWidth;
+                int height = (i/(imageMax/2))*imageHeight;
+                imageViews[i] = new ImageView();
+                imageViews[i].Size2D = new Size2D(imageWidth, imageHeight);
+                imageViews[i].Position2D = new Position2D(width,height);
+                imageViews[i].ResourceUrl = url[i];
+                imageViews[i].PlaceHolderUrl = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "images/placeholder_image.png";
+                imageViews[i].TransitionEffect = true;
+                mainWin.Add(imageViews[i]);
+            }
+
+            mTimer = new Timer(5000);
+            mTimer.Tick += ((object target, Timer.TickEventArgs args) =>
+            {
+                image_count++;
+                for(int i=0;i<imageMax;i++)
+                {
+                    imageViews[i].ResourceUrl = url[(image_count+i)%imageMax];
+                }
+                return true;
+            });
+
+            mTimer.Start();
+        }
+    }
+}
diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/images/placeholder_image.png b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/images/placeholder_image.png
new file mode 100755 (executable)
index 0000000..6151e06
Binary files /dev/null and b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/images/placeholder_image.png differ
diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/images/placeholder_image_large.png b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/images/placeholder_image_large.png
new file mode 100755 (executable)
index 0000000..93b67e5
Binary files /dev/null and b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/res/images/placeholder_image_large.png differ