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

Side by Side Diff: client/samples/swarm/Views.dart

Issue 8363040: Implement measurement using futures (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to all comments 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 // This file contains View framework classes. 5 // This file contains View framework classes.
6 // As it grows, it may need to be split into multiple files. 6 // As it grows, it may need to be split into multiple files.
7 7
8 /** A factory that creates a view from a data model. */ 8 /** A factory that creates a view from a data model. */
9 interface ViewFactory<D> { 9 interface ViewFactory<D> {
10 View newView(D item); 10 View newView(D item);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 scroller = new Scroller( 213 scroller = new Scroller(
214 _containerElem, 214 _containerElem,
215 _vertical /* verticalScrollEnabled */, 215 _vertical /* verticalScrollEnabled */,
216 !_vertical /* horizontalScrollEnabled */, 216 !_vertical /* horizontalScrollEnabled */,
217 true /* momentumEnabled */, 217 true /* momentumEnabled */,
218 () { 218 () {
219 num width = _layout.getWidth(_viewLength); 219 num width = _layout.getWidth(_viewLength);
220 num height = _layout.getHeight(_viewLength); 220 num height = _layout.getHeight(_viewLength);
221 width = width != null ? width : 0; 221 width = width != null ? width : 0;
222 height = height != null ? height : 0; 222 height = height != null ? height : 0;
223 return new Size(width, height); 223 final completer = new Completer<Size>();
224 completer.complete(new Size(width, height));
225 return completer.future;
224 }, 226 },
225 _paginate && _snapToItems ? 227 _paginate && _snapToItems ?
226 Scroller.FAST_SNAP_DECELERATION_FACTOR : 1); 228 Scroller.FAST_SNAP_DECELERATION_FACTOR : 1);
227 scroller.onContentMoved.add((e) => renderVisibleItems(false)); 229 scroller.onContentMoved.add((e) => renderVisibleItems(false));
228 if (_pages != null) { 230 if (_pages != null) {
229 watch(_pages.target, (s) => _onPageSelected()); 231 watch(_pages.target, (s) => _onPageSelected());
230 } 232 }
231 233
232 if (_snapToItems) { 234 if (_snapToItems) {
233 scroller.onDecelStart.add((e) => _decelStart()); 235 scroller.onDecelStart.add((e) => _decelStart());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 style.height = '${height}px'; 282 style.height = '${height}px';
281 } 283 }
282 // TODO(jacobr): this should be specified by the default CSS for a 284 // TODO(jacobr): this should be specified by the default CSS for a
283 // GenericListView. 285 // GenericListView.
284 style.overflow = 'hidden'; 286 style.overflow = 'hidden';
285 } 287 }
286 288
287 289
288 void onResize() { 290 void onResize() {
289 int lastViewLength = _viewLength; 291 int lastViewLength = _viewLength;
290 calculateViewLength(); 292 node.rect.then((ElementRect rect) {
291 if (_viewLength != lastViewLength) { 293 if (_vertical) {
nweiz 2011/10/28 03:58:38 I feel like ?: would read much better here.
Jacob 2011/10/31 22:09:50 Done.
292 if (_scrollbar != null) { 294 _viewLength = rect.offset.height;
293 _scrollbar.refresh(); 295 } else {
296 _viewLength = rect.offset.width;
294 } 297 }
295 renderVisibleItems(true); 298 if (_viewLength != lastViewLength) {
296 } 299 if (_scrollbar != null) {
297 } 300 _scrollbar.refresh();
298 301 }
299 void calculateViewLength() { 302 renderVisibleItems(true);
300 if (_vertical) { 303 }
301 _viewLength = node.offsetHeight; 304 });
302 } else {
303 _viewLength = node.offsetWidth;
304 }
305 } 305 }
306 306
307 void enterDocument() { 307 void enterDocument() {
308 if (scroller != null) { 308 if (scroller != null) {
309 onResize(); 309 onResize();
310 310
311 if (_scrollbar != null) { 311 if (_scrollbar != null) {
312 _scrollbar.initialize(); 312 _scrollbar.initialize();
313 } 313 }
314 } 314 }
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 980
981 container = node.query('.dialog-body'); 981 container = node.query('.dialog-body');
982 container.nodes.add(_content.node); 982 container.nodes.add(_content.node);
983 983
984 return node; 984 return node;
985 } 985 }
986 986
987 /** Override to handle dialog done. */ 987 /** Override to handle dialog done. */
988 void onDone() { } 988 void onDone() { }
989 } 989 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698