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; |
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) |
| 59 middleboxHeight = 0; |
53 | 60 |
54 // Position the boxes using calculated split points. | 61 // Position the boxes using calculated split points. |
55 this.topView_.setGeometry(left, top, width, topbarHeight); | 62 if (this.topView_) |
56 this.midView_.setGeometry(left, this.topView_.getBottom(), | 63 this.topView_.setGeometry(left, top, width, topbarHeight); |
57 width, middleboxHeight); | 64 this.midView_.setGeometry(left, top + topbarHeight, width, |
58 this.bottomView_.setGeometry(left, this.midView_.getBottom(), | 65 middleboxHeight); |
59 width, bottombarHeight); | 66 if (this.bottomView_) { |
| 67 this.bottomView_.setGeometry(left, top + topbarHeight + middleboxHeight, |
| 68 width, bottombarHeight); |
| 69 } |
60 }, | 70 }, |
61 | 71 |
62 show: function(isVisible) { | 72 show: function(isVisible) { |
63 superClass.prototype.show.call(this, isVisible); | 73 superClass.prototype.show.call(this, isVisible); |
64 this.topView_.show(isVisible); | 74 if (this.topView_) |
| 75 this.topView_.show(isVisible); |
65 this.midView_.show(isVisible); | 76 this.midView_.show(isVisible); |
66 this.bottomView_.show(isVisible); | 77 if (this.bottomView_) |
| 78 this.bottomView_.show(isVisible); |
67 } | 79 } |
68 }; | 80 }; |
69 | 81 |
70 return TopMidBottomView; | 82 return TopMidBottomView; |
71 })(); | 83 })(); |
OLD | NEW |