private void TestMeasureFuncWithDestructorForGC(YogaNode parent) { YogaNode child = new YogaNode(); parent.Insert(0, child); child.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(120, 130)); }); }
public void TestMeasureFuncWithChild() { YogaNode node = new YogaNode(); YogaNode child = new YogaNode(); node.Insert(0, child); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(100, 150)); }); }
public void TestMeasureFuncWithFloat() { YogaNode node = new YogaNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(123.4f, 81.7f)); }); node.CalculateLayout(); Assert.AreEqual(123.4f, node.LayoutWidth); Assert.AreEqual(81.7f, node.LayoutHeight); }
public void TestMeasureFunc() { YogaNode node = new YogaNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(100, 150)); }); node.CalculateLayout(); Assert.AreEqual(100, node.LayoutWidth); Assert.AreEqual(150, node.LayoutHeight); }
public void TestChildWithMeasureFunc() { YogaNode node = new YogaNode(); node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { return(MeasureOutput.Make(100, 150)); }); YogaNode child = new YogaNode(); Assert.Throws <InvalidOperationException>(() => node.Insert(0, child)); }
private YogaSize MeasureInternal( IntPtr node, float width, YogaMeasureMode widthMode, float height, YogaMeasureMode heightMode) { if (_measureFunction == null) { throw new InvalidOperationException("Measure function is not defined."); } long output = _measureFunction(this, width, widthMode, height, heightMode); return(new YogaSize { width = MeasureOutput.GetWidth(output), height = MeasureOutput.GetHeight(output) }); }