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
3 // found in the LICENSE file.
5 var TopMidBottomView = (function() {
8 // We inherit from View.
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. Either the top
14 * or the bottom bar may be null.
16 * +----------------------+
18 * +----------------------+
29 * +----------------------+
31 * +----------------------+
35 function TopMidBottomView(topView, midView, bottomView) {
36 superClass.call(this);
38 this.topView_ = topView;
39 this.midView_ = midView;
40 this.bottomView_ = bottomView;
43 TopMidBottomView.prototype = {
44 // Inherit the superclass's methods.
45 __proto__: superClass.prototype,
47 setGeometry: function(left, top, width, height) {
48 superClass.prototype.setGeometry.call(this, left, top, width, height);
50 // Calculate the vertical split points.
53 topbarHeight = this.topView_.getHeight();
54 var bottombarHeight = 0;
56 bottombarHeight = this.bottomView_.getHeight();
57 var middleboxHeight = height - (topbarHeight + bottombarHeight);
58 if (middleboxHeight < 0)
61 // Position the boxes using calculated split points.
63 this.topView_.setGeometry(left, top, width, topbarHeight);
64 this.midView_.setGeometry(left, top + topbarHeight, width,
66 if (this.bottomView_) {
67 this.bottomView_.setGeometry(left, top + topbarHeight + middleboxHeight,
68 width, bottombarHeight);
72 show: function(isVisible) {
73 superClass.prototype.show.call(this, isVisible);
75 this.topView_.show(isVisible);
76 this.midView_.show(isVisible);
78 this.bottomView_.show(isVisible);
82 return TopMidBottomView;