mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05:00
🐛 Fix problem calculating selrect for certain paths
This commit is contained in:
parent
02ab545cda
commit
f6b182a3b5
2 changed files with 35 additions and 32 deletions
|
@ -340,29 +340,31 @@
|
|||
(grc/points->rect points))))
|
||||
|
||||
(defn content->selrect [content]
|
||||
(let [calc-extremities
|
||||
(fn [command prev]
|
||||
(case (:command command)
|
||||
:move-to [(command->point command)]
|
||||
(let [extremities
|
||||
(loop [points #{}
|
||||
from-p nil
|
||||
move-p nil
|
||||
content (seq content)]
|
||||
(if content
|
||||
(let [command (first content)
|
||||
to-p (command->point command)
|
||||
|
||||
;; If it's a line we add the beginning point and endpoint
|
||||
:line-to [(command->point prev)
|
||||
(command->point command)]
|
||||
[from-p move-p command-pts]
|
||||
(case (:command command)
|
||||
:move-to [to-p to-p [to-p]]
|
||||
:close-path [move-p move-p [move-p]]
|
||||
:line-to [to-p move-p [from-p to-p]]
|
||||
:curve-to [to-p move-p
|
||||
(let [c1 (command->point command :c1)
|
||||
c2 (command->point command :c2)
|
||||
curve [from-p to-p c1 c2]]
|
||||
(into [from-p to-p]
|
||||
(->> (curve-extremities curve)
|
||||
(map #(curve-values curve %)))))]
|
||||
[to-p move-p []])]
|
||||
|
||||
;; We return the bezier extremities
|
||||
:curve-to (into [(command->point prev)
|
||||
(command->point command)]
|
||||
(let [curve [(command->point prev)
|
||||
(command->point command)
|
||||
(command->point command :c1)
|
||||
(command->point command :c2)]]
|
||||
(->> (curve-extremities curve)
|
||||
(map #(curve-values curve %)))))
|
||||
[]))
|
||||
|
||||
extremities (mapcat calc-extremities
|
||||
content
|
||||
(concat [nil] content))]
|
||||
(recur (apply conj points command-pts) from-p move-p (next content)))
|
||||
points))]
|
||||
(grc/points->rect extremities)))
|
||||
|
||||
(defn move-content [content move-vec]
|
||||
|
|
|
@ -1013,20 +1013,21 @@
|
|||
(d/ordered-set)))]
|
||||
(rx/of (dws/select-shapes shapes-to-select)))
|
||||
|
||||
(let [{:keys [id type shapes]} (get objects (first selected))]
|
||||
(case type
|
||||
:text
|
||||
(rx/of (dwe/start-edition-mode id))
|
||||
(when (d/not-empty? selected)
|
||||
(let [{:keys [id type shapes]} (get objects (first selected))]
|
||||
(case type
|
||||
:text
|
||||
(rx/of (dwe/start-edition-mode id))
|
||||
|
||||
(:group :bool :frame)
|
||||
(let [shapes-ids (into (d/ordered-set) shapes)]
|
||||
(rx/of (dws/select-shapes shapes-ids)))
|
||||
(:group :bool :frame)
|
||||
(let [shapes-ids (into (d/ordered-set) shapes)]
|
||||
(rx/of (dws/select-shapes shapes-ids)))
|
||||
|
||||
:svg-raw
|
||||
nil
|
||||
:svg-raw
|
||||
nil
|
||||
|
||||
(rx/of (dwe/start-edition-mode id)
|
||||
(dwdp/start-path-edit id)))))))))
|
||||
(rx/of (dwe/start-edition-mode id)
|
||||
(dwdp/start-path-edit id))))))))))
|
||||
|
||||
(defn select-parent-layer
|
||||
[]
|
||||
|
|
Loading…
Add table
Reference in a new issue