From: Agnelo Vaz Date: Thu, 15 Jun 2017 15:36:32 +0000 (+0100) Subject: Adding ResourceLoaded signal and API X-Git-Tag: accepted/tizen/unified/20170630.083250~13^2~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80ec6a044f559f44e15e612cb01ec3590473001e;p=platform%2Fcore%2Fcsapi%2Fnui.git Adding ResourceLoaded signal and API Change-Id: I92d671097042bff765c29b308a091805f16a31ab --- diff --git a/Tizen.NUI/src/public/BaseComponents/View.cs b/Tizen.NUI/src/public/BaseComponents/View.cs index 1d9ef46..d4b6c89 100755 --- a/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/Tizen.NUI/src/public/BaseComponents/View.cs @@ -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; + + /// + /// Event for ResourcesLoadedSignal signal which can be used to subscribe/unsubscribe the event handler provided by the user.
+ /// This signal is emitted after all resources required by a View are loaded and ready.
+ ///
+ 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 } /// + /// Query if all resources required by a View are loaded and ready. + /// + /// Most resources are only loaded when the control is placed on stage + /// + public bool IsResourceReady() + { + bool ret = NDalicPINVOKE.IsResourceReady(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// /// Raise the view to above the target view. /// /// 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; + } + /// /// Gets/Sets the origin of an view, within its parent's area.
/// 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.