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:
- name: navigation/arrow_back
- name: navigation/menu
- 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;
import 'dart:async';
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 'i18n/stock_messages_all.dart';
......@@ -32,6 +37,10 @@ class StocksAppState extends State<StocksApp> {
backupMode: BackupMode.enabled,
debugShowGrid: false,
debugShowSizes: false,
debugShowBaselines: false,
debugShowLayers: false,
debugShowPointers: false,
debugShowRainbow: false,
showPerformanceOverlay: false,
showSemanticsDebugger: false
);
......@@ -93,6 +102,10 @@ class StocksAppState extends State<StocksApp> {
Widget build(BuildContext context) {
assert(() {
debugPaintSizeEnabled = _configuration.debugShowSizes;
debugPaintBaselinesEnabled = _configuration.debugShowBaselines;
debugPaintLayerBordersEnabled = _configuration.debugShowLayers;
debugPaintPointersEnabled = _configuration.debugShowPointers;
debugRepaintRainbowEnabled = _configuration.debugShowRainbow;
return true;
});
return new MaterialApp(
......
......@@ -33,6 +33,23 @@ class StockSettingsState extends State<StockSettings> {
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) {
sendUpdates(config.configuration.copyWith(showPerformanceOverlay: value));
}
......@@ -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;
});
......
......@@ -11,6 +11,10 @@ class StockConfiguration {
this.backupMode,
this.debugShowGrid,
this.debugShowSizes,
this.debugShowBaselines,
this.debugShowLayers,
this.debugShowPointers,
this.debugShowRainbow,
this.showPerformanceOverlay,
this.showSemanticsDebugger
}) {
......@@ -18,6 +22,10 @@ class StockConfiguration {
assert(backupMode != null);
assert(debugShowGrid != null);
assert(debugShowSizes != null);
assert(debugShowBaselines != null);
assert(debugShowLayers != null);
assert(debugShowPointers != null);
assert(debugShowRainbow != null);
assert(showPerformanceOverlay != null);
assert(showSemanticsDebugger != null);
}
......@@ -26,6 +34,10 @@ class StockConfiguration {
final BackupMode backupMode;
final bool debugShowGrid;
final bool debugShowSizes;
final bool debugShowBaselines;
final bool debugShowLayers;
final bool debugShowPointers;
final bool debugShowRainbow;
final bool showPerformanceOverlay;
final bool showSemanticsDebugger;
......@@ -34,6 +46,10 @@ class StockConfiguration {
BackupMode backupMode,
bool debugShowGrid,
bool debugShowSizes,
bool debugShowBaselines,
bool debugShowLayers,
bool debugShowPointers,
bool debugShowRainbow,
bool showPerformanceOverlay,
bool showSemanticsDebugger
}) {
......@@ -42,6 +58,10 @@ class StockConfiguration {
backupMode: backupMode ?? this.backupMode,
debugShowGrid: debugShowGrid ?? this.debugShowGrid,
debugShowSizes: debugShowSizes ?? this.debugShowSizes,
debugShowBaselines: debugShowBaselines ?? this.debugShowBaselines,
debugShowLayers: debugShowLayers ?? this.debugShowLayers,
debugShowPointers: debugShowPointers ?? this.debugShowPointers,
debugShowRainbow: debugShowRainbow ?? this.debugShowRainbow,
showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay,
showSemanticsDebugger: showSemanticsDebugger ?? this.showSemanticsDebugger
);
......
......@@ -57,13 +57,13 @@ int debugPaintPointersColorValue = 0x00BBBB;
Color debugErrorBoxColor = const Color(0xFFFF0000);
/// 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.
HSVColor debugCurrentRepaintColor = const HSVColor.fromAHSV(0.4, 60.0, 1.0, 1.0);
/// 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.
bool debugPrintMarkNeedsPaintStacks = false;
......
......@@ -159,7 +159,7 @@ class PaintingContext {
if (!_isRecording)
return;
assert(() {
if (debugEnableRepaintRainbox)
if (debugRepaintRainbowEnabled)
canvas.drawRect(_paintBounds, new Paint()..color = debugCurrentRepaintColor.toColor());
if (debugPaintLayerBordersEnabled) {
Paint paint = new Paint()
......
......@@ -130,8 +130,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
ui.window.render(scene);
scene.dispose();
assert(() {
if (debugEnableRepaintRainbox)
debugCurrentRepaintColor = debugCurrentRepaintColor.withHue(debugCurrentRepaintColor.hue + debugRepaintRainboxHueIncrement);
if (debugRepaintRainbowEnabled)
debugCurrentRepaintColor = debugCurrentRepaintColor.withHue(debugCurrentRepaintColor.hue + debugRepaintRainbowHueIncrement);
return true;
});
} 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