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

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

Issue 1173233002: Separate out the raw (directly manipulating sky.view) examples from the rendering (using RenderObje… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « sky/examples/raw/shadowed_box.dart ('k') | sky/examples/raw/transform.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/raw/touch_demo.dart
diff --git a/sky/examples/raw/touch_demo.dart b/sky/examples/raw/touch_demo.dart
deleted file mode 100644
index 3f23c95fa29a43fe7363f4f05c4a61df4e8dc59c..0000000000000000000000000000000000000000
--- a/sky/examples/raw/touch_demo.dart
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'dart:math';
-import 'dart:sky';
-import 'package:sky/framework/app.dart';
-import 'package:sky/framework/rendering/box.dart';
-import 'package:sky/framework/rendering/object.dart';
-
-// Material design colors. :p
-List<int> colors = [
- 0xFF009688,
- 0xFFFFC107,
- 0xFF9C27B0,
- 0xFF03A9F4,
- 0xFF673AB7,
- 0xFFCDDC39,
-];
-
-class Dot {
- final Paint _paint;
- double x = 0.0;
- double y = 0.0;
- double radius = 0.0;
-
- Dot({int color}) : _paint = new Paint()..color = color;
-
- void update(PointerEvent event) {
- x = event.x;
- y = event.y;
- radius = 5 + (95 * event.pressure);
- }
-
- void paint(RenderObjectDisplayList canvas) {
- canvas.drawCircle(x, y, radius, _paint);
- }
-}
-
-class RenderTouchDemo extends RenderBox {
- Map<int, Dot> dots = new Map();
-
- RenderTouchDemo();
-
- void handleEvent(Event event, BoxHitTestEntry entry) {
- switch (event.type) {
- case 'pointerdown':
- int color = colors[event.pointer.remainder(colors.length)];
- dots[event.pointer] = new Dot(color: color)..update(event);
- break;
- case 'pointerup':
- dots.remove(event.pointer);
- break;
- case 'pointercancel':
- dots = new Map();
- break;
- case 'pointermove':
- dots[event.pointer].update(event);
- break;
- }
- markNeedsPaint();
- }
-
- void performLayout() {
- size = constraints.constrain(Size.infinite);
- }
-
- void paint(RenderObjectDisplayList canvas) {
- dots.forEach((_, Dot dot) {
- dot.paint(canvas);
- });
- }
-}
-
-AppView app;
-
-void main() {
- app = new AppView(new RenderTouchDemo());
-}
« no previous file with comments | « sky/examples/raw/shadowed_box.dart ('k') | sky/examples/raw/transform.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698