               (assoc-in [:editing-eids :editing-eids] #{entity-id})
               (assoc-in [:selected-eids :selected-eids] #{entity-id}))]
       r)))
+
+(defmethod control-event :drawing-started
+  [browser-state message [x y] state]
+  (handle-drawing-started state x y))
 
 (defmethod control-event :drawing-edited
   [browser-state message {:keys [layer x y]} state]

  (let [points (map js/parseInt (str/split (subs path 1) #" "))]
    (map (fn [[rx ry]] {:rx rx :ry ry}) (partition 2 points))))

(defmethod control-event :drawing-started
  [browser-state message [x y] state]
  (let [[rx ry] (cameras/screen->point (:camera state) x y)
        [snap-x snap-y] (cameras/snap-to-grid (:camera state) rx ry)
        {:keys [entity-id state]} (frontend.db/get-entity-id state)

        (assoc-in [:layer-properties-menu :x] rx)
        (assoc-in [:layer-properties-menu :y] ry))))

(defn handle-layer-properties-submitted [state]
  (-> state
    (assoc-in [:layer-properties-menu :opened?] false)))

(defmethod control-event :layer-properties-submitted
  [browser-state message _ state]
  (handle-layer-properties-submitted state))

(defn handle-layer-properties-submitted-after [current-state]
  (let [db (:db current-state)]
    (d/transact! db [(utils/remove-map-nils
                      (select-keys (get-in current-state [:layer-properties-menu :layer])
                                   [:db/id :layer/ui-id :layer/ui-target]))])))

(defmethod post-control-event! :layer-properties-submitted
  [browser-state message _ previous-state current-state]
  (handle-layer-properties-submitted-after current-state))

(defn empty-str->nil [s]
  (if (str/blank? s)
