[NUI] Add SetHiddenInput, GetHiddenInput to TextField
authorBowon Ryu <bowon.ryu@samsung.com>
Wed, 25 Aug 2021 08:18:18 +0000 (17:18 +0900)
committerhuiyu <35286162+huiyueun@users.noreply.github.com>
Tue, 7 Sep 2021 09:05:39 +0000 (18:05 +0900)
Add a HiddenInput struct to pass data of DALi HiddenInputSettings PropertyMap.
The HiddenInput struct can be used as an argument to
SetHiddenInput and GetHiddenInput methods.

// example
var hiddenInput = new Tizen.NUI.Text.HiddenInput();
hiddenInput.Mode = HiddenInputModeType.ShowLastCharacter;
hiddenInput.SubstituteCharacter = '★';
hiddenInput.SubstituteCount = 0;
hiddenInput.ShowLastCharacterDuration = 1000;

field.SetHiddenInput(hiddenInput);

Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs
src/Tizen.NUI/src/public/Common/NUIConstants.cs

index 8466caa..524d158 100755 (executable)
@@ -1348,6 +1348,46 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Set HiddenInput to TextField. <br />
+        /// </summary>
+        /// <param name="hiddenInput">The HiddenInput</param>
+        /// <remarks>
+        /// SetHiddenInput specifies the requested font style through <see cref="Tizen.NUI.Text.HiddenInput"/>. <br />
+        /// </remarks>
+        /// <example>
+        /// The following example demonstrates how to use the SetHiddenInput method.
+        /// <code>
+        /// var hiddenInput = new Tizen.NUI.Text.HiddenInput();
+        /// hiddenInput.Mode = HiddenInputModeType.ShowLastCharacter;
+        /// hiddenInput.SubstituteCharacter = '★';
+        /// hiddenInput.SubstituteCount = 0;
+        /// hiddenInput.ShowLastCharacterDuration = 1000;
+        /// field.SetHiddenInput(hiddenInput);
+        /// </code>
+        /// </example>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetHiddenInput(HiddenInput hiddenInput)
+        {
+            SetProperty(TextField.Property.HiddenInputSettings, new PropertyValue(TextUtils.GetHiddenInputMap(hiddenInput)));
+            NotifyPropertyChanged();
+        }
+
+        /// <summary>
+        /// Get HiddenInput from TextField. <br />
+        /// </summary>
+        /// <returns>The HiddenInput</returns>
+        /// <remarks>
+        /// <see cref="Tizen.NUI.Text.HiddenInput"/>
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public HiddenInput GetHiddenInput()
+        {
+            var map = new PropertyMap();
+            GetProperty(TextField.Property.HiddenInputSettings).Get(map);
+            return TextUtils.GetHiddenInputStruct(map);
+        }
+
+        /// <summary>
         /// The PixelSize property.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
index 10e8e38..bed09c3 100755 (executable)
@@ -1682,6 +1682,75 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// This method converts a HiddenInput struct to a PropertyMap and returns it.
+        /// The returned map can be used for set HiddenInputSettings PropertyMap in the SetHiddenInput method.
+        /// <param name="hiddenInput">The HiddenInput struct value.</param>
+        /// <returns> A PropertyMap for HiddenInput property. </returns>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static PropertyMap GetHiddenInputMap(HiddenInput hiddenInput)
+        {
+            var map = new PropertyMap();
+
+            map.Add(0, new PropertyValue((int)hiddenInput.Mode));
+
+            if (hiddenInput.SubstituteCharacter != null)
+                map.Add(1, new PropertyValue(Convert.ToInt32(hiddenInput.SubstituteCharacter)));
+
+            if (hiddenInput.SubstituteCount != null)
+                map.Add(2, new PropertyValue((int)hiddenInput.SubstituteCount));
+
+            if (hiddenInput.ShowLastCharacterDuration != null)
+                map.Add(3, new PropertyValue((int)hiddenInput.ShowLastCharacterDuration));
+
+            return map;
+        }
+
+        /// <summary>
+        /// This method converts a HiddenInputSettings map to a struct and returns it.
+        /// The returned struct can be returned to the user as a HiddenInput in the GetHiddenInput method.
+        /// <param name="map">The HiddenInput PropertyMap.</param>
+        /// <returns> A HiddenInput struct. </returns>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static HiddenInput GetHiddenInputStruct(PropertyMap map)
+        {
+            PropertyValue value = null;
+
+            var hiddenInput = new HiddenInput();
+
+            value = map.Find(0);
+            if (value != null)
+            {
+                value.Get(out int mode);
+                hiddenInput.Mode = (HiddenInputModeType)mode;
+            }
+
+            value = map.Find(1);
+            if (value != null)
+            {
+                value.Get(out int substituteCharacter);
+                hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter);
+            }
+
+            value = map.Find(2);
+            if (value != null)
+            {
+                value.Get(out int substituteCount);
+                hiddenInput.SubstituteCount = substituteCount;
+            }
+
+            value = map.Find(3);
+            if (value != null)
+            {
+                value.Get(out int showLastCharacterDuration);
+                hiddenInput.ShowLastCharacterDuration = showLastCharacterDuration;
+            }
+
+            return hiddenInput;
+        }
+
+        /// <summary>
         /// Copy the previously selected text into the clipboard and return the copied value.
         /// </summary>
         /// <param name="textEditor">The textEditor control from which the text is copied.</param>
index ed69f6d..95aef4a 100755 (executable)
@@ -2279,5 +2279,40 @@ namespace Tizen.NUI
             [EditorBrowsable(EditorBrowsableState.Never)]
             public bool Ellipsis { get; set; }
         }
+
+        /// <summary>
+        /// A struct to pass data of HiddenInputSettings PropertyMap. <br />
+        /// </summary>
+        /// <remarks>
+        /// The HiddenInput struct is used as an argument to SetHiddenInput and GetHiddenInput methods. <br />
+        /// See <see cref="Tizen.NUI.BaseComponents.TextField.SetHiddenInput"/> and <see cref="Tizen.NUI.BaseComponents.TextField.GetHiddenInput"/>. <br />
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public struct HiddenInput
+        {
+            /// <summary>
+            /// The mode for input text display. <br />
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public HiddenInputModeType Mode { get; set; }
+
+            /// <summary>
+            /// All input characters are substituted by this character (if null, the default value is '*'). <br />
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public char? SubstituteCharacter { get; set; }
+
+            /// <summary>
+            /// Length of text to show or hide, available when HideCount/ShowCount mode is used (if null, the default value is 0). <br />
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public int? SubstituteCount { get; set; }
+
+            /// <summary>
+            /// Hide last character after this duration, available when ShowLastCharacter mode (if null, the default value is 1000). <br />
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public int? ShowLastCharacterDuration { get; set; }
+        }
     }
 }