 (defn- build-color-adjustment-overlay
   "Create an overlay for adjusting a color cue parameter. `note`
   identifies the encoder that was touched to bring up this overlay,
-  `cue` is the cue whose variable is being adjusted, `effect` is the
-  effect which that cue is running, and `info` is the metadata about
-  that effect."
-  [controller note cue effect info]
+  `cue` is the cue whose variable is being adjusted, `v` is the map
+  identifying the variable itself, `effect` is the effect which that
+  cue is running, and `info` is the metadata about that effect.
+
+  Also suppresses the ability to scroll through the cue variables
+  while the encoder is being held."
+  [controller note cue v effect info]
   (let [anchors (atom #{note})  ; Track which encoders are keeping the overlay active
         x (quot note 2)
-        var-index (min (rem note 2) (dec (count (:variables cue))))
-        cue-var (get (:variables cue) var-index)
         effect-id (:id info)]
     ;; Take full cell, using both encoders to adjust hue and saturation.
     (let [[hue-note sat-note] (if (odd? note) [(dec note) note] [note (inc note)])
           [hue-control sat-control] (map control-for-top-encoder-note [hue-note sat-note])]
       (reify controllers/IOverlay
-        (captured-controls [this] #{hue-control sat-control})
+        (captured-controls [this] #{hue-control sat-control (+ 21 (* 2 x))})
         (captured-notes [this] (clojure.set/union #{hue-note sat-note} (set (drop 36 (range 100)))))
         (adjust-interface [this _]
           (when (same-effect-active controller cue (:id info))
             ;; Draw the color picker grid
             (System/arraycopy color-picker-grid 0 (:next-grid-pads controller) 0 64)
-            (let [current-color (or (cues/get-cue-variable cue cue-var :show (:show controller) :when-id effect-id)
+            (let [current-color (or (cues/get-cue-variable cue v :show (:show controller) :when-id effect-id)
                                     (aget color-picker-grid 6))]
               ;; Show the preview color at the bottom right
               (aset (:next-grid-pads controller) 7 current-color)

(defn- build-boolean-adjustment-overlay
  "Create an overlay for adjusting a boolean cue parameter. `note`
  identifies the encoder that was touched to bring up this overlay,
  `cue` is the cue whose variable is being adjusted, `effect` is the
  effect which that cue is running, and `info` is the metadata about
  that effect."
  [controller note cue effect info]
  (let [x (quot note 2)
        var-index (rem note 2)]
    (if (> (count (:variables cue)) 1)
      ;; More than one variable, adjust whichever's encoder was touched
      (reify controllers/IOverlay
        (captured-controls [this] #{(control-for-top-encoder-note note)})
        (captured-notes [this] #{note})
        (adjust-interface [this _]
          (when (same-effect-active controller cue (:id info))
            (draw-boolean-gauge controller x 8 (* 9 var-index)
                                 cue (get (:variables cue) var-index) (:id info))
            true))
        (handle-control-change [this message]
          (adjust-boolean-value controller message cue
                                (get (:variables cue) var-index) (:id info)))
        (handle-note-on [this message])
        (handle-note-off [this message]
          :done)

              ;; It's a grid pad. Set the color based on the selected note, unless it's the preview pad.
              (when-not (= note 43)
                (let [chosen-color (aget color-picker-grid (- note 36))]
                  (cues/set-cue-variable! cue v chosen-color :show (:show controller) :when-id effect-id)))))
          true)
        (handle-note-off [this message]
          (swap! anchors disj (:note message))
