mirror of
https://github.com/penpot/penpot.git
synced 2025-05-31 17:16:11 +02:00
✨ Curve tool improvements
This commit is contained in:
parent
ec1cc8ec64
commit
72c2a213b4
4 changed files with 44 additions and 30 deletions
|
@ -314,37 +314,41 @@
|
||||||
[redo-changes undo-changes])))
|
[redo-changes undo-changes])))
|
||||||
|
|
||||||
(defn add-shape
|
(defn add-shape
|
||||||
[attrs]
|
([attrs]
|
||||||
(us/verify ::shape-attrs attrs)
|
(add-shape attrs {}))
|
||||||
(ptk/reify ::add-shape
|
|
||||||
ptk/WatchEvent
|
|
||||||
(watch [it state _]
|
|
||||||
(let [page-id (:current-page-id state)
|
|
||||||
objects (wsh/lookup-page-objects state page-id)
|
|
||||||
|
|
||||||
id (or (:id attrs) (uuid/next))
|
([attrs {:keys [no-select?]}]
|
||||||
name (-> objects
|
(us/verify ::shape-attrs attrs)
|
||||||
(retrieve-used-names)
|
(ptk/reify ::add-shape
|
||||||
(generate-unique-name (:name attrs)))
|
ptk/WatchEvent
|
||||||
|
(watch [it state _]
|
||||||
|
(let [page-id (:current-page-id state)
|
||||||
|
objects (wsh/lookup-page-objects state page-id)
|
||||||
|
|
||||||
selected (wsh/lookup-selected state)
|
id (or (:id attrs) (uuid/next))
|
||||||
|
name (-> objects
|
||||||
|
(retrieve-used-names)
|
||||||
|
(generate-unique-name (:name attrs)))
|
||||||
|
|
||||||
[rchanges uchanges] (add-shape-changes
|
selected (wsh/lookup-selected state)
|
||||||
page-id
|
|
||||||
objects
|
|
||||||
selected
|
|
||||||
(-> attrs
|
|
||||||
(assoc :id id )
|
|
||||||
(assoc :name name)))]
|
|
||||||
|
|
||||||
(rx/concat
|
[rchanges uchanges] (add-shape-changes
|
||||||
(rx/of (dch/commit-changes {:redo-changes rchanges
|
page-id
|
||||||
:undo-changes uchanges
|
objects
|
||||||
:origin it})
|
selected
|
||||||
(select-shapes (d/ordered-set id)))
|
(-> attrs
|
||||||
(when (= :text (:type attrs))
|
(assoc :id id )
|
||||||
(->> (rx/of (start-edition-mode id))
|
(assoc :name name)))]
|
||||||
(rx/observe-on :async))))))))
|
|
||||||
|
(rx/concat
|
||||||
|
(rx/of (dch/commit-changes {:redo-changes rchanges
|
||||||
|
:undo-changes uchanges
|
||||||
|
:origin it})
|
||||||
|
(when-not no-select?
|
||||||
|
(select-shapes (d/ordered-set id))))
|
||||||
|
(when (= :text (:type attrs))
|
||||||
|
(->> (rx/of (start-edition-mode id))
|
||||||
|
(rx/observe-on :async)))))))))
|
||||||
|
|
||||||
(defn move-shapes-into-frame [frame-id shapes]
|
(defn move-shapes-into-frame [frame-id shapes]
|
||||||
(ptk/reify ::move-shapes-into-frame
|
(ptk/reify ::move-shapes-into-frame
|
||||||
|
|
|
@ -42,6 +42,15 @@
|
||||||
(when (= tool :path)
|
(when (= tool :path)
|
||||||
(rx/of (start-drawing :path)))
|
(rx/of (start-drawing :path)))
|
||||||
|
|
||||||
|
(when (= tool :curve)
|
||||||
|
(let [stopper (->> stream (rx/filter dwc/interrupt?))]
|
||||||
|
(->> stream
|
||||||
|
(rx/take-until stopper)
|
||||||
|
(rx/filter (ptk/type? ::common/handle-finish-drawing))
|
||||||
|
(rx/take 1)
|
||||||
|
(rx/observe-on :async)
|
||||||
|
(rx/map #(select-for-drawing tool data)))))
|
||||||
|
|
||||||
;; NOTE: comments are a special case and they manage they
|
;; NOTE: comments are a special case and they manage they
|
||||||
;; own interrupt cycle.q
|
;; own interrupt cycle.q
|
||||||
(when (and (not= tool :comments)
|
(when (and (not= tool :comments)
|
||||||
|
|
|
@ -24,7 +24,8 @@
|
||||||
(ptk/reify ::handle-finish-drawing
|
(ptk/reify ::handle-finish-drawing
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [shape (get-in state [:workspace-drawing :object])]
|
(let [tool (get-in state [:workspace-drawing :tool])
|
||||||
|
shape (get-in state [:workspace-drawing :object])]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(when (:initialized? shape)
|
(when (:initialized? shape)
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
|
@ -55,7 +56,7 @@
|
||||||
(rx/of (dwu/start-undo-transaction))
|
(rx/of (dwu/start-undo-transaction))
|
||||||
(rx/empty))
|
(rx/empty))
|
||||||
|
|
||||||
(rx/of (dwc/add-shape shape))
|
(rx/of (dwc/add-shape shape {:no-select? (= tool :curve)}))
|
||||||
|
|
||||||
(if (= :frame (:type shape))
|
(if (= :frame (:type shape))
|
||||||
(->> (uw/ask! {:cmd :selection/query
|
(->> (uw/ask! {:cmd :selection/query
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
show-draw-area? drawing-obj
|
show-draw-area? drawing-obj
|
||||||
show-gradient-handlers? (= (count selected) 1)
|
show-gradient-handlers? (= (count selected) 1)
|
||||||
show-grids? (contains? layout :display-grid)
|
show-grids? (contains? layout :display-grid)
|
||||||
show-outlines? (and (nil? transform) (not edition) (not drawing-obj) (not (#{:comments :path} drawing-tool)))
|
show-outlines? (and (nil? transform) (not edition) (not drawing-obj) (not (#{:comments :path :curve} drawing-tool)))
|
||||||
show-pixel-grid? (>= zoom 8)
|
show-pixel-grid? (>= zoom 8)
|
||||||
show-presence? page-id
|
show-presence? page-id
|
||||||
show-prototypes? (= options-mode :prototype)
|
show-prototypes? (= options-mode :prototype)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue