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

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

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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/UIState.dart ('k') | samples/swarm/swarm_ui_lib/base/AnimationScheduler.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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 void onSelectedItemChange() { 165 void onSelectedItemChange() {
166 // TODO(rnystrom): use Observable to track the last value of _selectedItem 166 // TODO(rnystrom): use Observable to track the last value of _selectedItem
167 // rather than tracking it ourselves. 167 // rather than tracking it ourselves.
168 _select(findIndex(_lastSelectedItem), false); 168 _select(findIndex(_lastSelectedItem), false);
169 _select(findIndex(_selectedItem.value), true); 169 _select(findIndex(_selectedItem.value), true);
170 _lastSelectedItem = _selectedItem.value; 170 _lastSelectedItem = _selectedItem.value;
171 } 171 }
172 172
173 Collection<View> get childViews { 173 Collection<View> get childViews {
174 return _itemViews.values; 174 return _itemViews.values.toList();
175 } 175 }
176 176
177 void _onClick(MouseEvent e) { 177 void _onClick(MouseEvent e) {
178 int index = _findAssociatedIndex(e.target); 178 int index = _findAssociatedIndex(e.target);
179 if (index != null) { 179 if (index != null) {
180 _selectedItem.value = _data[index]; 180 _selectedItem.value = _data[index];
181 } 181 }
182 } 182 }
183 183
184 int _findAssociatedIndex(Node leafNode) { 184 int _findAssociatedIndex(Node leafNode) {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
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().toInt();
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 num targetIntervalStart = 694 int targetIntervalStart =
695 Math.max(0,((-offset - bufferLength) / _itemLength).floor()); 695 Math.max(0, (-offset - bufferLength) ~/ _itemLength);
696 num targetIntervalEnd = GoogleMath.clamp( 696 num targetIntervalEnd = GoogleMath.clamp(
697 ((-offset + viewLength + bufferLength) / _itemLength).ceil(), 697 ((-offset + viewLength + bufferLength) / _itemLength).ceil(),
698 targetIntervalStart, 698 targetIntervalStart,
699 _data.length); 699 _data.length);
700 return new Interval(targetIntervalStart.toInt(), 700 return new Interval(targetIntervalStart, targetIntervalEnd.toInt());
701 targetIntervalEnd.toInt());
702 } 701 }
703 } 702 }
704 703
705 /** 704 /**
706 * Simple list view class where each item has fixed width and height. 705 * Simple list view class where each item has fixed width and height.
707 */ 706 */
708 class ListView<D> extends GenericListView<D> { 707 class ListView<D> extends GenericListView<D> {
709 708
710 /** 709 /**
711 * Creates a new ListView for the given data. If [:_data:] is an 710 * Creates a new ListView for the given data. If [:_data:] is an
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 975
977 container = node.query('.dialog-body'); 976 container = node.query('.dialog-body');
978 container.nodes.add(_content.node); 977 container.nodes.add(_content.node);
979 978
980 return node; 979 return node;
981 } 980 }
982 981
983 /** Override to handle dialog done. */ 982 /** Override to handle dialog done. */
984 void onDone() { } 983 void onDone() { }
985 } 984 }
OLDNEW
« no previous file with comments | « samples/swarm/UIState.dart ('k') | samples/swarm/swarm_ui_lib/base/AnimationScheduler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698