1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* This view stacks three boxes -- one at the top, one at the bottom, and
* one that fills the remaining space between those two.
*
* +----------------------+
* | topbar |
* +----------------------+
* | |
* | |
* | |
* | |
* | middlebox |
* | |
* | |
* | |
* | |
* | |
* +----------------------+
* | bottombar |
* +----------------------+
*
* @constructor
*/
function TopMidBottomView(topView, midView, bottomView) {
View.call(this);
this.topView_ = topView;
this.midView_ = midView;
this.bottomView_ = bottomView;
}
inherits(TopMidBottomView, View);
TopMidBottomView.prototype.setGeometry = function(left, top, width, height) {
TopMidBottomView.superClass_.setGeometry.call(this, left, top, width, height);
// Calculate the vertical split points.
var topbarHeight = this.topView_.getHeight();
var bottombarHeight = this.bottomView_.getHeight();
var middleboxHeight = height - (topbarHeight + bottombarHeight);
// Position the boxes using calculated split points.
this.topView_.setGeometry(left, top, width, topbarHeight);
this.midView_.setGeometry(left, this.topView_.getBottom(),
width, middleboxHeight);
this.bottomView_.setGeometry(left, this.midView_.getBottom(),
width, bottombarHeight);
};
TopMidBottomView.prototype.show = function(isVisible) {
TopMidBottomView.superClass_.show.call(this, isVisible);
this.topView_.show(isVisible);
this.midView_.show(isVisible);
this.bottomView_.show(isVisible);
};
|