mirror of
https://github.com/penpot/penpot.git
synced 2025-05-31 11:56:12 +02:00
✨ Rename handler->point to get-handler-point
This commit is contained in:
parent
0e61398d67
commit
61c23877c1
6 changed files with 16 additions and 14 deletions
|
@ -102,7 +102,8 @@
|
|||
(->> (d/enumerate content)
|
||||
(filterv (fn [[_ segment]] (= (helpers/segment->point segment) point)))))
|
||||
|
||||
(defn handler->point
|
||||
(defn get-handler-point
|
||||
"Given a segment index and prefix, get a handler point"
|
||||
[content index prefix]
|
||||
(when (and (some? index)
|
||||
(some? prefix))
|
||||
|
@ -397,11 +398,12 @@
|
|||
(assoc :c2x (:x h2))
|
||||
(assoc :c2y (:y h2))))))))
|
||||
|
||||
;; FIXME: optimize
|
||||
(defn is-curve?
|
||||
[content point]
|
||||
(let [handlers (-> (content->handlers content)
|
||||
(get point))
|
||||
handler-points (map #(handler->point content (first %) (second %)) handlers)]
|
||||
handler-points (map #(get-handler-point content (first %) (second %)) handlers)]
|
||||
(some #(not= point %) handler-points)))
|
||||
|
||||
(def ^:private xf:mapcat-points
|
||||
|
|
|
@ -330,9 +330,9 @@
|
|||
expect2 (gpt/point 439.0 802.0)
|
||||
expect3 (gpt/point 480.0 839.0)
|
||||
|
||||
result4 (path.segment/handler->point content 3 :c1)
|
||||
result5 (path.segment/handler->point content 1 :c1)
|
||||
result6 (path.segment/handler->point content 0 :c1)]
|
||||
result4 (path.segment/get-handler-point content 3 :c1)
|
||||
result5 (path.segment/get-handler-point content 1 :c1)
|
||||
result6 (path.segment/get-handler-point content 0 :c1)]
|
||||
|
||||
(t/is (= result1 expect1))
|
||||
(t/is (= result2 expect2))
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
prefix (or prefix :c1)
|
||||
position (or position (path.helpers/segment->point (nth content (dec index))))
|
||||
|
||||
old-handler (path.segment/handler->point content index prefix)
|
||||
old-handler (path.segment/get-handler-point content index prefix)
|
||||
|
||||
handler-position (cond-> (gpt/point x y)
|
||||
shift? (path.helpers/position-fixed-angle position))
|
||||
|
|
|
@ -264,7 +264,7 @@
|
|||
handler (-> content (nth index) (path.segment/get-handler prefix))
|
||||
|
||||
[op-idx op-prefix] (path.segment/opposite-index content index prefix)
|
||||
opposite (path.segment/handler->point content op-idx op-prefix)]
|
||||
opposite (path.segment/get-handler-point content op-idx op-prefix)]
|
||||
|
||||
(streams/drag-stream
|
||||
(rx/concat
|
||||
|
|
|
@ -79,8 +79,8 @@
|
|||
[op-idx op-prefix] (path.segment/opposite-index content index prefix)
|
||||
|
||||
node (path.segment/handler->node content index prefix)
|
||||
handler (path.segment/handler->point content index prefix)
|
||||
opposite (path.segment/handler->point content op-idx op-prefix)
|
||||
handler (path.segment/get-handler-point content index prefix)
|
||||
opposite (path.segment/get-handler-point content op-idx op-prefix)
|
||||
|
||||
[ocx ocy] (path.helpers/prefix->coords op-prefix)
|
||||
[odx ody] (calculate-opposite-delta node handler opposite match-angle? match-distance? dx dy)
|
||||
|
|
|
@ -245,8 +245,8 @@
|
|||
(defn- matching-handler? [content node handlers]
|
||||
(when (= 2 (count handlers))
|
||||
(let [[[i1 p1] [i2 p2]] handlers
|
||||
p1 (path.segment/handler->point content i1 p1)
|
||||
p2 (path.segment/handler->point content i2 p2)
|
||||
p1 (path.segment/get-handler-point content i1 p1)
|
||||
p2 (path.segment/get-handler-point content i2 p2)
|
||||
|
||||
v1 (gpt/to-vec node p1)
|
||||
v2 (gpt/to-vec node p2)
|
||||
|
@ -360,9 +360,9 @@
|
|||
|
||||
show-handler?
|
||||
(fn [[index prefix]]
|
||||
;; FIXME: handler->point is executed twice for each
|
||||
;; FIXME: get-handler-point is executed twice for each
|
||||
;; render, this can be optimized
|
||||
(let [handler-position (path.segment/handler->point content index prefix)]
|
||||
(let [handler-position (path.segment/get-handler-point content index prefix)]
|
||||
(not= position handler-position)))
|
||||
|
||||
position-handlers
|
||||
|
@ -385,7 +385,7 @@
|
|||
[:g.path-node {:key (dm/str pos-x "-" pos-y)}
|
||||
[:g.point-handlers {:pointer-events (when (= edit-mode :draw) "none")}
|
||||
(for [[hindex prefix] position-handlers]
|
||||
(let [handler-position (path.segment/handler->point content hindex prefix)
|
||||
(let [handler-position (path.segment/get-handler-point content hindex prefix)
|
||||
handler-hover? (contains? hover-handlers [hindex prefix])
|
||||
moving-handler? (= handler-position moving-handler)
|
||||
matching-handler? (matching-handler? content position position-handlers)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue