Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Unified Diff: sky/examples/raw/simple_render_tree.dart

Issue 1153543002: Make hit testing work in layout2.dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Add missing file Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/examples/raw/simple_render_tree.dart
diff --git a/sky/examples/raw/simple_render_tree.dart b/sky/examples/raw/simple_render_tree.dart
index 13df0b893a6082398962f0efe87bc62154f18e0b..2e686600a018b0c81dca2aec35cc7541cfb9f209 100644
--- a/sky/examples/raw/simple_render_tree.dart
+++ b/sky/examples/raw/simple_render_tree.dart
@@ -7,8 +7,11 @@ import 'dart:sky';
import 'package:sky/framework/layout2.dart';
class SimpleBlock extends RenderDecoratedBox {
+ final int backgroundColor;
+
SimpleBlock(int backgroundColor)
- : super(new BoxDecoration(backgroundColor: backgroundColor));
+ : super(new BoxDecoration(backgroundColor: backgroundColor)),
+ backgroundColor = backgroundColor;
BoxDimensions getIntrinsicDimensions(BoxConstraints constraints) {
return new BoxDimensions.withConstraints(constraints, height: 200.0);
@@ -19,16 +22,47 @@ class SimpleBlock extends RenderDecoratedBox {
setHeight(constraints, 200.0);
layoutDone();
}
+
+ bool handlePointer(PointerEvent event, { double x: 0.0, double y: 0.0 }) {
+ if (event.type == 'pointerdown') {
+ setBoxDecoration(new BoxDecoration(backgroundColor: 0xFFFF0000));
+ return true;
+ }
+
+ if (event.type == 'pointerup') {
+ setBoxDecoration(new BoxDecoration(backgroundColor: backgroundColor));
+ return true;
+ }
+
+ return false;
Hixie 2015/05/21 19:31:42 This is a rectangle with no holes, so it should al
+ }
+}
+
+RenderView renderView;
+
+void beginFrame(double timeStamp) {
+ RenderNode.flushLayout();
+
+ renderView.paintFrame();
+}
+
+bool handleEvent(Event event) {
+ if (event is! PointerEvent)
+ return false;
+ return renderView.handlePointer(event, x: event.x, y: event.y);
}
void main() {
+ view.setEventCallback(handleEvent);
+ view.setBeginFrameCallback(beginFrame);
+
var root = new RenderBlock(
decoration: new BoxDecoration(backgroundColor: 0xFF00FFFF));
-
root.add(new SimpleBlock(0xFF00FF00));
root.add(new SimpleBlock(0xFF0000FF));
- RenderView renderView = new RenderView(root: root);
+ renderView = new RenderView(root: root);
renderView.layout(newWidth: view.width, newHeight: view.height);
- renderView.paintFrame();
+
+ view.scheduleFrame();
}

Powered by Google App Engine
This is Rietveld 408576698