Esempio n. 1
0
        public static bool hitTestBoxChild(this RenderSliver it, HitTestResult result, RenderBox child,
                                           float mainAxisPosition = 0.0f, float crossAxisPosition = 0.0f)
        {
            bool  rightWayUp                = _getRightWayUp(it.constraints);
            float absolutePosition          = mainAxisPosition - it.childMainAxisPosition(child);
            float absoluteCrossAxisPosition = crossAxisPosition - it.childCrossAxisPosition(child);

            switch (it.constraints.axis)
            {
            case Axis.horizontal:
                if (!rightWayUp)
                {
                    absolutePosition = child.size.width - absolutePosition;
                }

                return(child.hitTest(result,
                                     position: new Offset(absolutePosition, absoluteCrossAxisPosition)));

            case Axis.vertical:
                if (!rightWayUp)
                {
                    absolutePosition = child.size.height - absolutePosition;
                }

                return(child.hitTest(result,
                                     position: new Offset(absoluteCrossAxisPosition, absolutePosition)));
            }

            return(false);
        }
Esempio n. 2
0
        public static void applyPaintTransformForBoxChild(this RenderSliver it, RenderBox child,
                                                          Matrix3 transform)
        {
            bool  rightWayUp     = _getRightWayUp(it.constraints);
            float delta          = it.childMainAxisPosition(child);
            float crossAxisDelta = it.childCrossAxisPosition(child);

            switch (it.constraints.axis)
            {
            case Axis.horizontal:
                if (!rightWayUp)
                {
                    delta = it.geometry.paintExtent - child.size.width - delta;
                }

                transform.preTranslate(delta, crossAxisDelta);
                break;

            case Axis.vertical:
                if (!rightWayUp)
                {
                    delta = it.geometry.paintExtent - child.size.height - delta;
                }

                transform.preTranslate(crossAxisDelta, delta);
                break;
            }
        }
Esempio n. 3
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);
            }
                       ));
        }