                               [t (ha/extrapolate ha-def ha t)]))
                           os)))))
 
+(def segmented-control
+  (let [props (fn [this] (aget (.-props this) "args"))
+        c
+        (.createClass js/React
+                      #js {:shouldComponentUpdate
+                           (fn [next-props _next-state]
+                             (this-as this
+                               (not= (aget next-props "args") (props this))))
+                           :render
+                           (fn []
+                             (this-as this
+                               (let [[label options selected on-change] (props this)
+                                     ]
+                                 (sab/html [:div
+                                            (map
+                                              (fn [{name :name type :type prototype :prototype :as o}]
+                                                [:button
+                                                 {:style   {:backgroundColor (if (= selected o)
+                                                                               "#4479BA"
+                                                                               "#CCCCCC")}
+                                                  :onClick (fn [evt]
+                                                             (println type prototype)
+                                                             (on-change o))}
+                                                 name])
+                                              options)]))))})
+        f (.createFactory js/React c)]
+    (fn [& args]
+      (f #js {:args args}))))
+
 (def world-widget
   (let [props (fn [this] (aget (.-props this) "args"))
         ; world -> view: scale up and flip

                            (get old-defs old-type))
                  old-val (when old-val
                            (ha/extrapolate old-def old-val t))
                  old-at-init? (= (.-v0 old-val)
                                  (.-v0 old-init))
                  ; if the old val was at the initial valuation,
                  ; then moving the initial valuation should update the old val.
                  old-val (if old-at-init?


(defn num-changer [world label key update-fn!]
  (sab/html
    [:div {:style {:width 170 :display "inline-block" :fontSize "12px"}}
     [:label {:key   (str key "-label")
              :style {:width "95%"}} label]
     [:input {:type     "number"
              :style    {:width "95%"}
              :key      (str key "-field")
              :value    (key @world)
              :onChange (fn [evt]
                          (update-fn! world key (.parseInt js/window (.-value (.-target evt)))))}]]))

(defn world-update-desc-key! [world key val]
  (world-update-desc! world (assoc (:desc @world)
