예제 #1
0
        private void TestMeasureFuncWithDestructorForGC(YogaNode parent)
        {
            YogaNode child = new YogaNode();

            parent.Insert(0, child);
            child.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
                return(MeasureOutput.Make(120, 130));
            });
        }
예제 #2
0
        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));
            });
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
파일: YogaNodeTest.cs 프로젝트: Timmmm/yoga
        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));
        }
예제 #6
0
        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)
            });
        }