| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * | 10 * |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @constructor | 30 * @constructor |
| 31 * @extends {WebInspector.View} | 31 * @extends {WebInspector.View} |
| 32 * @param {boolean} isVertical | 32 * @param {boolean} isVertical |
| 33 * @param {boolean} secondIsSidebar | 33 * @param {boolean} secondIsSidebar |
| 34 * @param {string=} settingName | 34 * @param {string=} settingName |
| 35 * @param {number=} defaultSidebarWidth | 35 * @param {number=} defaultSidebarWidth |
| 36 * @param {number=} defaultSidebarHeight | 36 * @param {number=} defaultSidebarHeight |
| 37 * @param {boolean=} constraintsInDip |
| 37 */ | 38 */ |
| 38 WebInspector.SplitView = function(isVertical, secondIsSidebar, settingName, defa
ultSidebarWidth, defaultSidebarHeight) | 39 WebInspector.SplitView = function(isVertical, secondIsSidebar, settingName, defa
ultSidebarWidth, defaultSidebarHeight, constraintsInDip) |
| 39 { | 40 { |
| 40 WebInspector.View.call(this); | 41 WebInspector.View.call(this); |
| 41 | 42 |
| 42 this.registerRequiredCSS("splitView.css"); | 43 this.registerRequiredCSS("splitView.css"); |
| 43 this.element.classList.add("split-view"); | 44 this.element.classList.add("split-view"); |
| 44 | 45 |
| 45 this._mainView = new WebInspector.VBox(); | 46 this._mainView = new WebInspector.VBox(); |
| 46 this._mainElement = this._mainView.element; | 47 this._mainElement = this._mainView.element; |
| 47 this._mainElement.className = "split-view-contents scroll-target split-view-
main vbox"; // Override | 48 this._mainElement.className = "split-view-contents scroll-target split-view-
main vbox"; // Override |
| 48 | 49 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 61 } | 62 } |
| 62 | 63 |
| 63 this._resizerWidget = new WebInspector.ResizerWidget(); | 64 this._resizerWidget = new WebInspector.ResizerWidget(); |
| 64 this._resizerWidget.setEnabled(true); | 65 this._resizerWidget.setEnabled(true); |
| 65 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eStart, this._onResizeStart, this); | 66 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eStart, this._onResizeStart, this); |
| 66 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eUpdate, this._onResizeUpdate, this); | 67 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eUpdate, this._onResizeUpdate, this); |
| 67 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eEnd, this._onResizeEnd, this); | 68 this._resizerWidget.addEventListener(WebInspector.ResizerWidget.Events.Resiz
eEnd, this._onResizeEnd, this); |
| 68 | 69 |
| 69 this._defaultSidebarWidth = defaultSidebarWidth || 200; | 70 this._defaultSidebarWidth = defaultSidebarWidth || 200; |
| 70 this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWid
th; | 71 this._defaultSidebarHeight = defaultSidebarHeight || this._defaultSidebarWid
th; |
| 72 this._constraintsInDip = !!constraintsInDip; |
| 71 this._settingName = settingName; | 73 this._settingName = settingName; |
| 72 | 74 |
| 73 this.setSecondIsSidebar(secondIsSidebar); | 75 this.setSecondIsSidebar(secondIsSidebar); |
| 74 | 76 |
| 75 this._innerSetVertical(isVertical); | 77 this._innerSetVertical(isVertical); |
| 76 this._showMode = WebInspector.SplitView.ShowMode.Both; | 78 this._showMode = WebInspector.SplitView.ShowMode.Both; |
| 77 | 79 |
| 78 // Should be called after isVertical has the right value. | 80 // Should be called after isVertical has the right value. |
| 79 this.installResizer(this._resizerElement); | 81 this.installResizer(this._resizerElement); |
| 80 } | 82 } |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 isResizable: function() | 362 isResizable: function() |
| 361 { | 363 { |
| 362 return this._resizerWidget.isEnabled(); | 364 return this._resizerWidget.isEnabled(); |
| 363 }, | 365 }, |
| 364 | 366 |
| 365 /** | 367 /** |
| 366 * @param {number} size | 368 * @param {number} size |
| 367 */ | 369 */ |
| 368 setSidebarSize: function(size) | 370 setSidebarSize: function(size) |
| 369 { | 371 { |
| 372 size *= WebInspector.zoomManager.zoomFactor(); |
| 370 this._savedSidebarSize = size; | 373 this._savedSidebarSize = size; |
| 371 this._saveSetting(); | 374 this._saveSetting(); |
| 372 this._innerSetSidebarSize(size, false, true); | 375 this._innerSetSidebarSize(size, false, true); |
| 373 }, | 376 }, |
| 374 | 377 |
| 375 /** | 378 /** |
| 376 * @return {number} | 379 * @return {number} |
| 377 */ | 380 */ |
| 378 sidebarSize: function() | 381 sidebarSize: function() |
| 379 { | 382 { |
| 380 return Math.max(0, this._sidebarSize); | 383 var size = Math.max(0, this._sidebarSize); |
| 384 return size / WebInspector.zoomManager.zoomFactor(); |
| 381 }, | 385 }, |
| 382 | 386 |
| 383 /** | 387 /** |
| 384 * Returns total size in DIP. | 388 * Returns total size in DIP. |
| 385 * @return {number} | 389 * @return {number} |
| 386 */ | 390 */ |
| 387 _totalSizeDIP: function() | 391 _totalSizeDIP: function() |
| 388 { | 392 { |
| 389 if (!this._totalSize) { | 393 if (!this._totalSize) { |
| 390 this._totalSize = this._isVertical ? this.element.offsetWidth : this
.element.offsetHeight; | 394 this._totalSize = this._isVertical ? this.element.offsetWidth : this
.element.offsetHeight; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 }, | 562 }, |
| 559 | 563 |
| 560 /** | 564 /** |
| 561 * @param {number} sidebarSize | 565 * @param {number} sidebarSize |
| 562 * @param {boolean=} userAction | 566 * @param {boolean=} userAction |
| 563 * @return {number} | 567 * @return {number} |
| 564 */ | 568 */ |
| 565 _applyConstraints: function(sidebarSize, userAction) | 569 _applyConstraints: function(sidebarSize, userAction) |
| 566 { | 570 { |
| 567 var totalSize = this._totalSizeDIP(); | 571 var totalSize = this._totalSizeDIP(); |
| 568 var zoomFactor = WebInspector.zoomManager.zoomFactor(); | 572 var zoomFactor = this._constraintsInDip ? 1 : WebInspector.zoomManager.z
oomFactor(); |
| 569 | 573 |
| 570 var constraints = this._sidebarView.constraints(); | 574 var constraints = this._sidebarView.constraints(); |
| 571 var minSidebarSize = this.isVertical() ? constraints.minimum.width : con
straints.minimum.height; | 575 var minSidebarSize = this.isVertical() ? constraints.minimum.width : con
straints.minimum.height; |
| 572 if (!minSidebarSize) | 576 if (!minSidebarSize) |
| 573 minSidebarSize = WebInspector.SplitView.MinPadding; | 577 minSidebarSize = WebInspector.SplitView.MinPadding; |
| 574 minSidebarSize *= zoomFactor; | 578 minSidebarSize *= zoomFactor; |
| 575 | 579 |
| 576 var preferredSidebarSize = this.isVertical() ? constraints.preferred.wid
th : constraints.preferred.height; | 580 var preferredSidebarSize = this.isVertical() ? constraints.preferred.wid
th : constraints.preferred.height; |
| 577 if (!preferredSidebarSize) | 581 if (!preferredSidebarSize) |
| 578 preferredSidebarSize = WebInspector.SplitView.MinPadding; | 582 preferredSidebarSize = WebInspector.SplitView.MinPadding; |
| 579 preferredSidebarSize *= zoomFactor; | 583 preferredSidebarSize *= zoomFactor; |
| 580 // Allow sidebar to be less than preferred by explicit user action. | 584 // Allow sidebar to be less than preferred by explicit user action. |
| 581 if (sidebarSize < preferredSidebarSize) | 585 if (sidebarSize < preferredSidebarSize) |
| 582 preferredSidebarSize = Math.max(sidebarSize, minSidebarSize); | 586 preferredSidebarSize = Math.max(sidebarSize, minSidebarSize); |
| 583 | 587 |
| 584 constraints = this._mainView.constraints(); | 588 constraints = this._mainView.constraints(); |
| 585 var minMainSize = this.isVertical() ? constraints.minimum.width : constr
aints.minimum.height; | 589 var minMainSize = this.isVertical() ? constraints.minimum.width : constr
aints.minimum.height; |
| 586 if (!minMainSize) | 590 if (!minMainSize) |
| 587 minMainSize = WebInspector.SplitView.MinPadding; | 591 minMainSize = WebInspector.SplitView.MinPadding; |
| 588 minMainSize *= zoomFactor; | 592 minMainSize *= zoomFactor; |
| 589 | 593 |
| 590 var preferredMainSize = this.isVertical() ? constraints.preferred.width
: constraints.preferred.height; | 594 var preferredMainSize = this.isVertical() ? constraints.preferred.width
: constraints.preferred.height; |
| 591 if (!preferredMainSize) | 595 if (!preferredMainSize) |
| 592 preferredMainSize = WebInspector.SplitView.MinPadding; | 596 preferredMainSize = WebInspector.SplitView.MinPadding; |
| 593 preferredMainSize *= zoomFactor; | 597 preferredMainSize *= zoomFactor; |
| 594 var savedMainSize = this.isVertical() ? this._savedVerticalMainSize : th
is._savedHorizontalMainSize; | 598 var savedMainSize = this.isVertical() ? this._savedVerticalMainSize : th
is._savedHorizontalMainSize; |
| 595 if (typeof savedMainSize !== "undefined") | 599 if (typeof savedMainSize !== "undefined") |
| 596 preferredMainSize = Math.min(preferredMainSize, savedMainSize); | 600 preferredMainSize = Math.min(preferredMainSize, savedMainSize * zoom
Factor); |
| 597 if (userAction) | 601 if (userAction) |
| 598 preferredMainSize = minMainSize; | 602 preferredMainSize = minMainSize; |
| 599 | 603 |
| 600 // Enough space for preferred. | 604 // Enough space for preferred. |
| 601 var totalPreferred = preferredMainSize + preferredSidebarSize; | 605 var totalPreferred = preferredMainSize + preferredSidebarSize; |
| 602 if (totalPreferred <= totalSize) | 606 if (totalPreferred <= totalSize) |
| 603 return Number.constrain(sidebarSize, preferredSidebarSize, totalSize
- preferredMainSize); | 607 return Number.constrain(sidebarSize, preferredSidebarSize, totalSize
- preferredMainSize); |
| 604 | 608 |
| 605 // Enough space for minimum. | 609 // Enough space for minimum. |
| 606 if (minMainSize + minSidebarSize <= totalSize) { | 610 if (minMainSize + minSidebarSize <= totalSize) { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 this._showHideSidebarButton.state = sidebarHidden ? "show" : "hide"; | 879 this._showHideSidebarButton.state = sidebarHidden ? "show" : "hide"; |
| 876 this._showHideSidebarButton.element.classList.toggle("top-sidebar-show-h
ide-button", !this.isVertical() && !this.isSidebarSecond()); | 880 this._showHideSidebarButton.element.classList.toggle("top-sidebar-show-h
ide-button", !this.isVertical() && !this.isSidebarSecond()); |
| 877 this._showHideSidebarButton.element.classList.toggle("right-sidebar-show
-hide-button", this.isVertical() && this.isSidebarSecond()); | 881 this._showHideSidebarButton.element.classList.toggle("right-sidebar-show
-hide-button", this.isVertical() && this.isSidebarSecond()); |
| 878 this._showHideSidebarButton.element.classList.toggle("bottom-sidebar-sho
w-hide-button", !this.isVertical() && this.isSidebarSecond()); | 882 this._showHideSidebarButton.element.classList.toggle("bottom-sidebar-sho
w-hide-button", !this.isVertical() && this.isSidebarSecond()); |
| 879 this._showHideSidebarButton.element.classList.toggle("left-sidebar-show-
hide-button", this.isVertical() && !this.isSidebarSecond()); | 883 this._showHideSidebarButton.element.classList.toggle("left-sidebar-show-
hide-button", this.isVertical() && !this.isSidebarSecond()); |
| 880 this._showHideSidebarButton.title = sidebarHidden ? WebInspector.UIStrin
g("Show %s", this._showHideSidebarButtonTitle) : WebInspector.UIString("Hide %s"
, this._showHideSidebarButtonTitle); | 884 this._showHideSidebarButton.title = sidebarHidden ? WebInspector.UIStrin
g("Show %s", this._showHideSidebarButtonTitle) : WebInspector.UIString("Hide %s"
, this._showHideSidebarButtonTitle); |
| 881 }, | 885 }, |
| 882 | 886 |
| 883 __proto__: WebInspector.View.prototype | 887 __proto__: WebInspector.View.prototype |
| 884 } | 888 } |
| OLD | NEW |