From 3b1df57b5a8884f80ea2114e55ba71eb5c620da4 Mon Sep 17 00:00:00 2001 From: dongsug-song <35130733+dongsug-song@users.noreply.github.com> Date: Tue, 25 Jun 2019 19:27:38 +0900 Subject: [PATCH] [NUI] Add VisualEventSignal(internal) (#901) --- .../internal/Interop/Interop.VisualEventSignal.cs | 36 + src/Tizen.NUI/src/internal/VisualEventSignal.cs | 148 ++++ .../BaseComponents/AnimatedVectorImageView.cs | 692 ----------------- .../public/BaseComponents/VectorAnimationView.cs | 822 +++++++++++++++++++++ src/Tizen.NUI/src/public/NUIConstants.cs | 42 +- src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs | 1 + 6 files changed, 1034 insertions(+), 707 deletions(-) create mode 100755 src/Tizen.NUI/src/internal/Interop/Interop.VisualEventSignal.cs create mode 100755 src/Tizen.NUI/src/internal/VisualEventSignal.cs delete mode 100755 src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs create mode 100755 src/Tizen.NUI/src/public/BaseComponents/VectorAnimationView.cs diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.VisualEventSignal.cs b/src/Tizen.NUI/src/internal/Interop/Interop.VisualEventSignal.cs new file mode 100755 index 0000000..465886a --- /dev/null +++ b/src/Tizen.NUI/src/internal/Interop/Interop.VisualEventSignal.cs @@ -0,0 +1,36 @@ + +using global::System; +using System.Runtime.InteropServices; + +namespace Tizen.NUI +{ + internal static partial class Interop + { + internal static partial class VisualEventSignal + { + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_Empty")] + public static extern bool Empty(HandleRef jarg1); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_GetConnectionCount")] + public static extern uint GetConnectionCount(HandleRef jarg1); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_Connect")] + public static extern void Connect(HandleRef jarg1, HandleRef jarg2); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_Disconnect")] + public static extern void Disconnect(HandleRef jarg1, HandleRef jarg2); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_Emit")] + public static extern void Emit(HandleRef jarg1, HandleRef jarg2, int jarg3, int jarg4); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_VisualEventSignal")] + public static extern IntPtr New(); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_VisualEventSignal")] + public static extern void Delete(HandleRef jarg1); + + [DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_View_VisualEventSignal")] + public static extern IntPtr NewWithView(HandleRef jarg1); + } + } +} diff --git a/src/Tizen.NUI/src/internal/VisualEventSignal.cs b/src/Tizen.NUI/src/internal/VisualEventSignal.cs new file mode 100755 index 0000000..24149a1 --- /dev/null +++ b/src/Tizen.NUI/src/internal/VisualEventSignal.cs @@ -0,0 +1,148 @@ +/* + * 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. + * + */ + +using global::System; +using System.Runtime.InteropServices; + +namespace Tizen.NUI +{ + internal class VisualEventSignal : IDisposable + { + public VisualEventSignal() : this(Interop.VisualEventSignal.New(), true) + { + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + ~VisualEventSignal() + { + if (!isDisposeQueued) + { + isDisposeQueued = true; + DisposeQueue.Instance.Add(this); + } + } + + public void Dispose() + { + 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); + 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 != IntPtr.Zero) + { + if (swigCMemOwn) + { + swigCMemOwn = false; + Interop.VisualEventSignal.Delete(swigCPtr); + } + swigCPtr = new HandleRef(null, IntPtr.Zero); + } + disposed = true; + } + + public bool Empty() + { + bool ret = Interop.VisualEventSignal.Empty(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public uint GetConnectionCount() + { + uint ret = Interop.VisualEventSignal.GetConnectionCount(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + public void Connect(Delegate func) + { + NUILog.Debug("VisualEventSignal.Connect()!"); + + IntPtr ip = Marshal.GetFunctionPointerForDelegate(func); + { + Interop.VisualEventSignal.Connect(swigCPtr, new HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + public void Disconnect(Delegate func) + { + NUILog.Debug("VisualEventSignal.Disconnect()!"); + + IntPtr ip = Marshal.GetFunctionPointerForDelegate(func); + { + Interop.VisualEventSignal.Disconnect(swigCPtr, new HandleRef(this, ip)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + + public void Emit(BaseComponents.View target, int visualIndex, int signalId) + { + Interop.VisualEventSignal.Emit(swigCPtr, BaseComponents.View.getCPtr(target), visualIndex, signalId); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + internal VisualEventSignal(IntPtr cPtr, bool cMemoryOwn) + { + swigCMemOwn = cMemoryOwn; + swigCPtr = new HandleRef(this, cPtr); + } + + internal static HandleRef getCPtr(VisualEventSignal obj) + { + return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; + } + + private HandleRef swigCPtr; + protected bool swigCMemOwn; + + private bool isDisposeQueued = false; + protected bool disposed = false; + + } +} diff --git a/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs deleted file mode 100755 index 61b1733..0000000 --- a/src/Tizen.NUI/src/public/BaseComponents/AnimatedVectorImageView.cs +++ /dev/null @@ -1,692 +0,0 @@ -/* - * 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.BaseComponents -{ - using global::System; - using global::System.Runtime.InteropServices; - using System.ComponentModel; - using Tizen.NUI; - using tizenlog = Tizen.Log; - - /// - /// AnimatedVectorImageView renders an animated vector image - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public class AnimatedVectorImageView : ImageView - { - /// - /// AnimatedVectorImageView constructor - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public AnimatedVectorImageView() - { - } - - /// - /// Animation finished event - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler Finished - { - add - { - if (finishedEventHandler == null) - { - tizenlog.Debug(debugTag, $"Finished()! add!"); - visualEventSignalCallback = onVisualEventSignal; - VisualEventSignal().Connect(visualEventSignalCallback); - } - finishedEventHandler += value; - } - remove - { - tizenlog.Debug(debugTag, $"Finished()! remove!"); - finishedEventHandler -= value; - if (finishedEventHandler == null && visualEventSignalCallback != null) - { - VisualEventSignal().Disconnect(visualEventSignalCallback); - } - } - } - - /// - /// Enumeration for what state the vector animation is in - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public enum PlayStateType - { - /// - /// Invalid - /// - Invalid = -1, - /// - /// Vector Animation has stopped - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - Stopped, - /// - /// The vector animation is playing - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - Playing, - /// - /// The vector animation is paused - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - Paused - } - - /// - /// Resource URL - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public string URL - { - get - { - string ret = ResourceUrl; - tizenlog.Debug(debugTag, $"URL get! base resource mUrl={ret}, name={Name}"); - PropertyMap map = Image; - if (map != null) - { - PropertyValue val = map.Find(ImageVisualProperty.URL); - if (val != null) - { - if (val.Get(out ret)) - { - tizenlog.Debug(debugTag, $"gotten url={ret}"); - return ret; - } - } - } - tizenlog.Error(tag, "[ERROR] fail to get ResourceUrl from dali"); - return ret; - } - set - { - tizenlog.Debug(debugTag, $"URL set! value={value}"); - string ret = (value == null ? "" : value); - url = ret; - PropertyMap map = new PropertyMap(); - map.Add(Visual.Property.Type, new PropertyValue((int)DevelVisual.Type.AnimatedVectorImage)) - .Add(ImageVisualProperty.URL, new PropertyValue(ret)); - Image = map; - } - } - - /// - /// The number of times the AnimatedVectorImageView will be looped - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public int LoopCount - { - set - { - tizenlog.Debug(debugTag, $"LoopCount set val={value}"); - PropertyMap map = new PropertyMap(); - map.Add(ImageVisualProperty.LoopCount, new PropertyValue(value)); - DoAction(vectorImageVisualIndex, (int)actionType.updateProperty, new PropertyValue(map)); - } - get - { - tizenlog.Debug(debugTag, $"LoopCount get!"); - PropertyMap map = base.Image; - var ret = 0; - if (map != null) - { - PropertyValue val = map.Find(ImageVisualProperty.LoopCount); - if (val != null) - { - if (val.Get(out ret)) - { - tizenlog.Debug(debugTag, $"gotten loop count={ret}"); - return ret; - } - } - } - tizenlog.Error(tag, "[ERROR] fail to get LoopCount from dali"); - return ret; - } - } - - /// - /// The playing state - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public PlayStateType PlayState - { - get - { - var ret = -1; - PropertyMap map = Image; - if (map != null) - { - PropertyValue val = map.Find((int)DevelVisual.Type.AnimatedVectorImage); - if (val != null) - { - if (val.Get(out ret)) - { - return (PlayStateType)ret; - } - } - } - tizenlog.Error(tag, $"[ERROR] fail to get PlayState from dali"); - return (PlayStateType)ret; - } - } - - /// - /// The animation progress - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public float CurrentProgress - { - set - { - float val = value; - tizenlog.Debug(debugTag, $"set progress={val}"); - DoAction(vectorImageVisualIndex, (int)actionType.jumpTo, new PropertyValue(val)); - } - get - { - float ret = -1.0f; - PropertyMap map = Image; - if (map != null) - { - PropertyValue val = map.Find(ImageVisualProperty.CurrentProgress); - if (val != null) - { - if (val.Get(out ret)) - { - return ret; - } - } - } - tizenlog.Error(tag, $"[ERROR] fail to get CurrentProgress from dali"); - return ret; - } - } - - /// - /// The animation frame - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public int CurrentFrame - { - set - { - currentFrame = value; - //to do - } - get - { - //to do - return currentFrame; - } - } - - /// - /// Animation will play between the values specified. Both values should be between 0-1, otherwise they will be ignored. - /// If the range provided is not in proper order(minimum, maximum ), it will be reordered. - /// Default 0 and 1 - /// - /// Vector2 type, between 0 and 1 - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public void SetPlayRange(Vector2 range) - { - PropertyMap map = new PropertyMap(); - map.Add(ImageVisualProperty.PlayRange, new PropertyValue(range)); - DoAction(vectorImageVisualIndex, (int)actionType.updateProperty, new PropertyValue(map)); - } - - /// - /// Get Animation play range - /// - /// Vector2 type, between 0 and 1 - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - public Vector2 GetPlayRange() - { - Vector2 ret = new Vector2(-1.0f, -1.0f); - PropertyMap map = Image; - if (map != null) - { - PropertyValue val = map.Find(ImageVisualProperty.PlayRange); - if (val != null) - { - if (val.Get(ret)) - { - return ret; - } - } - } - tizenlog.Error(tag, $"[ERROR] fail to get PlayRange from dali"); - return ret; - - } - - /// - /// Play AnimatedVectorImageView - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - new public void Play() - { - tizenlog.Debug(debugTag, $"play() called! my mUrl={url}"); - base.Play(); - } - - /// - /// Pause AnimatedVectorImageView - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - new public void Pause() - { - tizenlog.Debug(debugTag, $"pause() called! my mUrl={url}"); - base.Pause(); - } - - /// - /// Stop AnimatedVectorImageView - /// - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - new public void Stop() - { - tizenlog.Debug(debugTag, $"stop() called! my mUrl={url}"); - base.Stop(); - } - - /// - /// You can override it to clean-up your own resources - /// - /// DisposeTypes - /// none - // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) - [EditorBrowsable(EditorBrowsableState.Never)] - protected override 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. - base.Dispose(type); - } - - internal class VisualEventSignalArgs : EventArgs - { - public int VisualIndex - { - get - { - return visualIndex; - } - set - { - visualIndex = value; - } - } - - public int SignalId - { - get - { - return signalId; - } - set - { - signalId = value; - } - } - - int visualIndex; - int signalId; - } - - private enum actionType - { - /// - /// Play the animated vector image - /// - play, - /// - /// Pause the animated vector image - /// - pause, - /// - /// Stop the animated vector image. This is also Default playback mode - /// - stop, - /// - /// Jump to the specified frame. Property::FLOAT value should be passed - /// - jumpTo, - /// - /// Update the properties of the animated vector image - /// - updateProperty - }; - - private struct DevelVisual - { - internal enum Type - { - /// - /// Renders an animated gradient - /// - AnimatedGradient = Tizen.NUI.Visual.Type.AnimatedImage + 1, - /// - /// Renders an animated vector image - /// - AnimatedVectorImage = Tizen.NUI.Visual.Type.AnimatedImage + 2, - } - } - - private const string debugTag = "NUITEST"; - private const string tag = "NUI"; - //DummyControl.Property.TEST_VISUAL - private const int vectorImageVisualIndex = 10000000 + 1000 + 2; - private string url; - private int currentFrame; - private event EventHandler finishedEventHandler; - - private void OnFinished() - { - finishedEventHandler?.Invoke(this, null); - } - - private void onVisualEventSignal(IntPtr targetView, int visualIndex, int signalId) - { - OnFinished(); - - if (targetView != IntPtr.Zero) - { - View v = Registry.GetManagedBaseHandleFromNativePtr(targetView) as View; - if (v != null) - { - tizenlog.Debug(debugTag, $"targetView is not null! name={v.Name}"); - } - else - { - tizenlog.Debug(debugTag, $"target is something created from dali"); - } - } - VisualEventSignalArgs e = new VisualEventSignalArgs(); - e.VisualIndex = visualIndex; - e.SignalId = signalId; - visualEventSignalHandler?.Invoke(this, e); - - tizenlog.Debug(debugTag, $"@@ onVisualEventSignal()! visualIndex={visualIndex}, signalId={signalId}"); - } - - [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void VisualEventSignalCallbackType(IntPtr targetView, int visualIndex, int signalId); - - private VisualEventSignalCallbackType visualEventSignalCallback; - - private EventHandler visualEventSignalHandler; - - internal event EventHandler VisualEvent - { - add - { - if (visualEventSignalHandler == null) - { - visualEventSignalCallback = onVisualEventSignal; - VisualEventSignal().Connect(visualEventSignalCallback); - } - visualEventSignalHandler += value; - } - remove - { - visualEventSignalHandler -= value; - if (visualEventSignalHandler == null && VisualEventSignal().Empty() == false) - { - VisualEventSignal().Disconnect(visualEventSignalCallback); - } - } - } - - internal void EmitVisualEventSignal(int visualIndex, int signalId) - { - VisualEventSignal().Emit(this, visualIndex, signalId); - } - - internal VisualEventSignal VisualEventSignal() - { - VisualEventSignal ret = new VisualEventSignal(InterOp.View_VisaulEventSignal(View.getCPtr(this)), false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - } // AnimatedVectorImageView : ImageView -} // namespace Tizen.NUI.BaseComponents - -namespace Tizen.NUI -{ - using Tizen.NUI.BaseComponents; - using global::System; - using global::System.Runtime.InteropServices; - using System.ComponentModel; - using tizenlog = Tizen.Log; - - internal class VisualEventSignal : IDisposable - { - public VisualEventSignal() : this(InterOp.new_VisualEventSignal(), true) - { - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - ~VisualEventSignal() - { - if (!isDisposeQueued) - { - isDisposeQueued = true; - DisposeQueue.Instance.Add(this); - } - } - - /// - /// Dispose - /// - public void Dispose() - { - 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); - 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 != IntPtr.Zero) - { - if (swigCMemOwn) - { - swigCMemOwn = false; - InterOp.delete_VisualEventSignal(swigCPtr); - } - swigCPtr = new HandleRef(null, IntPtr.Zero); - } - disposed = true; - } - - public bool Empty() - { - bool ret = InterOp.VisualEventSignal_Empty(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public uint GetConnectionCount() - { - uint ret = InterOp.VisualEventSignal_GetConnectionCount(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - public void Connect(Delegate func) - { - tizenlog.Debug(tag, $"Connect()!"); - - IntPtr ip = Marshal.GetFunctionPointerForDelegate(func); - { - InterOp.VisualEventSignal_Connect(swigCPtr, new HandleRef(this, ip)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - } - - public void Disconnect(Delegate func) - { - IntPtr ip = Marshal.GetFunctionPointerForDelegate(func); - { - InterOp.VisualEventSignal_Disconnect(swigCPtr, new HandleRef(this, ip)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - } - - public void Emit(View target, int visualIndex, int signalId) - { - InterOp.VisualEventSignal_Emit(swigCPtr, View.getCPtr(target), visualIndex, signalId); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - - internal VisualEventSignal(IntPtr cPtr, bool cMemoryOwn) - { - swigCMemOwn = cMemoryOwn; - swigCPtr = new HandleRef(this, cPtr); - } - - internal static HandleRef getCPtr(VisualEventSignal obj) - { - return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; - } - - private const string tag = "NUI"; - private HandleRef swigCPtr; - protected bool swigCMemOwn; - - private bool isDisposeQueued = false; - protected bool disposed = false; - - } // internal class VisualEventSignal : IDisposable -} // namespace Tizen.NUI - -namespace Tizen.NUI -{ - using global::System.Runtime.InteropServices; - using global::System; - - internal partial class InterOp - { - const string Lib = "libdali-csharp-binder.so"; - - [DllImport(Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_Empty")] - public static extern bool VisualEventSignal_Empty(HandleRef jarg1); - - [DllImport(Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_GetConnectionCount")] - public static extern uint VisualEventSignal_GetConnectionCount(HandleRef jarg1); - - [DllImport(Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_Connect")] - public static extern void VisualEventSignal_Connect(HandleRef jarg1, HandleRef jarg2); - - [DllImport(Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_Disconnect")] - public static extern void VisualEventSignal_Disconnect(HandleRef jarg1, HandleRef jarg2); - - [DllImport(Lib, EntryPoint = "CSharp_Dali_VisualEventSignal_Emit")] - public static extern void VisualEventSignal_Emit(HandleRef jarg1, HandleRef jarg2, int jarg3, int jarg4); - - [DllImport(Lib, EntryPoint = "CSharp_Dali_new_VisualEventSignal")] - public static extern IntPtr new_VisualEventSignal(); - - [DllImport(Lib, EntryPoint = "CSharp_Dali_delete_VisualEventSignal")] - public static extern void delete_VisualEventSignal(HandleRef jarg1); - - [DllImport(Lib, EntryPoint = "CSharp_Dali_View_VisualEventSignal")] - public static extern IntPtr View_VisaulEventSignal(HandleRef jarg1); - } -} diff --git a/src/Tizen.NUI/src/public/BaseComponents/VectorAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/VectorAnimationView.cs new file mode 100755 index 0000000..af61697 --- /dev/null +++ b/src/Tizen.NUI/src/public/BaseComponents/VectorAnimationView.cs @@ -0,0 +1,822 @@ +/* + * 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. + * + */ + +using global::System; +using global::System.Runtime.InteropServices; +using System.ComponentModel; +using tizenlog = Tizen.Log; + +namespace Tizen.NUI.BaseComponents +{ + /// + /// AnimatedVectorImageView renders an animated vector image + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public class VectorAnimationViewTBD : ImageView + { + #region Constructor, Distructor, Dispose + /// + /// Construct VectorAnimationView. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public VectorAnimationViewTBD() : base() + { + NUILog.Debug($"AnimatedVectorImageView() constructor!"); + //default value in NUI level + currentStates.url = ""; + currentStates.frame = 0; + currentStates.loopCount = 0; + currentStates.repeatMode = RepeatModes.Restart; + currentStates.stopEndAction = EndActions.Cancel; + currentStates.framePlayRangeMin = -1; + currentStates.framePlayRangeMax = -1; + currentStates.changed = false; + currentStates.totalFrame = -1; + currentStates.scale = 1.0f; + } + + /// + /// Construct VectorAnimationView. + /// + /// Set scaling factor for Vector Animation, while creating. + /// + /// Throw API implementation is pending + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public VectorAnimationViewTBD(float scale) : base() + { + currentStates.scale = scale; + } + + /// + /// You can override it to clean-up your own resources + /// + /// DisposeTypes + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + NUILog.Debug($"Dispose(type={type})!"); + + 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. + + //disconnect event signal! + if (finishedEventHandler != null && visualEventSignalCallback != null) + { + VisualEventSignal().Disconnect(visualEventSignalCallback); + finishedEventHandler = null; + NUILog.Debug($"disconnect event signal!!!!"); + } + + base.Dispose(type); + } + #endregion + + + #region Property + /// + /// Set Resource URL + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public string ResourceURL + { + set + { + NUILog.Debug($"URL set! value={value}"); + string ret = (value == null ? "" : value); + currentStates.url = ret; + currentStates.changed = true; + + PropertyMap map = new PropertyMap(); + map.Add(Visual.Property.Type, new PropertyValue((int)DevelVisual.Type.AnimatedVectorImage)) + .Add(ImageVisualProperty.URL, new PropertyValue(currentStates.url)) + .Add(ImageVisualProperty.LoopCount, new PropertyValue(currentStates.loopCount)); + //.Add(ImageVisualProperty.StopEndAction, new PropertyValue((int)currentStates.stopEndAction)) + //.Add(ImageVisualProperty.RepeatMode, new PropertyValue((int)currentStates.repeatMode)); + Image = map; + } + get + { + string ret = ResourceUrl; + NUILog.Debug($"URL get! base resource mUrl={ret}, name={Name}"); + PropertyMap map = Image; + if (map != null) + { + PropertyValue val = map.Find(ImageVisualProperty.URL); + if (val != null) + { + if (val.Get(out ret)) + { + NUILog.Debug($"gotten url={ret}"); + return ret; + } + } + } + tizenlog.Error(tag, "[ERROR] fail to get ResourceUrl from dali"); + return ret; + } + } + + /// + /// The playing state + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public PlayStateType PlayState + { + get + { + var ret = -1; + PropertyMap map = Image; + if (map != null) + { + PropertyValue val = map.Find((int)DevelVisual.Type.AnimatedVectorImage); + if (val != null) + { + if (val.Get(out ret)) + { + return (PlayStateType)ret; + } + } + } + tizenlog.Error(tag, $"[ERROR] fail to get PlayState from dali"); + return (PlayStateType)ret; + } + } + + /// + /// The number of total frame + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public int TotalFrameNumber + { + get + { + int ret = -1; + PropertyMap map = Image; + if (map != null) + { + PropertyValue val = map.Find(ImageVisualProperty.TotalFrameNumber); + if (val != null) + { + if (val.Get(out ret)) + { + NUILog.Debug($"TotalFrameNumber get! ret={ret}"); + currentStates.totalFrame = ret; + return ret; + } + } + } + tizenlog.Error(tag, $"[ERROR] fail to get TotalFrameNumber from dali"); + return ret; + } + } + + /// + /// CurrentFrame of animation. + /// + /// Returns user set value for the current frame. Cannot provide actual playing current frame. + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public int CurrentFrame + { + set + { + currentStates.frame = value; + NUILog.Debug($"set CurrentFrame={currentStates.frame}"); + DoAction(vectorImageVisualIndex, (int)actionType.jumpTo, new PropertyValue(currentStates.frame)); + } + get + { + int ret = -1; + PropertyMap map = Image; + if (map != null) + { + PropertyValue val = map.Find(ImageVisualProperty.CurrentFrameNumber); + if (val != null) + { + if (val.Get(out ret)) + { + NUILog.Debug($"CurrentFrame get! val={ret}"); + return ret; + } + } + } + tizenlog.Error(tag, $"[ERROR] fail to get CurrentFrame from dali"); + return ret; + } + } + + /// + /// RepeatMode of animation. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public RepeatModes RepeatMode + { + set + { + currentStates.repeatMode = (RepeatModes)value; + currentStates.changed = true; + + + NUILog.Debug($"RepeatMode set val={currentStates.repeatMode}"); + //PropertyMap map = new PropertyMap(); + //map.Add(ImageVisualProperty.RepeatMode, new PropertyValue((int)currentStates.repeatMode)); + //DoAction(vectorImageVisualIndex, (int)actionType.updateProperty, new PropertyValue(map)); + } + get + { + NUILog.Debug($"RepeatMode get!"); + PropertyMap map = base.Image; + var ret = 0; + //if (map != null) + //{ + // PropertyValue val = map.Find(ImageVisualProperty.RepeatMode); + // if (val != null) + // { + // if (val.Get(out ret)) + // { + // NUILog.Debug($"gotten RepeatMode={ret}"); + // if (ret != (int)currentStates.repeatMode && ret > 0) + // { + // NUILog.Debug($"different RepeatMode! gotten={ret}, repeatMode={currentStates.repeatMode}"); + // return (int)currentStates.repeatMode; + // } + // return ret; + // } + // } + //} + tizenlog.Error(tag, "[ERROR] fail to get repeatMode from dali"); + return (RepeatModes)ret; + } + } + + /// + /// Get state of animation. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public AnimationStates AnimationState + { + private set; + get; + } + + /// + /// RepeatCount of animation. + /// The repeat count is 0 by default. + /// If the RepeatCount is 0, the animation is never repeated. + /// If the RepeatCount is greater than 0, the repeat mode will be taken into account. + /// If RepeatCount is -1, animation is infinite loops. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public int RepeatCount + { + set + { + if (value < 0) + { + currentStates.loopCount = -1; + } + else + { + currentStates.loopCount = value; + } + currentStates.changed = true; + + NUILog.Debug($"LoopCount set val={currentStates.loopCount}"); + PropertyMap map = new PropertyMap(); + map.Add(ImageVisualProperty.LoopCount, new PropertyValue(currentStates.loopCount)); + DoAction(vectorImageVisualIndex, (int)actionType.updateProperty, new PropertyValue(map)); + } + get + { + NUILog.Debug($"LoopCount get!"); + PropertyMap map = base.Image; + var ret = 0; + if (map != null) + { + PropertyValue val = map.Find(ImageVisualProperty.LoopCount); + if (val != null) + { + if (val.Get(out ret)) + { + NUILog.Debug($"gotten loop count={ret}"); + if (ret != currentStates.loopCount && ret > 0) + { + NUILog.Debug($"different loop count! gotten={ret}, loopCount={currentStates.loopCount}"); + return currentStates.loopCount; + } + return (ret < 0 ? ret : ret - 1); + } + } + } + tizenlog.Error(tag, "[ERROR] fail to get LoopCount from dali"); + return ret; + } + } + #endregion + + + #region Method + /// + /// Set minimum frame and maximum frame + /// + /// minimum frame. + /// maximum frame. + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetMinAndMaxFrame(int minFrame, int maxFrame) + { + var mMinFrame = (minFrame) > 0 ? minFrame : 0; + var mMaxFrame = (maxFrame) > 0 ? maxFrame : 0; + + if (mMinFrame > mMaxFrame) + { + return; + } + NUILog.Debug($"SetMinAndMaxFrame()! minFrame={mMinFrame}, maxFrame={mMaxFrame}"); + + Vector2 range = new Vector2((float)mMinFrame, (float)mMaxFrame); + SetFramePlayRange(range); + } + + /// + /// Play Animation. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public new void Play() + { + NUILog.Debug($"Play() called!"); + debugPrint(); + base.Play(); + AnimationState = AnimationStates.Playing; + } + + /// + /// Pause Animation. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public new void Pause() + { + NUILog.Debug($"Pause() called!"); + debugPrint(); + base.Pause(); + AnimationState = AnimationStates.Paused; + } + + /// + /// Stop Animation. + /// + /// Defines, what should be behaviour after cancel operation + /// End action is Cancel, Animation Stops at the Current Frame. + /// End action is Discard, Animation Stops at the Min Frame + /// End action is StopFinal, Animation Stops at the Max Frame + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public void Stop(EndActions endAction = EndActions.Cancel) + { + NUILog.Debug($"Stop()!"); + if (AnimationState == AnimationStates.Stopped) + { + return; + } + + AnimationState = AnimationStates.Stopped; + StopEndAction = (int)endAction; + + NUILog.Debug($"Stop() called!"); + debugPrint(); + base.Stop(); + } + #endregion + + + #region Event, Enum, Struct, ETC + /// + /// Animation finished event + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public event EventHandler Finished + { + add + { + if (finishedEventHandler == null) + { + NUILog.Debug($"Finished()! add!"); + visualEventSignalCallback = onVisualEventSignal; + VisualEventSignal().Connect(visualEventSignalCallback); + } + finishedEventHandler += value; + } + remove + { + NUILog.Debug($"Finished()! remove!"); + finishedEventHandler -= value; + if (finishedEventHandler == null && visualEventSignalCallback != null) + { + VisualEventSignal().Disconnect(visualEventSignalCallback); + } + } + } + + /// + /// Enumeration for what state the vector animation is in + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public enum PlayStateType + { + /// + /// Invalid + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Invalid = -1, + /// + /// Vector Animation has stopped + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Stopped = 0, + /// + /// The vector animation is playing + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Playing = 1, + /// + /// The vector animation is paused + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Paused = 2 + } + + /// + /// AnimationStates of animation. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public enum AnimationStates + { + /// The animation has stopped. + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Stopped = 0, + /// The animation is playing. + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Playing = 1, + /// The animation is paused. + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Paused = 2 + } + + /// + /// EndActions of animation. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public enum EndActions + { + /// End action is Cancel, Animation Stops at the Current Frame. + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Cancel = 0, + /// End action is Discard, Animation Stops at the Min Frame + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Discard = 1, + /// End action is StopFinal, Animation Stops at the Max Frame + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + StopFinal = 2 + } + + /// + /// RepeatMode of animation. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + public enum RepeatModes + { + /// + /// When the animation reaches the end and RepeatCount is nonZero, the animation restarts from the beginning. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Restart = 1, + /// + /// When the animation reaches the end and RepeatCount nonZero, the animation reverses direction on every animation cycle. + /// + // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API) + [EditorBrowsable(EditorBrowsableState.Never)] + Reverse = 2 + } + #endregion + + + #region Internal + internal void SetPlayRange(Vector2 range) + { + PropertyMap map = new PropertyMap(); + map.Add(ImageVisualProperty.PlayRange, new PropertyValue(range)); + DoAction(vectorImageVisualIndex, (int)actionType.updateProperty, new PropertyValue(map)); + NUILog.Debug($"SetPlayRange(range min={range.X}, max={range.Y})"); + } + + internal void SetFramePlayRange(Vector2 range) + { + currentStates.framePlayRangeMin = (int)range.X; + currentStates.framePlayRangeMax = (int)range.Y; + currentStates.changed = true; + + PropertyArray array = new PropertyArray(); + array.PushBack(new PropertyValue(currentStates.framePlayRangeMin)); + array.PushBack(new PropertyValue(currentStates.framePlayRangeMax)); + + PropertyMap map = new PropertyMap(); + map.Add(ImageVisualProperty.PlayRange, new PropertyValue(array)); + DoAction(vectorImageVisualIndex, (int)actionType.updateProperty, new PropertyValue(map)); + NUILog.Debug($"SetFramePlayRange(range min={currentStates.framePlayRangeMin}, max={currentStates.framePlayRangeMax})"); + } + + internal Vector2 GetPlayRange() + { + Vector2 ret = new Vector2(-1.0f, -1.0f); + PropertyMap map = Image; + if (map != null) + { + PropertyValue val = map.Find(ImageVisualProperty.PlayRange); + if (val != null) + { + if (val.Get(ret)) + { + return ret; + } + } + } + tizenlog.Error(tag, $"[ERROR] fail to get PlayRange from dali"); + return ret; + } + + internal float CurrentProgress + { + get + { + float ret = -1.0f; + int currentFrame = -1; + PropertyMap map = Image; + if (map != null) + { + PropertyValue val = map.Find(ImageVisualProperty.CurrentFrameNumber); + if (val != null) + { + if (val.Get(out currentFrame)) + { + int total = TotalFrameNumber; + if (total != -1) + { + ret = (float)currentFrame / (float)total; + NUILog.Debug($"CurrentProgress get! currentFrame={currentFrame}, total={total}, ret={ret}"); + return ret; + } + else + { + tizenlog.Error(tag, $"[ERROR] fail to get total frame number from dali"); + return -1.0f; + } + } + } + } + tizenlog.Error(tag, $"[ERROR] fail to get CurrentProgress from dali"); + return -1.0f; + } + } + + internal int StopEndAction + { + set + { + currentStates.stopEndAction = (EndActions)value; + currentStates.changed = true; + + NUILog.Debug($"StopEndAction set val={currentStates.stopEndAction}"); + //PropertyMap map = new PropertyMap(); + //map.Add(ImageVisualProperty.StopEndAction, new PropertyValue((int)currentStates.stopEndAction)); + //DoAction(vectorImageVisualIndex, (int)actionType.updateProperty, new PropertyValue(map)); + } + get + { + NUILog.Debug($"StopEndAction get!"); + PropertyMap map = base.Image; + var ret = 0; + //if (map != null) + //{ + // PropertyValue val = map.Find(ImageVisualProperty.StopEndAction); + // if (val != null) + // { + // if (val.Get(out ret)) + // { + // NUILog.Debug($"gotten stopEndAction={ret}"); + // if (ret != (int)currentStates.stopEndAction && ret > 0) + // { + // NUILog.Debug($"different stopEndAction! gotten={ret}, stopEndAction={currentStates.stopEndAction}"); + // return (int)currentStates.stopEndAction; + // } + // return (ret); + // } + // } + //} + tizenlog.Error(tag, "[ERROR] fail to get stopEndAction from dali"); + return ret; + } + } + + internal class VisualEventSignalArgs : EventArgs + { + public int VisualIndex + { + get + { + return visualIndex; + } + set + { + visualIndex = value; + } + } + + public int SignalId + { + get + { + return signalId; + } + set + { + signalId = value; + } + } + + int visualIndex; + int signalId; + } + + internal struct states + { + internal string url; + internal int frame; + internal int loopCount; + internal RepeatModes repeatMode; + internal EndActions stopEndAction; + internal int framePlayRangeMin; + internal int framePlayRangeMax; + internal bool changed; + internal int totalFrame; + internal float scale; + }; + internal states currentStates; + + internal event EventHandler VisualEvent + { + add + { + if (visualEventSignalHandler == null) + { + visualEventSignalCallback = onVisualEventSignal; + VisualEventSignal().Connect(visualEventSignalCallback); + } + visualEventSignalHandler += value; + } + remove + { + visualEventSignalHandler -= value; + if (visualEventSignalHandler == null && VisualEventSignal().Empty() == false) + { + VisualEventSignal().Disconnect(visualEventSignalCallback); + } + } + } + + internal void EmitVisualEventSignal(int visualIndex, int signalId) + { + VisualEventSignal().Emit(this, visualIndex, signalId); + } + + internal VisualEventSignal VisualEventSignal() + { + VisualEventSignal ret = new VisualEventSignal(Interop.VisualEventSignal.NewWithView(View.getCPtr(this)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + #endregion + + + #region Private + private enum actionType + { + play, + pause, + stop, + jumpTo, + updateProperty, + }; + + private struct DevelVisual + { + internal enum Type + { + AnimatedGradient = Visual.Type.AnimatedImage + 1, + AnimatedVectorImage = Visual.Type.AnimatedImage + 2, + } + } + + private const string tag = "NUI"; + private const int vectorImageVisualIndex = 10000000 + 1000 + 2; + private event EventHandler finishedEventHandler; + + private void OnFinished() + { + finishedEventHandler?.Invoke(this, null); + } + + private void onVisualEventSignal(IntPtr targetView, int visualIndex, int signalId) + { + OnFinished(); + + if (targetView != IntPtr.Zero) + { + View v = Registry.GetManagedBaseHandleFromNativePtr(targetView) as View; + if (v != null) + { + NUILog.Debug($"targetView is not null! name={v.Name}"); + } + else + { + NUILog.Debug($"target is something created from dali"); + } + } + VisualEventSignalArgs e = new VisualEventSignalArgs(); + e.VisualIndex = visualIndex; + e.SignalId = signalId; + visualEventSignalHandler?.Invoke(this, e); + + NUILog.Debug($"@@ onVisualEventSignal()! visualIndex={visualIndex}, signalId={signalId}"); + } + + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + private delegate void VisualEventSignalCallbackType(IntPtr targetView, int visualIndex, int signalId); + + private VisualEventSignalCallbackType visualEventSignalCallback; + private EventHandler visualEventSignalHandler; + + private void debugPrint() + { + NUILog.Debug($"======= currentStates"); + NUILog.Debug($"url={currentStates.url}, loopCount={currentStates.loopCount}, framePlayRangeMin={currentStates.framePlayRangeMin}, framePlayRangeMax={currentStates.framePlayRangeMax} \n"); + } + #endregion + } +} diff --git a/src/Tizen.NUI/src/public/NUIConstants.cs b/src/Tizen.NUI/src/public/NUIConstants.cs index 9e2e0de..2fadd2d 100755 --- a/src/Tizen.NUI/src/public/NUIConstants.cs +++ b/src/Tizen.NUI/src/public/NUIConstants.cs @@ -1806,39 +1806,51 @@ namespace Tizen.NUI public static readonly int LoopCount = NDalic.IMAGE_VISUAL_LOOP_COUNT; /// - /// The playing range the AnimatedVectorImageVisual will use. - /// Animation will play between the values specified. Both values should be between 0-1, - /// otherwise they will be ignored. If the range provided is not in proper order ( minimum,maximum ), it will be reordered. - /// Type Property::VECTOR2, between 0 and 1 - /// Default 0 and 1 + /// @brief The playing range the AnimatedVectorImageVisual will use. + /// Animation will play between the values specified.The array can only have two values, and more will be ignored. + /// Both values should be between 0 and the total frame number, otherwise they will be ignored. + /// If the range provided is not in proper order (minimum, maximum), it will be reordered. + /// @details Name "playRange", Type Property::ARRAY of Property::INTEGER + /// @note Default 0 and the total frame number. /// /// - /// Inhouse API + /// Hidden API (Inhouse API) + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly int PlayRange = NDalic.IMAGE_VISUAL_ORIENTATION_CORRECTION + 4; + + /// + /// @brief The playing state the AnimatedVectorImageVisual will use. + /// @details Name "playState", type PlayState (Property::INTEGER) + /// @note This property is read-only. + /// + /// + /// Hidden API (Inhouse API) /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly int PlayRange = OrientationCorrection + 4; + public static readonly int PlayState = NDalic.IMAGE_VISUAL_ORIENTATION_CORRECTION + 5; /// - /// The playing state the AnimatedVectorImageVisual will use. - /// Type PlayState (Property::INTEGER) - /// This property is read-only. + /// @brief The current frame number the AnimatedVectorImageVisual will use. + /// @details Name "currentFrameNumber", Type Property::INTEGER, between[0, the maximum frame number] or between the play range if specified + /// @note This property is read-only. /// /// /// Inhouse API /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly int PlayState = OrientationCorrection + 5; + public static readonly int CurrentFrameNumber = NDalic.IMAGE_VISUAL_ORIENTATION_CORRECTION + 6; /// - /// The animation progress the AnimatedVectorImageVisual will use. - /// Type Property::FLOAT, between [0, 1] or between the play range if specified - /// This property is read-only. + /// @brief The total frame number the AnimatedVectorImageVisual will use. + /// @details Name "totalFrameNumber", Type Property::INTEGER. + /// @note This property is read-only. /// /// /// Inhouse API /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly int CurrentProgress = OrientationCorrection + 6; + public static readonly int TotalFrameNumber = NDalic.IMAGE_VISUAL_ORIENTATION_CORRECTION + 7; } /// diff --git a/src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs b/src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs index 4749b65..a7e93c9 100755 --- a/src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs +++ b/src/Tizen.NUI/src/public/Xaml/ViewExtensions.cs @@ -75,6 +75,7 @@ namespace Tizen.NUI.Xaml return XamlLoader.LoadObject(path); } + /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static TXaml LoadFromXamlFile(this TXaml view, string nameOfXamlFile) { -- 2.7.4