OLD | NEW |
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 225 } |
226 | 226 |
227 // Now, go through and round each position to an integer. Then | 227 // Now, go through and round each position to an integer. Then |
228 // compute the sizes based on those integers. | 228 // compute the sizes based on those integers. |
229 num finalPosition = position; | 229 num finalPosition = position; |
230 | 230 |
231 for (int i = 0; i < tracks.length; i++) { | 231 for (int i = 0; i < tracks.length; i++) { |
232 int startEdge = tracks[i].start; | 232 int startEdge = tracks[i].start; |
233 int endEdge; | 233 int endEdge; |
234 if (i < tracks.length - 1) { | 234 if (i < tracks.length - 1) { |
235 endEdge = tracks[i + 1].start.round().toInt(); | 235 endEdge = tracks[i + 1].start.round(); |
236 tracks[i + 1].start = endEdge; | 236 tracks[i + 1].start = endEdge; |
237 } else { | 237 } else { |
238 endEdge = finalPosition.round().toInt(); | 238 endEdge = finalPosition.round(); |
239 } | 239 } |
240 int breadth = endEdge - startEdge; | 240 int breadth = endEdge - startEdge; |
241 | 241 |
242 // check that we're not off by >= 1px. | 242 // check that we're not off by >= 1px. |
243 assert((endEdge - startEdge - tracks[i].usedBreadth).abs() < 1); | 243 assert((endEdge - startEdge - tracks[i].usedBreadth).abs() < 1); |
244 | 244 |
245 tracks[i].usedBreadth = breadth; | 245 tracks[i].usedBreadth = breadth; |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |