Expose dirtied func in Javascript bindings
This commit is contained in:
@@ -23,6 +23,13 @@ static YGSize globalMeasureFunc(YGNodeRef nodeRef, float width, YGMeasureMode wi
|
|||||||
return ygSize;
|
return ygSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void globalDirtiedFunc(YGNodeRef nodeRef)
|
||||||
|
{
|
||||||
|
Node const & node = *reinterpret_cast<Node const *>(YGNodeGetContext(nodeRef));
|
||||||
|
|
||||||
|
node.callDirtiedFunc();
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ Node * Node::createDefault(void)
|
/* static */ Node * Node::createDefault(void)
|
||||||
{
|
{
|
||||||
return new Node(nullptr);
|
return new Node(nullptr);
|
||||||
@@ -429,6 +436,24 @@ Size Node::callMeasureFunc(double width, int widthMode, double height, int heigh
|
|||||||
return m_measureFunc->call<Size>(width, widthMode, height, heightMode);
|
return m_measureFunc->call<Size>(width, widthMode, height, heightMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Node::setDirtiedFunc(nbind::cbFunction & dirtiedFunc)
|
||||||
|
{
|
||||||
|
m_dirtiedFunc.reset(new nbind::cbFunction(dirtiedFunc));
|
||||||
|
|
||||||
|
YGNodeSetDirtiedFunc(m_node, &globalDirtiedFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::unsetDirtiedFunc(void) {
|
||||||
|
m_dirtiedFunc.reset(nullptr);
|
||||||
|
|
||||||
|
YGNodeSetDirtiedFunc(m_node, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Node::callDirtiedFunc(void) const
|
||||||
|
{
|
||||||
|
m_dirtiedFunc->call<void>();
|
||||||
|
}
|
||||||
|
|
||||||
void Node::markDirty(void)
|
void Node::markDirty(void)
|
||||||
{
|
{
|
||||||
YGNodeMarkDirty(m_node);
|
YGNodeMarkDirty(m_node);
|
||||||
|
@@ -161,6 +161,15 @@ class Node {
|
|||||||
|
|
||||||
Size callMeasureFunc(double width, int widthMode, double height, int heightMode) const;
|
Size callMeasureFunc(double width, int widthMode, double height, int heightMode) const;
|
||||||
|
|
||||||
|
public: // Dirtied func mutators
|
||||||
|
|
||||||
|
void setDirtiedFunc(nbind::cbFunction & dirtiedFunc);
|
||||||
|
void unsetDirtiedFunc(void);
|
||||||
|
|
||||||
|
public: // Dirtied func inspectors
|
||||||
|
|
||||||
|
void callDirtiedFunc(void) const;
|
||||||
|
|
||||||
public: // Dirtiness accessors
|
public: // Dirtiness accessors
|
||||||
|
|
||||||
void markDirty(void);
|
void markDirty(void);
|
||||||
@@ -194,5 +203,5 @@ class Node {
|
|||||||
YGNodeRef m_node;
|
YGNodeRef m_node;
|
||||||
|
|
||||||
std::unique_ptr<nbind::cbFunction> m_measureFunc;
|
std::unique_ptr<nbind::cbFunction> m_measureFunc;
|
||||||
|
std::unique_ptr<nbind::cbFunction> m_dirtiedFunc;
|
||||||
};
|
};
|
||||||
|
@@ -155,6 +155,9 @@ NBIND_CLASS(Node)
|
|||||||
method(setMeasureFunc);
|
method(setMeasureFunc);
|
||||||
method(unsetMeasureFunc);
|
method(unsetMeasureFunc);
|
||||||
|
|
||||||
|
method(setDirtiedFunc);
|
||||||
|
method(unsetDirtiedFunc);
|
||||||
|
|
||||||
method(markDirty);
|
method(markDirty);
|
||||||
method(isDirty);
|
method(isDirty);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user