CanvasView: Add RemoveAllDrawables() API 81/261181/7
authorJunsuChoi <jsuya.choi@samsung.com>
Tue, 13 Jul 2021 03:00:12 +0000 (12:00 +0900)
committerjunsu choi <jsuya.choi@samsung.com>
Thu, 29 Jul 2021 04:15:43 +0000 (04:15 +0000)
Add an API that removes the all drawables registered with AddDrawable().

Change-Id: I6a47c4ce980cdebb374acfe8dfb87b0a815de138

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp
automated-tests/src/dali-toolkit/utc-Dali-CanvasView.cpp
dali-toolkit/devel-api/controls/canvas-view/canvas-view.cpp
dali-toolkit/devel-api/controls/canvas-view/canvas-view.h
dali-toolkit/internal/controls/canvas-view/canvas-view-impl.cpp
dali-toolkit/internal/controls/canvas-view/canvas-view-impl.h

index 5849f996c749a7922bf0251c8b8dffde27280fe3..f280f6f802a1eb244f4827e7f524b2c90df1506e 100644 (file)
@@ -88,6 +88,15 @@ public:
     return false;
   }
 
+  bool RemoveAllDrawables()
+  {
+    if (mDrawable)
+    {
+      return true;
+    }
+    return false;
+  }
+
   Devel::PixelBuffer GetPixelBuffer()
   {
     return mPixelBuffer;
@@ -207,6 +216,11 @@ bool CanvasRenderer::RemoveDrawable(Dali::CanvasRenderer::Drawable& drawable)
   return Internal::Adaptor::GetImplementation(*this).RemoveDrawable(drawable);
 }
 
+bool CanvasRenderer::RemoveAllDrawables()
+{
+  return Internal::Adaptor::GetImplementation(*this).RemoveAllDrawables();
+}
+
 bool CanvasRenderer::SetSize(const Vector2& size)
 {
   return Internal::Adaptor::GetImplementation(*this).SetSize(size);
index f6b3d10207f106da1b16611ebdf6f5a7e2db7493..36cf1df33cc4876b1e93dee1597209b1d82a9161 100644 (file)
@@ -196,6 +196,34 @@ int UtcDaliCanvasViewRemoveN(void)
   END_TEST;
 }
 
+int UtcDaliCanvasViewRemoveAllP(void)
+{
+  ToolkitTestApplication application;
+  CanvasView canvasView = CanvasView::New(Vector2(100,100));
+  DALI_TEST_CHECK( canvasView );
+
+  Dali::CanvasRenderer::Shape shape = Dali::CanvasRenderer::Shape::New();
+
+  canvasView.AddDrawable(shape);
+
+  canvasView.RemoveAllDrawables();
+
+  END_TEST;
+}
+
+int UtcDaliCanvasViewRemoveAllN(void)
+{
+  ToolkitTestApplication application;
+
+  CanvasView canvasView = CanvasView::New(Vector2(100,100));
+  DALI_TEST_CHECK( canvasView );
+
+  canvasView.RemoveAllDrawables();
+
+  END_TEST;
+}
+
+
 int UtcDaliCanvasViewChangeSizeP(void)
 {
   ToolkitTestApplication application;
index a0577d8565781847a4a93528b1c199e784fdc357..a00cd35be1cd738353f5a005f26da8a2eb45875d 100644 (file)
@@ -78,6 +78,11 @@ bool CanvasView::RemoveDrawable(Dali::CanvasRenderer::Drawable& drawable)
   return Dali::Toolkit::GetImpl(*this).RemoveDrawable(drawable);
 }
 
+void CanvasView::RemoveAllDrawables()
+{
+  Dali::Toolkit::GetImpl(*this).RemoveAllDrawables();
+}
+
 CanvasView::CanvasView(Internal::CanvasView& implementation)
 : Control(implementation)
 {
index 5860539e3dc2fa261c950fb528f1c417dbb774da..64e13971e3b4f53953fc11f4cbd649cf93b8fb41 100644 (file)
@@ -169,6 +169,11 @@ public:
    */
   bool RemoveDrawable(Dali::CanvasRenderer::Drawable& drawable);
 
+  /**
+   * @brief Remove all drawable objects added to the CanvasView.
+   */
+  void RemoveAllDrawables();
+
 public: // Not intended for application developers
   /// @cond internal
   /**
index 1e933584d4c70f1b5bac3071df6d9c28f322c3df..c04a730634d045a60d12fc24e0719446d18df2e2 100644 (file)
@@ -260,6 +260,15 @@ bool CanvasView::RemoveDrawable(Dali::CanvasRenderer::Drawable& drawable)
   return false;
 }
 
+bool CanvasView::RemoveAllDrawables()
+{
+  if(mCanvasRenderer && mCanvasRenderer.RemoveAllDrawables())
+  {
+    return true;
+  }
+  return false;
+}
+
 bool CanvasView::SetViewBox(const Vector2& viewBox)
 {
   if(mCanvasRenderer && mCanvasRenderer.SetViewBox(viewBox))
index 842877d5596f793cb317235c47818198baf884a3..6b6cf936f312f4982e752cd27cca4c27309c45cd 100644 (file)
@@ -84,6 +84,11 @@ public:
    */
   bool RemoveDrawable(Dali::CanvasRenderer::Drawable& drawable);
 
+  /**
+   * @copydoc Toolkit::Control::CanvasView::RemoveAllDrawables
+   */
+  bool RemoveAllDrawables();
+
 private: // From Control
   /**
    * @copydoc Control::OnRelayout