コード例 #1
0
        public Size layoutChild(object childId, BoxConstraints constraints) {
            RenderBox child = this._idToChild[childId];
            D.assert(() => {
                if (child == null) {
                    throw new UIWidgetsError(
                        $"The {this} custom multichild layout delegate tried to lay out a non-existent child.\n" +
                        $"There is no child with the id \"{childId}\"."
                    );
                }

                if (!this._debugChildrenNeedingLayout.Remove(child)) {
                    throw new UIWidgetsError(
                        $"The $this custom multichild layout delegate tried to lay out the child with id \"{childId}\" more than once.\n" +
                        "Each child must be laid out exactly once."
                    );
                }

                try {
                    D.assert(constraints.debugAssertIsValid(isAppliedConstraint: true));
                }
                catch (AssertionError exception) {
                    throw new UIWidgetsError(
                        $"The {this} custom multichild layout delegate provided invalid box constraints for the child with id \"{childId}\".\n" +
                        $"{exception}n" +
                        "The minimum width and height must be greater than or equal to zero.\n" +
                        "The maximum width must be greater than or equal to the minimum width.\n" +
                        "The maximum height must be greater than or equal to the minimum height.");
                }

                return true;
            });
            child.layout(constraints, parentUsesSize: true);
            return child.size;
        }
コード例 #2
0
ファイル: shifted_box.cs プロジェクト: wxFancer/UIWidgets
 protected override void performLayout()
 {
     this.size = this._getSize(this.constraints);
     if (this.child != null)
     {
         BoxConstraints childConstraints = this.layoutDelegate.getConstraintsForChild(this.constraints);
         D.assert(childConstraints.debugAssertIsValid(isAppliedConstraint: true));
         this.child.layout(childConstraints, parentUsesSize: !childConstraints.isTight);
         BoxParentData childParentData = (BoxParentData)this.child.parentData;
         childParentData.offset = this.layoutDelegate.getPositionForChild(this.size,
                                                                          childConstraints.isTight ? childConstraints.smallest : this.child.size);
     }
 }
コード例 #3
0
        public Size layoutChild(object childId, BoxConstraints constraints)
        {
            RenderBox child = _idToChild[childId];

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

                if (!_debugChildrenNeedingLayout.Remove(child))
                {
                    throw new UIWidgetsError(
                        $"The $this custom multichild layout delegate tried to lay out the child with id \"{childId}\" more than once.\n" +
                        "Each child must be laid out exactly once."
                        );
                }

                try {
                    D.assert(constraints.debugAssertIsValid(isAppliedConstraint: true));
                }
                catch (AssertionError exception) {
                    throw new UIWidgetsError(new List <DiagnosticsNode> {
                        new ErrorSummary(
                            $"The $this custom multichild layout delegate provided invalid box constraints for the child with id {childId}."),
                        new DiagnosticsProperty <AssertionError>("Exception", exception, showName: false),
                        new ErrorDescription(
                            "The minimum width and height must be greater than or equal to zero.\n" +
                            "The maximum width must be greater than or equal to the minimum width.\n" +
                            "The maximum height must be greater than or equal to the minimum height."
                            )
                    });
                }

                return(true);
            });
            child.layout(constraints, parentUsesSize: true);
            return(child.size);
        }
コード例 #4
0
 public AnimatedContainer(
     Key key = null,
     AlignmentGeometry alignment = null,
     EdgeInsetsGeometry padding  = null,
     Color color                     = null,
     Decoration decoration           = null,
     Decoration foregroundDecoration = null,
     float?width                     = null,
     float?height                    = null,
     BoxConstraints constraints      = null,
     EdgeInsetsGeometry margin       = null,
     Matrix4 transform               = null,
     Widget child                    = null,
     Curve curve                     = null,
     TimeSpan?duration               = null,
     VoidCallback onEnd              = null
     ) : base(key: key, curve: curve ?? Curves.linear, duration: duration, onEnd: onEnd)
 {
     D.assert(duration != null);
     D.assert(margin == null || margin.isNonNegative);
     D.assert(padding == null || padding.isNonNegative);
     D.assert(decoration == null || decoration.debugAssertIsValid());
     D.assert(constraints == null || constraints.debugAssertIsValid());
     D.assert(color == null || decoration == null,
              () => "Cannot provide both a color and a decoration\n" +
              "The color argument is just a shorthand for \"decoration: new BoxDecoration(backgroundColor: color)\".");
     this.alignment            = alignment;
     this.padding              = padding;
     this.foregroundDecoration = foregroundDecoration;
     this.margin      = margin;
     this.transform   = transform;
     this.child       = child;
     this.decoration  = decoration ?? (color != null ? new BoxDecoration(color: color) : null);
     this.constraints =
         (width != null || height != null)
             ? constraints?.tighten(width: width, height: height)
         ?? BoxConstraints.tightFor(width: width, height: height)
             : constraints;
 }
コード例 #5
0
        public Container(
            Key key = null,
            AlignmentGeometry alignment = null,
            EdgeInsetsGeometry padding  = null,
            Color color                     = null,
            Decoration decoration           = null,
            Decoration foregroundDecoration = null,
            float?width                     = null,
            float?height                    = null,
            BoxConstraints constraints      = null,
            EdgeInsetsGeometry margin       = null,
            Matrix4 transform               = null,
            Widget child                    = null,
            Clip clipBehavior               = Clip.none
            ) : base(key: key)
        {
            D.assert(margin == null || margin.isNonNegative);
            D.assert(padding == null || padding.isNonNegative);
            D.assert(decoration == null || decoration.debugAssertIsValid());
            D.assert(constraints == null || constraints.debugAssertIsValid());
            D.assert(color == null || decoration == null,
                     () => "Cannot provide both a color and a decoration\n" +
                     "The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\"."
                     );
            D.assert(clipBehavior != null);

            this.alignment            = alignment;
            this.padding              = padding;
            this.foregroundDecoration = foregroundDecoration;
            this.color       = color;
            this.decoration  = decoration;// ?? (color != null ? new BoxDecoration(color) : null);
            this.constraints = (width != null || height != null)
                ? (constraints != null ? constraints.tighten(width, height) : BoxConstraints.tightFor(width, height))
                : constraints;
            this.margin       = margin;
            this.transform    = transform;
            this.child        = child;
            this.clipBehavior = clipBehavior;
        }
コード例 #6
0
ファイル: container.cs プロジェクト: wxFancer/UIWidgets
        public Container(
            Key key                        = null,
            Alignment alignment            = null,
            EdgeInsets padding             = null,
            Color color                    = null,
            Decoration decoration          = null,
            Decoration forgroundDecoration = null,
            double?width                   = null,
            double?height                  = null,
            BoxConstraints constraints     = null,
            EdgeInsets margin              = null,
            Matrix3 transfrom              = null,
            Widget child                   = null
            ) : base(key)
        {
            D.assert(margin == null || margin.isNonNegative);
            D.assert(padding == null || padding.isNonNegative);
            D.assert(decoration == null || decoration.debugAssertIsValid());
            D.assert(constraints == null || constraints.debugAssertIsValid());
            D.assert(color == null || decoration == null,
                     "Cannot provide both a color and a decoration\n" +
                     "The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\"."
                     );

            this.alignment            = alignment;
            this.padding              = padding;
            this.foregroundDecoration = forgroundDecoration;
            this.margin    = margin;
            this.transform = transfrom;
            this.child     = child;

            this.decoration  = decoration ?? (color != null ? new BoxDecoration(color) : null);
            this.constraints = (width != null || height != null)
                ? (constraints != null ? constraints.tighten(width, height) : BoxConstraints.tightFor(width, height))
                : constraints;
        }
コード例 #7
0
 Size _getSize(BoxConstraints constraints)
 {
     D.assert(constraints.debugAssertIsValid());
     return(constraints.constrain(this._delegate.getSize(constraints)));
 }