Adding ResourceLoaded signal and API
authorAgnelo Vaz <agnelo.vaz@samsung.com>
Thu, 15 Jun 2017 15:36:32 +0000 (16:36 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Fri, 16 Jun 2017 09:33:58 +0000 (10:33 +0100)
Change-Id: I92d671097042bff765c29b308a091805f16a31ab

src/Tizen.NUI/src/public/BaseComponents/View.cs

index 1d9ef46..d4b6c89 100755 (executable)
@@ -677,6 +677,50 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        // Resource Ready Signal
+
+        private EventHandler _resourcesLoadedEventHandler;
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        private delegate void ResourcesLoadedCallbackType(IntPtr control);
+        private ResourcesLoadedCallbackType _ResourcesLoadedCallback;
+
+        /// <summary>
+        /// Event for ResourcesLoadedSignal signal which can be used to subscribe/unsubscribe the event handler provided by the user.<br>
+        /// This signal is emitted after all resources required by a View are loaded and ready.<br>
+        /// </summary>
+        public event EventHandler ResourcesLoaded
+        {
+            add
+            {
+                if (_resourcesLoadedEventHandler == null)
+                {
+                    _ResourcesLoadedCallback = OnResourcesLoaded;
+                    this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
+                }
+
+                _resourcesLoadedEventHandler += value;
+            }
+
+            remove
+            {
+                _resourcesLoadedEventHandler -= value;
+
+                if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
+                {
+                    this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
+                }
+            }
+        }
+
+        private void OnResourcesLoaded(IntPtr view)
+        {
+            if (_resourcesLoadedEventHandler != null)
+            {
+                _resourcesLoadedEventHandler(this, null);
+            }
+        }
+
+
         internal static View GetViewFromPtr(global::System.IntPtr cPtr)
         {
             View ret = new View(cPtr, false);
@@ -1842,6 +1886,18 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Query if all resources required by a View are loaded and ready.
+        /// </summary>
+        /// <remarks>Most resources are only loaded when the control is placed on stage
+        /// </remarks>
+        public bool IsResourceReady()
+        {
+            bool ret = NDalicPINVOKE.IsResourceReady(swigCPtr);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
         /// Raise the view to above the target view.
         /// </summary>
         /// <remarks>Sibling order of views within the parent will be updated automatically.
@@ -2656,6 +2712,13 @@ namespace Tizen.NUI.BaseComponents
             return ret;
         }
 
+        internal ViewSignal ResourcesLoadedSignal()
+        {
+            ViewSignal ret = new ViewSignal(NDalicPINVOKE.ResourceReadySignal(swigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
         /// <summary>
         /// Gets/Sets the origin of an view, within its parent's area.<br>
         /// This is expressed in unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent, and(1.0, 1.0, 0.5) is the bottom-right corner.<br>