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

Side by Side Diff: client/view/CompositeView.dart

Issue 9382027: Move client/{base, observable, layout, touch, util, view} to samples/ui_lib . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 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 | « client/util/utilslib.dart ('k') | client/view/ConveyorView.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 /**
6 * A View that is composed of child views.
7 */
8 class CompositeView extends View {
9
10 List<View> childViews;
11
12 // TODO(rnystrom): Allowing this to be public is gross. CompositeView should
13 // encapsulate its markup and provide accessors to do the limited amount of
14 // things that external users need to access this for.
15 Element container;
16
17 Scroller scroller;
18 Scrollbar _scrollbar;
19
20 final String _cssName;
21 final bool _scrollable;
22 final bool _vertical;
23 final bool _nestedContainer;
24 final bool _showScrollbar;
25
26 CompositeView(String this._cssName, [nestedContainer = false,
27 scrollable = false, vertical = false,
28 showScrollbar = false])
29 : super(),
30 _nestedContainer = nestedContainer,
31 _scrollable = scrollable,
32 _vertical = vertical,
33 _showScrollbar = showScrollbar,
34 childViews = new List<View>() {
35 }
36
37 Element render() {
38 Element node = new Element.html('<div class="$_cssName"></div>');
39
40 if (_nestedContainer) {
41 container = new Element.html('<div class="scroll-container"></div>');
42 node.nodes.add(container);
43 } else {
44 container = node;
45 }
46
47 if (_scrollable) {
48 scroller = new Scroller(container,
49 _vertical /* verticalScrollEnabled */,
50 !_vertical /* horizontalScrollEnabled */,
51 true /* momementumEnabled */);
52 if (_showScrollbar) {
53 _scrollbar = new Scrollbar(scroller);
54 }
55 }
56
57 for (View childView in childViews) {
58 container.nodes.add(childView.node);
59 }
60
61 return node;
62 }
63
64 void afterRender(Element node) {
65 if (_scrollbar !== null) {
66 _scrollbar.initialize();
67 }
68 }
69
70 View addChild(View view) {
71 childViews.add(view);
72 // TODO(rnystrom): Container shouldn't be null. Remove this check.
73 if (container !== null) {
74 container.nodes.add(view.node);
75 }
76 childViewAdded(view);
77 return view;
78 }
79
80 void removeChild(View view) {
81 childViews = childViews.filter(bool _(e) { return view != e; });
82 // TODO(rnystrom): Container shouldn't be null. Remove this check.
83 if (container !== null) {
84 view.node.remove();
85 }
86 }
87 }
OLDNEW
« no previous file with comments | « client/util/utilslib.dart ('k') | client/view/ConveyorView.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698