From 32efb93466db6c9dddc2c97fda94a83f3c2a00f9 Mon Sep 17 00:00:00 2001 From: Craig Gidney Date: Sat, 23 Mar 2019 17:02:46 -0700 Subject: [PATCH] Don't add touch blockers to circuit area when drawing custom circuit gates in toolbox --- src/draw/Painter.js | 14 +++++++++++++- src/ui/DisplayedToolbox.js | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/draw/Painter.js b/src/draw/Painter.js index f70f93b6..dded626c 100644 --- a/src/draw/Painter.js +++ b/src/draw/Painter.js @@ -56,13 +56,25 @@ class Painter { * @type {!RestartableRng} */ this.rng = rng; + + this._ignoringTouchBlockers = 0; + } + + startIgnoringIncomingTouchBlockers() { + this._ignoringTouchBlockers += 1 + } + + stopIgnoringIncomingTouchBlockers() { + this._ignoringTouchBlockers -= 1 } /** * @param {!{rect: !Rect, cursor: undefined|!string}} blocker */ noteTouchBlocker(blocker) { - this.touchBlockers.push(blocker); + if (this._ignoringTouchBlockers === 0) { + this.touchBlockers.push(blocker); + } } /** diff --git a/src/ui/DisplayedToolbox.js b/src/ui/DisplayedToolbox.js index dce22dd7..a87ca07a 100644 --- a/src/ui/DisplayedToolbox.js +++ b/src/ui/DisplayedToolbox.js @@ -290,6 +290,7 @@ class DisplayedToolbox { */ static _paintGate(painter, gate, rect, isHighlighted, stats) { let drawer = gate.customDrawer || GatePainting.DEFAULT_DRAWER; + painter.startIgnoringIncomingTouchBlockers(); drawer(new GateDrawParams( painter, true, // inToolbox @@ -302,6 +303,7 @@ class DisplayedToolbox { undefined, // positionInCircuit [], // focusPoints undefined)); // customStatsForCircuitPos + painter.stopIgnoringIncomingTouchBlockers(); } /**