🐛 Fix problem calculating selrect for certain paths

This commit is contained in:
alonso.torres 2024-01-30 18:02:25 +01:00
parent 02ab545cda
commit f6b182a3b5
2 changed files with 35 additions and 32 deletions

View file

@ -340,29 +340,31 @@
(grc/points->rect points)))) (grc/points->rect points))))
(defn content->selrect [content] (defn content->selrect [content]
(let [calc-extremities (let [extremities
(fn [command prev] (loop [points #{}
from-p nil
move-p nil
content (seq content)]
(if content
(let [command (first content)
to-p (command->point command)
[from-p move-p command-pts]
(case (:command command) (case (:command command)
:move-to [(command->point command)] :move-to [to-p to-p [to-p]]
:close-path [move-p move-p [move-p]]
;; If it's a line we add the beginning point and endpoint :line-to [to-p move-p [from-p to-p]]
:line-to [(command->point prev) :curve-to [to-p move-p
(command->point command)] (let [c1 (command->point command :c1)
c2 (command->point command :c2)
;; We return the bezier extremities curve [from-p to-p c1 c2]]
:curve-to (into [(command->point prev) (into [from-p to-p]
(command->point command)]
(let [curve [(command->point prev)
(command->point command)
(command->point command :c1)
(command->point command :c2)]]
(->> (curve-extremities curve) (->> (curve-extremities curve)
(map #(curve-values curve %))))) (map #(curve-values curve %)))))]
[])) [to-p move-p []])]
extremities (mapcat calc-extremities (recur (apply conj points command-pts) from-p move-p (next content)))
content points))]
(concat [nil] content))]
(grc/points->rect extremities))) (grc/points->rect extremities)))
(defn move-content [content move-vec] (defn move-content [content move-vec]

View file

@ -1013,6 +1013,7 @@
(d/ordered-set)))] (d/ordered-set)))]
(rx/of (dws/select-shapes shapes-to-select))) (rx/of (dws/select-shapes shapes-to-select)))
(when (d/not-empty? selected)
(let [{:keys [id type shapes]} (get objects (first selected))] (let [{:keys [id type shapes]} (get objects (first selected))]
(case type (case type
:text :text
@ -1026,7 +1027,7 @@
nil nil
(rx/of (dwe/start-edition-mode id) (rx/of (dwe/start-edition-mode id)
(dwdp/start-path-edit id))))))))) (dwdp/start-path-edit id))))))))))
(defn select-parent-layer (defn select-parent-layer
[] []