From 4f75e970555e2d497e71ef8ea4225d0beb72fa05 Mon Sep 17 00:00:00 2001 From: "xb.teng" Date: Tue, 13 Jun 2017 18:40:10 +0800 Subject: [PATCH] [Tizen] manual binding for TextEditor and InputMethod There are changes: 1. Add event ScrollStateChanged for TextEditor 2. Add InputMethod high level class for TextField 3. Fix a issue of ImageView 4. Update sample to test new feature Conflicts: Tizen.NUI/Tizen.NUI.csproj Tizen.NUI/src/public/NUIConstants.cs Change-Id: I81c84181ad54a4a62dea7ddd97167ffe3b1c4ab2 --- src/Tizen.NUI/src/internal/ManualPINVOKE.cs | 25 ++ .../src/internal/ScrollStateChangedSignal.cs | 142 ++++++++ .../src/public/BaseComponents/ImageView.cs | 1 + .../src/public/BaseComponents/TextEditor.cs | 94 +++++ src/Tizen.NUI/src/public/InputMethod.cs | 380 +++++++++++++++++++++ src/Tizen.NUI/src/public/NUIConstants.cs | 42 ++- 6 files changed, 671 insertions(+), 13 deletions(-) create mode 100755 src/Tizen.NUI/src/internal/ScrollStateChangedSignal.cs create mode 100755 src/Tizen.NUI/src/public/InputMethod.cs diff --git a/src/Tizen.NUI/src/internal/ManualPINVOKE.cs b/src/Tizen.NUI/src/internal/ManualPINVOKE.cs index 5669090..fd11376 100755 --- a/src/Tizen.NUI/src/internal/ManualPINVOKE.cs +++ b/src/Tizen.NUI/src/internal/ManualPINVOKE.cs @@ -664,5 +664,30 @@ namespace Tizen.NUI [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_delete_StateChangedSignalType")] public static extern void delete_StateChangedSignalType(global::System.Runtime.InteropServices.HandleRef jarg1); + //manual pinvoke for text-editor ScrollStateChangedSignal + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_TextEditor_ScrollStateChangedSignal")] + public static extern global::System.IntPtr TextEditor_ScrollStateChangedSignal(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ScrollStateChangedSignal_Empty")] + public static extern bool ScrollStateChangedSignal_Empty(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ScrollStateChangedSignal_GetConnectionCount")] + public static extern uint ScrollStateChangedSignal_GetConnectionCount(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ScrollStateChangedSignal_Connect")] + public static extern void ScrollStateChangedSignal_Connect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ScrollStateChangedSignal_Disconnect")] + public static extern void ScrollStateChangedSignal_Disconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_ScrollStateChangedSignal_Emit")] + public static extern void ScrollStateChangedSignal_Emit(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_new_ScrollStateChangedSignal")] + public static extern global::System.IntPtr new_ScrollStateChangedSignal(); + + [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_delete_ScrollStateChangedSignal")] + public static extern void delete_ScrollStateChangedSignal(global::System.Runtime.InteropServices.HandleRef jarg1); + } } diff --git a/src/Tizen.NUI/src/internal/ScrollStateChangedSignal.cs b/src/Tizen.NUI/src/internal/ScrollStateChangedSignal.cs new file mode 100755 index 0000000..e3c9c0a --- /dev/null +++ b/src/Tizen.NUI/src/internal/ScrollStateChangedSignal.cs @@ -0,0 +1,142 @@ +//------------------------------------------------------------------------------ +// +// +// This file was automatically generated by SWIG (http://www.swig.org). +// Version 3.0.12 +// +// Do not make changes to this file unless you know what you are doing--modify +// the SWIG interface file instead. +//------------------------------------------------------------------------------ +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI +{ + + internal class ScrollStateChangedSignal : global::System.IDisposable + { + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + protected bool swigCMemOwn; + + internal ScrollStateChangedSignal(global::System.IntPtr cPtr, bool cMemoryOwn) + { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ScrollStateChangedSignal obj) + { + 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; + + + ~ScrollStateChangedSignal() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + public void Dispose() + { + //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; + } + + 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 (swigCMemOwn) + { + swigCMemOwn = false; + NDalicManualPINVOKE.delete_ScrollStateChangedSignal(swigCPtr); + } + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + } + + disposed = true; + } + + public bool Empty() + { + bool ret = NDalicManualPINVOKE.ScrollStateChangedSignal_Empty(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public uint GetConnectionCount() + { + uint ret = NDalicManualPINVOKE.ScrollStateChangedSignal_GetConnectionCount(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Connect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + NDalicManualPINVOKE.ScrollStateChangedSignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + public void Disconnect(System.Delegate func) + { + System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(func); + { + NDalicManualPINVOKE.ScrollStateChangedSignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + public void Emit(View arg) + { + NDalicManualPINVOKE.ScrollStateChangedSignal_Emit(swigCPtr, View.getCPtr(arg)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + public ScrollStateChangedSignal() : this(NDalicManualPINVOKE.new_ScrollStateChangedSignal(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + } + +} diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index 95a31ca..7152e60 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -245,6 +245,7 @@ namespace Tizen.NUI.BaseComponents { get { + GetProperty(ImageView.Property.RESOURCE_URL).Get(out _url); return _url; } set diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 2b7b678..26fd4c2 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -151,6 +151,93 @@ namespace Tizen.NUI.BaseComponents } + /// + /// Event arguments that passed via ScrollStateChanged signal. + /// + public class ScrollStateChangedEventArgs : EventArgs + { + private TextEditor _textEditor; + private ScrollState _scrollState; + + /// + /// TextEditor - is the texteditor control which has the scroll state changed. + /// + public TextEditor TextEditor + { + get + { + return _textEditor; + } + set + { + _textEditor = value; + } + } + + /// + /// ScrollState - is the texteditor control scroll state. + /// + public ScrollState ScrollState + { + get + { + return _scrollState; + } + set + { + _scrollState = value; + } + } + } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void ScrollStateChangedCallbackDelegate(IntPtr textEditor, ScrollState state); + private EventHandler _textEditorScrollStateChangedEventHandler; + private ScrollStateChangedCallbackDelegate _textEditorScrollStateChangedCallbackDelegate; + + /// + /// Event for ScrollStateChanged signal which can be used to subscribe/unsubscribe the event handler + /// provided by the user. ScrollStateChanged signal is emitted when the scroll state changes.
+ ///
+ public event EventHandler ScrollStateChanged + { + add + { + if (_textEditorScrollStateChangedEventHandler == null) + { + _textEditorScrollStateChangedCallbackDelegate = OnScrollStateChanged; + ScrollStateChangedSignal(this).Connect(_textEditorScrollStateChangedCallbackDelegate); + } + _textEditorScrollStateChangedEventHandler += value; + } + remove + { + _textEditorScrollStateChangedEventHandler -= value; + if (_textEditorScrollStateChangedEventHandler == null && ScrollStateChangedSignal(this).Empty() == false) + { + ScrollStateChangedSignal(this).Disconnect(_textEditorScrollStateChangedCallbackDelegate); + } + } + } + + private void OnScrollStateChanged(IntPtr textEditor, ScrollState state) + { + ScrollStateChangedEventArgs e = new ScrollStateChangedEventArgs(); + + if (textEditor != null) + { + // Populate all members of "e" (ScrollStateChangedEventArgs) with real data + e.TextEditor = TextEditor.GetTextEditorFromPtr(textEditor); + e.ScrollState = state; + } + + if (_textEditorScrollStateChangedEventHandler != null) + { + //here we send all data to user event handlers + _textEditorScrollStateChangedEventHandler(this, e); + } + } + internal static TextEditor GetTextEditorFromPtr(global::System.IntPtr cPtr) { TextEditor ret = new TextEditor(cPtr, false); @@ -262,6 +349,13 @@ namespace Tizen.NUI.BaseComponents return ret; } + internal ScrollStateChangedSignal ScrollStateChangedSignal(TextEditor textEditor) + { + ScrollStateChangedSignal ret = new ScrollStateChangedSignal(NDalicManualPINVOKE.TextEditor_ScrollStateChangedSignal(TextEditor.getCPtr(textEditor)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + internal SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t InputStyleChangedSignal() { SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t ret = new SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t(NDalicPINVOKE.TextEditor_InputStyleChangedSignal(swigCPtr), false); diff --git a/src/Tizen.NUI/src/public/InputMethod.cs b/src/Tizen.NUI/src/public/InputMethod.cs new file mode 100755 index 0000000..c8aa42c --- /dev/null +++ b/src/Tizen.NUI/src/public/InputMethod.cs @@ -0,0 +1,380 @@ +// Copyright (c) 2017 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. +// + +namespace Tizen.NUI +{ + + /// + /// A class encapsulating the input method map. + /// + public class InputMethod + { + private PanelLayoutType? _panelLayout = null; + private ActionButtonTitleType? _actionButton = null; + private AutoCapitalType? _autoCapital = null; + private int? _variation = null; + + /// + /// Default constructor. + /// + public InputMethod() + { + } + + /// + /// Get or set panel layout. + /// + public PanelLayoutType PanelLayout + { + get + { + return _panelLayout ?? PanelLayoutType.Normal; + } + set + { + _panelLayout = value; + } + } + + /// + /// Get or set action button. + /// + public ActionButtonTitleType ActionButton + { + get + { + return _actionButton ?? ActionButtonTitleType.Default; + } + set + { + _actionButton = value; + } + } + + /// + /// Get or set auto capital. + /// + public AutoCapitalType AutoCapital + { + get + { + return _autoCapital ?? AutoCapitalType.None; + } + set + { + _autoCapital = value; + } + } + + /// + /// Get or set variation. + /// + public int Variation + { + get + { + return _variation ?? 0; + } + set + { + _variation = value; + } + } + + /// + /// Get or set variation for normal layout. + /// + public NormalLayoutType NormalVariation + { + get + { + return (NormalLayoutType) (_variation ?? 0); + } + set + { + _variation = (int)value; + } + } + + /// + /// Get or set variation for number only layout. + /// + public NumberOnlyLayoutType NumberOnlyVariation + { + get + { + return (NumberOnlyLayoutType) (_variation ?? 0); + } + set + { + _variation = (int)value; + } + } + + /// + /// Get or set variation for password layout. + /// + public PasswordLayoutType PasswordVariation + { + get + { + return (PasswordLayoutType) (_variation ?? 0); + } + set + { + _variation = (int)value; + } + } + + private PropertyMap ComposingInputMethodMap() + { + PropertyMap _outputMap = new PropertyMap(); + if (_panelLayout != null) { _outputMap.Add("PANEL_LAYOUT", new PropertyValue((int)_panelLayout)); } + if (_actionButton != null) { _outputMap.Add("ACTION_BUTTON", new PropertyValue((int)_actionButton)); } + if (_autoCapital != null) { _outputMap.Add("AUTO_CAPITALISE", new PropertyValue((int)_autoCapital)); } + if (_variation != null) { _outputMap.Add("VARIATION", new PropertyValue((int)_variation)); } + return _outputMap; + } + + /// + /// Get the input method map. + /// + public PropertyMap OutputMap + { + get + { + return ComposingInputMethodMap(); + } + } + + /// + /// SetType that can be changed in the system Input Method. + /// + public enum CategoryType + { + /// + /// Set Keyboard layout. + /// + PanelLayout, + /// + /// Set Action button title. + /// + ActionButtonTitle, + /// + /// Set Auto capitalise of input. + /// + AutoCapitalise, + /// + /// Set variation. + /// + Variation + } + + /// + /// Autocapitalization Types. + /// + public enum AutoCapitalType + { + /// + /// No auto-capitalization when typing. + /// + None, + /// + /// Autocapitalize each word typed. + /// + Word, + /// + /// Autocapitalize the start of each sentence. + /// + Sentence, + /// + /// Autocapitalize all letters. + /// + Allcharacter + } + + /// + /// Input panel (virtual keyboard) layout types.. + /// + public enum PanelLayoutType + { + /// + /// Default layout. + /// + Normal, + /// + /// Number layout. + /// + Number, + /// + /// Email layout. + /// + Email, + /// + /// URL layout. + /// + URL, + /// + /// Phone number layout. + /// + PhoneNumber, + /// + /// IP layout. + /// + IP, + /// + /// Month layout. + /// + Month, + /// + /// Number layout. + /// + NumberOnly, + /// + /// Hexadecimal layout. + /// + HEX, + /// + /// Command-line terminal layout including ESC, Alt, Ctrl key, so on (no auto-correct, no auto-capitalization). + /// + Terminal, + /// + /// Like normal, but no auto-correct, no auto-capitalization etc. + /// + Password, + /// + /// Date and time layout. + /// + Datetime, + /// + /// Emoticon layout. + /// + Emoticon + } + + /// + /// Specifies what the Input Method "action" button functionality is set to. + /// + public enum ActionButtonTitleType + { + /// + /// Default action. + /// + Default, + /// + /// Done. + /// + Done, + /// + /// Go action. + /// + Go, + /// + /// Join action. + /// + Join, + /// + /// Login action. + /// + Login, + /// + /// Next action. + /// + Next, + /// + /// Previous action. + /// + Previous, + /// + /// Search action. + /// + Search, + /// + /// Send action. + /// + Send, + /// + /// Sign in action. + /// + SignIn, + /// + /// Unspecified action. + /// + Unspecified, + /// + /// Nothing to do. + /// + None + } + + /// + /// Available variation for Normal layout. + /// + public enum NormalLayoutType + { + /// + /// The plain normal layout. + /// + Normal, + /// + /// Filename layout. sysbols such as '/' should be disabled. + /// + WithFilename, + /// + /// The name of a person. + /// + WithPersonName + } + + /// + /// Available variation for Number only layout. + /// + public enum NumberOnlyLayoutType + { + /// + /// The plain normal number layout. + /// + Normal, + /// + /// The number layout to allow a positive or negative sign at the start. + /// + WithSigned, + /// + /// The number layout to allow decimal point to provide fractional value. + /// + WithDecimal, + /// + /// The number layout to allow decimal point and negative sign. + /// + WithSignedAndDecimal + } + + /// + /// Available variation for Password layout. + /// + public enum PasswordLayoutType + { + /// + /// The normal password layout. + /// + Normal, + /// + /// The password layout to allow only number. + /// + WithNumberOnly + } + + } +} diff --git a/src/Tizen.NUI/src/public/NUIConstants.cs b/src/Tizen.NUI/src/public/NUIConstants.cs index 4ce1930..4104329 100755 --- a/src/Tizen.NUI/src/public/NUIConstants.cs +++ b/src/Tizen.NUI/src/public/NUIConstants.cs @@ -16,13 +16,13 @@ using System.ComponentModel; namespace Tizen.NUI { public enum ScrollModeType - { - XAxisScrollEnabled, - XAxisSnapToInterval, - XAxisScrollBoundary, - YAxisScrollEnabled, - YAxisSnapToInterval, - YAxisScrollBoundary + { + XAxisScrollEnabled, + XAxisSnapToInterval, + XAxisScrollBoundary, + YAxisScrollEnabled, + YAxisSnapToInterval, + YAxisScrollBoundary } /// @@ -33,8 +33,8 @@ namespace Tizen.NUI /// /// Actor will use its own color. /// - UseOwnColor, - /// + UseOwnColor, + /// /// Actor will use its parent color. /// UseParentColor, @@ -1297,7 +1297,8 @@ namespace Tizen.NUI /// /// An enum of screen mode. /// - public enum ScreenMode { + public enum ScreenMode + { /// /// The mode which turns the screen off after a timeout. /// @@ -1311,7 +1312,8 @@ namespace Tizen.NUI /// /// An enum of notification window's priority level. /// - public enum NotificationLevel { + public enum NotificationLevel + { /// /// No notification level.
/// Default level.
@@ -1339,7 +1341,8 @@ namespace Tizen.NUI /// /// An enum of Window types. /// - public enum WindowType { + public enum WindowType + { /// /// A default window type.
/// Indicates a normal, top-level window. @@ -1509,7 +1512,20 @@ namespace Tizen.NUI } } + /// + /// An enum of scroll state of text eidtor. + /// + public enum ScrollState + { + /// + /// Scrolling is started. + /// + Started, - + /// + /// Scrolling is finished. + /// + Finished + } } -- 2.7.4