Exemplo n.º 1
0
        public override void applyPaintTransform(RenderObject child, Matrix4 transform)
        {
            D.assert(child != null);
            SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;

            childParentData.applyPaintTransform(transform);
        }
Exemplo n.º 2
0
 public override void debugPaint(PaintingContext context, Offset offset)
 {
     base.debugPaint(context, offset);
     D.assert(() => {
         if (D.debugPaintSizeEnabled)
         {
             Size parentSize = getAbsoluteSize();
             Rect outerRect  = offset & parentSize;
             Size childSize;
             Rect innerRect = null;
             if (child != null)
             {
                 childSize = child.getAbsoluteSize();
                 SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
                 innerRect = (offset + childParentData.paintOffset) & childSize;
                 D.assert(innerRect.top >= outerRect.top);
                 D.assert(innerRect.left >= outerRect.left);
                 D.assert(innerRect.right <= outerRect.right);
                 D.assert(innerRect.bottom <= outerRect.bottom);
             }
             D.debugPaintPadding(context.canvas, outerRect, innerRect);
         }
         return(true);
     });
 }
Exemplo n.º 3
0
 public override void paint(PaintingContext context, Offset offset)
 {
     if (child != null && child.geometry.visible)
     {
         SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
         context.paintChild(child, offset + childParentData.paintOffset);
     }
 }
Exemplo n.º 4
0
 protected override bool hitTestChildren(SliverHitTestResult result, float mainAxisPosition = 0.0f, float crossAxisPosition = 0.0f)
 {
     if (child != null && child.geometry.hitTestExtent > 0.0)
     {
         SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
         result.addWithAxisOffset(
             mainAxisPosition: mainAxisPosition,
             crossAxisPosition: crossAxisPosition,
             mainAxisOffset: childMainAxisPosition(child) ?? 0.0f,
             crossAxisOffset: (float)childCrossAxisPosition(child),
             paintOffset: childParentData.paintOffset,
             hitTest: child.hitTest
             );
     }
     return(false);
 }
Exemplo n.º 5
0
        protected override void performLayout()
        {
            SliverConstraints constraints = this.constraints;

            D.assert(resolvedPadding != null);
            float?beforePadding    = this.beforePadding;
            float?afterPadding     = this.afterPadding;
            float?mainAxisPadding  = this.mainAxisPadding;
            float?crossAxisPadding = this.crossAxisPadding;

            if (child == null)
            {
                geometry = new SliverGeometry(
                    scrollExtent: mainAxisPadding ?? 0.0f,
                    paintExtent: Mathf.Min(mainAxisPadding ?? 0.0f, constraints.remainingPaintExtent),
                    maxPaintExtent: mainAxisPadding ?? 0.0f
                    );
                return;
            }
            child.layout(
                constraints.copyWith(
                    scrollOffset: Mathf.Max(0.0f, constraints.scrollOffset - beforePadding ?? 0.0f),
                    cacheOrigin: Mathf.Min(0.0f, constraints.cacheOrigin + beforePadding ?? 0.0f),
                    overlap: 0.0f,
                    remainingPaintExtent: constraints.remainingPaintExtent - calculatePaintOffset(constraints, from: 0.0f, to: beforePadding ?? 0.0f),
                    remainingCacheExtent: constraints.remainingCacheExtent - calculateCacheOffset(constraints, from: 0.0f, to: beforePadding ?? 0.0f),
                    crossAxisExtent: Mathf.Max(0.0f, constraints.crossAxisExtent - crossAxisPadding ?? 0.0f),
                    precedingScrollExtent: beforePadding ?? 0.0f + constraints.precedingScrollExtent
                    ),
                parentUsesSize: true
                );
            SliverGeometry childLayoutGeometry = child.geometry;

            if (childLayoutGeometry.scrollOffsetCorrection != null)
            {
                geometry = new SliverGeometry(
                    scrollOffsetCorrection: childLayoutGeometry.scrollOffsetCorrection
                    );
                return;
            }
            float beforePaddingPaintExtent = calculatePaintOffset(
                constraints,
                from: 0.0f,
                to: beforePadding ?? 0.0f
                );
            float afterPaddingPaintExtent = calculatePaintOffset(
                constraints,
                from: beforePadding ?? 0.0f + childLayoutGeometry.scrollExtent,
                to: mainAxisPadding ?? 0.0f + childLayoutGeometry.scrollExtent
                );
            float mainAxisPaddingPaintExtent = beforePaddingPaintExtent + afterPaddingPaintExtent;
            float beforePaddingCacheExtent   = calculateCacheOffset(
                constraints,
                from: 0.0f,
                to: beforePadding ?? 0.0f
                );
            float afterPaddingCacheExtent = calculateCacheOffset(
                constraints,
                from: beforePadding ?? 0.0f + childLayoutGeometry.scrollExtent,
                to: mainAxisPadding ?? 0.0f + childLayoutGeometry.scrollExtent
                );
            float mainAxisPaddingCacheExtent = afterPaddingCacheExtent + beforePaddingCacheExtent;
            float paintExtent = Mathf.Min(
                beforePaddingPaintExtent + Mathf.Max(childLayoutGeometry.paintExtent, childLayoutGeometry.layoutExtent + afterPaddingPaintExtent),
                constraints.remainingPaintExtent
                );

            geometry = new SliverGeometry(
                scrollExtent: (mainAxisPadding ?? 0.0f) + childLayoutGeometry.scrollExtent,
                paintExtent: paintExtent,
                layoutExtent: Mathf.Min(mainAxisPaddingPaintExtent + childLayoutGeometry.layoutExtent, paintExtent),
                cacheExtent: Mathf.Min(mainAxisPaddingCacheExtent + childLayoutGeometry.cacheExtent, constraints.remainingCacheExtent),
                maxPaintExtent: (mainAxisPadding ?? 0.0f) + childLayoutGeometry.maxPaintExtent,
                hitTestExtent: Mathf.Max(
                    mainAxisPaddingPaintExtent + childLayoutGeometry.paintExtent,
                    beforePaddingPaintExtent + childLayoutGeometry.hitTestExtent
                    ),
                hasVisualOverflow: childLayoutGeometry.hasVisualOverflow
                );
            SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;

            switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection))
            {
            case AxisDirection.up:
                childParentData.paintOffset = new Offset(resolvedPadding.left, calculatePaintOffset(constraints, from: resolvedPadding.bottom + childLayoutGeometry.scrollExtent, to: resolvedPadding.bottom + childLayoutGeometry.scrollExtent + resolvedPadding.top));
                break;

            case AxisDirection.right:
                childParentData.paintOffset = new Offset(calculatePaintOffset(constraints, from: 0.0f, to: resolvedPadding.left), resolvedPadding.top);
                break;

            case AxisDirection.down:
                childParentData.paintOffset = new Offset(resolvedPadding.left, calculatePaintOffset(constraints, from: 0.0f, to: resolvedPadding.top));
                break;

            case AxisDirection.left:
                childParentData.paintOffset = new Offset(calculatePaintOffset(constraints, from: resolvedPadding.right + childLayoutGeometry.scrollExtent, to: resolvedPadding.right + childLayoutGeometry.scrollExtent + resolvedPadding.left), resolvedPadding.top);
                break;
            }
            D.assert(childParentData.paintOffset != null);
            D.assert(beforePadding == this.beforePadding);
            D.assert(afterPadding == this.afterPadding);
            D.assert(mainAxisPadding == this.mainAxisPadding);
            D.assert(crossAxisPadding == this.crossAxisPadding);
        }