From 9ae9532a0ff8020dfd1d6ea471eb2614e3968f0f Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Fri, 30 Jul 2021 09:26:22 +0900 Subject: [PATCH] [NUI] CanvasView: Add RemoveDrawable/RemoveAllDrawables method (#3355) Add a method to selectively remove the added drawable or remove all. --- .../src/internal/Interop/Interop.CanvasView.cs | 6 +++++ .../BaseComponents/VectorGraphics/CanvasView.cs | 29 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.CanvasView.cs b/src/Tizen.NUI/src/internal/Interop/Interop.CanvasView.cs index 5a7bf0c..7c173a9 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.CanvasView.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.CanvasView.cs @@ -31,6 +31,12 @@ namespace Tizen.NUI [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] public static extern bool AddDrawable(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CanvasView_RemoveDrawable")] + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)] + public static extern bool RemoveDrawable(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2); + + [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CanvasView_RemoveAllDrawables")] + public static extern void RemoveAllDrawables(global::System.Runtime.InteropServices.HandleRef jarg1); } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/CanvasView.cs b/src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/CanvasView.cs index 53ae87c..e1ea271 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/CanvasView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/VectorGraphics/CanvasView.cs @@ -100,5 +100,34 @@ namespace Tizen.NUI.BaseComponents.VectorGraphics drawables.Add(drawable); } } + + /// + /// Remove drawable object to the CanvasView. + /// This method is similar to deregistration. + /// + /// Drawable object + /// Thrown when drawable is null. + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveDrawable(Drawable drawable) + { + if (drawable == null) + { + throw new ArgumentNullException(nameof(drawable)); + } + Interop.CanvasView.RemoveDrawable(View.getCPtr(this), BaseHandle.getCPtr(drawable)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + drawables.Remove(drawable); + } + + /// + /// Remove all drawable objects added to the CanvasView. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void RemoveAllDrawables() + { + Interop.CanvasView.RemoveAllDrawables(View.getCPtr(this)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + drawables.Clear(); + } } } -- 2.7.4