mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 05:41:39 +02: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 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 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 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
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
|
@ -107,7 +107,8 @@
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(assoc-in state [:workspace-local :expanded id] true))))
|
(assoc-in state [:workspace-local :expanded id] true))))
|
||||||
|
|
||||||
(def collapse-all
|
(defn collapse-all
|
||||||
|
[]
|
||||||
(ptk/reify ::collapse-all
|
(ptk/reify ::collapse-all
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
|
|
|
@ -37,29 +37,29 @@
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ stream]
|
(watch [_ _ stream]
|
||||||
(let [stoper (rx/filter (ptk/type? ::clear-drawing) stream)]
|
(rx/merge
|
||||||
(rx/merge
|
(when (= tool :path)
|
||||||
(when (= tool :path)
|
(rx/of (start-drawing :path)))
|
||||||
(rx/of (start-drawing :path)))
|
|
||||||
|
|
||||||
(when (= tool :curve)
|
(when (= tool :curve)
|
||||||
(let [stopper (->> stream (rx/filter dwc/interrupt?))]
|
(let [stopper (->> stream (rx/filter dwc/interrupt?))]
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter (ptk/type? ::common/handle-finish-drawing))
|
(rx/filter (ptk/type? ::common/handle-finish-drawing))
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/observe-on :async)
|
(rx/observe-on :async)
|
||||||
(rx/map #(select-for-drawing tool data))
|
(rx/map #(select-for-drawing tool data))
|
||||||
(rx/take-until stopper))))
|
(rx/take-until stopper))))
|
||||||
|
|
||||||
;; 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)
|
||||||
(not= tool :path))
|
(not= tool :path))
|
||||||
|
(let [stopper (rx/filter (ptk/type? ::clear-drawing) stream)]
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter dwc/interrupt?)
|
(rx/filter dwc/interrupt?)
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/map (constantly common/clear-drawing))
|
(rx/map common/clear-drawing)
|
||||||
(rx/take-until stoper)))))))))
|
(rx/take-until stopper)))))))))
|
||||||
|
|
||||||
|
|
||||||
;; NOTE/TODO: when an exception is raised in some point of drawing the
|
;; 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?)))
|
#(update-drawing % (cond-> point snap-pixel? gpt/round) shift?)))
|
||||||
|
|
||||||
(rx/take-until stoper))
|
(rx/take-until stoper))
|
||||||
(rx/of common/handle-finish-drawing))))))
|
(rx/of (common/handle-finish-drawing)))))))
|
||||||
|
|
|
@ -16,13 +16,15 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[potok.core :as ptk]))
|
[potok.core :as ptk]))
|
||||||
|
|
||||||
(def clear-drawing
|
(defn clear-drawing
|
||||||
|
[]
|
||||||
(ptk/reify ::clear-drawing
|
(ptk/reify ::clear-drawing
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(update state :workspace-drawing dissoc :tool :object))))
|
(update state :workspace-drawing dissoc :tool :object))))
|
||||||
|
|
||||||
(def handle-finish-drawing
|
(defn handle-finish-drawing
|
||||||
|
[]
|
||||||
(ptk/reify ::handle-finish-drawing
|
(ptk/reify ::handle-finish-drawing
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
|
@ -71,5 +73,6 @@
|
||||||
(rx/empty)))))
|
(rx/empty)))))
|
||||||
|
|
||||||
;; Delay so the mouse event can read the drawing state
|
;; Delay so the mouse event can read the drawing state
|
||||||
(->> (rx/of clear-drawing)
|
(->> (rx/of (clear-drawing))
|
||||||
(rx/delay 0)))))))
|
(rx/delay 0)))))))
|
||||||
|
|
||||||
|
|
|
@ -59,15 +59,22 @@
|
||||||
(dissoc :segments)
|
(dissoc :segments)
|
||||||
(assoc :content content)
|
(assoc :content content)
|
||||||
(assoc :selrect selrect)
|
(assoc :selrect selrect)
|
||||||
(assoc :points points))))
|
(assoc :points points)
|
||||||
|
|
||||||
(defn finish-drawing-curve [state]
|
(cond-> (or (empty? points) (nil? selrect) (<= (count content) 1))
|
||||||
(update-in
|
(assoc :initialized? false)))))
|
||||||
state [:workspace-drawing :object]
|
|
||||||
(fn [shape]
|
(defn finish-drawing-curve
|
||||||
(-> shape
|
[]
|
||||||
(update :segments #(ups/simplify % simplify-tolerance))
|
(ptk/reify ::finish-drawing-curve
|
||||||
(curve-to-path)))))
|
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 []
|
(defn handle-drawing-curve []
|
||||||
(ptk/reify ::handle-drawing-curve
|
(ptk/reify ::handle-drawing-curve
|
||||||
|
@ -81,6 +88,6 @@
|
||||||
(rx/map (fn [pt] #(insert-point-segment % pt)))
|
(rx/map (fn [pt] #(insert-point-segment % pt)))
|
||||||
(rx/take-until stoper))
|
(rx/take-until stoper))
|
||||||
(rx/of (setup-frame-curve)
|
(rx/of (setup-frame-curve)
|
||||||
finish-drawing-curve
|
(finish-drawing-curve)
|
||||||
common/handle-finish-drawing))))))
|
(common/handle-finish-drawing)))))))
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(rx/of (setup-frame-path)
|
(rx/of (setup-frame-path)
|
||||||
dwdc/handle-finish-drawing
|
(dwdc/handle-finish-drawing)
|
||||||
(dwc/start-edition-mode shape-id)
|
(dwc/start-edition-mode shape-id)
|
||||||
(change-edit-mode :draw)))))
|
(change-edit-mode :draw)))))
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(if (and expanded? (kbd/shift? event))
|
(if (and expanded? (kbd/shift? event))
|
||||||
(st/emit! dwc/collapse-all)
|
(st/emit! (dwc/collapse-all))
|
||||||
(st/emit! (dwc/toggle-collapse id))))
|
(st/emit! (dwc/toggle-collapse id))))
|
||||||
|
|
||||||
toggle-blocking
|
toggle-blocking
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue