Esempio n. 1
0
 internal MeasureOutput measure(MeasureOutput measureOutput, float width)
 {
     if (!IsMeasureDefined)
     {
         throw new Exception("Measure function isn't defined!");
     }
     return(Assertions.assertNotNull(mMeasureFunction)(this, width));
 }
Esempio n. 2
0
 internal MeasureOutput measure(MeasureOutput measureOutput, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode)
 {
     if (!IsMeasureDefined)
     {
         throw new Exception("Measure function isn't defined!");
     }
     return(Assertions.assertNotNull(mMeasureFunction)(this, width, widthMode, height, heightMode));
 }
Esempio n. 3
0
        private void TestMeasureFuncWithDestructorForGC(CSSNode parent)
        {
            CSSNode child = new CSSNode();

            parent.Insert(0, child);
            child.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
                return(MeasureOutput.Make(120, 130));
            });
        }
Esempio n. 4
0
        public void TestMeasureFuncWithChild()
        {
            CSSNode node  = new CSSNode();
            CSSNode child = new CSSNode();

            node.Insert(0, child);
            node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
                return(MeasureOutput.Make(100, 150));
            });
        }
Esempio n. 5
0
        public void TestMeasureFuncWithFloat()
        {
            CSSNode node = new CSSNode();

            node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
                return(MeasureOutput.Make(123.4f, 81.7f));
            });
            node.CalculateLayout();
            Assert.AreEqual(123, node.LayoutWidth);
            Assert.AreEqual(81, node.LayoutHeight);
        }
Esempio n. 6
0
        public void TestMeasureFunc()
        {
            CSSNode node = new CSSNode();

            node.SetMeasureFunction((_, width, widthMode, height, heightMode) => {
                return(MeasureOutput.Make(100, 150));
            });
            node.CalculateLayout();
            Assert.AreEqual(100, node.LayoutWidth);
            Assert.AreEqual(150, node.LayoutHeight);
        }
Esempio n. 7
0
 public void SetMeasureFunction(MeasureFunction measureFunction)
 {
     _measureFunction = measureFunction;
     if (measureFunction != null)
     {
         _cssMeasureFunc = MeasureInternal;
         _measureOutput  = new MeasureOutput();
     }
     else
     {
         _cssMeasureFunc = null;
         _measureOutput  = null;
     }
     Native.CSSNodeSetMeasureFunc(_cssNode, _cssMeasureFunc);
 }
Esempio n. 8
0
        private CSSSize MeasureInternal(
            IntPtr node,
            float width,
            CSSMeasureMode widthMode,
            float height,
            CSSMeasureMode heightMode)
        {
            if (_measureFunction == null)
            {
                throw new InvalidOperationException("Measure function is not defined.");
            }

            long output = _measureFunction(this, width, widthMode, height, heightMode);

            return(new CSSSize {
                width = MeasureOutput.GetWidth(output), height = MeasureOutput.GetHeight(output)
            });
        }
Esempio n. 9
0
        private CSSSize MeasureInternal(
            IntPtr context,
            float width,
            CSSMeasureMode widthMode,
            float height,
            CSSMeasureMode heightMode)
        {
            if (_measureFunction == null)
            {
                throw new InvalidOperationException("Measure function is not defined.");
            }

            var measureResult = new MeasureOutput();

            _measureFunction(this, width, widthMode, height, heightMode, measureResult);

            return(new CSSSize {
                width = measureResult.Width, height = measureResult.Height
            });
        }