Example #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);
        }
Example #2
0
        public override RectCallback getRectCallback(RenderBox referenceBox)
        {
            return(() => {
                RenderObject cell = referenceBox;
                AbstractNodeMixinDiagnosticableTree table = cell.parent;
                Matrix4 transform = Matrix4.identity();
                while (table is RenderObject && !(table is RenderTable))
                {
                    RenderObject parentBox = table as RenderObject;
                    parentBox.applyPaintTransform(cell, transform);
                    D.assert(table == cell.parent);
                    cell = parentBox;
                    table = table.parent;
                }

                if (table is RenderTable renderTable)
                {
                    TableCellParentData cellParentData = cell.parentData as TableCellParentData;
                    Rect rect = renderTable.getRowBox(cellParentData.y);
                    // The rect is in the table's coordinate space. We need to change it to the
                    // TableRowInkWell's coordinate space.
                    renderTable.applyPaintTransform(cell, transform);
                    Offset offset = MatrixUtils.getAsTranslation(transform);
                    if (offset != null)
                    {
                        return rect.shift(-offset);
                    }
                }

                return Rect.zero;
            }
                   );
        }
Example #3
0
 public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverScrollingPersistentHeader(
     RenderBox child = null,
     OverScrollHeaderStretchConfiguration stretchConfiguration = null
     ) : base(child: child,
              stretchConfiguration: stretchConfiguration)
 {
 }
        float _getIdealOffset(
            RenderBox parentBox,
            float halfWidthNeeded,
            float scale,
            Offset center
            )
        {
            const float edgeMargin  = 4.0f;
            Rect        topLobeRect = Rect.fromLTWH(
                -_topLobeRadius - halfWidthNeeded,
                -_topLobeRadius - _distanceBetweenTopBottomCenters,
                2.0f * (_topLobeRadius + halfWidthNeeded),
                2.0f * _topLobeRadius
                );

            Offset topLeft     = (topLobeRect.topLeft * scale) + center;
            Offset bottomRight = (topLobeRect.bottomRight * scale) + center;
            float  shift       = 0.0f;

            if (topLeft.dx < edgeMargin)
            {
                shift = edgeMargin - topLeft.dx;
            }

            if (bottomRight.dx > parentBox.size.width - edgeMargin)
            {
                shift = parentBox.size.width - bottomRight.dx - edgeMargin;
            }

            shift = scale == 0.0f ? 0.0f : shift / scale;
            return(shift);
        }
Example #5
0
        void _handleTap()
        {
            RenderBox  itemBox    = (RenderBox)this.context.findRenderObject();
            Rect       itemRect   = itemBox.localToGlobal(Offset.zero) & itemBox.size;
            EdgeInsets menuMargin = ButtonTheme.of(this.context).alignedDropdown
                ? DropdownConstants._kAlignedMenuMargin
                : DropdownConstants._kUnalignedMenuMargin;

            D.assert(this._dropdownRoute == null);
            this._dropdownRoute = new _DropdownRoute <T>(
                items: this.widget.items,
                buttonRect: menuMargin.inflateRect(itemRect),
                padding: DropdownConstants._kMenuItemPadding,
                selectedIndex: this._selectedIndex ?? 0,
                elevation: this.widget.elevation,
                theme: Theme.of(this.context, shadowThemeOnly: true),
                style: this._textStyle,
                barrierLabel: MaterialLocalizations.of(this.context).modalBarrierDismissLabel
                );

            Navigator.push(this.context, this._dropdownRoute).Then(newValue => {
                _DropdownRouteResult <T> value = newValue as _DropdownRouteResult <T>;
                this._dropdownRoute            = null;
                if (!this.mounted || newValue == null)
                {
                    return;
                }

                if (this.widget.onChanged != null)
                {
                    this.widget.onChanged(value.result);
                }
            });
        }
        public override void paint(
            PaintingContext context,
            Offset center,
            Animation <float> activationAnimation = null,
            Animation <float> enableAnimation     = null,
            bool?isDiscrete             = null,
            TextPainter labelPainter    = null,
            RenderBox parentBox         = null,
            SliderThemeData sliderTheme = null,
            float?value = null
            )
        {
            Canvas     canvas      = context.canvas;
            FloatTween radiusTween = new FloatTween(
                begin: 0.0f,
                end: this.overlayRadius
                );

            canvas.drawCircle(
                center,
                radiusTween.evaluate(activationAnimation),
                new Paint {
                color = sliderTheme.overlayColor
            }
                );
        }
        public override void paint(
            PaintingContext context,
            Offset center,
            RenderBox parentBox               = null,
            SliderThemeData sliderTheme       = null,
            Animation <float> enableAnimation = null,
            Offset thumbCenter = null,
            bool?isEnabled     = null
            )
        {
            Color begin;
            Color end;

            bool isTickMarkRightOfThumb = center.dx > thumbCenter.dx;

            begin = isTickMarkRightOfThumb
                ? sliderTheme.disabledInactiveTickMarkColor
                : sliderTheme.disabledActiveTickMarkColor;
            end = isTickMarkRightOfThumb ? sliderTheme.inactiveTickMarkColor : sliderTheme.activeTickMarkColor;

            Paint paint = new Paint {
                color = new ColorTween(begin: begin, end: end).evaluate(enableAnimation)
            };

            float tickMarkRadius = this.getPreferredSize(
                isEnabled: isEnabled,
                sliderTheme: sliderTheme
                ).width / 2f;

            context.canvas.drawCircle(center, tickMarkRadius, paint);
        }
        public override void paint(
            PaintingContext context,
            Offset center,
            Animation <float> activationAnimation = null,
            Animation <float> enableAnimation     = null,
            bool?isDiscrete             = null,
            TextPainter labelPainter    = null,
            RenderBox parentBox         = null,
            SliderThemeData sliderTheme = null,
            float?value = null)
        {
            ColorTween enableColor = new ColorTween(
                begin: sliderTheme.disabledThumbColor,
                end: sliderTheme.valueIndicatorColor
                );

            this._drawValueIndicator(
                parentBox,
                context.canvas,
                center,
                new Paint {
                color = enableColor.evaluate(enableAnimation)
            },
                activationAnimation.value,
                labelPainter
                );
        }
Example #9
0
 public RenderAnimatedSize(
     TickerProvider vsync     = null,
     TimeSpan?duration        = null,
     TimeSpan?reverseDuration = null,
     Curve curve = null,
     AlignmentGeometry alignment = null,
     TextDirection?textDirection = null,
     RenderBox child             = null
     ) : base(child: child, alignment: alignment ?? Alignment.center, textDirection: textDirection)
 {
     curve = curve ?? Curves.linear;
     D.assert(vsync != null);
     D.assert(duration != null);
     _vsync      = vsync;
     _controller = new AnimationController(
         vsync: this.vsync,
         duration: duration,
         reverseDuration: reverseDuration);
     _controller.addListener(() => {
         if (_controller.value != _lastValue)
         {
             markNeedsLayout();
         }
     });
     _animation = new CurvedAnimation(
         parent: _controller,
         curve: curve);
 }
 public RenderSliverFloatingPersistentHeader(
     RenderBox child = null,
     FloatingHeaderSnapConfiguration snapConfiguration = null
     ) : base(child: child)
 {
     this._snapConfiguration = snapConfiguration;
 }
Example #11
0
        public RenderAnimatedSize(
            TickerProvider vsync = null,
            TimeSpan?duration    = null,
            Curve curve          = null,
            Alignment alignment  = null,
            RenderBox child      = null
            ) : base(child: child, alignment: alignment ?? Alignment.center)
        {
            D.assert(vsync != null);
            D.assert(duration != null);

            curve            = curve ?? Curves.linear;
            this._vsync      = vsync;
            this._controller = new AnimationController(
                vsync: this.vsync,
                duration: duration);
            this._controller.addListener(() => {
                if (this._controller.value != this._lastValue)
                {
                    this.markNeedsLayout();
                }
            });
            this._animation = new CurvedAnimation(
                parent: this._controller,
                curve: curve);
        }
Example #12
0
 public override InteractiveInkFeature create(
     MaterialInkController controller = null,
     RenderBox referenceBox           = null,
     Offset position           = null,
     Color color               = null,
     bool containedInkWell     = false,
     RectCallback rectCallback = null,
     BorderRadius borderRadius = null,
     ShapeBorder customBorder  = null,
     float?radius              = null,
     VoidCallback onRemoved    = null
     )
 {
     D.assert(controller != null);
     D.assert(referenceBox != null);
     D.assert(position != null);
     D.assert(color != null);
     return(new InkRipple(
                controller: controller,
                referenceBox: referenceBox,
                position: position,
                color: color,
                containedInkWell: containedInkWell,
                rectCallback: rectCallback,
                borderRadius: borderRadius,
                customBorder: customBorder,
                radius: radius,
                onRemoved: onRemoved));
 }
Example #13
0
        public UnityEditorRenderPointerListener(
            PointerDragFromEditorEnterEventListener onPointerDragFromEditorEnter     = null,
            PointerDragFromEditorHoverEventListener onPointerDragFromEditorHover     = null,
            PointerDragFromEditorExitEventListener onPointerDragFromEditorExit       = null,
            PointerDragFromEditorReleaseEventListener onPointerDragFromEditorRelease = null,
            HitTestBehavior behavior = HitTestBehavior.deferToChild,
            RenderBox child          = null
            ) : base(behavior: behavior, child: child)
        {
            _onPointerDragFromEditorEnter   = onPointerDragFromEditorEnter;
            _onPointerDragFromEditorHover   = onPointerDragFromEditorHover;
            _onPointerDragFromEditorExit    = onPointerDragFromEditorExit;
            _onPointerDragFromEditorRelease = onPointerDragFromEditorRelease;

            if (_onPointerDragFromEditorEnter != null ||
                _onPointerDragFromEditorHover != null ||
                _onPointerDragFromEditorExit != null ||
                _onPointerDragFromEditorRelease != null
                )
            {
                _hoverAnnotation = new EditorMouseTrackerAnnotation(
                    onDragFromEditorEnter: _onPointerDragFromEditorEnter,
                    onDragFromEditorHover: _onPointerDragFromEditorHover,
                    onDragFromEditorExit: _onPointerDragFromEditorExit,
                    onDragFromEditorRelease: _onPointerDragFromEditorRelease
                    );
            }
        }
        public void positionChild(object childId, Offset offset)
        {
            RenderBox child = this._idToChild[childId];

            D.assert(() => {
                if (child == null)
                {
                    throw new UIWidgetsError(
                        $"The {this} custom multichild layout delegate tried to position out a non-existent child:\n" +
                        $"There is no child with the id \"{childId}\"."
                        );
                }

                if (offset == null)
                {
                    throw new UIWidgetsError(
                        $"The {this} custom multichild layout delegate provided a null position for the child with id \"{childId}\"."
                        );
                }

                return(true);
            });
            MultiChildLayoutParentData childParentData = (MultiChildLayoutParentData)child.parentData;

            childParentData.offset = offset;
        }
 public override void didAdoptChild(RenderBox child)
 {
     if (child != renderObject.child)
     {
         base.didAdoptChild(child);
     }
 }
Example #16
0
 public bool Equals(AGSBoundingBoxes boxes)
 {
     if (this == boxes)
     {
         return(true);
     }
     if (boxes == null)
     {
         return(false);
     }
     if (TextureBox == null && boxes.TextureBox != null)
     {
         return(false);
     }
     if (TextureBox != null && boxes.TextureBox == null)
     {
         return(false);
     }
     if (TextureBox != null && !TextureBox.Equals(boxes.TextureBox))
     {
         return(false);
     }
     return(RenderBox.Equals(boxes.RenderBox) && HitTestBox.Equals(boxes.HitTestBox) &&
            PreCropRenderBox.Equals(boxes.PreCropRenderBox));
 }
Example #17
0
        void _layoutRects(_NextChild nextChild, RenderBox leftChild, RenderBox rightChild)
        {
            RenderBox child = leftChild;
            float     start = 0.0f;

            while (child != null)
            {
                _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData;
                Offset childOffset = new Offset(start, 0.0f);
                childParentData.offset = childOffset;
                Rect  childRect  = Rect.fromLTWH(start, 0.0f, child.size.width, child.size.height);
                RRect rChildRect = null;
                if (child == leftChild)
                {
                    rChildRect = RRect.fromRectAndCorners(childRect, topLeft: Radius.circular(3.0f),
                                                          bottomLeft: Radius.circular(3.0f));
                }
                else if (child == rightChild)
                {
                    rChildRect = RRect.fromRectAndCorners(childRect, topRight: Radius.circular(3.0f),
                                                          bottomRight: Radius.circular(3.0f));
                }
                else
                {
                    rChildRect = RRect.fromRectAndCorners(childRect, topRight: Radius.zero);
                }
                childParentData.surroundingRect = rChildRect;
                start += child.size.width;
                child  = nextChild(child);
            }
        }
Example #18
0
        public override List <DiagnosticsNode> debugDescribeChildren()
        {
            if (this._children.isEmpty())
            {
                return(new List <DiagnosticsNode> {
                    DiagnosticsNode.message("table is empty")
                });
            }

            List <DiagnosticsNode> children = new List <DiagnosticsNode>();

            for (int y = 0; y < this.rows; y++)
            {
                for (int x = 0; x < this.columns; x++)
                {
                    int       xy    = x + y * this.columns;
                    RenderBox child = this._children[xy];
                    string    name  = $"child ({x}, {y})";
                    if (child != null)
                    {
                        children.Add(child.toDiagnosticsNode(name: name));
                    }
                    else
                    {
                        children.Add(new DiagnosticsProperty <object>(name, null, ifNull: "is null",
                                                                      showSeparator: false));
                    }
                }
            }

            return(children);
        }
Example #19
0
        public InkHighlight(
            MaterialInkController controller = null,
            RenderBox referenceBox           = null,
            Color color               = null,
            BoxShape shape            = BoxShape.rectangle,
            BorderRadius borderRadius = null,
            ShapeBorder customBorder  = null,
            RectCallback rectCallback = null,
            VoidCallback onRemoved    = null) : base(
                controller: controller,
                referenceBox: referenceBox,
                color: color,
                onRemoved: onRemoved)
        {
            D.assert(color != null);
            D.assert(controller != null);
            D.assert(referenceBox != null);
            this._shape        = shape;
            this._borderRadius = borderRadius ?? BorderRadius.zero;
            this._customBorder = customBorder;
            this._rectCallback = rectCallback;

            this._alphaController = new AnimationController(
                duration: InkHighlightUtils._kHighlightFadeDuration,
                vsync: controller.vsync);
            this._alphaController.addListener(controller.markNeedsPaint);
            this._alphaController.addStatusListener(this._handleAlphaStatusChanged);
            this._alphaController.forward();

            this._alpha = this._alphaController.drive(new IntTween(
                                                          begin: 0, end: color.alpha));

            this.controller.addInkFeature(this);
        }
Example #20
0
 public _RenderInputPadding(
     Size minSize,
     RenderBox child = null
     ) : base(child: child)
 {
     _minSize = minSize;
 }
Example #21
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);
            }
        }
Example #22
0
 public RenderSliverPinnedPersistentHeader(
     RenderBox child = null,
     OverScrollHeaderStretchConfiguration stretchConfiguration = null
     ) : base(child: child,
              stretchConfiguration: stretchConfiguration)
 {
 }
Example #23
0
        public static Rect _globalBoundingBoxFor(BuildContext context)
        {
            RenderBox box = (RenderBox)context.findRenderObject();

            D.assert(box != null && box.hasSize);
            return(box.getTransformTo(null).mapRect(Offset.zero & box.size));
        }
Example #24
0
        void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex)
        {
            D.assert(child != null);

            _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData;

            context.canvas.drawRRect(
                childParentData.surroundingRect.shift(offset),
                new Paint()
            {
                color = backgroundColors[childIndex],
                style = PaintingStyle.fill
            }
                );
            context.canvas.drawRRect(
                childParentData.surroundingRect.shift(offset),
                new Paint()
            {
                color       = borderColor,
                strokeWidth = 1.0f,
                style       = PaintingStyle.stroke
            }
                );

            context.paintChild(child, childParentData.offset + offset);
        }
Example #25
0
 protected RenderAligningShiftedBox(
     Alignment alignment = null,
     RenderBox child     = null
     ) : base(child)
 {
     this._alignment = alignment ?? Alignment.center;
 }
Example #26
0
        bool ensureTooltopVisible()
        {
            if (this._entry != null)
            {
                this._timer?.cancel();
                this._timer = null;
                this._controller.forward();
                return(false);
            }

            RenderBox box    = (RenderBox)this.context.findRenderObject();
            Offset    target = box.localToGlobal(box.size.center(Offset.zero));

            Widget overlay = new _TooltipOverlay(
                message: this.widget.message,
                height: this.widget.height,
                padding: this.widget.padding,
                animation: new CurvedAnimation(
                    parent: this._controller,
                    curve: Curves.fastOutSlowIn),
                target: target,
                verticalOffset: this.widget.verticalOffset,
                preferBelow: this.widget.preferBelow
                );

            this._entry = new OverlayEntry(builder: (BuildContext context) => overlay);
            Overlay.of(this.context, debugRequiredFor: this.widget).insert(this._entry);
            GestureBinding.instance.pointerRouter.addGlobalRoute(this._handlePointerEvent);
            this._controller.forward();
            return(true);
        }
Example #27
0
        void _startSplash(TapDownDetails details = null, BuildContext context = null)
        {
            D.assert(details != null || context != null);

            Offset globalPosition;

            if (context != null)
            {
                RenderBox referenceBox = context.findRenderObject() as RenderBox;
                D.assert(referenceBox.hasSize, () => "InkResponse must be done with layout before starting a splash.");
                globalPosition = referenceBox.localToGlobal(referenceBox.paintBounds.center);
            }
            else
            {
                globalPosition = details.globalPosition;
            }

            InteractiveInkFeature splash = _createInkFeature(globalPosition);

            _splashes = _splashes ?? new HashSet <InteractiveInkFeature>();
            _splashes.Add(splash);
            _currentSplash = splash;
            updateKeepAlive();
            updateHighlight(_HighlightType.pressed, value: true);
        }
Example #28
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;
            }
        }
Example #29
0
        public void createChild(int index, RenderBox after = null)
        {
            D.assert(_currentlyUpdatingChildIndex == null);
            owner.buildScope(this, () => {
                bool insertFirst = after == null;
                D.assert(insertFirst || _childElements[index - 1] != null);
                _currentBeforeChild = insertFirst ? null : (RenderBox)_childElements[index - 1].renderObject;
                Element newChild;
                try {
                    _currentlyUpdatingChildIndex = index;
                    _childElements.TryGetValue(index, out newChild);
                    newChild = updateChild(newChild, _build(index), index);
                }
                finally {
                    _currentlyUpdatingChildIndex = null;
                }

                if (newChild != null)
                {
                    _childElements[index] = newChild;
                }
                else
                {
                    _childElements.Remove(index);
                }
            });
        }
Example #30
0
        public virtual void didAdoptChild(RenderBox child)
        {
            D.assert(_currentlyUpdatingChildIndex != null);
            SliverMultiBoxAdaptorParentData childParentData = (SliverMultiBoxAdaptorParentData)child.parentData;

            childParentData.index = _currentlyUpdatingChildIndex.Value;
        }
Example #31
0
 static void box_EventUpdateViewport(RenderBox _sender)
 {
     Export.DebugOut("EventUpdateViewport");
 }
Example #32
0
 static void box_EventUpdateViewport(RenderBox _sender)
 {
     ExampleApplication.DebugOut("EventUpdateViewport");
 }