[NUI] Add brokenImageUrl
authortscholb <scholb.kim@samsung.com>
Tue, 7 Sep 2021 04:59:50 +0000 (13:59 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Mon, 27 Sep 2021 08:27:23 +0000 (17:27 +0900)
Add brokenImageUrl for setting broken image
users can use three Types BrokenImage from ThemeManger
the broken images are automatically changed internally considering the size of broken image and view.

src/Tizen.NUI/src/internal/Interop/Interop.StyleManager.cs
src/Tizen.NUI/src/public/Common/StyleManager.cs
src/Tizen.NUI/src/public/Theme/Theme.cs
src/Tizen.NUI/src/public/Theme/ThemeManager.cs

index f66bc8e..06d23e7 100755 (executable)
@@ -51,6 +51,12 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_StyleManager_SWIGUpcast")]
             public static extern global::System.IntPtr Upcast(global::System.IntPtr jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_StyleManager_SetBrokenImageUrl")]
+            public static extern void SetBrokenImageUrl(global::System.Runtime.InteropServices.HandleRef jarg1,uint jarg2, string jarg3);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_StyleManager_GetBrokenImageUrl")]
+            public static extern string GetBrokenImageUrl(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2);
         }
     }
 }
index 3c38637..5e68aa7 100755 (executable)
@@ -175,6 +175,43 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        /// <summary>
+        /// The Type of BrokenImage
+        /// </summary>
+        internal enum BrokenImageType
+        {
+            Small = 0,
+            Normal = 1,
+            Large = 2
+        }
+
+        /// <summary>
+        /// Sets the broken image url.
+        /// The broken image is the image to show when image loading is failed.
+        /// When the broken image and type are set in the Application,
+        /// the proper brokenImage is set automatically considering the size of view and the size of the brokenImage.
+        /// This Api is used from theme manager.
+        /// </summary>
+        /// <param name="type"> The type for brokenImage </param>
+        /// <param name="url"> The url for brokenImage </param>
+        internal void SetBrokenImageUrl(BrokenImageType type, string url)
+        {
+            Interop.StyleManager.SetBrokenImageUrl(SwigCPtr, (uint)type, url);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+
+        /// <summary>
+        /// Gets the broken image url
+        /// </summary>
+        /// <param name="type"> The type for brokenImage</param>
+        /// <returns> the url for brokenImage </returns>
+        internal string GetBrokenImageUrl(BrokenImageType type)
+        {
+            string ret = Interop.StyleManager.GetBrokenImageUrl(SwigCPtr, (uint)type);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
         internal StyleManager(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
         }
index 36d7ade..b0f1d4c 100755 (executable)
@@ -108,6 +108,24 @@ namespace Tizen.NUI
         public string Version { get; set; } = null;
 
         /// <summary>
+        /// The url of small broken image
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public string SmallBrokenImageUrl { get; set; } = null;
+
+        /// <summary>
+        /// The url of broken image
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public string BrokenImageUrl { get; set; } = null;
+
+        /// <summary>
+        /// The url of large broken image
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public string LargeBrokenImageUrl { get; set; } = null;
+
+        /// <summary>
         /// For Xaml use only.
         /// The bulit-in theme id that will be used as base of this.
         /// View styles with same key are merged.
@@ -289,7 +307,10 @@ namespace Tizen.NUI
             var result = new Theme()
             {
                 Id = this.Id,
-                Resources = Resources
+                Resources = Resources,
+                SmallBrokenImageUrl = this.SmallBrokenImageUrl,
+                BrokenImageUrl = this.BrokenImageUrl,
+                LargeBrokenImageUrl = this.LargeBrokenImageUrl
             };
 
             foreach (var item in this)
@@ -322,6 +343,12 @@ namespace Tizen.NUI
 
             if (Version == null) Version = theme.Version;
 
+            SmallBrokenImageUrl = theme.SmallBrokenImageUrl;
+
+            BrokenImageUrl = theme.BrokenImageUrl;
+
+            LargeBrokenImageUrl = theme.LargeBrokenImageUrl;
+
             foreach (var item in theme)
             {
                 if (item.Value == null)
@@ -354,6 +381,13 @@ namespace Tizen.NUI
                 Version = theme.Version;
             }
 
+            SmallBrokenImageUrl = theme.SmallBrokenImageUrl;
+
+            BrokenImageUrl = theme.BrokenImageUrl;
+
+            LargeBrokenImageUrl = theme.LargeBrokenImageUrl;
+
+
             foreach (var item in theme)
             {
                 if (item.Value == null)
index 5ade00b..998067d 100755 (executable)
@@ -161,6 +161,10 @@ namespace Tizen.NUI
                 newTheme.Id = "NONAME";
             }
 
+            StyleManager.Instance.SetBrokenImageUrl(StyleManager.BrokenImageType.Small, newTheme.SmallBrokenImageUrl ?? "");
+            StyleManager.Instance.SetBrokenImageUrl(StyleManager.BrokenImageType.Normal, newTheme.BrokenImageUrl ?? "");
+            StyleManager.Instance.SetBrokenImageUrl(StyleManager.BrokenImageType.Large, newTheme.LargeBrokenImageUrl ?? "");
+
             userTheme = newTheme;
             UpdateThemeForInitialize();
             UpdateThemeForUpdate();