diff --git a/src/ui/DisplayedInspector.js b/src/ui/DisplayedInspector.js index 1fc15a22..d42096fe 100644 --- a/src/ui/DisplayedInspector.js +++ b/src/ui/DisplayedInspector.js @@ -73,14 +73,13 @@ class DisplayedInspector { * @returns {!DisplayedInspector} */ static empty(drawArea) { - let topToolbox = new DisplayedToolbox('Toolbox', 0, Gates.TopToolboxGroups, true, 3); + let topToolbox = new DisplayedToolbox('Toolbox', 0, Gates.TopToolboxGroups, true); let displayedCircuit = DisplayedCircuit.empty(topToolbox.desiredHeight()); let bottomToolbox = new DisplayedToolbox( 'Toolboxâ‚‚', displayedCircuit.top + displayedCircuit.desiredHeight(), Gates.BottomToolboxGroups, - false, - 4); + false); return new DisplayedInspector( drawArea, displayedCircuit, diff --git a/src/ui/DisplayedToolbox.js b/src/ui/DisplayedToolbox.js index 699a85ed..876ba82f 100644 --- a/src/ui/DisplayedToolbox.js +++ b/src/ui/DisplayedToolbox.js @@ -32,7 +32,6 @@ class DisplayedToolbox { * @param {!number} top * @param {!Array}>} toolboxGroups * @param {!boolean} labelsOnTop - * @param {!int} groupHeight * @param {undefined|!Array}>=} originalGroups * @param {undefined|!CachablePainting=undefined} standardAppearance */ @@ -41,7 +40,6 @@ class DisplayedToolbox { top, toolboxGroups, labelsOnTop, - groupHeight, originalGroups=undefined, standardAppearance=undefined) { /** @type {!String} */ @@ -52,8 +50,6 @@ class DisplayedToolbox { this.toolboxGroups = toolboxGroups; /** @type {!boolean} */ this.labelsOnTop = labelsOnTop; - /** @type {!int} */ - this.groupHeight = groupHeight; /** @type {!Array}>} */ this._originalGroups = originalGroups || this.toolboxGroups; /** @@ -68,6 +64,13 @@ class DisplayedToolbox { this._paintStandardContents(painter); painter.ctx.restore(); }); + + /** @type {!int} */ + this.groupHeight = 1; + for (let group of toolboxGroups) { + let h = Math.ceil(group.gates.length / 2); + this.groupHeight = Math.max(this.groupHeight, h); + } } /** @@ -90,7 +93,6 @@ class DisplayedToolbox { this.top, groups, this.labelsOnTop, - this.groupHeight, this._originalGroups, this._standardApperance); } @@ -181,7 +183,6 @@ class DisplayedToolbox { newTop, this.toolboxGroups, this.labelsOnTop, - this.groupHeight, this._originalGroups, this._standardApperance); }