Example #1
0
        protected override void debugPaintSize(PaintingContext context, Offset offset)
        {
            D.assert(() => {
                if (child == null)
                {
                    return(true);
                }

                //_debugPaint ??= new Paint()
                if (_debugPaint == null)
                {
                    _debugPaint = new Paint();
                }

                _debugPaint.shader = ui.Gradient.linear(
                    new Offset(0.0f, 0.0f),
                    new Offset(10.0f, 10.0f),
                    new List <Color> {
                    new Color(0x00000000), new Color(0xFFFF00FF), new Color(0xFFFF00FF),
                    new Color(0x00000000)
                },
                    new List <float> {
                    0.25f, 0.25f, 0.75f, 0.75f
                },
                    TileMode.repeated
                    );
                _debugPaint.strokeWidth            = 2.0f;
                _debugPaint.style                  = PaintingStyle.stroke;
                _ToolbarParentData childParentData = child.parentData as _ToolbarParentData;
                context.canvas.drawPath(_clipPath().shift(offset + childParentData.offset), _debugPaint);
                return(true);
            });
        }
Example #2
0
        Path _clipPath()
        {
            _ToolbarParentData childParentData = child.parentData as _ToolbarParentData;
            Path rrect = new Path();

            rrect.addRRect(
                RRect.fromRectAndRadius(
                    new Offset(0, _isArrowPointingDown ? 0 : CupertinoTextSelectionUtils._kToolbarArrowSize.height)
                    & new Size(child.size.width, child.size.height - CupertinoTextSelectionUtils._kToolbarArrowSize.height),
                    CupertinoTextSelectionUtils._kToolbarBorderRadius
                    ));

            float arrowTipX = child.size.width / 2 + childParentData.arrowXOffsetFromCenter;

            float arrowBottomY = _isArrowPointingDown
        ? child.size.height - CupertinoTextSelectionUtils._kToolbarArrowSize.height
        : CupertinoTextSelectionUtils._kToolbarArrowSize.height;

            float arrowTipY = _isArrowPointingDown ? child.size.height : 0;

            Path arrow = new Path();

            arrow.moveTo(arrowTipX, arrowTipY);
            arrow.lineTo(arrowTipX - CupertinoTextSelectionUtils._kToolbarArrowSize.width / 2, arrowBottomY);
            arrow.lineTo(arrowTipX + CupertinoTextSelectionUtils._kToolbarArrowSize.width / 2, arrowBottomY);
            arrow.close();

            return(Path.combine(PathOperation.union, rrect, arrow));
        }
Example #3
0
        protected override void performLayout()
        {
            BoxConstraints constraints = this.constraints;

            size = constraints.biggest;

            if (child == null)
            {
                return;
            }
            BoxConstraints enforcedConstraint = constraints
                                                .deflate(EdgeInsets.symmetric(horizontal: CupertinoTextSelectionUtils._kToolbarScreenPadding))
                                                .loosen();

            child.layout(heightConstraint.enforce(enforcedConstraint), parentUsesSize: true);
            _ToolbarParentData childParentData = child.parentData as _ToolbarParentData;


            float lowerBound      = child.size.width / 2 + CupertinoTextSelectionUtils._kToolbarScreenPadding;
            float upperBound      = size.width - child.size.width / 2 - CupertinoTextSelectionUtils._kToolbarScreenPadding;
            float adjustedCenterX = _arrowTipX.clamp(lowerBound, upperBound);

            childParentData.offset = new Offset(adjustedCenterX - child.size.width / 2, _barTopY);
            childParentData.arrowXOffsetFromCenter = _arrowTipX - adjustedCenterX;
        }
Example #4
0
        public override void paint(PaintingContext context, Offset offset)
        {
            if (child == null)
            {
                return;
            }

            _ToolbarParentData childParentData = child.parentData as _ToolbarParentData;

            context.pushClipPath(
                needsCompositing,
                offset + childParentData.offset,
                Offset.zero & child.size,
                _clipPath(),
                (PaintingContext innerContext, Offset innerOffset) => innerContext.paintChild(child, innerOffset)
                );
        }