diff --git a/src/ui/DisplayedInspector.js b/src/ui/DisplayedInspector.js index b6449b4c..1fc15a22 100644 --- a/src/ui/DisplayedInspector.js +++ b/src/ui/DisplayedInspector.js @@ -321,33 +321,12 @@ class DisplayedInspector { this._drawHint_useControls(painter); } - /** - * @returns {!number} - * @private - */ - _watchOutputsChangeVisibility() { - if (this.displayedCircuit.circuitDefinition.customInitialValues.size > 0) { - return 0; - } - - let gatesInCircuit = this.displayedCircuit.circuitDefinition.countGatesUpTo(2); - let gatesInPlay = gatesInCircuit + (this.hand.isBusy() ? 1 : 0); - if (gatesInCircuit >= 2 || gatesInPlay === 0) { - return 0; - } - - let handPosY = this.hand.pos === undefined ? Infinity : this.hand.pos.y; - return gatesInCircuit === 0 ? (handPosY - 125)/25 : - gatesInPlay === 2 ? (150 - handPosY)/25 : - 1.0; - } - /** * @param {!Painter} painter * @private */ _drawHint_watchOutputsChange(painter) { - let visibilityFactor = this._watchOutputsChangeVisibility(); + let visibilityFactor = this._hintVisibility(); if (visibilityFactor <= 0) { return; } @@ -382,20 +361,22 @@ class DisplayedInspector { painter.ctx.restore(); } + _hintVisibility() { + if (this.displayedCircuit.circuitDefinition.columns.length > 0) { + return 0; + } + return this.hand.pos === undefined || !this.hand.isBusy() ? 1.0 : + this.hand.heldGate !== undefined && this.hand.heldGate.isControl() ? 1.0 : + (150-this.hand.pos.y)/50; + } + /** * @param {!Painter} painter * @private */ _drawHint_dragGatesOntoCircuit(painter) { - if (this.displayedCircuit.circuitDefinition.hasNonControlGates()) { - return; - } - - let visibilityFactor = - this.hand.pos === undefined || !this.hand.isBusy() ? 1.0 : - this.hand.heldGate !== undefined && this.hand.heldGate.isControl() ? 1.0 : - (150-this.hand.pos.y)/50; + let visibilityFactor = this._hintVisibility(); if (visibilityFactor <= 0) { return; } @@ -404,7 +385,7 @@ class DisplayedInspector { painter.ctx.globalAlpha *= Math.min(1, visibilityFactor); painter.ctx.save(); - painter.ctx.translate(70, 190); + painter.ctx.translate(130, 195); painter.ctx.rotate(Math.PI * 0.05); painter.ctx.fillStyle = 'red'; painter.ctx.font = '16px sans-serif'; @@ -428,41 +409,12 @@ class DisplayedInspector { painter.ctx.restore(); } - /** - * @returns {!number} - * @private - */ - _useControlsHintVisibility() { - let circ = this.displayedCircuit.circuitDefinition; - let gatesInCircuit = circ.countGatesUpTo(2); - let gatesInPlay = gatesInCircuit + (this.hand.heldGate !== undefined ? 1 : 0); - - if (circ.customInitialValues.size > 0) { - return 0; - } - - let gate = circ.gateInSlot(0, 0); - if (circ.hasControls() || !circ.hasNonControlGates() || (gate !== undefined && gate.height > 1)) { - return 0; - } - - if (gatesInCircuit === 1 && gatesInPlay === 1 && !this.displayedCircuit.isBeingEdited()) { - return 1; - } - - if (gatesInCircuit === 1 && gatesInPlay === 2 && this.displayedCircuit.isBeingEdited()) { - return (150-this.hand.pos.y)/50; - } - - return 0; - } - /** * @param {!Painter} painter * @private */ _drawHint_useControls(painter) { - let visibilityFactor = this._useControlsHintVisibility(); + let visibilityFactor = this._hintVisibility(); if (visibilityFactor <= 0) { return; }