mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 08:11:30 -05:00
🐛 Fix error when drawing curves with only one point
This commit is contained in:
parent
2a1ca07554
commit
1c87195fa6
8 changed files with 47 additions and 35 deletions
|
@ -94,6 +94,7 @@
|
|||
- Fix multi user not working [Taiga #3195](https://tree.taiga.io/project/penpot/issue/3195)
|
||||
- Fix guides are not duplicated with the artboard [Taiga #3072](https://tree.taiga.io/project/penpot/issue/3072)
|
||||
- Fix problem when changing group size with decimal values [Taiga #3203](https://tree.taiga.io/project/penpot/issue/3203)
|
||||
- Fix error when drawing curves with only one point [Taiga #3282](https://tree.taiga.io/project/penpot/issue/3282)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
|
|
@ -107,7 +107,8 @@
|
|||
(update [_ state]
|
||||
(assoc-in state [:workspace-local :expanded id] true))))
|
||||
|
||||
(def collapse-all
|
||||
(defn collapse-all
|
||||
[]
|
||||
(ptk/reify ::collapse-all
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
|
|
@ -37,29 +37,29 @@
|
|||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ stream]
|
||||
(let [stoper (rx/filter (ptk/type? ::clear-drawing) stream)]
|
||||
(rx/merge
|
||||
(when (= tool :path)
|
||||
(rx/of (start-drawing :path)))
|
||||
(rx/merge
|
||||
(when (= tool :path)
|
||||
(rx/of (start-drawing :path)))
|
||||
|
||||
(when (= tool :curve)
|
||||
(let [stopper (->> stream (rx/filter dwc/interrupt?))]
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::common/handle-finish-drawing))
|
||||
(rx/take 1)
|
||||
(rx/observe-on :async)
|
||||
(rx/map #(select-for-drawing tool data))
|
||||
(rx/take-until stopper))))
|
||||
(when (= tool :curve)
|
||||
(let [stopper (->> stream (rx/filter dwc/interrupt?))]
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::common/handle-finish-drawing))
|
||||
(rx/take 1)
|
||||
(rx/observe-on :async)
|
||||
(rx/map #(select-for-drawing tool data))
|
||||
(rx/take-until stopper))))
|
||||
|
||||
;; NOTE: comments are a special case and they manage they
|
||||
;; own interrupt cycle.q
|
||||
(when (and (not= tool :comments)
|
||||
(not= tool :path))
|
||||
;; NOTE: comments are a special case and they manage they
|
||||
;; own interrupt cycle.q
|
||||
(when (and (not= tool :comments)
|
||||
(not= tool :path))
|
||||
(let [stopper (rx/filter (ptk/type? ::clear-drawing) stream)]
|
||||
(->> stream
|
||||
(rx/filter dwc/interrupt?)
|
||||
(rx/take 1)
|
||||
(rx/map (constantly common/clear-drawing))
|
||||
(rx/take-until stoper)))))))))
|
||||
(rx/map common/clear-drawing)
|
||||
(rx/take-until stopper)))))))))
|
||||
|
||||
|
||||
;; NOTE/TODO: when an exception is raised in some point of drawing the
|
||||
|
|
|
@ -101,4 +101,4 @@
|
|||
#(update-drawing % (cond-> point snap-pixel? gpt/round) shift?)))
|
||||
|
||||
(rx/take-until stoper))
|
||||
(rx/of common/handle-finish-drawing))))))
|
||||
(rx/of (common/handle-finish-drawing)))))))
|
||||
|
|
|
@ -16,13 +16,15 @@
|
|||
[beicon.core :as rx]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
(def clear-drawing
|
||||
(defn clear-drawing
|
||||
[]
|
||||
(ptk/reify ::clear-drawing
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update state :workspace-drawing dissoc :tool :object))))
|
||||
|
||||
(def handle-finish-drawing
|
||||
(defn handle-finish-drawing
|
||||
[]
|
||||
(ptk/reify ::handle-finish-drawing
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
|
@ -71,5 +73,6 @@
|
|||
(rx/empty)))))
|
||||
|
||||
;; Delay so the mouse event can read the drawing state
|
||||
(->> (rx/of clear-drawing)
|
||||
(->> (rx/of (clear-drawing))
|
||||
(rx/delay 0)))))))
|
||||
|
||||
|
|
|
@ -59,15 +59,22 @@
|
|||
(dissoc :segments)
|
||||
(assoc :content content)
|
||||
(assoc :selrect selrect)
|
||||
(assoc :points points))))
|
||||
(assoc :points points)
|
||||
|
||||
(defn finish-drawing-curve [state]
|
||||
(update-in
|
||||
state [:workspace-drawing :object]
|
||||
(fn [shape]
|
||||
(-> shape
|
||||
(update :segments #(ups/simplify % simplify-tolerance))
|
||||
(curve-to-path)))))
|
||||
(cond-> (or (empty? points) (nil? selrect) (<= (count content) 1))
|
||||
(assoc :initialized? false)))))
|
||||
|
||||
(defn finish-drawing-curve
|
||||
[]
|
||||
(ptk/reify ::finish-drawing-curve
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(letfn [(update-curve [shape]
|
||||
(-> shape
|
||||
(update :segments #(ups/simplify % simplify-tolerance))
|
||||
(curve-to-path)))]
|
||||
(-> state
|
||||
(update-in [:workspace-drawing :object] update-curve))))))
|
||||
|
||||
(defn handle-drawing-curve []
|
||||
(ptk/reify ::handle-drawing-curve
|
||||
|
@ -81,6 +88,6 @@
|
|||
(rx/map (fn [pt] #(insert-point-segment % pt)))
|
||||
(rx/take-until stoper))
|
||||
(rx/of (setup-frame-curve)
|
||||
finish-drawing-curve
|
||||
common/handle-finish-drawing))))))
|
||||
(finish-drawing-curve)
|
||||
(common/handle-finish-drawing)))))))
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of (setup-frame-path)
|
||||
dwdc/handle-finish-drawing
|
||||
(dwdc/handle-finish-drawing)
|
||||
(dwc/start-edition-mode shape-id)
|
||||
(change-edit-mode :draw)))))
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(if (and expanded? (kbd/shift? event))
|
||||
(st/emit! dwc/collapse-all)
|
||||
(st/emit! (dwc/collapse-all))
|
||||
(st/emit! (dwc/toggle-collapse id))))
|
||||
|
||||
toggle-blocking
|
||||
|
|
Loading…
Add table
Reference in a new issue