             [uxbox.shapes :as shapes]
             [uxbox.library.icons :as _icons]
             [uxbox.data.projects :as dp]
+            [uxbox.data.workspace :as dw]
             [uxbox.ui.mixins :as mx]
             [uxbox.ui.dom :as dom]
             [uxbox.ui.util :as util]

   :stroke "gray"})

(defn- shape-render
  [own {:keys [x y] :as shape}]
  (let [local (:rum/local own)]
    (html
     [:g {
          :on-mouse-down
          (fn [event]
            (println "mouse-down")
            (rx/push! wb/selected-shape-b shape))

          ;; :on-mouse-move
          ;; (fn [event]
          ;;   (when (:drop @local)
          ;;     (println "mouse-move" @wb/mouse-position2)
          ;;     (let [target (.-currentTarget event)
          ;;           [nx ny] @wb/mouse-position2
          ;;           svg (aget (.-childNodes target) 0)]
          ;;       (.setAttribute svg "x" nx)
          ;;       (.setAttribute svg "y" ny)))
          ;;   false)

          :on-mouse-up
          (fn [event]

            (rx/push! wb/selected-shape-b :nothing)
            (dom/stop-propagation event))
          }
      (shapes/render shape)
      (if (contains? selected id)
        [:g {:class "controls"}
         [:rect {:x x :y y :width width :height height
                 :style {:stroke "black" :fill "transparent"
                         :stroke-opacity "0.5"}}]
         [:circle (merge default-selection-props
                         {:cx x :cy y})]
         [:circle (merge default-selection-props
                         {:cx (+ x width) :cy y})]
         [:circle (merge default-selection-props
                         {:cx x :cy (+ y height)})]
         [:circle (merge default-selection-props
                         {:cx (+ x width) :cy (+ y height)})]])])))


;; (defn- shape-render
;;   [own shape]
