ArtboardInstance its own type
diff --git a/include/rive/artboard.hpp b/include/rive/artboard.hpp
index 003b72c..5f33451 100644
--- a/include/rive/artboard.hpp
+++ b/include/rive/artboard.hpp
@@ -22,6 +22,7 @@
class DrawTarget;
class ArtboardImporter;
class NestedArtboard;
+ class ArtboardInstance;
class Artboard : public ArtboardBase, public CoreContext, public ShapePaintContainer {
friend class File;
@@ -132,7 +133,7 @@
/// Make an instance of this artboard, must be explictly deleted when no
/// longer needed.
- std::unique_ptr<Artboard> instance() const;
+ std::unique_ptr<ArtboardInstance> instance() const;
/// Returns true if the artboard is an instance of another
bool isInstance() const { return m_IsInstance; }
@@ -151,6 +152,10 @@
StatusCode import(ImportStack& importStack) override;
};
+
+ class ArtboardInstance : public Artboard {
+ public:
+ };
} // namespace rive
#endif
diff --git a/src/artboard.cpp b/src/artboard.cpp
index 85251ea..7a3cf9f 100644
--- a/src/artboard.cpp
+++ b/src/artboard.cpp
@@ -31,6 +31,7 @@
// Instances reference back to the original artboard's animations and state
// machines, so don't delete them here, they'll get cleaned up when the
// source is deleted.
+ // TODO: move this logic into ArtboardInstance destructor???
if (!m_IsInstance) {
for (auto object : m_Animations) {
delete object;
@@ -490,8 +491,10 @@
return m_StateMachines[index];
}
-std::unique_ptr<Artboard> Artboard::instance() const {
- std::unique_ptr<Artboard> artboardClone(clone()->as<Artboard>());
+std::unique_ptr<ArtboardInstance> Artboard::instance() const {
+ std::unique_ptr<ArtboardInstance> artboardClone(new ArtboardInstance);
+ artboardClone->copy(*this);
+
artboardClone->m_FrameOrigin = m_FrameOrigin;
std::vector<Core*>& cloneObjects = artboardClone->m_Objects;