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

Side by Side Diff: samples/swarm/swarm_ui_lib/layout/GridLayout.dart

Issue 12090093: Reapply "Rename mappedBy to map." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed bug in previous commit. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/swarm/DataSource.dart ('k') | samples/swarm/swarm_ui_lib/observable/observable.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of layout; 5 part of layout;
6 6
7 /** 7 /**
8 * Implements a grid-based layout system based on: 8 * Implements a grid-based layout system based on:
9 * [http://dev.w3.org/csswg/css3-grid-align/] 9 * [http://dev.w3.org/csswg/css3-grid-align/]
10 * 10 *
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 * 1. That each Grid Track satisfies its minSizing 148 * 1. That each Grid Track satisfies its minSizing
149 * 2. That each Grid Track grows from the breadth which satisfied its 149 * 2. That each Grid Track grows from the breadth which satisfied its
150 * minSizing to a breadth which satifies its 150 * minSizing to a breadth which satifies its
151 * maxSizing, subject to RemainingSpace. 151 * maxSizing, subject to RemainingSpace.
152 */ 152 */
153 // Note: spec does not correctly doc all the parameters to this function. 153 // Note: spec does not correctly doc all the parameters to this function.
154 void _computeUsedBreadthOfTracks(List<GridTrack> tracks) { 154 void _computeUsedBreadthOfTracks(List<GridTrack> tracks) {
155 155
156 // TODO(jmesserly): as a performance optimization we could cache this 156 // TODO(jmesserly): as a performance optimization we could cache this
157 final items = view.childViews 157 final items = view.childViews
158 .mappedBy((view_) => view_.layout) 158 .map((view_) => view_.layout)
159 .toList(); 159 .toList();
160 CollectionUtils.sortBy(items, (item) => _getSpanCount(item)); 160 CollectionUtils.sortBy(items, (item) => _getSpanCount(item));
161 161
162 // 1. Initialize per Grid Track variables 162 // 1. Initialize per Grid Track variables
163 for (final t in tracks) { 163 for (final t in tracks) {
164 // percentage or length sizing functions will return a value 164 // percentage or length sizing functions will return a value
165 // min-content, max-content, or a fraction will be set to 0 165 // min-content, max-content, or a fraction will be set to 0
166 t.usedBreadth = t.minSizing.resolveLength(_getGridContentSize()); 166 t.usedBreadth = t.minSizing.resolveLength(_getGridContentSize());
167 t.maxBreadth = t.maxSizing.resolveLength(_getGridContentSize()); 167 t.maxBreadth = t.maxSizing.resolveLength(_getGridContentSize());
168 t.updatedBreadth = 0; 168 t.updatedBreadth = 0;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 415 }
416 416
417 /** 417 /**
418 * Scans children creating GridLayoutParams as needed, and creates all of the 418 * Scans children creating GridLayoutParams as needed, and creates all of the
419 * rows and columns that we will need. 419 * rows and columns that we will need.
420 * 420 *
421 * Note: this can potentially create new rows/columns, so this needs to be 421 * Note: this can potentially create new rows/columns, so this needs to be
422 * run before the track sizing algorithm. 422 * run before the track sizing algorithm.
423 */ 423 */
424 void _ensureAllTracks() { 424 void _ensureAllTracks() {
425 final items = view.childViews.mappedBy((view_) => view_.layout); 425 final items = view.childViews.map((view_) => view_.layout);
426 426
427 for (final child in items) { 427 for (final child in items) {
428 if (child.layoutParams == null) { 428 if (child.layoutParams == null) {
429 final p = new GridLayoutParams(child.view, this); 429 final p = new GridLayoutParams(child.view, this);
430 _ensureTrack(_rowTracks, rowSizing, p.row, p.rowSpan); 430 _ensureTrack(_rowTracks, rowSizing, p.row, p.rowSpan);
431 _ensureTrack(_columnTracks, columnSizing, p.column, p.columnSpan); 431 _ensureTrack(_columnTracks, columnSizing, p.column, p.columnSpan);
432 child.layoutParams = p; 432 child.layoutParams = p;
433 } 433 }
434 child.cacheExistingBrowserLayout(); 434 child.cacheExistingBrowserLayout();
435 } 435 }
436 } 436 }
437 437
438 /** 438 /**
439 * Given the track sizes that were computed, position children in the grid. 439 * Given the track sizes that were computed, position children in the grid.
440 */ 440 */
441 void _setBoundsOfChildren() { 441 void _setBoundsOfChildren() {
442 final items = view.childViews.mappedBy((view_) => view_.layout); 442 final items = view.childViews.map((view_) => view_.layout);
443 443
444 for (final item in items) { 444 for (final item in items) {
445 GridLayoutParams childLayout = item.layoutParams; 445 GridLayoutParams childLayout = item.layoutParams;
446 var xPos = _getTrackLocationX(childLayout); 446 var xPos = _getTrackLocationX(childLayout);
447 var yPos = _getTrackLocationY(childLayout); 447 var yPos = _getTrackLocationY(childLayout);
448 448
449 int left = xPos.start, width = xPos.length; 449 int left = xPos.start, width = xPos.length;
450 int top = yPos.start, height = yPos.length; 450 int top = yPos.start, height = yPos.length;
451 451
452 // Somewhat counterintuitively (at least to me): 452 // Somewhat counterintuitively (at least to me):
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 512 }
513 return result; 513 return result;
514 } 514 }
515 515
516 int _getSpanCount(ViewLayout item) { 516 int _getSpanCount(ViewLayout item) {
517 GridLayoutParams childLayout = item.layoutParams; 517 GridLayoutParams childLayout = item.layoutParams;
518 return (_dimension == Dimension.WIDTH ? 518 return (_dimension == Dimension.WIDTH ?
519 childLayout.columnSpan : childLayout.rowSpan); 519 childLayout.columnSpan : childLayout.rowSpan);
520 } 520 }
521 } 521 }
OLDNEW
« no previous file with comments | « samples/swarm/DataSource.dart ('k') | samples/swarm/swarm_ui_lib/observable/observable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698