From: Bowon Ryu Date: Mon, 15 Jul 2024 01:31:45 +0000 (+0900) Subject: [NUI] Add RequestAsyncHeightForWidth to TextLabel X-Git-Tag: submit/tizen/20240821.061804~1^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8641a1462298039acf3eb3c43fd3cc1d8de5bbd2;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add RequestAsyncHeightForWidth to TextLabel RequestAsyncHeightForWidth computes the hegiht for width of text asynchronously. The result is received through the AsyncHeightForWidthComputed. Signed-off-by: Bowon Ryu --- diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs b/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs index 82288048a..3e7aee5d1 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs @@ -211,11 +211,17 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_RequestAsyncNaturalSize")] public static extern void RequestAsyncNaturalSize(global::System.Runtime.InteropServices.HandleRef textLabelRef); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_RequestAsyncHeightForWidth")] + public static extern void RequestAsyncHeightForWidth(global::System.Runtime.InteropServices.HandleRef textLabelRef, float width); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_AsyncTextRenderedSignal")] public static extern global::System.IntPtr AsyncTextRenderedSignal(global::System.Runtime.InteropServices.HandleRef jarg1); [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_AsyncNaturalSizeComputedSignal")] public static extern global::System.IntPtr AsyncNaturalSizeComputedSignal(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_AsyncHeightForWidthComputedSignal")] + public static extern global::System.IntPtr AsyncHeightForWidthComputedSignal(global::System.Runtime.InteropServices.HandleRef jarg1); } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 543af9d3f..0133a50a6 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -385,6 +385,17 @@ namespace Tizen.NUI.BaseComponents if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } + /// + /// Requests asynchronous computation of the height of the text based on the given width. + /// + /// The width of text to compute. + [EditorBrowsable(EditorBrowsableState.Never)] + public void RequestAsyncHeightForWidth(float width) + { + Interop.TextLabel.RequestAsyncHeightForWidth(SwigCPtr, width); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + /// /// The TranslatableText property.
/// The text can set the SID value.
diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabelEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabelEvent.cs index 78eb8ff6e..5fd377a8b 100644 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabelEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabelEvent.cs @@ -41,6 +41,9 @@ namespace Tizen.NUI.BaseComponents private EventHandler textLabelAsyncTextNaturalSizeComputedEventHandler; private AsyncTextNaturalSizeComputedCallbackDelegate textLabelAsyncTextNaturalSizeComputedCallbackDelegate; + private EventHandler textLabelAsyncTextHeightForWidthComputedEventHandler; + private AsyncTextHeightForWidthComputedCallbackDelegate textLabelAsyncTextHeightForWidthComputedCallbackDelegate; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void AnchorClickedCallbackDelegate(IntPtr textLabel, IntPtr href, uint hrefLength); @@ -53,6 +56,49 @@ namespace Tizen.NUI.BaseComponents [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void AsyncTextNaturalSizeComputedCallbackDelegate(IntPtr textLabel, float width, float height); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void AsyncTextHeightForWidthComputedCallbackDelegate(IntPtr textLabel, float width, float height); + + + /// + /// The AsyncHeightForWidthComputed signal is emitted when the async natural size computed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler AsyncHeightForWidthComputed + { + add + { + if (textLabelAsyncTextHeightForWidthComputedEventHandler == null) + { + textLabelAsyncTextHeightForWidthComputedCallbackDelegate = (OnAsyncHeightForWidthComputed); + AsyncHeightForWidthComputedSignal().Connect(textLabelAsyncTextHeightForWidthComputedCallbackDelegate); + } + textLabelAsyncTextHeightForWidthComputedEventHandler += value; + } + remove + { + textLabelAsyncTextHeightForWidthComputedEventHandler -= value; + if (textLabelAsyncTextHeightForWidthComputedEventHandler == null && AsyncHeightForWidthComputedSignal().Empty() == false) + { + AsyncHeightForWidthComputedSignal().Disconnect(textLabelAsyncTextHeightForWidthComputedCallbackDelegate); + } + } + } + + internal TextLabelSignal AsyncHeightForWidthComputedSignal() + { + TextLabelSignal ret = new TextLabelSignal(Interop.TextLabel.AsyncHeightForWidthComputedSignal(SwigCPtr), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + private void OnAsyncHeightForWidthComputed(IntPtr textLabel, float width, float height) + { + AsyncTextSizeComputedEventArgs e = new AsyncTextSizeComputedEventArgs(width, height); + + //here we send all data to user event handlers + textLabelAsyncTextHeightForWidthComputedEventHandler?.Invoke(this, e); + } /// /// The AsyncNaturalSizeComputed signal is emitted when the async natural size computed.