From: jeon <42333230+jhyuni@users.noreply.github.com> Date: Thu, 23 Jul 2020 08:28:38 +0000 (+0900) Subject: [NUI] Add WindowSystem softkey APIs (#1836) X-Git-Tag: accepted/tizen/unified/20210219.040944~542 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1c00cb55f04fb50fc0f5faedd0ba6afd18c061b;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add WindowSystem softkey APIs (#1836) --- diff --git a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.SoftkeyClient.cs b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.SoftkeyClient.cs new file mode 100644 index 0000000..52c5409 --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.SoftkeyClient.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.NUI +{ + internal static partial class Interop + { + internal static partial class SoftkeyClient + { + const string lib = "libtzsh_softkey.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_create")] + internal static extern IntPtr Create(IntPtr tzsh, IntPtr win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_destroy")] + internal static extern int Destroy(IntPtr softkeyClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_show")] + internal static extern int Show(IntPtr softkeyClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_hide")] + internal static extern int Hide(IntPtr softkeyClient); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_visible_state_get")] + internal static extern int GetVisibleState(IntPtr softkeyClient, out int visible); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_expand_state_set")] + internal static extern int SetExpandState(IntPtr softkeyClient, int expand); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_expand_state_get")] + internal static extern int GetExpandState(IntPtr softkeyClient, out int expand); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_opacity_state_set")] + internal static extern int SetOpacityState(IntPtr softkeyClient, int opacity); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_global_opacity_state_get")] + internal static extern int GetOpacityState(IntPtr softkeyClient, out int opacity); + + internal enum VisibleState + { + Unknown = 0x0, + Shown = 0x1, + Hidden = 0x2, + } + + internal enum ExpandState + { + Unknown = 0x0, + On = 0x1, + Off = 0x2, + } + + internal enum OpacityState + { + Unknown = 0x0, + Opaque = 0x1, + Transparent = 0x2, + } + } + } +} diff --git a/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.SoftkeyService.cs b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.SoftkeyService.cs new file mode 100644 index 0000000..a4f4cee --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/internal/Interop/Interop.SoftkeyService.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.NUI +{ + internal static partial class Interop + { + internal static partial class SoftkeyService + { + const string lib = "libtzsh_softkey_service.so.0"; + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_create")] + internal static extern IntPtr Create(IntPtr tzsh, IntPtr win); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_destroy")] + internal static extern int Destroy(IntPtr softkeyService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_show")] + internal static extern int Show(IntPtr softkeyService); + + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_hide")] + internal static extern int Hide(IntPtr softkeyService); + + internal delegate void SoftkeyVisibleEventCallback(IntPtr data, IntPtr softkeyService, int visible); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_visible_request_cb_set")] + internal static extern int SetVisibleEventHandler(IntPtr softkeyService, SoftkeyVisibleEventCallback func, IntPtr data); + + internal delegate void SoftkeyExpandEventCallback(IntPtr data, IntPtr softkeyService, int expand); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_expand_request_cb_set")] + internal static extern int SetExpandEventHandler(IntPtr softkeyService, SoftkeyExpandEventCallback func, IntPtr data); + + internal delegate void SoftkeyOpacityEventCallback(IntPtr data, IntPtr softkeyService, int opacity); + [global::System.Runtime.InteropServices.DllImport(lib, EntryPoint = "tzsh_softkey_service_opacity_request_cb_set")] + internal static extern int SetOpacityEventHandler(IntPtr softkeyService, SoftkeyOpacityEventCallback func, IntPtr data); + + internal enum VisibleState + { + Hide = 0x0, + Show = 0x1, + } + + internal enum ExpandState + { + Off = 0x0, + On = 0x1, + } + + internal enum OpacityState + { + Opaque = 0x0, + Transparent = 0x1, + } + } + } +} diff --git a/src/Tizen.NUI.WindowSystem/src/public/ShellEnums.cs b/src/Tizen.NUI.WindowSystem/src/public/ShellEnums.cs new file mode 100644 index 0000000..3066564 --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/public/ShellEnums.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.ComponentModel; + +namespace Tizen.NUI.WindowSystem.Shell +{ + /// + /// Visible state of softkey. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum SoftkeyVisibleState + { + /// + /// Unknown state. There is no softkey service. + /// + Unknown = 0x0, + /// + /// Shown state. + /// + Shown = 0x1, + /// + /// Hidden state. + /// + Hidden = 0x2, + } + + /// + /// Expand state of softkey. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum SoftkeyExpandState + { + /// + /// Unknown state. There is no softkey service. + /// + Unknown = 0x0, + /// + /// Expandable state. + /// + On = 0x1, + /// + /// Not Expandable state. + /// + Off = 0x2, + } + + /// + /// Opacity state of softkey. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public enum SoftkeyOpacityState + { + /// + /// Unknown state. There is no softkey service. + /// + Unknown = 0x0, + /// + /// Opaque state. + /// + Opaque = 0x1, + /// + /// Transparent state. + /// + Transparent = 0x2, + } +} diff --git a/src/Tizen.NUI.WindowSystem/src/public/SoftkeyClient.cs b/src/Tizen.NUI.WindowSystem/src/public/SoftkeyClient.cs new file mode 100644 index 0000000..f316a12 --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/public/SoftkeyClient.cs @@ -0,0 +1,292 @@ +/* + * Copyright(c) 2020 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.ComponentModel; + +namespace Tizen.NUI.WindowSystem.Shell +{ + /// + /// Class for the Tizen softkey client. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class SoftkeyClient : IDisposable + { + private TizenShell _tzsh; + private IntPtr _softkeyClient; + private int _tzshWin; + private bool disposed = false; + private bool isDisposeQueued = false; + + /// + /// Creates a new Softkey Client handle. + /// + /// The TizenShell instance. + /// The window to provide service of the quickpanel. + /// http://tizen.org/privilege/windowsystem.admin + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + /// Thrown when failed because of an invalid operation or no service. + /// Thrown when the caller does not have privilege to use this method. + /// Thrown when the feature is not supported. + public SoftkeyClient(TizenShell tzShell, Window win) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.GetNativeHandle() == IntPtr.Zero) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = win.GetNativeId(); + _softkeyClient = Interop.SoftkeyClient.Create(_tzsh.GetNativeHandle(), (IntPtr)_tzshWin); + if (_softkeyClient == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// Destructor. + /// + ~SoftkeyClient() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + if (isDisposeQueued) + { + Dispose(DisposeTypes.Implicit); + } + else + { + Dispose(DisposeTypes.Explicit); + GC.SuppressFinalize(this); + } + } + + /// + protected virtual void Dispose(DisposeTypes type) + { + if (!disposed) + { + if (_softkeyClient != IntPtr.Zero) + { + int res = Interop.SoftkeyClient.Destroy(_softkeyClient); + _softkeyClient = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Gets the visible state of a softkey service window. + /// + /// The visible state of the softkey service window. + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public SoftkeyVisibleState Visible + { + get + { + return GetVisible(); + } + } + + /// + /// Gets the expand state of a softkey service window. + /// + /// The expand state of the softkey service window. + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public SoftkeyExpandState Expand + { + get + { + return GetExpand(); + } + set + { + SetExpand(value); + } + } + + /// + /// Gets the opacity state of a softkey service window. + /// + /// The opacity state of the softkey service window. + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public SoftkeyOpacityState Opacity + { + get + { + return GetOpacity(); + } + set + { + SetOpacity(value); + } + } + + /// + /// Requests to show the softkey service window. + /// + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public void Show() + { + int res = Interop.SoftkeyClient.Show(_softkeyClient); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to hide the softkey service window. + /// + /// Thrown when failed of invalid argument. + /// Thrown when the feature is not supported. + /// Thrown when failed because of an invalid operation or no service. + public void Hide() + { + int res = Interop.SoftkeyClient.Hide(_softkeyClient); + _tzsh.ErrorCodeThrow(res); + } + + private SoftkeyVisibleState GetVisible() + { + int res = Interop.SoftkeyClient.GetVisibleState(_softkeyClient, out int vis); + + _tzsh.ErrorCodeThrow(res); + + return ChangeVisibleStateToPublic((Interop.SoftkeyClient.VisibleState)vis); + } + + private SoftkeyExpandState GetExpand() + { + int res = Interop.SoftkeyClient.GetExpandState(_softkeyClient, out int expand); + + _tzsh.ErrorCodeThrow(res); + + return ChangeExpandStateToPublic((Interop.SoftkeyClient.ExpandState)expand); + } + + private void SetExpand(SoftkeyExpandState expand) + { + int res = Interop.SoftkeyClient.SetExpandState(_softkeyClient, (int)(ChangeExpandStateToInternal(expand))); + + _tzsh.ErrorCodeThrow(res); + } + + private SoftkeyOpacityState GetOpacity() + { + int res = Interop.SoftkeyClient.GetOpacityState(_softkeyClient, out int opacity); + + _tzsh.ErrorCodeThrow(res); + + return ChangeOpacityStateToPublic((Interop.SoftkeyClient.OpacityState)opacity); + } + + private void SetOpacity(SoftkeyOpacityState opacity) + { + int res = Interop.SoftkeyClient.SetOpacityState(_softkeyClient, (int)(ChangeOpacityStateToInternal(opacity))); + + _tzsh.ErrorCodeThrow(res); + } + + private SoftkeyVisibleState ChangeVisibleStateToPublic(Interop.SoftkeyClient.VisibleState state) + { + if (state == Interop.SoftkeyClient.VisibleState.Shown) + return SoftkeyVisibleState.Shown; + else if (state == Interop.SoftkeyClient.VisibleState.Hidden) + return SoftkeyVisibleState.Hidden; + else + return SoftkeyVisibleState.Unknown; + } + + private Interop.SoftkeyClient.VisibleState ChangeVisibleStateToInternal(SoftkeyVisibleState state) + { + if (state == SoftkeyVisibleState.Shown) + return Interop.SoftkeyClient.VisibleState.Shown; + else if (state == SoftkeyVisibleState.Hidden) + return Interop.SoftkeyClient.VisibleState.Hidden; + else + return Interop.SoftkeyClient.VisibleState.Unknown; + } + + private SoftkeyExpandState ChangeExpandStateToPublic(Interop.SoftkeyClient.ExpandState state) + { + if (state == Interop.SoftkeyClient.ExpandState.On) + return SoftkeyExpandState.On; + else if (state == Interop.SoftkeyClient.ExpandState.Off) + return SoftkeyExpandState.Off; + else + return SoftkeyExpandState.Unknown; + } + + private Interop.SoftkeyClient.ExpandState ChangeExpandStateToInternal(SoftkeyExpandState state) + { + if (state == SoftkeyExpandState.On) + return Interop.SoftkeyClient.ExpandState.On; + else if (state == SoftkeyExpandState.Off) + return Interop.SoftkeyClient.ExpandState.Off; + else + return Interop.SoftkeyClient.ExpandState.Unknown; + } + + private SoftkeyOpacityState ChangeOpacityStateToPublic(Interop.SoftkeyClient.OpacityState state) + { + if (state == Interop.SoftkeyClient.OpacityState.Opaque) + return SoftkeyOpacityState.Opaque; + else if (state == Interop.SoftkeyClient.OpacityState.Transparent) + return SoftkeyOpacityState.Transparent; + else + return SoftkeyOpacityState.Unknown; + } + + private Interop.SoftkeyClient.OpacityState ChangeOpacityStateToInternal(SoftkeyOpacityState state) + { + if (state == SoftkeyOpacityState.Opaque) + return Interop.SoftkeyClient.OpacityState.Opaque; + else if (state == SoftkeyOpacityState.Transparent) + return Interop.SoftkeyClient.OpacityState.Transparent; + else + return Interop.SoftkeyClient.OpacityState.Unknown; + } + } +} diff --git a/src/Tizen.NUI.WindowSystem/src/public/SoftkeyService.cs b/src/Tizen.NUI.WindowSystem/src/public/SoftkeyService.cs new file mode 100644 index 0000000..22fd777 --- /dev/null +++ b/src/Tizen.NUI.WindowSystem/src/public/SoftkeyService.cs @@ -0,0 +1,282 @@ +/* + * Copyright(c) 2020 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.ComponentModel; + +namespace Tizen.NUI.WindowSystem.Shell +{ + /// + /// Class for the Tizen softkey service. + /// + /// This class is need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class SoftkeyService : IDisposable + { + private TizenShell _tzsh; + private IntPtr _softkeyService; + private int _tzshWin; + private bool disposed = false; + private bool isDisposeQueued = false; + + private Interop.SoftkeyService.SoftkeyVisibleEventCallback _onVisibleChanged; + private Interop.SoftkeyService.SoftkeyExpandEventCallback _onExpandChanged; + private Interop.SoftkeyService.SoftkeyOpacityEventCallback _onOpacityChanged; + + private event EventHandler _visibleChanged; + private event EventHandler _expandChanged; + private event EventHandler _opacityChanged; + + /// + /// Creates a new Softkey Service handle. + /// + /// The TizenShell instance. + /// The window to provide service of the quickpanel. + /// Thrown when failed of invalid argument. + /// Thrown when a argument is null. + public SoftkeyService(TizenShell tzShell, Window win) + { + if (tzShell == null) + { + throw new ArgumentNullException(nameof(tzShell)); + } + if (tzShell.GetNativeHandle() == IntPtr.Zero) + { + throw new ArgumentException("tzShell is not initialized."); + } + if (win == null) + { + throw new ArgumentNullException(nameof(win)); + } + + _tzsh = tzShell; + _tzshWin = win.GetNativeId(); + _softkeyService = Interop.SoftkeyService.Create(_tzsh.GetNativeHandle(), (IntPtr)_tzshWin); + if (_softkeyService == IntPtr.Zero) + { + int err = Tizen.Internals.Errors.ErrorFacts.GetLastResult(); + _tzsh.ErrorCodeThrow(err); + } + } + + /// + /// Destructor. + /// + ~SoftkeyService() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + /// + /// Dispose. + /// + public void Dispose() + { + if (isDisposeQueued) + { + Dispose(DisposeTypes.Implicit); + } + else + { + Dispose(DisposeTypes.Explicit); + GC.SuppressFinalize(this); + } + } + + /// + protected virtual void Dispose(DisposeTypes type) + { + if (!disposed) + { + if (_softkeyService != IntPtr.Zero) + { + int res = Interop.SoftkeyService.Destroy(_softkeyService); + _softkeyService = IntPtr.Zero; + } + disposed = true; + } + } + + /// + /// Emits the event when the visible state of the softkey service window is changed. + /// + /// Thrown when failed of invalid argument. + public event EventHandler VisibleChanged + { + add + { + if (_visibleChanged == null) + { + _onVisibleChanged = OnVisibleChanged; + int res = Interop.SoftkeyService.SetVisibleEventHandler(_softkeyService, _onVisibleChanged, IntPtr.Zero); + _tzsh.ErrorCodeThrow(res); + } + _visibleChanged += value; + } + remove + { + _visibleChanged -= value; + if (_visibleChanged == null) + { + int res = Interop.SoftkeyService.SetVisibleEventHandler(_softkeyService, null, IntPtr.Zero); + _tzsh.ErrorCodeThrow(res); + } + } + } + + /// + /// Emits the event when the expand state of the softkey service window is changed. + /// + /// Thrown when failed of invalid argument. + public event EventHandler ExpandChanged + { + add + { + if (_expandChanged == null) + { + _onExpandChanged = OnExpandChanged; + int res = Interop.SoftkeyService.SetExpandEventHandler(_softkeyService, _onExpandChanged, IntPtr.Zero); + _tzsh.ErrorCodeThrow(res); + } + _expandChanged += value; + } + remove + { + _expandChanged -= value; + if (_expandChanged == null) + { + int res = Interop.SoftkeyService.SetExpandEventHandler(_softkeyService, null, IntPtr.Zero); + _tzsh.ErrorCodeThrow(res); + } + } + } + + /// + /// Emits the event when the opacity state of the softkey service window is changed. + /// + /// Thrown when failed of invalid argument. + public event EventHandler OpacityChanged + { + add + { + if (_opacityChanged == null) + { + _onOpacityChanged = OnOpacityChanged; + int res = Interop.SoftkeyService.SetOpacityEventHandler(_softkeyService, _onOpacityChanged, IntPtr.Zero); + _tzsh.ErrorCodeThrow(res); + } + _opacityChanged += value; + } + remove + { + _opacityChanged -= value; + if (_opacityChanged == null) + { + int res = Interop.SoftkeyService.SetOpacityEventHandler(_softkeyService, null, IntPtr.Zero); + _tzsh.ErrorCodeThrow(res); + } + } + } + + private void OnVisibleChanged(IntPtr data, IntPtr softkeyService, int visible) + { + _visibleChanged?.Invoke(this, ChangeVisibleStateToPublic((Interop.SoftkeyService.VisibleState)visible)); + } + + private void OnExpandChanged(IntPtr data, IntPtr softkeyService, int expand) + { + _expandChanged?.Invoke(this, ChangeExpandStateToPublic((Interop.SoftkeyService.ExpandState)expand)); + } + + private void OnOpacityChanged(IntPtr data, IntPtr softkeyService, int opacity) + { + _opacityChanged?.Invoke(this, ChangeOpacityStateToPublic((Interop.SoftkeyService.OpacityState)opacity)); + } + + /// + /// Requests to show the softkey service window. + /// + /// Thrown when failed of invalid argument. + public void Show() + { + int res = Interop.SoftkeyService.Show(_softkeyService); + _tzsh.ErrorCodeThrow(res); + } + + /// + /// Requests to hide the softkey service window. + /// + /// Thrown when failed of invalid argument. + public void Hide() + { + int res = Interop.SoftkeyService.Hide(_softkeyService); + _tzsh.ErrorCodeThrow(res); + } + + private SoftkeyVisibleState ChangeVisibleStateToPublic(Interop.SoftkeyService.VisibleState state) + { + if (state == Interop.SoftkeyService.VisibleState.Show) + return SoftkeyVisibleState.Shown; + else + return SoftkeyVisibleState.Hidden; + } + + private Interop.SoftkeyService.VisibleState ChangeVisibleStateToInternal(SoftkeyVisibleState state) + { + if (state == SoftkeyVisibleState.Shown) + return Interop.SoftkeyService.VisibleState.Show; + else + return Interop.SoftkeyService.VisibleState.Hide; + } + + private SoftkeyExpandState ChangeExpandStateToPublic(Interop.SoftkeyService.ExpandState state) + { + if (state == Interop.SoftkeyService.ExpandState.On) + return SoftkeyExpandState.On; + else + return SoftkeyExpandState.Off; + } + + private Interop.SoftkeyService.ExpandState ChangeExpandStateToInternal(SoftkeyExpandState state) + { + if (state == SoftkeyExpandState.On) + return Interop.SoftkeyService.ExpandState.On; + else + return Interop.SoftkeyService.ExpandState.Off; + } + + private SoftkeyOpacityState ChangeOpacityStateToPublic(Interop.SoftkeyService.OpacityState state) + { + if (state == Interop.SoftkeyService.OpacityState.Opaque) + return SoftkeyOpacityState.Opaque; + else + return SoftkeyOpacityState.Transparent; + } + + private Interop.SoftkeyService.OpacityState ChangeOpacityStateToInternal(SoftkeyOpacityState state) + { + if (state == SoftkeyOpacityState.Opaque) + return Interop.SoftkeyService.OpacityState.Opaque; + else + return Interop.SoftkeyService.OpacityState.Transparent; + } + } +} diff --git a/test/Tizen.NUI.WindowSystem.Samples/Tizen.NUI.WindowSystem.Samples.cs b/test/Tizen.NUI.WindowSystem.Samples/Tizen.NUI.WindowSystem.Samples.cs index 9d7044f..a38f80f 100644 --- a/test/Tizen.NUI.WindowSystem.Samples/Tizen.NUI.WindowSystem.Samples.cs +++ b/test/Tizen.NUI.WindowSystem.Samples/Tizen.NUI.WindowSystem.Samples.cs @@ -1,4 +1,7 @@ using System; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Tizen.Applications.ComponentBased.Common; using Tizen.NUI; using Tizen.NUI.BaseComponents; using Tizen.NUI.Components; @@ -18,6 +21,19 @@ namespace Tizen.NUI.WindowSystem.Samples Shell.QuickPanelService qpService; Shell.TizenRegion qpRegion; Button BtnService; + Timer _timer; + + Shell.SoftkeyClient softkeyClient; + Button BtnSoftkeyClient; + TextLabel textSoftkeyClientVisible; + TextLabel textSoftkeyClientExpand; + TextLabel textSoftkeyClientOpacity; + + Shell.SoftkeyService softkeyService; + Button BtnSoftkeyService; + TextLabel textSoftkeyServiceVisible; + TextLabel textSoftkeyServiceExpand; + TextLabel textSoftkeyServiceOpacity; protected override void OnCreate() { @@ -43,15 +59,35 @@ namespace Tizen.NUI.WindowSystem.Samples { Text = "QuickPanelService", Size = new Size(400, 100), - Position = new Position(100, 500), + Position = new Position(100, 400), + Margin = 10, + }; + + BtnSoftkeyClient = new Button() + { + Text = "SoftkeyClient", + Size = new Size(400, 100), + Position = new Position(100, 600), + Margin = 10, + }; + + BtnSoftkeyService = new Button() + { + Text = "SoftkeyService", + Size = new Size(400, 100), + Position = new Position(100, 800), Margin = 10, }; window.Add(BtnClient); window.Add(BtnService); + window.Add(BtnSoftkeyClient); + window.Add(BtnSoftkeyService); BtnClient.ClickEvent += BtnClient_ClickEvent; BtnService.ClickEvent += BtnService_ClickEvent; + BtnSoftkeyClient.ClickEvent += BtnSoftkeyClient_ClickEvent; + BtnSoftkeyService.ClickEvent += BtnSoftkeyService_ClickEvent; tzShell = new Shell.TizenShell(); @@ -85,6 +121,8 @@ namespace Tizen.NUI.WindowSystem.Samples window.Remove(BtnService); window.Remove(BtnClient); + window.Remove(BtnSoftkeyService); + window.Remove(BtnSoftkeyClient); qpClient = new Shell.QuickPanelClient(tzShell, window, Shell.QuickPanelClient.Types.SystemDefault); qpClient.VisibleChanged += OnVisibleEvent; @@ -195,10 +233,15 @@ namespace Tizen.NUI.WindowSystem.Samples private void BtnService_ClickEvent(object sender, Button.ClickEventArgs e) { Window window = NUIApplication.GetDefaultWindow(); + Shell.QuickPanelService.Types type = Shell.QuickPanelService.Types.AppsMenu; window.Remove(BtnService); window.Remove(BtnClient); - qpService = new Shell.QuickPanelService(tzShell, window, Shell.QuickPanelService.Types.SystemDefault); + window.Remove(BtnSoftkeyService); + window.Remove(BtnSoftkeyClient); + qpService = new Shell.QuickPanelService(tzShell, window, type); + //if ((type == Shell.QuickPanelService.Types.ContextMenu) || (type == Shell.QuickPanelService.Types.AppsMenu)) + //window.AddAuxiliaryHint("wm.policy.win.user.geometry", "1"); TextLabel textServiceType = new TextLabel($"Type: {qpService.ServiceType}"); textServiceType.Position = new Position(0, -300); @@ -261,6 +304,13 @@ namespace Tizen.NUI.WindowSystem.Samples Position = new Position(400, 1000), Margin = 10, }; + Button BtnTimerStop = new Button() + { + Text = "TimerStop", + Size = new Size(300, 80), + Position = new Position(50, 50), + Margin = 10, + }; BtnShow.ClickEvent += BtnServiceShow_ClickEvent; BtnHide.ClickEvent += BtnServiceHide_ClickEvent; @@ -272,6 +322,8 @@ namespace Tizen.NUI.WindowSystem.Samples BtnLockTrue.ClickEvent += BtnLockTrue_ClickEvent; BtnLockFalse.ClickEvent += BtnLockFalse_ClickEvent; + BtnTimerStop.ClickEvent += BtnTimerStop_ClickEvent; + window.Add(BtnShow); window.Add(BtnHide); @@ -282,6 +334,8 @@ namespace Tizen.NUI.WindowSystem.Samples window.Add(BtnLockTrue); window.Add(BtnLockFalse); + window.Add(BtnTimerStop); + qpRegion = new Shell.TizenRegion(tzShell); qpRegion.Add(window.WindowPosition.X, window.WindowPosition.Y, window.WindowSize.Width, window.WindowSize.Height - 50); qpService.SetContentRegion(0, qpRegion); @@ -291,6 +345,27 @@ namespace Tizen.NUI.WindowSystem.Samples qpRegion.Add(window.WindowPosition.X, window.WindowPosition.Y + window.WindowSize.Height - 50, window.WindowSize.Width, 50); qpService.SetHandlerRegion(0, qpRegion); qpRegion.Dispose(); + + _timer = new Timer(2000); + _timer.Tick += Timer_Tick; + _timer.Start(); + } + + bool _cnt = true; + + private bool Timer_Tick(object source, Timer.TickEventArgs e) + { + if (_cnt) + { + qpService.Show(); + } + else + { + qpService.Hide(); + } + _cnt = !_cnt; + return true; + } private void BtnServiceShow_ClickEvent(object sender, Button.ClickEventArgs e) @@ -322,6 +397,254 @@ namespace Tizen.NUI.WindowSystem.Samples { qpService.LockScroll(false); } + private void BtnTimerStop_ClickEvent(object sender, Button.ClickEventArgs e) + { + _timer.Stop(); + } + + private void BtnSoftkeyClient_ClickEvent(object sender, Button.ClickEventArgs e) + { + Window window = NUIApplication.GetDefaultWindow(); + + window.Remove(BtnService); + window.Remove(BtnClient); + window.Remove(BtnSoftkeyService); + window.Remove(BtnSoftkeyClient); + softkeyClient = new Shell.SoftkeyClient(tzShell, window); + + textSoftkeyClientVisible = new TextLabel($"Visible: {softkeyClient.Visible}"); + textSoftkeyClientVisible.Position = new Position(0, -100); + textSoftkeyClientVisible.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyClientVisible.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyClientVisible.TextColor = Color.Blue; + textSoftkeyClientVisible.PointSize = 12.0f; + textSoftkeyClientVisible.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyClientVisible.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyClientVisible); + + textSoftkeyClientExpand = new TextLabel($"Expand: {softkeyClient.Expand}"); + textSoftkeyClientExpand.Position = new Position(0, 0); + textSoftkeyClientExpand.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyClientExpand.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyClientExpand.TextColor = Color.Blue; + textSoftkeyClientExpand.PointSize = 12.0f; + textSoftkeyClientExpand.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyClientExpand.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyClientExpand); + + textSoftkeyClientOpacity = new TextLabel($"Opacity: {softkeyClient.Opacity}"); + textSoftkeyClientOpacity.Position = new Position(0, 100); + textSoftkeyClientOpacity.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyClientOpacity.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyClientOpacity.TextColor = Color.Blue; + textSoftkeyClientOpacity.PointSize = 12.0f; + textSoftkeyClientOpacity.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyClientOpacity.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyClientOpacity); + + Button BtnExpandSetOn = new Button() + { + Text = "Expand On", + Size = new Size(300, 100), + Position = new Position(50, 800), + Margin = 10, + }; + Button BtnExpandSetOff = new Button() + { + Text = "Expand Off", + Size = new Size(300, 100), + Position = new Position(400, 800), + Margin = 10, + }; + Button BtnOpacitySetOpaque = new Button() + { + Text = "Opacity Opaque", + Size = new Size(300, 100), + Position = new Position(50, 1000), + Margin = 10, + }; + Button BtnOpacitySetTransparent = new Button() + { + Text = "Opacity Transparent", + Size = new Size(300, 100), + Position = new Position(400, 1000), + Margin = 10, + }; + Button BtnShow = new Button() + { + Text = "Show", + Size = new Size(200, 100), + Position = new Position(50, 1100), + Margin = 10, + }; + Button BtnHide = new Button() + { + Text = "Hide", + Size = new Size(200, 100), + Position = new Position(410, 1100), + Margin = 10, + }; + + BtnExpandSetOn.ClickEvent += BtnExpandSetOn_ClickEvent; + BtnExpandSetOff.ClickEvent += BtnExpandSetOff_ClickEvent; + BtnOpacitySetOpaque.ClickEvent += BtnOpacitySetOpaque_ClickEvent; + BtnOpacitySetTransparent.ClickEvent += BtnOpacitySetTransparent_ClickEvent; + BtnShow.ClickEvent += BtnSoftkeyClientShow_ClickEvent; + BtnHide.ClickEvent += BtnSoftkeyClientHide_ClickEvent; + + window.Add(BtnExpandSetOn); + window.Add(BtnExpandSetOff); + window.Add(BtnOpacitySetOpaque); + window.Add(BtnOpacitySetTransparent); + window.Add(BtnShow); + window.Add(BtnHide); + } + + private void BtnExpandSetOn_ClickEvent(object sender, Button.ClickEventArgs e) + { + softkeyClient.Expand = Shell.SoftkeyExpandState.On; + textSoftkeyClientExpand.Text = $"Expand: {softkeyClient.Expand}"; + } + + private void BtnExpandSetOff_ClickEvent(object sender, Button.ClickEventArgs e) + { + softkeyClient.Expand = Shell.SoftkeyExpandState.Off; + textSoftkeyClientExpand.Text = $"Expand: {softkeyClient.Expand}"; + } + + private void BtnOpacitySetOpaque_ClickEvent(object sender, Button.ClickEventArgs e) + { + softkeyClient.Opacity = Shell.SoftkeyOpacityState.Opaque; + textSoftkeyClientOpacity.Text = $"Opacity: {softkeyClient.Opacity}"; + } + + private void BtnOpacitySetTransparent_ClickEvent(object sender, Button.ClickEventArgs e) + { + softkeyClient.Opacity = Shell.SoftkeyOpacityState.Transparent; + textSoftkeyClientOpacity.Text = $"Opacity: {softkeyClient.Opacity}"; + } + + private async Task ControlSoftKeyVisible(bool visible) + { + if (visible) + softkeyClient.Show(); + else + softkeyClient.Hide(); + await Task.Delay(50); + textSoftkeyClientVisible.Text = $"Visible: {softkeyClient.Visible}"; + } + + private void BtnSoftkeyClientShow_ClickEvent(object sender, Button.ClickEventArgs e) + { + _ = ControlSoftKeyVisible(true); + } + + private void BtnSoftkeyClientHide_ClickEvent(object sender, Button.ClickEventArgs e) + { + _ = ControlSoftKeyVisible(false); + } + + private void BtnSoftkeyService_ClickEvent(object sender, Button.ClickEventArgs e) + { + Window window = NUIApplication.GetDefaultWindow(); + window.WindowSize = new Size(500, 500); + window.WindowPosition = new Position(0, 700); + + window.Remove(BtnService); + window.Remove(BtnClient); + window.Remove(BtnSoftkeyService); + window.Remove(BtnSoftkeyClient); + softkeyService = new Shell.SoftkeyService(tzShell, window); + + textSoftkeyServiceVisible = new TextLabel($"Visible: None"); + textSoftkeyServiceVisible.Position = new Position(0, -100); + textSoftkeyServiceVisible.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyServiceVisible.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyServiceVisible.TextColor = Color.Blue; + textSoftkeyServiceVisible.PointSize = 12.0f; + textSoftkeyServiceVisible.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyServiceVisible.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyServiceVisible); + + textSoftkeyServiceExpand = new TextLabel($"Expand: None"); + textSoftkeyServiceExpand.Position = new Position(0, 0); + textSoftkeyServiceExpand.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyServiceExpand.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyServiceExpand.TextColor = Color.Blue; + textSoftkeyServiceExpand.PointSize = 12.0f; + textSoftkeyServiceExpand.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyServiceExpand.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyServiceExpand); + + textSoftkeyServiceOpacity = new TextLabel($"Opacity: None"); + textSoftkeyServiceOpacity.Position = new Position(0, 100); + textSoftkeyServiceOpacity.HorizontalAlignment = HorizontalAlignment.Center; + textSoftkeyServiceOpacity.VerticalAlignment = VerticalAlignment.Center; + textSoftkeyServiceOpacity.TextColor = Color.Blue; + textSoftkeyServiceOpacity.PointSize = 12.0f; + textSoftkeyServiceOpacity.HeightResizePolicy = ResizePolicyType.FillToParent; + textSoftkeyServiceOpacity.WidthResizePolicy = ResizePolicyType.FillToParent; + window.Add(textSoftkeyServiceOpacity); + + Button BtnShow = new Button() + { + Text = "Show", + Size = new Size(200, 100), + Position = new Position(50, 800), + Margin = 10, + }; + Button BtnHide = new Button() + { + Text = "Hide", + Size = new Size(200, 100), + Position = new Position(410, 800), + Margin = 10, + }; + + window.Add(BtnShow); + window.Add(BtnHide); + + BtnShow.ClickEvent += BtnSoftkeyServiceShow_ClickEvent; + BtnHide.ClickEvent += BtnSoftkeyServiceHide_ClickEvent; + + softkeyService.VisibleChanged += OnSoftkeyServiceVisibleEvent; + softkeyService.ExpandChanged += OnSoftkeyServiceExpandEvent; + softkeyService.OpacityChanged += OnSoftkeyServiceOpacityEvent; + } + + public void OnSoftkeyServiceVisibleEvent(object sender, Shell.SoftkeyVisibleState state) + { + Shell.SoftkeyService obj = (Shell.SoftkeyService)sender; + textSoftkeyServiceVisible.Text = $"Visible: {state}"; + if (state == Shell.SoftkeyVisibleState.Shown) + { + obj.Show(); + } + else + { + obj.Hide(); + } + } + + public void OnSoftkeyServiceExpandEvent(object sender, Shell.SoftkeyExpandState state) + { + textSoftkeyServiceExpand.Text = $"Expand: {state}"; + } + + public void OnSoftkeyServiceOpacityEvent(object sender, Shell.SoftkeyOpacityState state) + { + textSoftkeyServiceOpacity.Text = $"Opacity: {state}"; + } + + private void BtnSoftkeyServiceShow_ClickEvent(object sender, Button.ClickEventArgs e) + { + softkeyService.Show(); + } + + private void BtnSoftkeyServiceHide_ClickEvent(object sender, Button.ClickEventArgs e) + { + softkeyService.Hide(); + } static void Main(string[] args) { diff --git a/test/Tizen.NUI.WindowSystem.Samples/Tizen.NUI.WindowSystem.Samples.sln b/test/Tizen.NUI.WindowSystem.Samples/Tizen.NUI.WindowSystem.Samples.sln index 28d09d9..a6eca93 100644 --- a/test/Tizen.NUI.WindowSystem.Samples/Tizen.NUI.WindowSystem.Samples.sln +++ b/test/Tizen.NUI.WindowSystem.Samples/Tizen.NUI.WindowSystem.Samples.sln @@ -21,13 +21,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.Components", "..\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.Information", "..\..\src\Tizen.System.Information\Tizen.System.Information.csproj", "{1C93CF1D-452C-4EF8-BE4F-01023FC7318A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.Tests", "..\..\..\charp_api\tct-suite-vs\Tizen.NUI.Tests\Tizen.NUI.Tests.csproj", "{1F9B16FA-115C-4592-9EE2-18F011BBDEA1}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.framework", "..\..\..\charp_api\tct-suite-vs\nunit.framework\nunit.framework.csproj", "{37B85E87-6F6B-410A-9471-0774C3263033}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunitlite", "..\..\..\charp_api\tct-suite-vs\nunitlite\nunitlite.csproj", "{5E92B3C2-BF09-4C15-943C-8E251D0A7B58}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.NUI.WindowSystem", "..\..\src\Tizen.NUI.WindowSystem\Tizen.NUI.WindowSystem.csproj", "{FB1E79E8-90E1-4AB4-8C69-D3A17E33865E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.WindowSystem", "..\..\src\Tizen.NUI.WindowSystem\Tizen.NUI.WindowSystem.csproj", "{FB1E79E8-90E1-4AB4-8C69-D3A17E33865E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.NUI.Samples", "..\Tizen.NUI.Samples\Tizen.NUI.Samples\Tizen.NUI.Samples.csproj", "{E43F3735-04C1-4BC6-84E1-7316D22AA488}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -71,10 +71,6 @@ Global {1C93CF1D-452C-4EF8-BE4F-01023FC7318A}.Debug|Any CPU.Build.0 = Debug|Any CPU {1C93CF1D-452C-4EF8-BE4F-01023FC7318A}.Release|Any CPU.ActiveCfg = Release|Any CPU {1C93CF1D-452C-4EF8-BE4F-01023FC7318A}.Release|Any CPU.Build.0 = Release|Any CPU - {1F9B16FA-115C-4592-9EE2-18F011BBDEA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1F9B16FA-115C-4592-9EE2-18F011BBDEA1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1F9B16FA-115C-4592-9EE2-18F011BBDEA1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1F9B16FA-115C-4592-9EE2-18F011BBDEA1}.Release|Any CPU.Build.0 = Release|Any CPU {37B85E87-6F6B-410A-9471-0774C3263033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {37B85E87-6F6B-410A-9471-0774C3263033}.Debug|Any CPU.Build.0 = Debug|Any CPU {37B85E87-6F6B-410A-9471-0774C3263033}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -87,6 +83,10 @@ Global {FB1E79E8-90E1-4AB4-8C69-D3A17E33865E}.Debug|Any CPU.Build.0 = Debug|Any CPU {FB1E79E8-90E1-4AB4-8C69-D3A17E33865E}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB1E79E8-90E1-4AB4-8C69-D3A17E33865E}.Release|Any CPU.Build.0 = Release|Any CPU + {E43F3735-04C1-4BC6-84E1-7316D22AA488}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E43F3735-04C1-4BC6-84E1-7316D22AA488}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E43F3735-04C1-4BC6-84E1-7316D22AA488}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E43F3735-04C1-4BC6-84E1-7316D22AA488}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/Tizen.NUI.WindowSystem.Samples/tizen-manifest.xml b/test/Tizen.NUI.WindowSystem.Samples/tizen-manifest.xml index c6640ad..1f10b26 100644 --- a/test/Tizen.NUI.WindowSystem.Samples/tizen-manifest.xml +++ b/test/Tizen.NUI.WindowSystem.Samples/tizen-manifest.xml @@ -1,16 +1,16 @@  - - - - - Tizen.NUI.WindowSystem.Samples.png - - + + + + + Tizen.NUI.WindowSystem.Samples.png + + + + + + http://tizen.org/privilege/windowsystem.admin + + +