From: xb.teng Date: Wed, 24 May 2017 15:40:12 +0000 (+0800) Subject: Add HiddenInput for TextField X-Git-Tag: nui_0.2.41~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85861042cc6e1234c864f6b3543623c381c49ad8;p=platform%2Fcore%2Fcsapi%2Fnui.git Add HiddenInput for TextField Change-Id: I1843c731eae1f223477a49bdac7f4f9f386d7984 --- diff --git a/NUISamples/NUISamples/NUISamples.TizenTV/NUISamples.TizenTV.csproj b/NUISamples/NUISamples/NUISamples.TizenTV/NUISamples.TizenTV.csproj index 07d8a15..d389ee3 100755 --- a/NUISamples/NUISamples/NUISamples.TizenTV/NUISamples.TizenTV.csproj +++ b/NUISamples/NUISamples/NUISamples.TizenTV/NUISamples.TizenTV.csproj @@ -71,6 +71,7 @@ + diff --git a/NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test.cs b/NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test.cs new file mode 100755 index 0000000..a00a794 --- /dev/null +++ b/NUISamples/NUISamples/NUISamples.TizenTV/examples/text-test.cs @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2016 Samsung Electronics Co., Ltd. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +using System; +using System.Runtime.InteropServices; +using Tizen.NUI; +using Tizen.NUI.UIComponents; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Constants; + +namespace TextTest +{ + class Example : NUIApplication + { + public Example() : base() + { + } + + public Example(string stylesheet) : base(stylesheet) + { + } + + public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode) + { + } + + protected override void OnCreate() + { + base.OnCreate(); + Initialize(); + } + + public void Initialize() + { + Window window = Window.Instance; + window.BackgroundColor = Color.White; + + TextLabel pixelLabel = new TextLabel("Test Pixel Size 32.0f"); + pixelLabel.Position2D = new Position2D(10, 10); + pixelLabel.PixelSize = 32.0f; + pixelLabel.BackgroundColor = Color.Magenta; + window.GetDefaultLayer().Add(pixelLabel); + + TextLabel pointLabel = new TextLabel("Test Point Size 32.0f"); + pointLabel.Position2D = new Position2D(10, 100); + pointLabel.PointSize = 32.0f; + pointLabel.BackgroundColor = Color.Red; + window.GetDefaultLayer().Add(pointLabel); + + TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled."); + ellipsis.Size2D = new Size2D(100, 80); + ellipsis.Position2D = new Position2D(10, 200); + ellipsis.PointSize = 20.0f; + ellipsis.Ellipsis = true; + ellipsis.BackgroundColor = Color.Cyan; + window.GetDefaultLayer().Add(ellipsis); + + TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop."); + autoScrollStopMode.Size2D = new Size2D(400, 50); + autoScrollStopMode.Position2D = new Position2D(10, 300); + autoScrollStopMode.PointSize = 15.0f; + autoScrollStopMode.BackgroundColor = Color.Green; + autoScrollStopMode.AutoScrollStopMode = AutoScrollStopMode.FinishLoop; + autoScrollStopMode.EnableAutoScroll = true; + window.GetDefaultLayer().Add(autoScrollStopMode); + + TextField field = new TextField(); + field.Size2D = new Size2D(400, 100); + field.Position2D = new Position2D(10, 400); + field.BackgroundColor = Color.Cyan; + field.PlaceholderText = "input someth..."; + PropertyMap hiddenMap = new PropertyMap(); + hiddenMap.Add(HiddenInputProperty.Mode, new PropertyValue((int)HiddenInputModeType.ShowLastCharacter)); + hiddenMap.Add(HiddenInputProperty.ShowDuration, new PropertyValue(2)); + hiddenMap.Add(HiddenInputProperty.SubstituteCount, new PropertyValue(4)); + hiddenMap.Add(HiddenInputProperty.SubstituteCharacter, new PropertyValue(0x23)); + field.HiddenInputSettings = hiddenMap; + window.GetDefaultLayer().Add(field); + } + + [STAThread] + static void _Main(string[] args) + { + Example example = new Example(); + example.Run(args); + } + } +} diff --git a/Tizen.NUI/src/internal/ManualPINVOKE.cs b/Tizen.NUI/src/internal/ManualPINVOKE.cs old mode 100644 new mode 100755 index 56da23b..6cbe612 --- a/Tizen.NUI/src/internal/ManualPINVOKE.cs +++ b/Tizen.NUI/src/internal/ManualPINVOKE.cs @@ -584,5 +584,16 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_TextLabel_Property_AUTO_SCROLL_LOOP_DELAY_get")] public static extern int TextLabel_Property_AUTO_SCROLL_LOOP_DELAY_get(); + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_HIDDENINPUT_PROPERTY_MODE_get")] + public static extern int HIDDENINPUT_PROPERTY_MODE_get(); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_HIDDENINPUT_PROPERTY_SUBSTITUTE_CHARACTER_get")] + public static extern int HIDDENINPUT_PROPERTY_SUBSTITUTE_CHARACTER_get(); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_HIDDENINPUT_PROPERTY_SUBSTITUTE_COUNT_get")] + public static extern int HIDDENINPUT_PROPERTY_SUBSTITUTE_COUNT_get(); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint = "CSharp_HIDDENINPUT_PROPERTY_SHOW_DURATION_get")] + public static extern int HIDDENINPUT_PROPERTY_SHOW_DURATION_get(); } } diff --git a/Tizen.NUI/src/public/BaseComponents/View.cs b/Tizen.NUI/src/public/BaseComponents/View.cs index f34776c..4e735f5 100755 --- a/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/Tizen.NUI/src/public/BaseComponents/View.cs @@ -705,31 +705,69 @@ namespace Tizen.NUI.BaseComponents return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } + //A Flag to check who called Dispose(). (By User or DisposeQueue) + private bool isDisposeQueued = false; + //A Flat to check if it is already disposed. + protected bool disposed = false; + ~Property() { - DisposeQueue.Instance.Add(this); + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } } public void Dispose() { - if (!Window.IsInstalled()) { - DisposeQueue.Instance.Add(this); + //Throw excpetion if Dispose() is called in separate thread. + if (!Window.IsInstalled()) + { + throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread."); + } + + if (isDisposeQueued) + { + Dispose(DisposeTypes.Implicit); + } + else + { + Dispose(DisposeTypes.Explicit); + System.GC.SuppressFinalize(this); + } + } + + protected virtual void Dispose(DisposeTypes type) + { + if (disposed) + { return; } - lock (this) + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (swigCPtr.Handle != global::System.IntPtr.Zero) { - if (swigCPtr.Handle != global::System.IntPtr.Zero) + if (swigCMemOwn) { - if (swigCMemOwn) - { - swigCMemOwn = false; - NDalicPINVOKE.delete_View_Property(swigCPtr); - } - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + swigCMemOwn = false; + NDalicPINVOKE.delete_View_Property(swigCPtr); } - global::System.GC.SuppressFinalize(this); + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } + + disposed = true; } internal static readonly int TOOLTIP = NDalicManualPINVOKE.View_Property_TOOLTIP_get(); diff --git a/Tizen.NUI/src/public/NUIConstants.cs b/Tizen.NUI/src/public/NUIConstants.cs index fc8bc7f..a2edc24 100755 --- a/Tizen.NUI/src/public/NUIConstants.cs +++ b/Tizen.NUI/src/public/NUIConstants.cs @@ -881,6 +881,44 @@ namespace Tizen.NUI } /// + /// HiddenInput Property. + /// + public struct HiddenInputProperty + { + public static readonly int Mode = NDalicManualPINVOKE.HIDDENINPUT_PROPERTY_MODE_get(); + public static readonly int SubstituteCharacter = NDalicManualPINVOKE.HIDDENINPUT_PROPERTY_SUBSTITUTE_CHARACTER_get(); + public static readonly int SubstituteCount = NDalicManualPINVOKE.HIDDENINPUT_PROPERTY_SUBSTITUTE_COUNT_get(); + public static readonly int ShowDuration = NDalicManualPINVOKE.HIDDENINPUT_PROPERTY_SHOW_DURATION_get(); + } + + /// + /// The type for HiddenInput mode. + /// + public enum HiddenInputModeType + { + /// + /// Don't hide text. + /// + HideNone, + /// + /// Hide all the input text. + /// + HideAll, + /// + /// Hide n characters from start. + /// + HideCount, + /// + /// Show n characters from start. + /// + ShowCount, + /// + /// Show last character for the duration(use ShowDuration property to modify duration). + /// + ShowLastCharacter + } + + /// /// ParentOrigin constants. /// public struct ParentOrigin