示例#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);
        }
示例#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;
            }
        }
示例#3
0
 public RenderSliverIgnorePointer(
     RenderSliver sliver = null,
     bool ignoring       = true
     )
 {
     _ignoring = ignoring;
     child     = sliver;
 }
示例#4
0
 public SliverHitTestEntry(RenderSliver target,
                           float mainAxisPosition  = 0.0f,
                           float crossAxisPosition = 0.0f
                           ) : base(target)
 {
     this.mainAxisPosition  = mainAxisPosition;
     this.crossAxisPosition = crossAxisPosition;
 }
示例#5
0
 public SliverHitTestEntry(RenderSliver target,
                           double mainAxisPosition  = 0.0,
                           double crossAxisPosition = 0.0
                           ) : base(target)
 {
     this.mainAxisPosition  = mainAxisPosition;
     this.crossAxisPosition = crossAxisPosition;
 }
示例#6
0
 public RenderSliverOpacity(
     RenderSliver sliver = null,
     float opacity       = 1.0f
     ) : base(child: sliver)
 {
     D.assert(opacity >= 0.0 && opacity <= 1.0);
     _opacity = opacity;
     _alpha   = ui.Color.getAlphaFromOpacity(opacity);
 }
示例#7
0
        public RenderSliverPadding(
            EdgeInsetsGeometry padding  = null,
            TextDirection?textDirection = null,
            RenderSliver child          = null
            )
        {
            D.assert(padding != null);
            D.assert(padding.isNonNegative);

            _padding       = padding;
            _textDirection = textDirection ?? TextDirection.ltr;
            this.child     = child;
        }
示例#8
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);
            }
                       ));
        }
示例#9
0
 public RenderSliverOffstage(
     RenderSliver sliver = null,
     bool offstage       = true) : base(child: sliver)
 {
     _offstage = offstage;
 }