mirror of
https://github.com/penpot/penpot.git
synced 2025-06-02 15:01:41 +02:00
♻️ Use new call convention for path drawing components
This commit is contained in:
parent
09c3490cae
commit
4f6dffabb4
5 changed files with 29 additions and 30 deletions
|
@ -204,7 +204,7 @@
|
||||||
angle (gpt/angle-with-other v1 v2)]
|
angle (gpt/angle-with-other v1 v2)]
|
||||||
(<= (- 180 angle) 0.1))))
|
(<= (- 180 angle) 0.1))))
|
||||||
|
|
||||||
(mf/defc path-editor
|
(mf/defc path-editor*
|
||||||
[{:keys [shape zoom]}]
|
[{:keys [shape zoom]}]
|
||||||
|
|
||||||
(let [editor-ref (mf/use-ref nil)
|
(let [editor-ref (mf/use-ref nil)
|
||||||
|
@ -261,11 +261,12 @@
|
||||||
[(->> selected-points (map base->point) (into #{}))
|
[(->> selected-points (map base->point) (into #{}))
|
||||||
(->> points (remove selected-points) (into #{}))])
|
(->> points (remove selected-points) (into #{}))])
|
||||||
|
|
||||||
show-snap? (and snap-toggled
|
show-snap?
|
||||||
(or (some? drag-handler)
|
(and snap-toggled
|
||||||
(some? preview)
|
(or (some? drag-handler)
|
||||||
(some? moving-handler)
|
(some? preview)
|
||||||
moving-nodes))
|
(some? moving-handler)
|
||||||
|
moving-nodes))
|
||||||
|
|
||||||
handle-double-click-outside
|
handle-double-click-outside
|
||||||
(fn [_]
|
(fn [_]
|
||||||
|
|
|
@ -501,7 +501,7 @@
|
||||||
:on-frame-select on-frame-select}])
|
:on-frame-select on-frame-select}])
|
||||||
|
|
||||||
(when show-draw-area?
|
(when show-draw-area?
|
||||||
[:& drawarea/draw-area
|
[:> drawarea/draw-area*
|
||||||
{:shape drawing-obj
|
{:shape drawing-obj
|
||||||
:zoom zoom
|
:zoom zoom
|
||||||
:tool drawing-tool}])
|
:tool drawing-tool}])
|
||||||
|
|
|
@ -11,29 +11,13 @@
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.main.ui.shapes.path :refer [path-shape]]
|
[app.main.ui.shapes.path :refer [path-shape]]
|
||||||
[app.main.ui.workspace.shapes :as shapes]
|
[app.main.ui.workspace.shapes :as shapes]
|
||||||
[app.main.ui.workspace.shapes.path.editor :refer [path-editor]]
|
[app.main.ui.workspace.shapes.path.editor :refer [path-editor*]]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(declare generic-draw-area)
|
(mf/defc generic-draw-area*
|
||||||
(declare path-draw-area)
|
{::mf/private true}
|
||||||
|
|
||||||
(mf/defc draw-area
|
|
||||||
[{:keys [shape zoom tool] :as props}]
|
|
||||||
|
|
||||||
;; Prevent rendering something that it's not a shape.
|
|
||||||
(when (cts/shape? shape)
|
|
||||||
[:g.draw-area
|
|
||||||
[:g {:style {:pointer-events "none"}}
|
|
||||||
[:& shapes/shape-wrapper {:shape shape}]]
|
|
||||||
|
|
||||||
(case tool
|
|
||||||
:path [:& path-editor {:shape shape :zoom zoom}]
|
|
||||||
:curve [:& path-shape {:shape shape :zoom zoom}]
|
|
||||||
#_:default [:& generic-draw-area {:shape shape :zoom zoom}])]))
|
|
||||||
|
|
||||||
(mf/defc generic-draw-area
|
|
||||||
[{:keys [shape zoom]}]
|
[{:keys [shape zoom]}]
|
||||||
(let [{:keys [x y width height]} (:selrect shape)]
|
(let [{:keys [x y width height]} (get shape :selrect)]
|
||||||
(when (and x y
|
(when (and x y
|
||||||
(not (mth/nan? x))
|
(not (mth/nan? x))
|
||||||
(not (mth/nan? y)))
|
(not (mth/nan? y)))
|
||||||
|
@ -45,3 +29,17 @@
|
||||||
:fill "none"
|
:fill "none"
|
||||||
:stroke-width (/ 1 zoom)}}])))
|
:stroke-width (/ 1 zoom)}}])))
|
||||||
|
|
||||||
|
(mf/defc draw-area*
|
||||||
|
[{:keys [shape zoom tool] :as props}]
|
||||||
|
|
||||||
|
;; Prevent rendering something that it's not a shape.
|
||||||
|
(when (cts/shape? shape)
|
||||||
|
[:g.draw-area
|
||||||
|
[:g {:style {:pointer-events "none"}}
|
||||||
|
[:& shapes/shape-wrapper {:shape shape}]]
|
||||||
|
|
||||||
|
(case tool
|
||||||
|
:path [:> path-editor* props]
|
||||||
|
:curve [:& path-shape {:shape shape :zoom zoom}]
|
||||||
|
#_:default [:> generic-draw-area* props])]))
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.context :as ctx]
|
[app.main.ui.context :as ctx]
|
||||||
[app.main.ui.css-cursors :as cur]
|
[app.main.ui.css-cursors :as cur]
|
||||||
[app.main.ui.workspace.shapes.path.editor :refer [path-editor]]
|
[app.main.ui.workspace.shapes.path.editor :refer [path-editor*]]
|
||||||
[app.util.array :as array]
|
[app.util.array :as array]
|
||||||
[app.util.debug :as dbg]
|
[app.util.debug :as dbg]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
|
@ -603,7 +603,7 @@
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(= edition shape-id)
|
(= edition shape-id)
|
||||||
[:& path-editor
|
[:> path-editor*
|
||||||
{:zoom zoom
|
{:zoom zoom
|
||||||
:shape shape}]
|
:shape shape}]
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,7 @@
|
||||||
:on-frame-select on-frame-select}])
|
:on-frame-select on-frame-select}])
|
||||||
|
|
||||||
(when show-draw-area?
|
(when show-draw-area?
|
||||||
[:& drawarea/draw-area
|
[:> drawarea/draw-area*
|
||||||
{:shape drawing-obj
|
{:shape drawing-obj
|
||||||
:zoom zoom
|
:zoom zoom
|
||||||
:tool drawing-tool}])
|
:tool drawing-tool}])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue