[NUI] Add Padding parameter for TextPageUtil (#2332)
authorJoogabYun <40262755+JoogabYun@users.noreply.github.com>
Tue, 8 Dec 2020 06:04:57 +0000 (15:04 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 8 Dec 2020 06:23:12 +0000 (15:23 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.TextUtils.cs
src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs
src/Tizen.NUI/src/public/Utility/TextPageUtil.cs

index 904725c..5f132d1 100755 (executable)
@@ -132,6 +132,12 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_RendererParameters_minLineSize_get")]
             public static extern float RendererParameters_minLineSize_get(global::System.Runtime.InteropServices.HandleRef jarg1);
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_RendererParameters_padding_set")]
+            public static extern void RendererParameters_padding_set(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_RendererParameters_padding_get")]
+            public static extern global::System.IntPtr RendererParameters_padding_get(global::System.Runtime.InteropServices.HandleRef jarg1);
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_RendererParameters")]
             public static extern void delete_RendererParameters(global::System.Runtime.InteropServices.HandleRef jarg1);
         }
index 653ba72..b37a819 100755 (executable)
@@ -640,6 +640,26 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        /// <summary>
+        /// Padding of TextLabel.
+        /// </summary>
+        // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Extents Padding
+        {
+            set
+            {
+                Interop.RendererParameters.RendererParameters_padding_set(swigCPtr, Extents.getCPtr(value));
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+            get
+            {
+                Extents ret = new Extents(Interop.RendererParameters.RendererParameters_padding_get(swigCPtr), true);
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                return ret;
+            }
+        }
+
     }
 
     /// <summary>
index 466e023..7aa78b2 100755 (executable)
@@ -31,23 +31,23 @@ namespace Tizen.NUI.Utility
     /// This is a class for stroing the text of a page.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
-    class PageData
+    internal class PageData
     {
-        public string previousTag { get; set; }
-        public string endTag { get; set; }
-        public int startOffset { get; set; }
-        public int endOffset { get; set; }
+        public string PreviousTag { get; set; }
+        public string EndTag { get; set; }
+        public int StartOffset { get; set; }
+        public int EndOffset { get; set; }
     }
 
     /// <summary>
     /// This is a class that stores information when parsing markup text.
     /// </summary>
     [EditorBrowsable(EditorBrowsableState.Never)]
-    class TagData
+    internal class TagData
     {
-        public string tagName { get; set; }
-        public string attributeName { get; set; }
-        public bool isEndTag { get; set; }
+        public string TagName { get; set; }
+        public string AttributeName { get; set; }
+        public bool IsEndTag { get; set; }
     }
 
     /// <summary>
@@ -124,6 +124,7 @@ namespace Tizen.NUI.Utility
             textParameters.EllipsisEnabled = true;
             textParameters.MarkupEnabled = previousMarkup;
             textParameters.MinLineSize = label.MinLineSize;
+            textParameters.Padding = label.Padding;
 
 
             Tizen.NUI.PropertyArray cutOffIndexArray = TextUtils.GetLastCharacterIndex(textParameters);
@@ -143,11 +144,11 @@ namespace Tizen.NUI.Utility
                 else
                 {
                     PageData pageData = new PageData();
-                    pageData.startOffset = offset;
+                    pageData.StartOffset = offset;
                     int cnt = (cutOffIndex - offset) < remainLength ? (cutOffIndex - offset) : remainLength;
                     remainLength -= cnt;
                     offset += cnt;
-                    pageData.endOffset = offset;
+                    pageData.EndOffset = offset;
                     pageList.Add(pageData);
                 }
                 totalPageCnt++;
@@ -176,10 +177,10 @@ namespace Tizen.NUI.Utility
             List<PageData> dataList = pageList.GetRange(pageNum - 1, 1);
             foreach (PageData data in dataList)
             {
-                int cnt = data.endOffset - data.startOffset;
+                int cnt = data.EndOffset - data.StartOffset;
                 char[] charArray = new char[cnt];
-                pageString.CopyTo(data.startOffset, charArray, 0, cnt);
-                string pageText = data.previousTag + new String(charArray) + data.endTag;
+                pageString.CopyTo(data.StartOffset, charArray, 0, cnt);
+                string pageText = data.PreviousTag + new String(charArray) + data.EndTag;
                 return pageText;
             }
             return "";
@@ -203,14 +204,14 @@ namespace Tizen.NUI.Utility
             bool isTag = false;
             bool isQuotationOpen = false;
             bool attributesFound = false;
-            tag.isEndTag = false;
+            tag.IsEndTag = false;
             bool isPreviousLessThan = true;
             bool isPreviousSlash = false;
 
             int character;
 
-            tag.tagName = "";
-            tag.attributeName = "";
+            tag.TagName = "";
+            tag.AttributeName = "";
             // SkipWhiteSpace(ref offset);
             while ((!isTag) && ((character = stream.Read()) != -1))
             {
@@ -220,7 +221,7 @@ namespace Tizen.NUI.Utility
                 {
                     if (isPreviousLessThan)
                     {
-                        tag.isEndTag = true;
+                        tag.IsEndTag = true;
                     }
                     else
                     {
@@ -235,16 +236,16 @@ namespace Tizen.NUI.Utility
                     isTag = true;
                     if (isPreviousSlash)
                     {
-                        tag.isEndTag = true;
+                        tag.IsEndTag = true;
                     }
 
                     if (!attributesFound)
                     {
-                        tag.tagName = new String(tagChaList.ToArray());
+                        tag.TagName = new String(tagChaList.ToArray());
                     }
                     else
                     {
-                        tag.attributeName = new String(tagChaList.ToArray());
+                        tag.AttributeName = new String(tagChaList.ToArray());
                     }
 
                     isPreviousSlash = false;
@@ -263,7 +264,7 @@ namespace Tizen.NUI.Utility
                     // Let's save tag name.
                     if (!attributesFound)
                     {
-                        tag.tagName = new String(tagChaList.ToArray());
+                        tag.TagName = new String(tagChaList.ToArray());
                         tagChaList.Clear();
                     }
                     tagChaList.Add((char)character);
@@ -293,15 +294,15 @@ namespace Tizen.NUI.Utility
             characterList.Clear();
             PageData pageData = new PageData();
 
-            pageData.startOffset = offset;
+            pageData.StartOffset = offset;
 
             // If the markup was previously open, the markup tag should be attached to the front.
             string tag = "";
             foreach (TagData data in tagList)
             {
-                tag += "<" + data.tagName + data.attributeName + ">";
+                tag += "<" + data.TagName + data.AttributeName + ">";
             }
-            pageData.previousTag = tag;
+            pageData.PreviousTag = tag;
 
 
             bool isTag = false;
@@ -319,7 +320,7 @@ namespace Tizen.NUI.Utility
 
                 if (isTag)
                 {
-                    if (tagData.isEndTag)
+                    if (tagData.IsEndTag)
                     {
                         int lastIndex = tagList.Count;
                         tagList.RemoveAt(lastIndex - 1);
@@ -341,11 +342,11 @@ namespace Tizen.NUI.Utility
             tag = "";
             foreach (TagData data in tagList)
             {
-                tag = "</" + data.tagName + ">" + tag;
+                tag = "</" + data.TagName + ">" + tag;
             }
-            pageData.endTag = tag;
+            pageData.EndTag = tag;
 
-            pageData.endOffset = offset;
+            pageData.EndOffset = offset;
             pageList.Add(pageData);
 
             if (character == -1) offset = -1;
@@ -353,4 +354,4 @@ namespace Tizen.NUI.Utility
         }
 
     }
-}
\ No newline at end of file
+}