Commit ca4d10d3 authored by Ian Hickson's avatar Ian Hickson

Merge pull request #1820 from Hixie/rainbox

Expose more debugging tools in Stocks
parents 19e51b96 a95c866b
...@@ -19,3 +19,7 @@ material-design-icons: ...@@ -19,3 +19,7 @@ material-design-icons:
- name: navigation/arrow_back - name: navigation/arrow_back
- name: navigation/menu - name: navigation/menu
- name: navigation/more_vert - name: navigation/more_vert
- name: editor/format_color_text
- name: image/filter_none
- name: hardware/mouse
- name: image/gradient
...@@ -7,7 +7,12 @@ library stocks; ...@@ -7,7 +7,12 @@ library stocks;
import 'dart:async'; import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart' show debugPaintSizeEnabled; import 'package:flutter/rendering.dart' show
debugPaintSizeEnabled,
debugPaintBaselinesEnabled,
debugPaintLayerBordersEnabled,
debugPaintPointersEnabled,
debugRepaintRainbowEnabled;
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'i18n/stock_messages_all.dart'; import 'i18n/stock_messages_all.dart';
...@@ -32,6 +37,10 @@ class StocksAppState extends State<StocksApp> { ...@@ -32,6 +37,10 @@ class StocksAppState extends State<StocksApp> {
backupMode: BackupMode.enabled, backupMode: BackupMode.enabled,
debugShowGrid: false, debugShowGrid: false,
debugShowSizes: false, debugShowSizes: false,
debugShowBaselines: false,
debugShowLayers: false,
debugShowPointers: false,
debugShowRainbow: false,
showPerformanceOverlay: false, showPerformanceOverlay: false,
showSemanticsDebugger: false showSemanticsDebugger: false
); );
...@@ -93,6 +102,10 @@ class StocksAppState extends State<StocksApp> { ...@@ -93,6 +102,10 @@ class StocksAppState extends State<StocksApp> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(() { assert(() {
debugPaintSizeEnabled = _configuration.debugShowSizes; debugPaintSizeEnabled = _configuration.debugShowSizes;
debugPaintBaselinesEnabled = _configuration.debugShowBaselines;
debugPaintLayerBordersEnabled = _configuration.debugShowLayers;
debugPaintPointersEnabled = _configuration.debugShowPointers;
debugRepaintRainbowEnabled = _configuration.debugShowRainbow;
return true; return true;
}); });
return new MaterialApp( return new MaterialApp(
......
...@@ -33,6 +33,23 @@ class StockSettingsState extends State<StockSettings> { ...@@ -33,6 +33,23 @@ class StockSettingsState extends State<StockSettings> {
sendUpdates(config.configuration.copyWith(debugShowSizes: value)); sendUpdates(config.configuration.copyWith(debugShowSizes: value));
} }
void _handleShowBaselinesChanged(bool value) {
sendUpdates(config.configuration.copyWith(debugShowBaselines: value));
}
void _handleShowLayersChanged(bool value) {
sendUpdates(config.configuration.copyWith(debugShowLayers: value));
}
void _handleShowPointersChanged(bool value) {
sendUpdates(config.configuration.copyWith(debugShowPointers: value));
}
void _handleShowRainbowChanged(bool value) {
sendUpdates(config.configuration.copyWith(debugShowRainbow: value));
}
void _handleShowPerformanceOverlayChanged(bool value) { void _handleShowPerformanceOverlayChanged(bool value) {
sendUpdates(config.configuration.copyWith(showPerformanceOverlay: value)); sendUpdates(config.configuration.copyWith(showPerformanceOverlay: value));
} }
...@@ -166,7 +183,59 @@ class StockSettingsState extends State<StockSettings> { ...@@ -166,7 +183,59 @@ class StockSettingsState extends State<StockSettings> {
), ),
] ]
) )
) ),
new DrawerItem(
icon: 'editor/format_color_text',
onPressed: () { _handleShowBaselinesChanged(!config.configuration.debugShowBaselines); },
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Show baselines (for debugging)')),
new Switch(
value: config.configuration.debugShowBaselines,
onChanged: _handleShowBaselinesChanged
),
]
)
),
new DrawerItem(
icon: 'image/filter_none',
onPressed: () { _handleShowLayersChanged(!config.configuration.debugShowLayers); },
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Show layer boundaries (for debugging)')),
new Switch(
value: config.configuration.debugShowLayers,
onChanged: _handleShowLayersChanged
),
]
)
),
new DrawerItem(
icon: 'hardware/mouse',
onPressed: () { _handleShowPointersChanged(!config.configuration.debugShowPointers); },
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Show pointer hit-testing (for debugging)')),
new Switch(
value: config.configuration.debugShowPointers,
onChanged: _handleShowPointersChanged
),
]
)
),
new DrawerItem(
icon: 'image/gradient',
onPressed: () { _handleShowRainbowChanged(!config.configuration.debugShowRainbow); },
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Show repaint rainbow (for debugging)')),
new Switch(
value: config.configuration.debugShowRainbow,
onChanged: _handleShowRainbowChanged
),
]
)
),
]); ]);
return true; return true;
}); });
......
...@@ -11,6 +11,10 @@ class StockConfiguration { ...@@ -11,6 +11,10 @@ class StockConfiguration {
this.backupMode, this.backupMode,
this.debugShowGrid, this.debugShowGrid,
this.debugShowSizes, this.debugShowSizes,
this.debugShowBaselines,
this.debugShowLayers,
this.debugShowPointers,
this.debugShowRainbow,
this.showPerformanceOverlay, this.showPerformanceOverlay,
this.showSemanticsDebugger this.showSemanticsDebugger
}) { }) {
...@@ -18,6 +22,10 @@ class StockConfiguration { ...@@ -18,6 +22,10 @@ class StockConfiguration {
assert(backupMode != null); assert(backupMode != null);
assert(debugShowGrid != null); assert(debugShowGrid != null);
assert(debugShowSizes != null); assert(debugShowSizes != null);
assert(debugShowBaselines != null);
assert(debugShowLayers != null);
assert(debugShowPointers != null);
assert(debugShowRainbow != null);
assert(showPerformanceOverlay != null); assert(showPerformanceOverlay != null);
assert(showSemanticsDebugger != null); assert(showSemanticsDebugger != null);
} }
...@@ -26,6 +34,10 @@ class StockConfiguration { ...@@ -26,6 +34,10 @@ class StockConfiguration {
final BackupMode backupMode; final BackupMode backupMode;
final bool debugShowGrid; final bool debugShowGrid;
final bool debugShowSizes; final bool debugShowSizes;
final bool debugShowBaselines;
final bool debugShowLayers;
final bool debugShowPointers;
final bool debugShowRainbow;
final bool showPerformanceOverlay; final bool showPerformanceOverlay;
final bool showSemanticsDebugger; final bool showSemanticsDebugger;
...@@ -34,6 +46,10 @@ class StockConfiguration { ...@@ -34,6 +46,10 @@ class StockConfiguration {
BackupMode backupMode, BackupMode backupMode,
bool debugShowGrid, bool debugShowGrid,
bool debugShowSizes, bool debugShowSizes,
bool debugShowBaselines,
bool debugShowLayers,
bool debugShowPointers,
bool debugShowRainbow,
bool showPerformanceOverlay, bool showPerformanceOverlay,
bool showSemanticsDebugger bool showSemanticsDebugger
}) { }) {
...@@ -42,6 +58,10 @@ class StockConfiguration { ...@@ -42,6 +58,10 @@ class StockConfiguration {
backupMode: backupMode ?? this.backupMode, backupMode: backupMode ?? this.backupMode,
debugShowGrid: debugShowGrid ?? this.debugShowGrid, debugShowGrid: debugShowGrid ?? this.debugShowGrid,
debugShowSizes: debugShowSizes ?? this.debugShowSizes, debugShowSizes: debugShowSizes ?? this.debugShowSizes,
debugShowBaselines: debugShowBaselines ?? this.debugShowBaselines,
debugShowLayers: debugShowLayers ?? this.debugShowLayers,
debugShowPointers: debugShowPointers ?? this.debugShowPointers,
debugShowRainbow: debugShowRainbow ?? this.debugShowRainbow,
showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay, showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay,
showSemanticsDebugger: showSemanticsDebugger ?? this.showSemanticsDebugger showSemanticsDebugger: showSemanticsDebugger ?? this.showSemanticsDebugger
); );
......
...@@ -57,13 +57,13 @@ int debugPaintPointersColorValue = 0x00BBBB; ...@@ -57,13 +57,13 @@ int debugPaintPointersColorValue = 0x00BBBB;
Color debugErrorBoxColor = const Color(0xFFFF0000); Color debugErrorBoxColor = const Color(0xFFFF0000);
/// Overlay a rotating set of colors when repainting layers in checked mode. /// Overlay a rotating set of colors when repainting layers in checked mode.
bool debugEnableRepaintRainbox = false; bool debugRepaintRainbowEnabled = false;
/// The current color to overlay when repainting a layer. /// The current color to overlay when repainting a layer.
HSVColor debugCurrentRepaintColor = const HSVColor.fromAHSV(0.4, 60.0, 1.0, 1.0); HSVColor debugCurrentRepaintColor = const HSVColor.fromAHSV(0.4, 60.0, 1.0, 1.0);
/// The amount to increment the hue of the current repaint color. /// The amount to increment the hue of the current repaint color.
double debugRepaintRainboxHueIncrement = 2.0; double debugRepaintRainbowHueIncrement = 2.0;
/// Log the call stacks that mark render objects as needing paint. /// Log the call stacks that mark render objects as needing paint.
bool debugPrintMarkNeedsPaintStacks = false; bool debugPrintMarkNeedsPaintStacks = false;
......
...@@ -159,7 +159,7 @@ class PaintingContext { ...@@ -159,7 +159,7 @@ class PaintingContext {
if (!_isRecording) if (!_isRecording)
return; return;
assert(() { assert(() {
if (debugEnableRepaintRainbox) if (debugRepaintRainbowEnabled)
canvas.drawRect(_paintBounds, new Paint()..color = debugCurrentRepaintColor.toColor()); canvas.drawRect(_paintBounds, new Paint()..color = debugCurrentRepaintColor.toColor());
if (debugPaintLayerBordersEnabled) { if (debugPaintLayerBordersEnabled) {
Paint paint = new Paint() Paint paint = new Paint()
......
...@@ -130,8 +130,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -130,8 +130,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
ui.window.render(scene); ui.window.render(scene);
scene.dispose(); scene.dispose();
assert(() { assert(() {
if (debugEnableRepaintRainbox) if (debugRepaintRainbowEnabled)
debugCurrentRepaintColor = debugCurrentRepaintColor.withHue(debugCurrentRepaintColor.hue + debugRepaintRainboxHueIncrement); debugCurrentRepaintColor = debugCurrentRepaintColor.withHue(debugCurrentRepaintColor.hue + debugRepaintRainbowHueIncrement);
return true; return true;
}); });
} finally { } finally {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment