mirror of
https://github.com/penpot/penpot.git
synced 2025-05-04 01:15:53 +02:00
⚡ Improve interactions and after-review fixes
This commit is contained in:
parent
c28a2acfc7
commit
493a7680e0
5 changed files with 51 additions and 25 deletions
|
@ -15,12 +15,16 @@
|
||||||
|
|
||||||
(defn calc-bool-content
|
(defn calc-bool-content
|
||||||
[shape objects]
|
[shape objects]
|
||||||
(->> (:shapes shape)
|
|
||||||
(map (d/getf objects))
|
(let [extract-content-xf
|
||||||
(filter (comp not :hidden))
|
(comp (map (d/getf objects))
|
||||||
(map #(stp/convert-to-path % objects))
|
(filter (comp not :hidden))
|
||||||
(mapv :content)
|
(map #(stp/convert-to-path % objects))
|
||||||
(pb/content-bool (:bool-type shape))))
|
(map :content))
|
||||||
|
|
||||||
|
shapes-content
|
||||||
|
(into [] extract-content-xf (:shapes shape))]
|
||||||
|
(pb/content-bool (:bool-type shape) shapes-content)))
|
||||||
|
|
||||||
(defn update-bool-selrect
|
(defn update-bool-selrect
|
||||||
"Calculates the selrect+points for the boolean shape"
|
"Calculates the selrect+points for the boolean shape"
|
||||||
|
|
|
@ -116,6 +116,14 @@
|
||||||
:show-distances?])
|
:show-distances?])
|
||||||
workspace-local =))
|
workspace-local =))
|
||||||
|
|
||||||
|
(def interactions-data
|
||||||
|
(l/derived #(select-keys % [:editing-interaction-index
|
||||||
|
:draw-interaction-to
|
||||||
|
:draw-interaction-to-frame
|
||||||
|
:move-overlay-to
|
||||||
|
:move-overlay-index])
|
||||||
|
workspace-local =))
|
||||||
|
|
||||||
(def local-displacement
|
(def local-displacement
|
||||||
(l/derived #(select-keys % [:modifiers :selected])
|
(l/derived #(select-keys % [:modifiers :selected])
|
||||||
workspace-local =))
|
workspace-local =))
|
||||||
|
@ -235,9 +243,8 @@
|
||||||
[ids]
|
[ids]
|
||||||
(let [selector
|
(let [selector
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
(let [objects (wsh/lookup-page-objects state)]
|
||||||
xform (comp (map (d/getf objects)) (remove nil?))]
|
(into [] (keep (d/getf objects)) ids)))]
|
||||||
(into [] xform ids)))]
|
|
||||||
(l/derived selector st/state =)))
|
(l/derived selector st/state =)))
|
||||||
|
|
||||||
(defn- set-content-modifiers [state]
|
(defn- set-content-modifiers [state]
|
||||||
|
|
|
@ -46,10 +46,17 @@
|
||||||
(rx/subs #(reset! buffer (vec %))))
|
(rx/subs #(reset! buffer (vec %))))
|
||||||
buffer))
|
buffer))
|
||||||
|
|
||||||
(def emit! (partial ptk/emit! state))
|
(defn emit!
|
||||||
|
([] nil)
|
||||||
|
([event]
|
||||||
|
(ptk/emit! state event)
|
||||||
|
nil)
|
||||||
|
([event & events]
|
||||||
|
(apply ptk/emit! state (cons event events))
|
||||||
|
nil))
|
||||||
|
|
||||||
(defn emitf
|
(defn emitf
|
||||||
[& events]
|
[& events]
|
||||||
#(ptk/emit! state events))
|
#(apply ptk/emit! state events))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,7 @@
|
||||||
drawing-tool (:tool drawing)
|
drawing-tool (:tool drawing)
|
||||||
drawing-obj (:object drawing)
|
drawing-obj (:object drawing)
|
||||||
|
|
||||||
xf-select-shape (comp (map (d/getf objects-modified)) (filter some?))
|
selected-shapes (into [] (keep (d/getf objects-modified)) selected)
|
||||||
selected-shapes (into [] xf-select-shape selected)
|
|
||||||
selected-frames (into #{} (map :frame-id) selected-shapes)
|
selected-frames (into #{} (map :frame-id) selected-shapes)
|
||||||
|
|
||||||
;; Only when we have all the selected shapes in one frame
|
;; Only when we have all the selected shapes in one frame
|
||||||
|
@ -329,6 +328,9 @@
|
||||||
(when show-prototypes?
|
(when show-prototypes?
|
||||||
[:& interactions/interactions
|
[:& interactions/interactions
|
||||||
{:selected selected
|
{:selected selected
|
||||||
|
:zoom zoom
|
||||||
|
:objects objects-modified
|
||||||
|
:current-transform transform
|
||||||
:hover-disabled? hover-disabled?}])
|
:hover-disabled? hover-disabled?}])
|
||||||
|
|
||||||
(when show-selrect?
|
(when show-selrect?
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"Visually show shape interactions in workspace"
|
"Visually show shape interactions in workspace"
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.types.interactions :as cti]
|
[app.common.types.interactions :as cti]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
|
@ -235,18 +236,23 @@
|
||||||
:fill "var(--color-primary)"}]]))))
|
:fill "var(--color-primary)"}]]))))
|
||||||
|
|
||||||
(mf/defc interactions
|
(mf/defc interactions
|
||||||
[{:keys [selected hover-disabled?] :as props}]
|
[{:keys [current-transform objects zoom selected hover-disabled?] :as props}]
|
||||||
(let [local (mf/deref refs/workspace-local)
|
(let [active-shapes (into []
|
||||||
zoom (mf/deref refs/selected-zoom)
|
(comp (filter #(seq (:interactions %)))
|
||||||
current-transform (:transform local)
|
(map gsh/transform-shape))
|
||||||
objects (mf/deref refs/workspace-page-objects)
|
(vals objects))
|
||||||
active-shapes (filter #(seq (:interactions %)) (vals objects))
|
|
||||||
selected-shapes (map #(get objects %) selected)
|
selected-shapes (into []
|
||||||
editing-interaction-index (:editing-interaction-index local)
|
(comp (map (d/getf objects))
|
||||||
draw-interaction-to (:draw-interaction-to local)
|
(map gsh/transform-shape))
|
||||||
draw-interaction-to-frame (:draw-interaction-to-frame local)
|
selected)
|
||||||
move-overlay-to (:move-overlay-to local)
|
|
||||||
move-overlay-index (:move-overlay-index local)
|
{:keys [editing-interaction-index
|
||||||
|
draw-interaction-to
|
||||||
|
draw-interaction-to-frame
|
||||||
|
move-overlay-to
|
||||||
|
move-overlay-index]} (mf/deref refs/interactions-data)
|
||||||
|
|
||||||
first-selected (first selected-shapes)
|
first-selected (first selected-shapes)
|
||||||
|
|
||||||
calc-level (fn [index interactions]
|
calc-level (fn [index interactions]
|
||||||
|
|
Loading…
Add table
Reference in a new issue