mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
Do not select shape when drawing.
This commit is contained in:
parent
6ba28830f3
commit
8c51048f76
4 changed files with 23 additions and 16 deletions
|
@ -25,7 +25,8 @@
|
|||
(let [{:keys [id x y width height group]} shape
|
||||
selected (rum/react uusc/selected-shapes-l)
|
||||
selected? (contains? selected id)
|
||||
on-mouse-down #(uusi/on-mouse-down % shape selected)
|
||||
drawing? (rum/react uusc/drawing-state-l)
|
||||
on-mouse-down #(uusi/on-mouse-down % shape selected drawing?)
|
||||
on-mouse-up #(uusi/on-mouse-up % shape)]
|
||||
(html
|
||||
[:g.shape {:class (when selected? "selected")
|
||||
|
|
|
@ -40,8 +40,12 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def ^:const selected-shapes-l
|
||||
(as-> (l/in [:workspace :selected]) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(-> (l/in [:workspace :selected])
|
||||
(l/focus-atom st/state)))
|
||||
|
||||
(def ^:const drawing-state-l
|
||||
(-> (l/in [:workspace :drawing])
|
||||
(l/focus-atom st/state)))
|
||||
|
||||
(defn- focus-shape
|
||||
[id]
|
||||
|
|
|
@ -13,15 +13,16 @@
|
|||
[uxbox.ui.shapes.core :as uusc]
|
||||
[uxbox.util.dom :as dom]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Icon Component
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; --- Icon Component
|
||||
|
||||
(defn on-mouse-down
|
||||
[event {:keys [id group] :as shape} selected]
|
||||
[event {:keys [id group] :as shape} selected drawing?]
|
||||
(let [selected? (contains? selected id)]
|
||||
(when-not (:blocked shape)
|
||||
(cond
|
||||
drawing?
|
||||
nil
|
||||
|
||||
(and group (:locked (ush/resolve-parent shape)))
|
||||
nil
|
||||
|
||||
|
@ -61,8 +62,9 @@
|
|||
[own shape]
|
||||
(let [{:keys [id x y width height group]} shape
|
||||
selected (rum/react uusc/selected-shapes-l)
|
||||
drawing? (rum/react uusc/drawing-state-l)
|
||||
selected? (contains? selected id)
|
||||
on-mouse-down #(on-mouse-down % shape selected)
|
||||
on-mouse-down #(on-mouse-down % shape selected drawing?)
|
||||
on-mouse-up #(on-mouse-up % shape)]
|
||||
(html
|
||||
[:g.shape {:class (when selected? "selected")
|
||||
|
@ -72,9 +74,7 @@
|
|||
(when (and selected? (= (count selected) 1))
|
||||
(handlers shape))])))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Icon Handlers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; --- Icon Handlers
|
||||
|
||||
(defn- handlers-render
|
||||
[own shape]
|
||||
|
@ -123,9 +123,7 @@
|
|||
:name "handlers"
|
||||
:mixins [mx/static]}))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Shape & Shape Svg
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; --- Shape & Shape Svg
|
||||
|
||||
(defmethod uusc/render-shape :builtin/icon
|
||||
[{:keys [data id] :as shape} _]
|
||||
|
|
|
@ -19,11 +19,14 @@
|
|||
(:import goog.events.EventType))
|
||||
|
||||
(defn on-mouse-down
|
||||
[event own {:keys [id group] :as shape} selected]
|
||||
[event own {:keys [id group] :as shape} selected drawing?]
|
||||
(let [selected? (contains? selected id)
|
||||
local (:rum/local own)]
|
||||
(when-not (:blocked shape)
|
||||
(cond
|
||||
drawing?
|
||||
nil
|
||||
|
||||
(:edition @local)
|
||||
nil
|
||||
|
||||
|
@ -108,7 +111,8 @@
|
|||
(let [{:keys [id x1 y1 content group]} shape
|
||||
selected (rum/react uusc/selected-shapes-l)
|
||||
selected? (and (contains? selected id) (= (count selected) 1))
|
||||
on-mouse-down #(on-mouse-down % own shape selected)
|
||||
drawing? (rum/react uusc/drawing-state-l)
|
||||
on-mouse-down #(on-mouse-down % own shape selected drawing?)
|
||||
on-mouse-up #(on-mouse-up % shape)
|
||||
local (:rum/local own)]
|
||||
(html
|
||||
|
|
Loading…
Add table
Reference in a new issue