From: Seungho Baek Date: Tue, 16 Jul 2024 07:18:41 +0000 (+0900) Subject: [NUI] Add InheritedVisibilityChanged Event X-Git-Tag: submit/tizen/20240807.070632~1^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4b8fd291a4f6f13050ebd4d7e1e43dd9f23d114f;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add InheritedVisibilityChanged Event Signed-off-by: Seungho Baek --- diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.ActorSignal.cs b/src/Tizen.NUI/src/internal/Interop/Interop.ActorSignal.cs index 97e527c1b..ca88e612a 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.ActorSignal.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.ActorSignal.cs @@ -82,6 +82,12 @@ namespace Tizen.NUI [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_VisibilityChangedSignal_Disconnect")] public static extern void VisibilityChangedDisconnect(HandleRef actor, HandleRef handler); + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_InheritedVisibilityChangedSignal_Connect")] + public static extern void AggregatedVisibilityChangedConnect(HandleRef actor, HandleRef handler); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_InheritedVisibilityChangedSignal_Disconnect")] + public static extern void AggregatedVisibilityChangedDisconnect(HandleRef actor, HandleRef handler); + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Actor_LayoutDirectionChangedSignal_Connect")] public static extern void LayoutDirectionChangedConnect(HandleRef actor, HandleRef handler); diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index 0b082de31..8234b1a1c 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -43,11 +43,12 @@ namespace Tizen.NUI.BaseComponents private HoverEventCallbackType hoverEventCallback; private EventHandler visibilityChangedEventHandler; private VisibilityChangedEventCallbackType visibilityChangedEventCallback; + private EventHandler aggregatedVisibilityChangedEventHandler; + private AggregatedVisibilityChangedEventCallbackType aggregatedVisibilityChangedEventCallback; private EventHandler keyInputFocusGainedEventHandler; - private KeyInputFocusGainedCallbackType keyInputFocusGainedCallback; - private EventHandler keyInputFocusLostEventHandler; + private EventHandler keyInputFocusLostEventHandler; private KeyInputFocusLostCallbackType keyInputFocusLostCallback; private EventHandler onRelayoutEventHandler; private OnRelayoutEventCallbackType onRelayoutEventCallback; @@ -64,30 +65,43 @@ namespace Tizen.NUI.BaseComponents [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void OffWindowEventCallbackType(IntPtr control); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void AggregatedVisibilityChangedEventCallbackType(IntPtr data, bool visibility); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void ResourcesLoadedCallbackType(IntPtr control); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void _backgroundResourceLoadedCallbackType(IntPtr view); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void KeyInputFocusGainedCallbackType(IntPtr control); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void KeyInputFocusLostCallbackType(IntPtr control); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void OnRelayoutEventCallbackType(IntPtr control); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void OnWindowEventCallbackType(IntPtr control); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type); @@ -477,6 +491,7 @@ namespace Tizen.NUI.BaseComponents } } } + /// /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.
/// This event is sent when the visibility of this or a parent view is changed.
@@ -517,6 +532,43 @@ namespace Tizen.NUI.BaseComponents } } } + /// + /// An event for aggregated visibility change which can be used to subscribe or unsubscribe the event handler.
+ /// This event is sent when visible property of this View, any of its parents (right up to the root layer) or Window changes.
+ ///
+ /// + /// + /// This event is NOT sent if the view becomes transparent (or the reverse), it's ONLY linked with Show() and Hide() of View and Window. + /// For reference, a view is only shown if the view, its parents (up to the root view) and Window are also visible, + /// they are not transparent, and the view has a non-zero size. + /// So if its parent is not visible, the view is not shown. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler AggregatedVisibilityChanged + { + add + { + if (aggregatedVisibilityChangedEventHandler == null) + { + aggregatedVisibilityChangedEventCallback = OnAggregatedVisibilityChanged; + Interop.ActorSignal.AggregatedVisibilityChangedConnect(SwigCPtr, aggregatedVisibilityChangedEventCallback.ToHandleRef(this)); + NDalicPINVOKE.ThrowExceptionIfExists(); + } + aggregatedVisibilityChangedEventHandler += value; + } + + remove + { + aggregatedVisibilityChangedEventHandler -= value; + if (aggregatedVisibilityChangedEventHandler == null && aggregatedVisibilityChangedEventCallback != null) + { + Interop.ActorSignal.AggregatedVisibilityChangedDisconnect(SwigCPtr, aggregatedVisibilityChangedEventCallback.ToHandleRef(this)); + NDalicPINVOKE.ThrowExceptionIfExists(); + aggregatedVisibilityChangedEventCallback = null; + } + } + } /// /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.
@@ -1024,6 +1076,18 @@ namespace Tizen.NUI.BaseComponents } } + // Callback for View aggregated visibility change signal + private void OnAggregatedVisibilityChanged(IntPtr data, bool visibility) + { + AggregatedVisibilityChangedEventArgs e = new AggregatedVisibilityChangedEventArgs(); + e.Visibility = visibility; + + if (aggregatedVisibilityChangedEventHandler != null) + { + aggregatedVisibilityChangedEventHandler(this, e); + } + } + // Callback for View layout direction change signal private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type) { diff --git a/src/Tizen.NUI/src/public/Common/AggregatedVisibilityChangedEventArgs.cs b/src/Tizen.NUI/src/public/Common/AggregatedVisibilityChangedEventArgs.cs new file mode 100644 index 000000000..3edad7d90 --- /dev/null +++ b/src/Tizen.NUI/src/public/Common/AggregatedVisibilityChangedEventArgs.cs @@ -0,0 +1,38 @@ +/* + * Copyright(c) 2024 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 +{ + /// + /// Event arguments of aggregated visibility changed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class AggregatedVisibilityChangedEventArgs : EventArgs + { + /// + /// Whether the view is now visible or not. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool Visibility + { + get; set; + } + } +} diff --git a/src/Tizen.NUI/src/public/Common/Layer.cs b/src/Tizen.NUI/src/public/Common/Layer.cs index eadf02152..51e1374bf 100755 --- a/src/Tizen.NUI/src/public/Common/Layer.cs +++ b/src/Tizen.NUI/src/public/Common/Layer.cs @@ -29,11 +29,19 @@ namespace Tizen.NUI { private Window window; private int layoutCount = 0; + private EventHandler visibilityChangedEventHandler; private VisibilityChangedEventCallbackType visibilityChangedEventCallback; + + private EventHandler aggregatedVisibilityChangedEventHandler; + private AggregatedVisibilityChangedEventCallbackType aggregatedVisibilityChangedEventCallback; + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate void AggregatedVisibilityChangedEventCallbackType(IntPtr data, bool visibility); + /// /// Creates a Layer object. /// @@ -69,6 +77,15 @@ namespace Tizen.NUI visibilityChangedEventCallback = null; } + if (aggregatedVisibilityChangedEventCallback != null) + { + NUILog.Debug($"[Dispose] aggregatedVisibilityChangedEventCallback"); + + Interop.ActorSignal.AggregatedVisibilityChangedDisconnect(GetBaseHandleCPtrHandleRef, aggregatedVisibilityChangedEventCallback.ToHandleRef(this)); + NDalicPINVOKE.ThrowExceptionIfExistsDebug(); + aggregatedVisibilityChangedEventCallback = null; + } + LayoutCount = 0; base.Dispose(type); @@ -646,6 +663,35 @@ namespace Tizen.NUI } } } + /// + /// An event for aggregated visibility change which can be used to subscribe or unsubscribe the event handler.
+ /// This event is sent when visible property of this or any of its parents (right up to the root) and Window changes.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler AggregatedVisibilityChanged + { + add + { + if (aggregatedVisibilityChangedEventHandler == null) + { + aggregatedVisibilityChangedEventCallback = OnAggregatedVisibilityChanged; + Interop.ActorSignal.AggregatedVisibilityChangedConnect(SwigCPtr, aggregatedVisibilityChangedEventCallback.ToHandleRef(this)); + NDalicPINVOKE.ThrowExceptionIfExists(); + } + aggregatedVisibilityChangedEventHandler += value; + } + + remove + { + aggregatedVisibilityChangedEventHandler -= value; + if (aggregatedVisibilityChangedEventHandler == null && aggregatedVisibilityChangedEventCallback != null) + { + Interop.ActorSignal.AggregatedVisibilityChangedDisconnect(SwigCPtr, aggregatedVisibilityChangedEventCallback.ToHandleRef(this)); + NDalicPINVOKE.ThrowExceptionIfExists(); + aggregatedVisibilityChangedEventCallback = null; + } + } + } /// /// Event arguments of visibility changed. @@ -894,5 +940,17 @@ namespace Tizen.NUI visibilityChangedEventHandler(this, e); } } + + // Callback for Layer aggregated visibility change signal + private void OnAggregatedVisibilityChanged(IntPtr data, bool visibility) + { + AggregatedVisibilityChangedEventArgs e = new AggregatedVisibilityChangedEventArgs(); + e.Visibility = visibility; + + if (aggregatedVisibilityChangedEventHandler != null) + { + aggregatedVisibilityChangedEventHandler(this, e); + } + } } }