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(); |
} |