[NUI] Add Window.Effect event (#1058)
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 10 Oct 2019 07:58:58 +0000 (16:58 +0900)
committerGitHub <noreply@github.com>
Thu, 10 Oct 2019 07:58:58 +0000 (16:58 +0900)
src/Tizen.NUI/src/internal/Interop/Interop.WindowEffectEventSignal.cs [new file with mode: 0755]
src/Tizen.NUI/src/internal/WindowEffectSignal.cs [new file with mode: 0755]
src/Tizen.NUI/src/public/Window.cs

diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.WindowEffectEventSignal.cs b/src/Tizen.NUI/src/internal/Interop/Interop.WindowEffectEventSignal.cs
new file mode 100755 (executable)
index 0000000..32d7970
--- /dev/null
@@ -0,0 +1,34 @@
+using System;
+
+namespace Tizen.NUI
+{
+    internal static partial class Interop
+    {
+        internal static partial class WindowTransitionEffectSignal
+        {
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Transition_EffectSignal")]
+            public static extern global::System.IntPtr GetSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Transition_Effect_Signal_Empty")]
+            public static extern bool Empty(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Transition_Effect_Signal_GetConnectionCount")]
+            public static extern uint GetConnectionCount(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Transition_Effect_Signal_Connect")]
+            public static extern void Connect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Transition_Effect_Signal_Disconnect")]
+            public static extern void Disconnect(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Transition_Effect_Signal_Emit")]
+            public static extern bool Emit(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2, int jarg3, int jarg4);
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Transition_Effect_Signal_new")]
+            public static extern global::System.IntPtr NewSignal();
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Window_Transition_Effect_Signal_delete")]
+            public static extern void DeleteSignal(global::System.Runtime.InteropServices.HandleRef jarg1);
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Tizen.NUI/src/internal/WindowEffectSignal.cs b/src/Tizen.NUI/src/internal/WindowEffectSignal.cs
new file mode 100755 (executable)
index 0000000..f7835b5
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright(c) 2019 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
+{
+    internal class WindowTransitionEffectSignal : Disposable
+    {
+        private global::System.Runtime.InteropServices.HandleRef swigCPtr;
+        protected bool swigCMemOwn;
+
+        internal WindowTransitionEffectSignal(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(WindowTransitionEffectSignal obj)
+        {
+            return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
+        }
+
+        protected override void Dispose(DisposeTypes type)
+        {
+            if (disposed)
+            {
+                return;
+            }
+
+            //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;
+                    Interop.WindowTransitionEffectSignal.DeleteSignal(swigCPtr);
+                }
+                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
+            }
+
+            base.Dispose(type);
+        }
+
+        public bool Empty()
+        {
+            bool ret = Interop.WindowTransitionEffectSignal.Empty(swigCPtr);
+
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        public uint GetConnectionCount()
+        {
+            uint ret = Interop.WindowTransitionEffectSignal.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<System.Delegate>(func);
+            {
+                Interop.WindowTransitionEffectSignal.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<System.Delegate>(func);
+            {
+                Interop.WindowTransitionEffectSignal.Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+        }
+
+        public bool Emit(Window arg1, int state, int type)
+        {
+            bool ret = Interop.WindowTransitionEffectSignal.Emit(swigCPtr, Window.getCPtr(arg1), state, type);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        public WindowTransitionEffectSignal(Window window) : this(Interop.WindowTransitionEffectSignal.GetSignal(Window.getCPtr(window)), true)
+        {
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+        }
+    }
+}
index 4f40777..582368a 100755 (executable)
@@ -1974,6 +1974,174 @@ namespace Tizen.NUI
                 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
             }
 
+            if(transitionEffectSignal != null)
+            {
+                TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
+            }
+
+        }
+
+        private void OnTransitionEffect(IntPtr window, int state, int type)
+        {
+            //Tizen.Log.Fatal("NUITEST", $"OnTransitionEffect() called");
+            if (window == global::System.IntPtr.Zero)
+            {
+                //Tizen.Log.Error("NUI", $"OnTransitionEffect() IntPtr window is null!");
+                return;
+            }
+
+            TransitionEffectArgs e = new TransitionEffectArgs();
+
+            e.State = (EffectStates)state;
+            //Tizen.Log.Error("NUITEST", $"e.State={e.State}");
+
+            e.Type = (EffectTypes)type;
+            //Tizen.Log.Error("NUITEST", $"e.Type={e.Type}");
+
+            if (transitionEffectHandler != null)
+            {
+                //Tizen.Log.Fatal("NUITEST", $"Execute transitionEffectHandler(this, e)!!!");
+                transitionEffectHandler(this, e);
+            }
+            return;
+        }
+
+        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        private delegate void TransitionEffectEventCallbackType(IntPtr window, int state, int type);
+
+        private TransitionEffectEventCallbackType transitionEffectEventCallback;
+
+        private event EventHandler<TransitionEffectArgs> transitionEffectHandler;
+
+        /// <summary>
+        /// EffectStates
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public enum EffectStates
+        {
+            /// <summary>
+            /// None
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            None = 0,
+            /// <summary>
+            /// Start
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            Start = 1,
+            /// <summary>
+            /// End
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            End = 2,
+        }
+
+        /// <summary>
+        /// EffectTypes
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public enum EffectTypes
+        {
+            /// <summary>
+            /// None
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            None = 0,
+            /// <summary>
+            /// Shown
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            Shown = 1,
+            /// <summary>
+            /// Hidden
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            Hidden = 2,
+            /// <summary>
+            /// Restacked
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            Restacked = 3,
+
+        }
+
+        /// <summary>
+        /// TransitionEffectArgs
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public class TransitionEffectArgs : EventArgs
+        {
+            private EffectStates state;
+            /// <summary>
+            /// State
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public EffectStates State
+            {
+                get
+                {
+                    return state;
+                }
+                set
+                {
+                    state = value;
+                }
+            }
+               private EffectTypes type;
+               /// <summary>
+               /// Type
+               /// </summary>
+               [EditorBrowsable(EditorBrowsableState.Never)]
+               public EffectTypes Type
+               {
+                       get
+                       {
+                               return type;
+                       }
+                       set
+                       {
+                               type = value;
+                }
+            }
+        }
+
+        /// <summary>
+        /// EffectStart
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public event EventHandler<TransitionEffectArgs> TransitionEffect
+        {
+            add
+            {
+                if (transitionEffectHandler== null)
+                {
+                    transitionEffectEventCallback = OnTransitionEffect;
+                    TransitionEffectEventSignal().Connect(transitionEffectEventCallback);
+                }
+                transitionEffectHandler += value;
+            }
+            remove
+            {
+                transitionEffectHandler -= value;
+                if (transitionEffectHandler == null && TransitionEffectEventSignal().Empty() == false)
+                {
+                    TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
+                }
+            }
+        }
+
+        private WindowTransitionEffectSignal transitionEffectSignal;
+        private WindowTransitionEffectSignal TransitionEffectEventSignal()
+        {
+            //Tizen.Log.Fatal("NUITEST", "TransitionEffectEventSignal()!");
+            if (transitionEffectSignal == null)
+            {
+                transitionEffectSignal = new WindowTransitionEffectSignal(this);
+                if (NDalicPINVOKE.SWIGPendingException.Pending)
+                    throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                //Tizen.Log.Fatal("NUITEST", $"transitionEffectSignal is null, new here!");
+            }
+            return transitionEffectSignal;
         }
 
     }