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

Side by Side Diff: client/samples/dartcombat/views.dart

Issue 8467034: Isolates in frog - tweaks in existing js code to make things run (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** Base class for all views. */ 5 /** Base class for all views. */
6 class View { 6 class View {
7 Document doc; 7 Document doc;
8 View(this.doc) {} 8 View(this.doc) {}
9 } 9 }
10 10
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 /** Utility methods used by the views above. */ 276 /** Utility methods used by the views above. */
277 class ViewUtil { 277 class ViewUtil {
278 278
279 /** Extract the position of a mouse event in a containing 500x500 grid. */ 279 /** Extract the position of a mouse event in a containing 500x500 grid. */
280 static Future<List<int>> positionFromEvent(Element gridNode, MouseEvent e) { 280 static Future<List<int>> positionFromEvent(Element gridNode, MouseEvent e) {
281 final completer = new Completer<List<int>>(); 281 final completer = new Completer<List<int>>();
282 gridNode.rect.then((ElementRect rect) { 282 gridNode.rect.then((ElementRect rect) {
283 int x = (e.pageX - rect.offset.left) ~/ 50; 283 int x = (e.pageX - rect.offset.left) ~/ 50;
284 int y = (e.pageY - rect.offset.top) ~/ 50; 284 int y = (e.pageY - rect.offset.top) ~/ 50;
285 completer.complete(const [x, y]); 285 completer.complete([x, y]);
jimhug 2011/11/08 15:39:01 Why did you lose the const here?
Siggi Cherem (dart-lang) 2011/11/08 17:56:42 Basically x, y are variables, which are not allowe
286 }); 286 });
287 return completer.future; 287 return completer.future;
288 } 288 }
289 289
290 /** Given a grid node (square or boat) place it at a grid coordinate. */ 290 /** Given a grid node (square or boat) place it at a grid coordinate. */
291 static void placeNodeAt(Element node, int x, int y) { 291 static void placeNodeAt(Element node, int x, int y) {
292 int xoffset = x * 50; 292 int xoffset = x * 50;
293 int yoffset = y * 50; 293 int yoffset = y * 50;
294 node.style.setProperty("top", yoffset.toString() + "px"); 294 node.style.setProperty("top", yoffset.toString() + "px");
295 node.style.setProperty("left", xoffset.toString() + "px"); 295 node.style.setProperty("left", xoffset.toString() + "px");
296 } 296 }
297 297
298 /** Create a div node with a given class name. */ 298 /** Create a div node with a given class name. */
299 static Element createDiv(View view, String className) { 299 static Element createDiv(View view, String className) {
300 Element node = view.doc.createElement("div"); 300 Element node = view.doc.createElement("div");
301 node.attributes["class"] = className; 301 node.attributes["class"] = className;
302 return node; 302 return node;
303 } 303 }
304 } 304 }
OLDNEW
« no previous file with comments | « client/samples/dartcombat/grids.dart ('k') | frog/frogsh » ('j') | frog/frogsh » ('J')

Powered by Google App Engine
This is Rietveld 408576698