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

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

Issue 12317107: ceil/floor/truncate/round return integers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reupload due to error3 Created 7 years, 9 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/solar3d/web/solar.dart ('k') | samples/swarm/swarm_ui_lib/layout/GridLayout.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 swarmlib; 5 part of swarmlib;
6 6
7 // This file contains View framework classes. 7 // This file contains View framework classes.
8 // As it grows, it may need to be split into multiple files. 8 // As it grows, it may need to be split into multiple files.
9 9
10 /** A factory that creates a view from a data model. */ 10 /** A factory that creates a view from a data model. */
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } else { 662 } else {
663 return itemLength * (_data.length - 1) + Math.max(viewLength, itemLength); 663 return itemLength * (_data.length - 1) + Math.max(viewLength, itemLength);
664 } 664 }
665 } 665 }
666 666
667 int getOffset(int index) { 667 int getOffset(int index) {
668 return index * _itemLength; 668 return index * _itemLength;
669 } 669 }
670 670
671 int getPageLength(int viewLength) { 671 int getPageLength(int viewLength) {
672 final itemsPerPage = (viewLength / _itemLength).floor(); 672 final itemsPerPage = viewLength ~/ _itemLength;
673 return (Math.max(1, itemsPerPage) * _itemLength).toInt(); 673 return Math.max(1, itemsPerPage) * _itemLength;
674 } 674 }
675 675
676 int getPage(int index, int viewLength) { 676 int getPage(int index, int viewLength) {
677 return (getOffset(index) / getPageLength(viewLength)).floor().toInt(); 677 return getOffset(index) ~/ getPageLength(viewLength);
678 } 678 }
679 679
680 int getPageStartIndex(int page, int viewLength) { 680 int getPageStartIndex(int page, int viewLength) {
681 return (getPageLength(viewLength) / _itemLength).toInt() * page; 681 return getPageLength(viewLength) ~/ _itemLength * page;
682 } 682 }
683 683
684 int getSnapIndex(num offset, int viewLength) { 684 int getSnapIndex(num offset, int viewLength) {
685 int index = (-offset / _itemLength).round().toInt(); 685 int index = (-offset / _itemLength).round();
686 if (_paginate) { 686 if (_paginate) {
687 index = getPageStartIndex(getPage(index, viewLength), viewLength); 687 index = getPageStartIndex(getPage(index, viewLength), viewLength);
688 } 688 }
689 return GoogleMath.clamp(index, 0, _data.length - 1); 689 return GoogleMath.clamp(index, 0, _data.length - 1);
690 } 690 }
691 691
692 Interval computeVisibleInterval( 692 Interval computeVisibleInterval(
693 num offset, num viewLength, num bufferLength) { 693 num offset, num viewLength, num bufferLength) {
694 int targetIntervalStart = 694 int targetIntervalStart =
695 Math.max(0, (-offset - bufferLength) ~/ _itemLength); 695 Math.max(0, (-offset - bufferLength) ~/ _itemLength);
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 975
976 container = node.query('.dialog-body'); 976 container = node.query('.dialog-body');
977 container.nodes.add(_content.node); 977 container.nodes.add(_content.node);
978 978
979 return node; 979 return node;
980 } 980 }
981 981
982 /** Override to handle dialog done. */ 982 /** Override to handle dialog done. */
983 void onDone() { } 983 void onDone() { }
984 } 984 }
OLDNEW
« no previous file with comments | « samples/solar3d/web/solar.dart ('k') | samples/swarm/swarm_ui_lib/layout/GridLayout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698