Пример #1
0
        protected override float?computeDistanceToActualBaseline(TextBaseline baseline)
        {
            D.assert(this.title != null);
            BoxParentData parentData = (BoxParentData)this.title.parentData;

            return(parentData.offset.dy + this.title.getDistanceToActualBaseline(baseline));
        }
Пример #2
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            D.assert(_children.Count == rows * columns);
            for (int index = _children.Count - 1; index >= 0; index--)
            {
                RenderBox child = _children[index];
                if (child != null)
                {
                    BoxParentData childParentData = (BoxParentData)child.parentData;
                    bool          isHit           = result.addWithPaintOffset(
                        offset: childParentData.offset,
                        position: position,
                        hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
                        D.assert(transformed == position - childParentData.offset);
                        return(child.hitTest(resultIn, position: transformed));
                    }
                        );
                    if (isHit)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #3
0
        public override void paint(PaintingContext context, Offset offset)
        {
            D.assert(this._children.Count == this.rows * this.columns);
            if (this.rows * this.columns == 0)
            {
                if (this.border != null)
                {
                    Rect borderRect = Rect.fromLTWH(offset.dx, offset.dy, this.size.width, 0.0f);
                    this.border.paint(context.canvas, borderRect, rows: new List <float>(), columns: new List <float>());
                }

                return;
            }

            D.assert(this._rowTops.Count == this.rows + 1);
            if (this._rowDecorations != null)
            {
                Canvas canvas = context.canvas;
                for (int y = 0; y < this.rows; y++)
                {
                    if (this._rowDecorations.Count <= y)
                    {
                        break;
                    }

                    if (this._rowDecorations[y] != null)
                    {
                        this._rowDecorationPainters[y] = this._rowDecorationPainters[y] ??
                                                         this._rowDecorations[y].createBoxPainter(this.markNeedsPaint);
                        this._rowDecorationPainters[y].paint(
                            canvas,
                            new Offset(offset.dx, offset.dy + this._rowTops[y]),
                            this.configuration.copyWith(
                                size: new Size(this.size.width, this._rowTops[y + 1] - this._rowTops[y])
                                )
                            );
                    }
                }
            }

            for (int index = 0; index < this._children.Count; index++)
            {
                RenderBox child = this._children[index];
                if (child != null)
                {
                    BoxParentData childParentData = (BoxParentData)child.parentData;
                    context.paintChild(child, childParentData.offset + offset);
                }
            }

            D.assert(this._rows == this._rowTops.Count - 1);
            D.assert(this._columns == this._columnLefts.Count);
            if (this.border != null)
            {
                Rect         borderRect = Rect.fromLTWH(offset.dx, offset.dy, this.size.width, this._rowTops.Last());
                List <float> rows       = this._rowTops.GetRange(1, this._rowTops.Count - 2);
                List <float> columns    = this._columnLefts.GetRange(1, this._columnLefts.Count - 1);
                this.border.paint(context.canvas, borderRect, rows: rows, columns: columns);
            }
        }
Пример #4
0
        protected override void performLayout()
        {
            BoxConstraints constraints = this.constraints;

            _resolve();
            D.assert(_resolvedPadding != null);
            if (child == null)
            {
                size = constraints.constrain(new Size(
                                                 _resolvedPadding.left + _resolvedPadding.right,
                                                 _resolvedPadding.top + _resolvedPadding.bottom
                                                 ));
                return;
            }
            BoxConstraints innerConstraints = constraints.deflate(_resolvedPadding);

            child.layout(innerConstraints, parentUsesSize: true);
            BoxParentData childParentData = child.parentData as BoxParentData;

            childParentData.offset = new Offset(_resolvedPadding.left, _resolvedPadding.top);
            size = constraints.constrain(new Size(
                                             _resolvedPadding.left + child.size.width + _resolvedPadding.right,
                                             _resolvedPadding.top + child.size.height + _resolvedPadding.bottom
                                             ));
        }
Пример #5
0
 protected override void performLayout()
 {
     this.size = this._getSize(this.constraints);
     if (this.child != null)
     {
         BoxConstraints childConstraints = this.layoutDelegate.getConstraintsForChild(this.constraints);
         D.assert(childConstraints.debugAssertIsValid(isAppliedConstraint: true));
         this.child.layout(childConstraints, parentUsesSize: !childConstraints.isTight);
         BoxParentData childParentData = (BoxParentData)this.child.parentData;
         childParentData.offset = this.layoutDelegate.getPositionForChild(this.size,
                                                                          childConstraints.isTight ? childConstraints.smallest : this.child.size);
     }
 }
Пример #6
0
        protected override bool hitTestChildren(HitTestResult result, Offset position)
        {
            D.assert(position != null);
            foreach (RenderBox child in this._children)
            {
                BoxParentData parentData = (BoxParentData)child.parentData;
                if (child.hitTest(result, position: position - parentData.offset))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #7
0
        public override void paint(PaintingContext context, Offset offset)
        {
            void doPaint(RenderBox child)
            {
                if (child != null)
                {
                    BoxParentData parentData = (BoxParentData)child.parentData;
                    context.paintChild(child, parentData.offset + offset);
                }
            }

            doPaint(this.leading);
            doPaint(this.title);
            doPaint(this.subtitle);
            doPaint(this.trailing);
        }
Пример #8
0
        protected override void performLayout()
        {
            if (child == null)
            {
                size = Size.zero;
            }
            else
            {
                child.layout(constraints, parentUsesSize: true);
                size = constraints.constrain(child.size);
            }

            BoxParentData childParentData = child.parentData as BoxParentData;

            childParentData.offset = Offset.zero;
            onLayout(size);
        }
Пример #9
0
        protected override bool hitTestChildren(HitTestResult result, Offset position = null)
        {
            D.assert(this._children.Count == this.rows * this.columns);
            for (int index = this._children.Count - 1; index >= 0; index--)
            {
                RenderBox child = this._children[index];
                if (child != null)
                {
                    BoxParentData childParentData = (BoxParentData)child.parentData;
                    if (child.hitTest(result, position: position - childParentData.offset))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #10
0
        protected override void performLayout()
        {
            BoxConstraints constraints = this.constraints;

            if (child != null)
            {
                child.layout(constraints, parentUsesSize: true);
                float height = Mathf.Max(child.size.width, minSize.width);
                float width  = Mathf.Max(child.size.height, minSize.height);
                size = constraints.constrain(new Size(height, width));
                BoxParentData childParentData = child.parentData as BoxParentData;
                childParentData.offset = Alignment.center.alongOffset(size - child.size as Offset);
            }
            else
            {
                size = Size.zero;
            }
        }
Пример #11
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position)
        {
            D.assert(position != null);
            foreach (RenderBox child in _children)
            {
                BoxParentData parentData = child.parentData as BoxParentData;
                bool          isHit      = result.addWithPaintOffset(
                    offset: parentData.offset,
                    position: position,
                    hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
                    D.assert(transformed == position - parentData.offset);
                    return(child.hitTest(resultIn, position: transformed));
                }
                    );
                if (isHit)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #12
0
        static void _positionBox(RenderBox box, Offset offset)
        {
            BoxParentData parentData = (BoxParentData)box.parentData;

            parentData.offset = offset;
        }
Пример #13
0
        protected override void debugPaintSize(PaintingContext context, Offset offset)
        {
            base.debugPaintSize(context, offset);
            D.assert(() => {
                Paint paint;
                if (this.child != null && !this.child.size.isEmpty)
                {
                    Path path;
                    paint = new Paint {
                        style       = PaintingStyle.stroke,
                        strokeWidth = 1.0f,
                        color       = new ui.Color(0xFFFFFF00)
                    };

                    BoxParentData childParentData = (BoxParentData)this.child.parentData;
                    if (childParentData.offset.dy > 0)
                    {
                        float headSize = Mathf.Min(childParentData.offset.dy * 0.2f, 10.0f);

                        float x = offset.dx + this.size.width / 2.0f;
                        float y = offset.dy;
                        path    = new Path();
                        path.moveTo(x, y);
                        path.lineTo(x += 0.0f, y += childParentData.offset.dy - headSize);
                        path.lineTo(x += headSize, y += 0.0f);
                        path.lineTo(x += -headSize, y += headSize);
                        path.lineTo(x += -headSize, y += -headSize);
                        path.lineTo(x += headSize, y += 0.0f);

                        x = offset.dx + this.size.width / 2.0f;
                        y = offset.dy + this.size.height;
                        path.moveTo(x, y);
                        path.lineTo(x += 0.0f, y += -childParentData.offset.dy + headSize);
                        path.lineTo(x += headSize, y += 0.0f);
                        path.lineTo(x += -headSize, y += -headSize);
                        path.lineTo(x += -headSize, y += headSize);
                        path.lineTo(x += headSize, y += 0.0f);
                        context.canvas.drawPath(path, paint);
                    }

                    if (childParentData.offset.dx > 0.0)
                    {
                        float headSize = Mathf.Min(childParentData.offset.dx * 0.2f, 10.0f);
                        float x        = offset.dx;
                        float y        = offset.dy + this.size.height / 2.0f;
                        path           = new Path();
                        path.moveTo(x, y);
                        path.lineTo(x += childParentData.offset.dx - headSize, y += 0.0f);
                        path.lineTo(x += 0.0f, y += headSize);
                        path.lineTo(x += headSize, y += -headSize);
                        path.lineTo(x += -headSize, y += -headSize);
                        path.lineTo(x += 0.0f, y += headSize);

                        path.moveTo(x  = offset.dx + this.size.width, y = offset.dy + this.size.height / 2.0f);
                        path.lineTo(x += -childParentData.offset.dx + headSize, y += 0.0f);
                        path.lineTo(x += 0.0f, y += headSize);
                        path.lineTo(x += -headSize, y += -headSize);
                        path.lineTo(x += headSize, y += -headSize);
                        path.lineTo(x += 0.0f, y += headSize);
                        path.close();
                        context.canvas.drawPath(path, paint);
                    }
                }
                else
                {
                    paint = new Paint {
                        color = new ui.Color(0x90909090),
                    };
                    context.canvas.drawRect(offset & this.size, paint);
                }

                return(true);
            });
        }