15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2011 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)var TopMidBottomView = (function() { 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 'use strict'; 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // We inherit from View. 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) var superClass = View; 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * This view stacks three boxes -- one at the top, one at the bottom, and 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * one that fills the remaining space between those two. Either the top 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * or the bottom bar may be null. 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * +----------------------+ 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | topbar | 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * +----------------------+ 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | middlebox | 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | | 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * +----------------------+ 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * | bottombar | 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * +----------------------+ 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @constructor 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) function TopMidBottomView(topView, midView, bottomView) { 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) superClass.call(this); 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.topView_ = topView; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.midView_ = midView; 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.bottomView_ = bottomView; 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TopMidBottomView.prototype = { 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Inherit the superclass's methods. 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) __proto__: superClass.prototype, 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) setGeometry: function(left, top, width, height) { 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) superClass.prototype.setGeometry.call(this, left, top, width, height); 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Calculate the vertical split points. 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) var topbarHeight = 0; 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (this.topView_) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) topbarHeight = this.topView_.getHeight(); 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) var bottombarHeight = 0; 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (this.bottomView_) 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bottombarHeight = this.bottomView_.getHeight(); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) var middleboxHeight = height - (topbarHeight + bottombarHeight); 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (middleboxHeight < 0) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) middleboxHeight = 0; 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Position the boxes using calculated split points. 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (this.topView_) 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.topView_.setGeometry(left, top, width, topbarHeight); 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.midView_.setGeometry(left, top + topbarHeight, width, 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) middleboxHeight); 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (this.bottomView_) { 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.bottomView_.setGeometry(left, top + topbarHeight + middleboxHeight, 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) width, bottombarHeight); 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }, 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) show: function(isVisible) { 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) superClass.prototype.show.call(this, isVisible); 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (this.topView_) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.topView_.show(isVisible); 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.midView_.show(isVisible); 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (this.bottomView_) 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) this.bottomView_.show(isVisible); 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) }; 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return TopMidBottomView; 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)})(); 84