mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Make RenderBlock painting match its hittesting
I added a clip in RenderBlock to make the painted pixels match the hittesting logic. This at least makes obvious all the numerous hittesting bugs in our system. :) I also moved demo_launcher to ScrollableList awesomeness. R=abarth@chromium.org, abarth@google.com Review URL: https://codereview.chromium.org/1223083002 .
This commit is contained in:
parent
427f162519
commit
2e8e2d0b72
@ -19,6 +19,7 @@ import 'package:sky/widgets/scaffold.dart';
|
||||
import 'package:sky/widgets/task_description.dart';
|
||||
import 'package:sky/widgets/theme.dart';
|
||||
import 'package:sky/widgets/tool_bar.dart';
|
||||
import 'package:sky/widgets/scrollable_list.dart';
|
||||
|
||||
AssetBundle _initBundle() {
|
||||
if (rootBundle != null)
|
||||
@ -132,11 +133,7 @@ List<Widget> demos = [
|
||||
const double kCardHeight = 120.0;
|
||||
const EdgeDims kListPadding = const EdgeDims.all(4.0);
|
||||
|
||||
class DemoList extends FixedHeightScrollable {
|
||||
DemoList({ String key }) : super(key: key, itemHeight: kCardHeight, padding: kListPadding);
|
||||
|
||||
int get itemCount => demos.length;
|
||||
|
||||
class DemoList extends Component {
|
||||
Widget buildDemo(SkyDemo demo) {
|
||||
return new Listener(
|
||||
key: demo.name,
|
||||
@ -166,12 +163,13 @@ class DemoList extends FixedHeightScrollable {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> buildItems(int start, int count) {
|
||||
return demos
|
||||
.skip(start)
|
||||
.take(count)
|
||||
.map(buildDemo)
|
||||
.toList(growable: false);
|
||||
Widget build() {
|
||||
return new ScrollableList<SkyDemo>(
|
||||
items: demos,
|
||||
itemHeight: kCardHeight,
|
||||
itemBuilder: buildDemo,
|
||||
padding: kListPadding
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,8 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
|
||||
// uses the maximum width provided by the parent
|
||||
// sizes itself to the height of its child stack
|
||||
|
||||
bool _hasVisualOverflow = false;
|
||||
|
||||
RenderBlock({
|
||||
List<RenderBox> children
|
||||
}) {
|
||||
@ -94,7 +96,12 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
|
||||
y += child.size.height;
|
||||
child = child.parentData.nextSibling;
|
||||
}
|
||||
// FIXME(eseidel): Block lays out its children with unconstrained height
|
||||
// yet itself remains constrained. Remember that our children wanted to
|
||||
// be taller than we are so we know to clip them (and not cause confusing
|
||||
// mismatch of painting vs. hittesting).
|
||||
size = new Size(width, constraints.constrainHeight(y));
|
||||
_hasVisualOverflow = y > size.height;
|
||||
assert(!size.isInfinite);
|
||||
}
|
||||
|
||||
@ -103,7 +110,14 @@ class RenderBlock extends RenderBox with ContainerRenderObjectMixin<RenderBox, B
|
||||
}
|
||||
|
||||
void paint(PaintingCanvas canvas, Offset offset) {
|
||||
if (_hasVisualOverflow) {
|
||||
canvas.save();
|
||||
canvas.clipRect(offset & size);
|
||||
}
|
||||
defaultPaint(canvas, offset);
|
||||
if (_hasVisualOverflow) {
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user