diff --git a/java/com/facebook/yoga/YogaEventListener.java b/java/com/facebook/yoga/YogaEventListener.java index 6d1d486b..97791224 100644 --- a/java/com/facebook/yoga/YogaEventListener.java +++ b/java/com/facebook/yoga/YogaEventListener.java @@ -10,4 +10,6 @@ public interface YogaEventListener { void onLayoutPassEnd(YogaNode node); -} \ No newline at end of file + void onNodeMeasure(YogaNode node); + +} diff --git a/tests/EventsTest.cpp b/tests/EventsTest.cpp index 44ade6fd..5cb5db02 100644 --- a/tests/EventsTest.cpp +++ b/tests/EventsTest.cpp @@ -131,6 +131,8 @@ void EventTest::listen(const YGNode& node, Event::Type type, Event::Data data) { break; case Event::LayoutPassEnd: break; + case Event::NodeMeasure: + break; } } diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 763d9bfc..c46104be 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -1635,6 +1635,10 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions( heightMeasureMode, layoutContext); +#ifdef YG_ENABLE_EVENTS + Event::publish(node, {layoutContext}); +#endif + node->setLayoutMeasuredDimension( YGNodeBoundAxis( node, diff --git a/yoga/event/event.h b/yoga/event/event.h index f0f42797..bff8dbfd 100644 --- a/yoga/event/event.h +++ b/yoga/event/event.h @@ -21,7 +21,8 @@ struct Event { NodeDeallocation, NodeLayout, LayoutPassStart, - LayoutPassEnd + LayoutPassEnd, + NodeMeasure, }; class Data; using Subscriber = void(const YGNode&, Type, Data); @@ -76,5 +77,10 @@ struct Event::TypedData { void* layoutContext; }; +template <> +struct Event::TypedData { + void* layoutContext; +}; + } // namespace yoga } // namespace facebook