Esempio n. 1
0
        void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex)
        {
            D.assert(child != null);

            _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData;

            context.canvas.drawRRect(
                childParentData.surroundingRect.shift(offset),
                new Paint()
            {
                color = backgroundColors[childIndex],
                style = PaintingStyle.fill
            }
                );
            context.canvas.drawRRect(
                childParentData.surroundingRect.shift(offset),
                new Paint()
            {
                color       = borderColor,
                strokeWidth = 1.0f,
                style       = PaintingStyle.stroke
            }
                );

            context.paintChild(child, childParentData.offset + offset);
        }
Esempio n. 2
0
        void _layoutRects(_NextChild nextChild, RenderBox leftChild, RenderBox rightChild)
        {
            RenderBox child = leftChild;
            float     start = 0.0f;

            while (child != null)
            {
                _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData;
                Offset childOffset = new Offset(start, 0.0f);
                childParentData.offset = childOffset;
                Rect  childRect  = Rect.fromLTWH(start, 0.0f, child.size.width, child.size.height);
                RRect rChildRect = null;
                if (child == leftChild)
                {
                    rChildRect = RRect.fromRectAndCorners(childRect, topLeft: Radius.circular(3.0f),
                                                          bottomLeft: Radius.circular(3.0f));
                }
                else if (child == rightChild)
                {
                    rChildRect = RRect.fromRectAndCorners(childRect, topRight: Radius.circular(3.0f),
                                                          bottomRight: Radius.circular(3.0f));
                }
                else
                {
                    rChildRect = RRect.fromRectAndCorners(childRect, topRight: Radius.zero);
                }
                childParentData.surroundingRect = rChildRect;
                start += child.size.width;
                child  = nextChild(child);
            }
        }
Esempio n. 3
0
        protected internal override float computeMaxIntrinsicHeight(float width)
        {
            RenderBox child     = firstChild;
            float     maxHeight = 0.0f;

            while (child != null)
            {
                _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData;
                float childHeight = child.getMaxIntrinsicHeight(width);
                maxHeight = Mathf.Max(maxHeight, childHeight);
                child     = childParentData.nextSibling;
            }
            return(maxHeight);
        }
Esempio n. 4
0
        protected internal override float computeMinIntrinsicWidth(float height)
        {
            RenderBox child    = firstChild;
            float     minWidth = 0.0f;

            while (child != null)
            {
                _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData;
                float childWidth = child.getMinIntrinsicWidth(height);
                minWidth = Mathf.Max(minWidth, childWidth);
                child    = childParentData.nextSibling;
            }
            return(minWidth * childCount);
        }
Esempio n. 5
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            D.assert(position != null);
            RenderBox child = lastChild;

            while (child != null)
            {
                _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData;
                if (childParentData.surroundingRect.contains(position))
                {
                    Offset center = (Offset.zero & child.size).center;
                    return(result.addWithRawTransform(
                               transform: MatrixUtils.forceToPoint(center),
                               position: center,
                               hitTest: (BoxHitTestResult result1, Offset position1) => {
                        D.assert(position1 == center);
                        return child.hitTest(result1, position: center);
                    }
                               ));
                }
                child = childParentData.previousSibling;
            }
            return(false);
        }