Skip to content

Commit

Permalink
inputs ref state machines and components ref artboards
Browse files Browse the repository at this point in the history
More native stability fixes interopping with Dart and tests.

Diffs=
432e7ae6c inputs ref state machines and components ref artboards  (#8057)

Co-authored-by: Luigi Rosso <[email protected]>
  • Loading branch information
luigi-rosso and luigi-rosso committed Sep 4, 2024
1 parent 084faa4 commit d126f67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bbc2bba5b013552e946e505d5f9445d6fe0b129f
432e7ae6ca80109e6f49a776cd639a0b4ec99ab9
3 changes: 2 additions & 1 deletion include/rive/artboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SMINumber;
class SMITrigger;

#ifdef WITH_RIVE_TOOLS
typedef void (*ArtboardCallback)(Artboard*);
typedef void (*ArtboardCallback)(void*);
#endif

class Artboard : public ArtboardBase, public CoreContext
Expand Down Expand Up @@ -376,6 +376,7 @@ class Artboard : public ArtboardBase, public CoreContext
ArtboardCallback m_layoutDirtyCallback = nullptr;

public:
void* callbackUserData;
void onLayoutChanged(ArtboardCallback callback) { m_layoutChangedCallback = callback; }
void onLayoutDirty(ArtboardCallback callback) { m_layoutDirtyCallback = callback; }
#endif
Expand Down
11 changes: 8 additions & 3 deletions src/artboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@

using namespace rive;

Artboard::Artboard() {}
Artboard::Artboard()
{
#ifdef WITH_RIVE_TOOLS
callbackUserData = this;
#endif
}

Artboard::~Artboard()
{
Expand Down Expand Up @@ -511,7 +516,7 @@ void Artboard::propagateSize()
#ifdef WITH_RIVE_TOOLS
if (m_layoutChangedCallback != nullptr)
{
m_layoutChangedCallback(this);
m_layoutChangedCallback(callbackUserData);
}
#endif
}
Expand Down Expand Up @@ -687,7 +692,7 @@ void Artboard::markLayoutDirty(LayoutComponent* layoutComponent)
#ifdef WITH_RIVE_TOOLS
if (m_dirtyLayout.empty() && m_layoutDirtyCallback != nullptr)
{
m_layoutDirtyCallback(this);
m_layoutDirtyCallback(callbackUserData);
}
#endif
m_dirtyLayout.insert(layoutComponent);
Expand Down

0 comments on commit d126f67

Please sign in to comment.