                                        {:key "lightness" :min 0 :max 100 :name "Lightness" :velocity true}
                                        color-var]))))
 
+(def light-groups
+  "The named groupings of lights to build rows of effects in the cue grid."
+  [:torrent :blade :ws :hex :puck :snowball])
+
+(defn group-end-keys
+  "Helper function to produce a vector of effect keywords to end all
+  effects running on light groups with a given suffix."
+  [effect-suffix]
+  (mapv #(keyword (str (name %) "-" effect-suffix)) light-groups))
+
+(defn build-group-cue-elements
+  "Helper function which builds the common variables needed to create
+  a cue which runs on either all lights or a named group of lights."
+  [group effect-suffix name-suffix]
+  (let [effect-key (or (when group (keyword (str (name group) "-" effect-suffix)))
+                       (keyword effect-suffix))
+        fixtures (or (when group (show/fixtures-named group))
+                     (show/all-fixtures))
+        end-keys (or (when group [(keyword effect-suffix)])
+                     (group-end-keys effect-suffix))
+        effect-name (str (case group
+                           nil "All"
+                           :ws "WS"
+                           (clojure.string/capitalize (name group)))
+                         " " (clojure.string/capitalize name-suffix))]
+    [effect-key fixtures end-keys effect-name]))
+
+(defn make-dimmer-cue
+  "Creates a cue which lets the operator adjust the dimmer level of a
+  group of fixtures. Group will be one of the values
+  in [[light-groups]], or `nil` if the cue should affect all lights."
+  [group x y color]
+  (let [[effect-key fixtures end-keys effect-name] (build-group-cue-elements group "dimmers" "dimmers")]
+    (ct/set-cue! (:cue-grid *show*) x y
+                 (cues/cue effect-key
+                           (fn [var-map] (dimmer-effect
+                                          (params/bind-keyword-param (:level var-map 255) Number 255)
+                                          fixtures
+                                          :effect-name effect-name))
+                           :variables [{:key "level" :min 0 :max 255 :start 255 :name "Level"}]
+                           :color color :end-keys end-keys))))
+
 (defn build-ratio-param
   "Creates a dynamic parameter for setting the beat ratio of one of
   the dimmer oscillator cues in [[make-cues]] by forming the ratio of



    ;; Dimmer cues to turn on and set brightness of groups of lights
    (ct/set-cue! (:cue-grid *show*) 0 2
                 (cues/cue :dimmers (fn [var-map] (global-dimmer-effect
                                                   (params/bind-keyword-param (:level var-map 255) Number 255)
                                                   :effect-name "All Dimmers"))
                           :variables [{:key "level" :min 0 :max 255 :start 255 :name "Level"}]
                           :color :yellow :end-keys [:torrent-dimmers :blade-dimmers :ws-dimmers
                                                     :puck-dimmers :hex-dimmers :snowball-dimmers]))
    (ct/set-cue! (:cue-grid *show*) 1 2
                 (cues/cue :torrent-dimmers (fn [var-map] (dimmer-effect
                                                           (params/bind-keyword-param (:level var-map 255) Number 255)
                                                           (show/fixtures-named "torrent")
                                                           :effect-name "Torrent Dimmers"))
                           :variables [{:key "level" :min 0 :max 255 :start 255 :name "Level"}]
                           :color :yellow :end-keys [:dimmers]))
    (ct/set-cue! (:cue-grid *show*) 2 2
                 (cues/cue :blade-dimmers (fn [var-map] (dimmer-effect
                                                         (params/bind-keyword-param (:level var-map 255) Number 255)
                                                         (show/fixtures-named "blade")
                                                         :effect-name "Blade Dimmers"))
                           :variables [{:key "level" :min 0 :max 255 :start 255 :name "Level"}]
                           :color :yellow :end-keys [:dimmers]))
    (ct/set-cue! (:cue-grid *show*) 3 2
                 (cues/cue :ws-dimmers (fn [var-map] (dimmer-effect
                                                      (params/bind-keyword-param (:level var-map 255) Number 255)
                                                      (show/fixtures-named "ws")
                                                      :effect-name "Weather System Dimmers"))
                           :variables [{:key "level" :min 0 :max 255 :start 255 :name "Level"}]
                           :color :yellow :end-keys [:dimmers]))

    (ct/set-cue! (:cue-grid *show*) 4 2
                 (cues/cue :hex-dimmers (fn [var-map] (dimmer-effect
                                                       (params/bind-keyword-param (:level var-map 255) Number 255)
                                                       (show/fixtures-named "hex")
                                                       :effect-name "Hex Dimmers"))
                           :variables [{:key "level" :min 0 :max 255 :start 255 :name "Level"}]
                           :color :yellow :end-keys [:dimmers]))
    (ct/set-cue! (:cue-grid *show*) 5 2
                 (cues/cue :puck-dimmers (fn [var-map] (dimmer-effect
                                                        (params/bind-keyword-param (:level var-map 255) Number 255)
                                                        (show/fixtures-named "puck")
                                                        :effect-name "Puck Dimmers"))
                           :variables [{:key "level" :min 0 :max 255 :start 255 :name "Level"}]
                           :color :yellow :end-keys [:dimmers]))
    (ct/set-cue! (:cue-grid *show*) 6 2
                 (cues/cue :snowball-dimmers (fn [var-map] (dimmer-effect
                                                            (params/bind-keyword-param (:level var-map 255) Number 255)
                                                            (show/fixtures-named "snowball")
                                                            :effect-name "Snowball Dimmers"))
                           :variables [{:key "level" :min 0 :max 255 :start 255 :name "Level"}]
                           :color :yellow :end-keys [:dimmers]))

    ;; TODO: Write a macro to make it easier to bind cue variables?
    (ct/set-cue! (:cue-grid *show*) 7 2

                                     {:key "cycles" :min 1 :max 10 :type :integer :start :starting-cycles
                                      :name "Cycles"}
                                     {:key "width" :min 0 :max 1 :start :starting-width :name "Width"}]
                         :end-keys end-keys))))

(defn x-phase
  "Return a value that ranges from zero for the leftmost fixture in a
