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 5849f99..f280f6f 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 f6b3d10..36cf1df 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 a0577d8..a00cd35 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 5860539..64e1397 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 1e93358..c04a730 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 842877d..6b6cf93 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