Commit 98f2c78e authored by Ian Hickson's avatar Ian Hickson

Merge pull request #1777 from Hixie/debug-touches

debugPaintPointersEnabled mode
parents 6c0635ca 76381b8f
......@@ -5,6 +5,7 @@
import 'dart:math' as math;
import 'dart:ui' as ui;
import 'package:flutter/gestures.dart';
import 'package:flutter/painting.dart';
import 'package:vector_math/vector_math_64.dart';
......@@ -620,11 +621,28 @@ abstract class RenderBox extends RenderObject {
/// The returned paint bounds are in the local coordinate system of this box.
Rect get paintBounds => Point.origin & size;
int _debugActivePointers = 0;
void handleEvent(InputEvent event, HitTestEntry entry) {
super.handleEvent(event, entry);
assert(() {
if (debugPaintPointersEnabled) {
if (event.type == 'pointerdown')
_debugActivePointers += 1;
if (event.type == 'pointerup' || event.type == 'pointercancel')
_debugActivePointers -= 1;
markNeedsPaint();
}
return true;
});
}
void debugPaint(PaintingContext context, Offset offset) {
if (debugPaintSizeEnabled)
debugPaintSize(context, offset);
if (debugPaintBaselinesEnabled)
debugPaintBaselines(context, offset);
if (debugPaintPointersEnabled)
debugPaintPointers(context, offset);
}
void debugPaintSize(PaintingContext context, Offset offset) {
Paint paint = new Paint()
......@@ -657,6 +675,13 @@ abstract class RenderBox extends RenderObject {
context.canvas.drawPath(path, paint);
}
}
void debugPaintPointers(PaintingContext context, Offset offset) {
if (_debugActivePointers > 0) {
Paint paint = new Paint()
..color = new Color(debugPaintPointersColorValue | ((0x04000000 * depth) & 0xFF000000));
context.canvas.drawRect(offset & size, paint);
}
}
String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(prefix)}${prefix}size: ${ hasSize ? size : "MISSING" }\n';
}
......
......@@ -30,6 +30,12 @@ ui.Color debugPaintLayerBordersColor = const ui.Color(0xFFFF9800);
/// Causes RenderObjects to paint warnings when painting outside their bounds.
bool debugPaintBoundsEnabled = false;
/// Causes RenderBox objects to flash while they are being tapped
bool debugPaintPointersEnabled = false;
/// The color to use when reporting pointers.
int debugPaintPointersColorValue = 0x00BBBB;
/// The color to use when painting RenderError boxes in checked mode.
ui.Color debugErrorBoxColor = const ui.Color(0xFFFF0000);
......
......@@ -1014,7 +1014,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
_debugDoingThisPaint = true;
debugLastActivePaint = _debugActivePaint;
_debugActivePaint = this;
debugPaint(context, offset);
if (debugPaintBoundsEnabled) {
context.canvas.save();
context.canvas.clipRect(paintBounds.shift(offset));
......@@ -1031,6 +1030,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
_debugReportException('paint', e, stack);
}
assert(() {
debugPaint(context, offset);
if (debugPaintBoundsEnabled)
context.canvas.restore();
_debugActivePaint = debugLastActivePaint;
......@@ -1082,8 +1082,7 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
// EVENTS
/// Override this function to handle events that hit this render object
void handleEvent(InputEvent event, HitTestEntry entry) {
}
void handleEvent(InputEvent event, HitTestEntry entry) { }
// HIT TESTING
......
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