Add API for adding WidgetInfo in runtime (#1517)
authortscholb <scholb.kim@samsung.com>
Mon, 6 Apr 2020 07:29:18 +0000 (16:29 +0900)
committerGitHub <noreply@github.com>
Mon, 6 Apr 2020 07:29:18 +0000 (16:29 +0900)
src/Tizen.NUI/src/internal/NUIWidgetCoreBackend.cs
src/Tizen.NUI/src/internal/WidgetApplication.cs
src/Tizen.NUI/src/public/NUIWidgetApplication.cs

index 7798fd6..69828cc 100755 (executable)
@@ -102,6 +102,14 @@ namespace Tizen.NUI
             _widgetInfo = widgetInfo;
         }
 
+        public void AddWidgetInfo(Dictionary<System.Type, string> widgetInfo)
+        {
+            if (_application != null)
+            {
+                _application.AddWidgetInfo( widgetInfo );
+            }
+        }
+
         /// <summary>
         /// Run Application.
         /// </summary>
index aca566a..680602f 100755 (executable)
@@ -107,6 +107,19 @@ namespace Tizen.NUI
             _widgetInfo = widgetInfo;
         }
 
+        public void AddWidgetInfo(Dictionary<Type, string> newWidgetInfo)
+        {
+            foreach (KeyValuePair<Type, string> widgetInfo in newWidgetInfo )
+            {
+                if ( _widgetInfo.ContainsKey(widgetInfo.Key) == false )
+                {
+                    _widgetInfo.Add(widgetInfo.Key, widgetInfo.Value );
+                    string widgetName = widgetInfo.Value;
+                    RegisterWidgetCreatingFunction(ref widgetName);
+                }
+            }
+        }
+
         public static System.IntPtr WidgetCreateFunction(ref string widgetName)
         {
             Dictionary<System.Type, string> widgetInfo = (Instance as WidgetApplication).WidgetInfo;
index e2a92fc..2857c66 100755 (executable)
@@ -62,6 +62,28 @@ namespace Tizen.NUI
             core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
         }
 
+        /// <summary>
+        /// Add WidgetInfo in runtime
+        /// </summary>
+        /// <param name="widgetType">Derived widget class type.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void AddWidgetType( System.Type widgetType )
+        {
+            NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
+            core?.AddWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
+        }
+
+        /// <summary>
+        /// Add WidgetInfo in runtime
+        /// </summary>
+        /// <param name="widgetTypes">Derived widget class type.</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void AddWidgetType( Dictionary<System.Type, string> widgetTypes )
+        {
+            NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
+            core?.AddWidgetInfo(widgetTypes);
+        }
+
         internal WidgetApplication ApplicationHandle
         {
             get