Exemple #1
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);
        }
Exemple #2
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            RenderBox child = _lastOnstageChild;

            for (int i = 0; i < _onstageChildCount; i++)
            {
                D.assert(child != null);
                StackParentData childParentData = child.parentData as StackParentData;

                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);
                }
                child = childParentData.previousSibling;
            }

            return(false);
        }
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            RenderBox child = lastChild;

            while (child != null)
            {
                _ToolbarParentData childParentData = child.parentData as _ToolbarParentData;

                if (!childParentData.shouldPaint)
                {
                    child = childParentData.previousSibling;
                    continue;
                }

                bool isHit = result.addWithPaintOffset(
                    offset: childParentData.offset,
                    position: position,
                    hitTest: (BoxHitTestResult boxResult, Offset boxTransformed) => {
                    D.assert(boxTransformed == position - childParentData.offset);
                    return(child.hitTest(boxResult, position: boxTransformed));
                }
                    );
                if (isHit)
                {
                    return(true);
                }

                child = childParentData.previousSibling;
            }

            return(false);
        }
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position)
        {
            D.assert(position != null);
            RenderBox child = lastChild;

            while (child != null)
            {
                _SlidingSegmentedControlContainerBoxParentData childParentData =
                    child.parentData as _SlidingSegmentedControlContainerBoxParentData;
                if ((childParentData.offset & child.size).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);
        }
Exemple #5
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            if (_foregroundPainter != null && ((_foregroundPainter.hitTest(position)) ?? false))
            {
                return(true);
            }

            return(base.hitTestChildren(result, position: position));
        }
Exemple #6
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            if (child != null)
            {
                return(child.hitTest(result, position));
            }

            return(false);
        }
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            _ToolbarParentData childParentData = child.parentData as _ToolbarParentData;

            return(result.addWithPaintOffset(
                       offset: childParentData.offset,
                       position: position,
                       hitTest: (BoxHitTestResult boxResult, Offset boxTransformed) => {
                D.assert(boxTransformed == position - childParentData.offset);
                return child.hitTest(boxResult, position: boxTransformed);
            }
                       ));
        }
Exemple #8
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            if (this.child != null)
            {
                return(result.addWithPaintOffset(
                           offset: this._paintOffset,
                           position: position,
                           hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
                    D.assert(transformed == position + (-this._paintOffset));
                    return this.child.hitTest(result, position: transformed);
                }
                           ));
            }

            return(false);
        }
Exemple #9
0
        public static bool hitTestBoxChild(
            this RenderSliver it,
            BoxHitTestResult result,
            RenderBox child,
            float mainAxisPosition  = 0.0f,
            float crossAxisPosition = 0.0f)
        {
            bool   rightWayUp                = _getRightWayUp(it.constraints);
            float? delta                     = it.childMainAxisPosition(child);
            float? crossAxisDelta            = it.childCrossAxisPosition(child);
            float? absolutePosition          = mainAxisPosition - delta;
            float? absoluteCrossAxisPosition = crossAxisPosition - crossAxisDelta;
            Offset paintOffset               = null;
            Offset transformedPosition       = null;

            switch (it.constraints.axis)
            {
            case Axis.horizontal:
                if (!rightWayUp)
                {
                    absolutePosition = child.size.width - absolutePosition;
                    delta            = it.geometry.paintExtent - child.size.width - delta;
                }
                paintOffset         = new Offset(delta ?? 0.0f, crossAxisDelta ?? 0.0f);
                transformedPosition = new Offset(absolutePosition ?? 0.0f, absoluteCrossAxisPosition ?? 0.0f);
                break;

            case Axis.vertical:
                if (!rightWayUp)
                {
                    absolutePosition = child.size.height - absolutePosition;
                    delta            = it.geometry.paintExtent - child.size.height - delta;
                }
                paintOffset         = new Offset(crossAxisDelta ?? 0.0f, delta ?? 0.0f);
                transformedPosition = new Offset(absoluteCrossAxisPosition ?? 0.0f, absolutePosition ?? 0.0f);
                break;
            }
            D.assert(paintOffset != null);
            D.assert(transformedPosition != null);
            return(result.addWithPaintOffset(
                       offset: paintOffset,
                       position: null, // Manually adapting from sliver to box position above.
                       hitTest: (BoxHitTestResult boxHitTestResult, Offset _) => {
                return child.hitTest(boxHitTestResult, position: transformedPosition);
            }
                       ));
        }
Exemple #10
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            if (this.child != null)
            {
                var childParentData = (BoxParentData)this.child.parentData;
                return(result.addWithPaintOffset(
                           offset: childParentData.offset,
                           position: position,
                           hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
                    D.assert(transformed == position - childParentData.offset);
                    return this.child.hitTest(resultIn, position: transformed);
                }
                           ));
            }

            return(false);
        }
Exemple #11
0
        protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0.0f,
                                                float crossAxisPosition = 0.0f)
        {
            RenderBox        child     = this.lastChild;
            BoxHitTestResult boxResult = new BoxHitTestResult(result);

            while (child != null)
            {
                if (this.hitTestBoxChild(boxResult, child, mainAxisPosition: mainAxisPosition,
                                         crossAxisPosition: crossAxisPosition))
                {
                    return(true);
                }

                child = this.childBefore(child);
            }

            return(false);
        }
Exemple #12
0
        protected override bool hitTestChildren(
            BoxHitTestResult result,
            Offset position = null
            )
        {
            D.assert(_paintTransform != null || debugNeedsLayout || child == null);
            if (child == null || _paintTransform == null)
            {
                return(false);
            }

            return(result.addWithPaintTransform(
                       transform: _paintTransform,
                       position: position,
                       hitTest: (BoxHitTestResult resultIn, Offset positionIn) => {
                return child.hitTest(resultIn, position: positionIn);
            }
                       ));
        }
Exemple #13
0
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            if (firstChild == null)
            {
                return(false);
            }

            D.assert(position != null);
            RenderBox       child           = _childAtIndex();
            StackParentData childParentData = (StackParentData)child.parentData;

            return(result.addWithPaintOffset(
                       offset: childParentData.offset,
                       position: position,
                       hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
                D.assert(transformed == position - childParentData.offset);
                return child.hitTest(resultIn, position: transformed);
            }
                       ));
        }
        protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
        {
            MultiChildLayoutParentData contentSectionParentData =
                contentSection.parentData as MultiChildLayoutParentData;
            MultiChildLayoutParentData actionsSectionParentData =
                actionsSection.parentData as MultiChildLayoutParentData;

            return(result.addWithPaintOffset(
                       offset: contentSectionParentData.offset,
                       position: position,
                       hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
                D.assert(transformed == position - contentSectionParentData.offset);
                return contentSection.hitTest(resultIn, position: transformed);
            }) || result.addWithPaintOffset(
                       offset: actionsSectionParentData.offset,
                       position: position,
                       hitTest: (BoxHitTestResult resultIn, Offset transformed) => {
                D.assert(transformed == position - actionsSectionParentData.offset);
                return actionsSection.hitTest(resultIn, position: transformed);
            }
                       ));
        }
Exemple #15
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);
        }
Exemple #16
0
        public override bool hitTest(BoxHitTestResult result, Offset position = null)
        {
            if (base.hitTest(result, position: position))
            {
                return(true);
            }

            Offset center = child.size.center(Offset.zero);

            return(result.addWithRawTransform(
                       transform: MatrixUtils.forceToPoint(center),
                       position: center,
                       hitTest: (BoxHitTestResult boxHitTest, Offset offsetPosition) => {
                D.assert(offsetPosition == center);
                //WARNING: inconsistent with flutter (zxw): I believe that there is a bug here in flutter
                //in flutter, the following line is "return child.hitTest(boxHitTest, position: center); ". This is nonsense since it will always return true regardless of the value of the input parameter: position.
                //we have tested a bit in flutter and found that, since an inputPadding has a Semantics as it parent which shares the same size, the Semantics's hitTest can hide this bug in flutter
                //Therefore this bug only occurs in UIWidgets
                //We are not very clear whether this is the best fix though. Please feel free to optimize it
                return child.hitTest(boxHitTest, position: position);
            }
                       ));
        }
Exemple #17
0
        public bool defaultHitTestChildren(BoxHitTestResult result, Offset position)
        {
            ChildType child = lastChild;

            while (child != null)
            {
                ParentDataType childParentData = child.parentData as ParentDataType;
                bool           isHit           = result.addWithPaintOffset(
                    offset: childParentData.offset,
                    position: position,
                    hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
                    D.assert(transformed == position - childParentData.offset);
                    return(child.hitTest(boxHitTestResult, position: transformed));
                }
                    );
                if (isHit)
                {
                    return(true);
                }
                child = childParentData.previousSibling;
            }
            return(false);
        }
Exemple #18
0
        protected override bool hitTestChildren(BoxHitTestResult boxHitTestResult, Offset position = null)
        {
            RenderBox child = firstChild;

            while (child != null)
            {
                TextParentData textParentData = child.parentData as TextParentData;
                Matrix4        transform      = Matrix4.translationValues(
                    textParentData.offset.dx,
                    textParentData.offset.dy,
                    0.0f
                    );
                transform.scale(
                    textParentData.scale,
                    textParentData.scale,
                    textParentData.scale
                    );
                bool isHit = boxHitTestResult.addWithPaintTransform(
                    transform: transform,
                    position: position,
                    hitTest: (BoxHitTestResult result, Offset transformed) => {
                    D.assert(() => {
                        Offset manualPosition = (position - textParentData.offset) / textParentData.scale;
                        return((transformed.dx - manualPosition.dx).abs() < foundation_.precisionErrorTolerance &&
                               (transformed.dy - manualPosition.dy).abs() < foundation_.precisionErrorTolerance);
                    });
                    return(child.hitTest(result, position: transformed));
                }
                    );
                if (isHit)
                {
                    return(true);
                }
                child = childAfter(child);
            }
            return(false);
        }
Exemple #19
0
        public bool defaultHitTestChildren(BoxHitTestResult result, Offset position)
        {
            // the x, y parameters have the top left of the node's box as the origin4
            ChildType child = this.lastChild;

            while (child != null)
            {
                ParentDataType childParentData = child.parentData as ParentDataType;
                bool           isHit           = result.addWithPaintOffset(
                    offset: childParentData.offset,
                    position: position,
                    hitTest: (BoxHitTestResult boxHitTestResult, Offset transformed) => {
                    D.assert(transformed == position - childParentData.offset);
                    return(child.hitTest(boxHitTestResult, position: transformed));
                }
                    );
                if (isHit)
                {
                    return(true);
                }
                child = childParentData.previousSibling;
            }
            return(false);
        }
 protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
 {
     return(defaultHitTestChildren(result, position: position));
 }
Exemple #21
0
 protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null
                                         )
 {
     return(false);
 }
Exemple #22
0
 protected override bool hitTestChildren(BoxHitTestResult result, Offset position = null)
 {
     return(child?.hitTest(result, position: position) ?? false);
 }