diff --git a/packages/flutter/lib/src/material/icon.dart b/packages/flutter/lib/src/material/icon.dart index 8c25d35387..46b46ab278 100644 --- a/packages/flutter/lib/src/material/icon.dart +++ b/packages/flutter/lib/src/material/icon.dart @@ -23,6 +23,8 @@ class IconThemeData { } int get hashCode => color.hashCode; + + String toString() => '$color'; } class IconTheme extends InheritedWidget { @@ -45,6 +47,10 @@ class IconTheme extends InheritedWidget { bool updateShouldNotify(IconTheme old) => data != old.data; + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('$data'); + } } AssetBundle _initIconBundle() { @@ -63,7 +69,10 @@ class Icon extends StatelessComponent { this.type: '', this.color, this.colorFilter - }) : super(key: key); + }) : super(key: key) { + assert(size != null); + assert(type != null); + } final int size; final String type; @@ -108,4 +117,10 @@ class Icon extends StatelessComponent { colorFilter: colorFilter ); } + + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('$type'); + description.add('size: $size'); + } } diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index f629806d30..4ea19a36fe 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -36,4 +36,9 @@ class IconButton extends StatelessComponent { ) ); } + + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('$icon'); + } } diff --git a/packages/flutter/lib/src/material/material_button.dart b/packages/flutter/lib/src/material/material_button.dart index bf5380d20a..1eb4591493 100644 --- a/packages/flutter/lib/src/material/material_button.dart +++ b/packages/flutter/lib/src/material/material_button.dart @@ -47,6 +47,12 @@ abstract class MaterialButton extends StatefulComponent { final bool enabled; final ButtonColor textColor; final GestureTapCallback onPressed; + + void debugFillDescription(List description) { + super.debugFillDescription(description); + if (!enabled) + description.add('disabled'); + } } abstract class MaterialButtonState extends State { diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 73052ecdc7..e688a447c0 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -14,15 +14,15 @@ const double _kLinearProgressIndicatorHeight = 6.0; const double _kMinCircularProgressIndicatorSize = 15.0; const double _kCircularProgressIndicatorStrokeWidth = 3.0; +// TODO(hansmuller) implement the support for buffer indicator + abstract class ProgressIndicator extends StatefulComponent { ProgressIndicator({ Key key, - this.value, - this.bufferValue + this.value }) : super(key: key); final double value; // Null for non-determinate progress indicator. - final double bufferValue; // TODO(hansmuller) implement the support for this. Color _getBackgroundColor(BuildContext context) => Theme.of(context).primarySwatch[200]; Color _getValueColor(BuildContext context) => Theme.of(context).primaryColor; @@ -31,6 +31,11 @@ abstract class ProgressIndicator extends StatefulComponent { Widget _buildIndicator(BuildContext context, double performanceValue); _ProgressIndicatorState createState() => new _ProgressIndicatorState(); + + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('${(value.clamp(0.0, 1.0) * 100.0).toStringAsFixed(1)}%'); + } } class _ProgressIndicatorState extends State { @@ -72,9 +77,8 @@ class _ProgressIndicatorState extends State { class LinearProgressIndicator extends ProgressIndicator { LinearProgressIndicator({ Key key, - double value, - double bufferValue - }) : super(key: key, value: value, bufferValue: bufferValue); + double value + }) : super(key: key, value: value); void _paint(BuildContext context, double performanceValue, Canvas canvas, Size size) { Paint paint = new Paint() @@ -120,9 +124,8 @@ class CircularProgressIndicator extends ProgressIndicator { CircularProgressIndicator({ Key key, - double value, - double bufferValue - }) : super(key: key, value: value, bufferValue: bufferValue); + double value + }) : super(key: key, value: value); void _paint(BuildContext context, double performanceValue, Canvas canvas, Size size) { Paint paint = new Paint() diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 00025c8376..3a9d40ea81 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -281,6 +281,16 @@ class TabLabel { final String text; final String icon; + + String toString() { + if (text != null && icon != null) + return '"$text" ($icon)'; + if (text != null) + return '"$text"'; + if (icon != null) + return '$icon'; + return 'EMPTY TAB LABEL'; + } } class Tab extends StatelessComponent { @@ -345,6 +355,11 @@ class Tab extends StatelessComponent { child: centeredLabel ); } + + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('$label'); + } } class _TabsScrollBehavior extends BoundedBehavior { diff --git a/packages/flutter/lib/src/material/theme.dart b/packages/flutter/lib/src/material/theme.dart index aeff56fb43..7d9233a7c5 100644 --- a/packages/flutter/lib/src/material/theme.dart +++ b/packages/flutter/lib/src/material/theme.dart @@ -28,4 +28,9 @@ class Theme extends InheritedWidget { } bool updateShouldNotify(Theme old) => data != old.data; + + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('$data'); + } } diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 7566fd405c..3b789d0409 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -124,4 +124,6 @@ class ThemeData { value = 37 * value + accentColorBrightness.hashCode; return value; } + + String toString() => '$primaryColor $brightness etc...'; } diff --git a/packages/flutter/lib/src/material/title.dart b/packages/flutter/lib/src/material/title.dart index deca5d18b8..293320c1a6 100644 --- a/packages/flutter/lib/src/material/title.dart +++ b/packages/flutter/lib/src/material/title.dart @@ -17,4 +17,9 @@ class Title extends StatelessComponent { updateTaskDescription(title, Theme.of(context).primaryColor); return child; } + + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('"$title"'); + } } diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index b26a99adbb..2341e818fa 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -254,7 +254,21 @@ class BoxConstraints extends Constraints { return value; } - String toString() => "BoxConstraints($minWidth<=w<=$maxWidth, $minHeight<=h<=$maxHeight)"; + String toString() { + if (minWidth == double.INFINITY && minHeight == double.INFINITY) + return 'BoxConstraints(biggest)'; + if (minWidth == 0 && maxWidth == double.INFINITY && + minHeight == 0 && maxHeight == double.INFINITY) + return 'BoxConstraints(unconstrained)'; + String describe(double min, double max, String dim) { + if (min == max) + return '$dim=${min.toStringAsFixed(1)}'; + return '${min.toStringAsFixed(1)}<=$dim<=${max.toStringAsFixed(1)}'; + } + final String width = describe(minWidth, maxWidth, 'w'); + final String height = describe(minHeight, maxHeight, 'h'); + return 'BoxConstraints($width, $height)'; + } } /// A hit test entry used by [RenderBox] diff --git a/packages/flutter/lib/src/rendering/stack.dart b/packages/flutter/lib/src/rendering/stack.dart index c6ba3f635f..85af118fe6 100644 --- a/packages/flutter/lib/src/rendering/stack.dart +++ b/packages/flutter/lib/src/rendering/stack.dart @@ -132,7 +132,7 @@ class RelativeRect { return value; } - String toString() => "RelativeRect.fromLTRB($left, $top, $right, $bottom)"; + String toString() => "RelativeRect.fromLTRB(${left.toStringAsFixed(1)}, ${top.toStringAsFixed(1)}, ${right.toStringAsFixed(1)}, ${bottom.toStringAsFixed(1)})"; } /// Parent data for use with [RenderStack] diff --git a/packages/flutter/lib/src/rendering/view.dart b/packages/flutter/lib/src/rendering/view.dart index 7b0d3548ef..a9b739bc83 100644 --- a/packages/flutter/lib/src/rendering/view.dart +++ b/packages/flutter/lib/src/rendering/view.dart @@ -23,6 +23,8 @@ class ViewConstraints { /// The orientation of the output surface (aspirational) final int orientation; + + String toString() => '$size'; } /// The root of the render tree @@ -53,7 +55,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin ViewConstraints get rootConstraints => _rootConstraints; ViewConstraints _rootConstraints; void set rootConstraints(ViewConstraints value) { - if (_rootConstraints == value) + if (rootConstraints == value) return; _rootConstraints = value; markNeedsLayout(); @@ -80,12 +82,12 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin } void performLayout() { - if (_rootConstraints.orientation != _orientation) { + if (rootConstraints.orientation != _orientation) { if (_orientation != null && child != null) - child.rotate(oldAngle: _orientation, newAngle: _rootConstraints.orientation, time: timeForRotation); - _orientation = _rootConstraints.orientation; + child.rotate(oldAngle: _orientation, newAngle: rootConstraints.orientation, time: timeForRotation); + _orientation = rootConstraints.orientation; } - _size = _rootConstraints.size; + _size = rootConstraints.size; assert(!_size.isInfinite); if (child != null) @@ -127,4 +129,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin } Rect get paintBounds => Point.origin & size; + + String debugDescribeSettings(String prefix) => '${prefix}view width: ${ui.view.width} (in device pixels)\n${prefix}view height: ${ui.view.height} (in device pixels)\n${prefix}device pixel ratio: ${ui.view.devicePixelRatio} (device pixels per logical pixel)\n${prefix}root constraints: $rootConstraints (in logical pixels)\n'; + // call to ${super.debugDescribeSettings(prefix)} is omitted because the root superclasses don't include any interesting information for this class } diff --git a/packages/flutter/lib/src/widgets/animated_container.dart b/packages/flutter/lib/src/widgets/animated_container.dart index 307fdd431f..8017dbaa16 100644 --- a/packages/flutter/lib/src/widgets/animated_container.dart +++ b/packages/flutter/lib/src/widgets/animated_container.dart @@ -123,7 +123,6 @@ class _AnimatedContainerState extends State { void _updateAllVariables() { setState(() { - _updateVariable(_constraints); _updateVariable(_constraints); _updateVariable(_decoration); _updateVariable(_foregroundDecoration); @@ -224,4 +223,24 @@ class _AnimatedContainerState extends State { height: _height?.value ); } + + void debugFillDescription(List description) { + super.debugFillDescription(description); + if (_constraints != null) + description.add('has constraints'); + if (_decoration != null) + description.add('has background'); + if (_foregroundDecoration != null) + description.add('has foreground'); + if (_margin != null) + description.add('has margin'); + if (_padding != null) + description.add('has padding'); + if (_transform != null) + description.add('has transform'); + if (_width != null) + description.add('has width'); + if (_height != null) + description.add('has height'); + } } diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 776e33bd4c..248f343a70 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -314,7 +314,7 @@ class ConstrainedBox extends OneChildRenderObjectWidget { void debugFillDescription(List description) { super.debugFillDescription(description); - description.add('constraints: $constraints'); + description.add('$constraints'); } } @@ -549,6 +549,26 @@ class Container extends StatelessComponent { return current; } + void debugFillDescription(List description) { + super.debugFillDescription(description); + if (constraints != null) + description.add('$constraints'); + if (decoration != null) + description.add('has background'); + if (foregroundDecoration != null) + description.add('has foreground'); + if (margin != null) + description.add('margin: $margin'); + if (padding != null) + description.add('padding: $padding'); + if (transform != null) + description.add('has transform'); + if (width != null) + description.add('width: $width'); + if (height != null) + description.add('height: $height'); + } + } diff --git a/packages/flutter/lib/src/widgets/focus.dart b/packages/flutter/lib/src/widgets/focus.dart index 5f2f129d3d..c5592b0310 100644 --- a/packages/flutter/lib/src/widgets/focus.dart +++ b/packages/flutter/lib/src/widgets/focus.dart @@ -22,8 +22,8 @@ class _FocusScope extends InheritedWidget { Widget child }) : super(key: key, child: child); - final bool scopeFocused; final FocusState focusState; + final bool scopeFocused; // These are mutable because we implicitly change them when they're null in // certain cases, basically pretending retroactively that we were constructed @@ -61,6 +61,15 @@ class _FocusScope extends InheritedWidget { return false; } + void debugFillDescription(List description) { + super.debugFillDescription(description); + if (scopeFocused) + description.add('this scope has focus'); + if (focusedScope != null) + description.add('focused subscope: $focusedScope'); + if (focusedWidget != null) + description.add('focused widget: $focusedWidget'); + } } class Focus extends StatefulComponent {