OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var TopMidBottomView = (function() { | 5 var TopMidBottomView = (function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 // We inherit from View. | 8 // We inherit from View. |
9 var superClass = View; | 9 var superClass = View; |
10 | 10 |
11 /** | 11 /** |
12 * This view stacks three boxes -- one at the top, one at the bottom, and | 12 * This view stacks three boxes -- one at the top, one at the bottom, and |
13 * one that fills the remaining space between those two. | 13 * one that fills the remaining space between those two. Either the top |
14 * or the bottom bar may be null. | |
14 * | 15 * |
15 * +----------------------+ | 16 * +----------------------+ |
16 * | topbar | | 17 * | topbar | |
17 * +----------------------+ | 18 * +----------------------+ |
18 * | | | 19 * | | |
19 * | | | 20 * | | |
20 * | | | 21 * | | |
21 * | | | 22 * | | |
22 * | middlebox | | 23 * | middlebox | |
23 * | | | 24 * | | |
(...skipping 16 matching lines...) Expand all Loading... | |
40 } | 41 } |
41 | 42 |
42 TopMidBottomView.prototype = { | 43 TopMidBottomView.prototype = { |
43 // Inherit the superclass's methods. | 44 // Inherit the superclass's methods. |
44 __proto__: superClass.prototype, | 45 __proto__: superClass.prototype, |
45 | 46 |
46 setGeometry: function(left, top, width, height) { | 47 setGeometry: function(left, top, width, height) { |
47 superClass.prototype.setGeometry.call(this, left, top, width, height); | 48 superClass.prototype.setGeometry.call(this, left, top, width, height); |
48 | 49 |
49 // Calculate the vertical split points. | 50 // Calculate the vertical split points. |
50 var topbarHeight = this.topView_.getHeight(); | 51 var topbarHeight = 0; |
eroman
2011/11/16 04:03:46
so the idea here is to make the subviews optional?
mmenke
2011/11/16 18:39:35
Yea. I'm actually thinking we may want to allow m
| |
51 var bottombarHeight = this.bottomView_.getHeight(); | 52 if (this.topView_) |
53 topbarHeight = this.topView_.getHeight(); | |
54 var bottombarHeight = 0; | |
55 if (this.bottomView_) | |
56 bottombarHeight = this.bottomView_.getHeight(); | |
52 var middleboxHeight = height - (topbarHeight + bottombarHeight); | 57 var middleboxHeight = height - (topbarHeight + bottombarHeight); |
58 if (middleboxHeight < 0) middleboxHeight = 0; | |
53 | 59 |
54 // Position the boxes using calculated split points. | 60 // Position the boxes using calculated split points. |
55 this.topView_.setGeometry(left, top, width, topbarHeight); | 61 if (this.topView_) |
56 this.midView_.setGeometry(left, this.topView_.getBottom(), | 62 this.topView_.setGeometry(left, top, width, topbarHeight); |
57 width, middleboxHeight); | 63 this.midView_.setGeometry(left, top + topbarHeight, width, |
58 this.bottomView_.setGeometry(left, this.midView_.getBottom(), | 64 middleboxHeight); |
59 width, bottombarHeight); | 65 if (this.bottomView_) { |
66 this.bottomView_.setGeometry(left, top + topbarHeight + middleboxHeight, | |
67 width, bottombarHeight); | |
68 } | |
60 }, | 69 }, |
61 | 70 |
62 show: function(isVisible) { | 71 show: function(isVisible) { |
63 superClass.prototype.show.call(this, isVisible); | 72 superClass.prototype.show.call(this, isVisible); |
64 this.topView_.show(isVisible); | 73 if (this.topView_) |
74 this.topView_.show(isVisible); | |
65 this.midView_.show(isVisible); | 75 this.midView_.show(isVisible); |
66 this.bottomView_.show(isVisible); | 76 if (this.bottomView_) |
77 this.bottomView_.show(isVisible); | |
67 } | 78 } |
68 }; | 79 }; |
69 | 80 |
70 return TopMidBottomView; | 81 return TopMidBottomView; |
71 })(); | 82 })(); |
OLD | NEW |