mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 07:56:10 +02:00
🐛 Minor improvements on refs
This commit is contained in:
parent
7446fe77b3
commit
d85a4d6539
7 changed files with 84 additions and 38 deletions
|
@ -219,3 +219,13 @@
|
||||||
e' (/ (- (* c f) (* d e)) det)
|
e' (/ (- (* c f) (* d e)) det)
|
||||||
f' (/ (- (* b e) (* a f)) det)]
|
f' (/ (- (* b e) (* a f)) det)]
|
||||||
(Matrix. a' b' c' d' e' f')))
|
(Matrix. a' b' c' d' e' f')))
|
||||||
|
|
||||||
|
(defn round
|
||||||
|
[mtx]
|
||||||
|
(-> mtx
|
||||||
|
(update :a mth/precision 4)
|
||||||
|
(update :b mth/precision 4)
|
||||||
|
(update :c mth/precision 4)
|
||||||
|
(update :d mth/precision 4)
|
||||||
|
(update :e mth/precision 4)
|
||||||
|
(update :f mth/precision 4)))
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.pages.helpers :as cph]))
|
[app.common.geom.shapes :as gsh]
|
||||||
|
[app.common.pages.helpers :as cph]
|
||||||
|
[app.common.path.commands :as upc]))
|
||||||
|
|
||||||
(defn lookup-page
|
(defn lookup-page
|
||||||
([state]
|
([state]
|
||||||
|
@ -50,6 +52,10 @@
|
||||||
(filter selectable?)
|
(filter selectable?)
|
||||||
selected)))))
|
selected)))))
|
||||||
|
|
||||||
|
(defn lookup-selected-raw
|
||||||
|
[state]
|
||||||
|
(dm/get-in state [:workspace-local :selected]))
|
||||||
|
|
||||||
(defn lookup-selected
|
(defn lookup-selected
|
||||||
([state]
|
([state]
|
||||||
(lookup-selected state nil))
|
(lookup-selected state nil))
|
||||||
|
@ -94,3 +100,26 @@
|
||||||
(-> (:workspace-libraries state)
|
(-> (:workspace-libraries state)
|
||||||
(assoc id {:id id
|
(assoc id {:id id
|
||||||
:data local}))))
|
:data local}))))
|
||||||
|
|
||||||
|
(defn- set-content-modifiers [state]
|
||||||
|
(fn [id shape]
|
||||||
|
(let [content-modifiers (dm/get-in state [:workspace-local :edit-path id :content-modifiers])]
|
||||||
|
(if (some? content-modifiers)
|
||||||
|
(update shape :content upc/apply-content-modifiers content-modifiers)
|
||||||
|
shape))))
|
||||||
|
|
||||||
|
(defn select-bool-children
|
||||||
|
[parent-id state]
|
||||||
|
(let [objects (lookup-page-objects state)
|
||||||
|
selected (lookup-selected-raw state)
|
||||||
|
modifiers (:workspace-modifiers state)
|
||||||
|
|
||||||
|
children-ids (cph/get-children-ids objects parent-id)
|
||||||
|
selected-children (into [] (filter selected) children-ids)
|
||||||
|
|
||||||
|
modifiers (select-keys modifiers selected-children)
|
||||||
|
children (select-keys objects children-ids)]
|
||||||
|
|
||||||
|
(as-> children $
|
||||||
|
(gsh/merge-modifiers $ modifiers)
|
||||||
|
(d/mapm (set-content-modifiers state) $))))
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.shapes :as gsh]
|
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.path.commands :as upc]
|
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[okulary.core :as l]))
|
[okulary.core :as l]))
|
||||||
|
@ -193,28 +191,29 @@
|
||||||
(assoc :pages (:pages data)))))
|
(assoc :pages (:pages data)))))
|
||||||
st/state =))
|
st/state =))
|
||||||
|
|
||||||
|
(def workspace-data
|
||||||
|
(l/derived :workspace-data st/state))
|
||||||
|
|
||||||
(def workspace-file-colors
|
(def workspace-file-colors
|
||||||
(l/derived (fn [state]
|
(l/derived (fn [data]
|
||||||
(when-let [file (:workspace-data state)]
|
(when data
|
||||||
(->> (:colors file)
|
(->> (:colors data)
|
||||||
(d/mapm #(assoc %2 :file-id (:id file))))))
|
(d/mapm #(assoc %2 :file-id (:id data))))))
|
||||||
st/state))
|
workspace-data
|
||||||
|
=))
|
||||||
|
|
||||||
(def workspace-recent-colors
|
(def workspace-recent-colors
|
||||||
(l/derived (fn [state]
|
(l/derived (fn [data]
|
||||||
(dm/get-in state [:workspace-data :recent-colors] []))
|
(get data :recent-colors []))
|
||||||
st/state))
|
workspace-data))
|
||||||
|
|
||||||
(def workspace-recent-fonts
|
(def workspace-recent-fonts
|
||||||
(l/derived (fn [state]
|
(l/derived (fn [data]
|
||||||
(dm/get-in state [:workspace-data :recent-fonts] []))
|
(get data :workspace-data []))
|
||||||
st/state))
|
workspace-data))
|
||||||
|
|
||||||
(def workspace-file-typography
|
(def workspace-file-typography
|
||||||
(l/derived (fn [state]
|
(l/derived :typographies workspace-data))
|
||||||
(when-let [file (:workspace-data state)]
|
|
||||||
(:typographies file)))
|
|
||||||
st/state))
|
|
||||||
|
|
||||||
(def workspace-project
|
(def workspace-project
|
||||||
(l/derived :workspace-project st/state))
|
(l/derived :workspace-project st/state))
|
||||||
|
@ -313,24 +312,8 @@
|
||||||
workspace-modifiers-with-objects
|
workspace-modifiers-with-objects
|
||||||
=))
|
=))
|
||||||
|
|
||||||
(defn- set-content-modifiers [state]
|
|
||||||
(fn [id shape]
|
|
||||||
(let [content-modifiers (dm/get-in state [:workspace-local :edit-path id :content-modifiers])]
|
|
||||||
(if (some? content-modifiers)
|
|
||||||
(update shape :content upc/apply-content-modifiers content-modifiers)
|
|
||||||
shape))))
|
|
||||||
|
|
||||||
(defn select-bool-children [id]
|
(defn select-bool-children [id]
|
||||||
(let [selector
|
(l/derived (partial wsh/select-bool-children id) st/state =))
|
||||||
(fn [state]
|
|
||||||
(let [objects (wsh/lookup-page-objects state)
|
|
||||||
modifiers (:workspace-modifiers state)
|
|
||||||
children (->> (cph/get-children-ids objects id)
|
|
||||||
(select-keys objects))]
|
|
||||||
(as-> children $
|
|
||||||
(gsh/merge-modifiers $ modifiers)
|
|
||||||
(d/mapm (set-content-modifiers state) $))))]
|
|
||||||
(l/derived selector st/state =)))
|
|
||||||
|
|
||||||
(def selected-data
|
(def selected-data
|
||||||
(l/derived #(let [selected (wsh/lookup-selected %)
|
(l/derived #(let [selected (wsh/lookup-selected %)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
(ns app.main.ui.shapes.filters
|
(ns app.main.ui.shapes.filters
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
@ -249,6 +250,7 @@
|
||||||
:height filter-height
|
:height filter-height
|
||||||
:filterUnits "objectBoundingBox"
|
:filterUnits "objectBoundingBox"
|
||||||
:color-interpolation-filters "sRGB"}
|
:color-interpolation-filters "sRGB"}
|
||||||
(for [entry filters]
|
(for [[index entry] (d/enumerate filters)]
|
||||||
[:& filter-entry {:entry entry}])])))
|
[:& filter-entry {:key (dm/str filter-id "-" index)
|
||||||
|
:entry entry}])])))
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
|
|
||||||
;; These position attributes are not really necesary but they are convenient for for the export
|
;; These position attributes are not really necesary but they are convenient for for the export
|
||||||
group-props (-> #js {:transform transform
|
group-props (-> #js {:transform transform
|
||||||
|
:className "text-container"
|
||||||
:x x
|
:x x
|
||||||
:y y
|
:y y
|
||||||
:width width
|
:width width
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
(let [shape-node (dom/query base-node (str "#shape-" id))
|
(let [shape-node (dom/query base-node (str "#shape-" id))
|
||||||
|
|
||||||
frame? (= :frame type)
|
frame? (= :frame type)
|
||||||
|
text? (= :text type)
|
||||||
group? (= :group type)
|
group? (= :group type)
|
||||||
mask? (and group? masked-group?)]
|
mask? (and group? masked-group?)]
|
||||||
|
|
||||||
|
@ -103,6 +104,10 @@
|
||||||
(dom/query-all shape-defs ".svg-def")
|
(dom/query-all shape-defs ".svg-def")
|
||||||
(dom/query-all shape-defs ".svg-mask-wrapper")))
|
(dom/query-all shape-defs ".svg-mask-wrapper")))
|
||||||
|
|
||||||
|
text?
|
||||||
|
[shape-node
|
||||||
|
(dom/query shape-node ".text-container")]
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[shape-node])))
|
[shape-node])))
|
||||||
|
|
||||||
|
@ -161,6 +166,10 @@
|
||||||
(str value))]
|
(str value))]
|
||||||
(dom/set-attribute! node att (str new-value))))
|
(dom/set-attribute! node att (str new-value))))
|
||||||
|
|
||||||
|
(defn override-transform-att!
|
||||||
|
[node att value]
|
||||||
|
(dom/set-attribute! node att (str value)))
|
||||||
|
|
||||||
(defn update-transform!
|
(defn update-transform!
|
||||||
[base-node shapes transforms modifiers]
|
[base-node shapes transforms modifiers]
|
||||||
(doseq [{:keys [id] :as shape} shapes]
|
(doseq [{:keys [id] :as shape} shapes]
|
||||||
|
@ -179,6 +188,17 @@
|
||||||
(dom/class? node "frame-children")
|
(dom/class? node "frame-children")
|
||||||
(set-transform-att! node "transform" (gmt/inverse transform))
|
(set-transform-att! node "transform" (gmt/inverse transform))
|
||||||
|
|
||||||
|
;; We need to update the shape transform matrix when there is a resize
|
||||||
|
;; we do it dinamicaly here
|
||||||
|
(dom/class? node "text-container")
|
||||||
|
(let [modifiers (dissoc modifiers :displacement :rotation)]
|
||||||
|
(when (not (gsh/empty-modifiers? modifiers))
|
||||||
|
(let [mtx (-> shape
|
||||||
|
(assoc :modifiers modifiers)
|
||||||
|
(gsh/transform-shape)
|
||||||
|
(gsh/transform-matrix {:no-flip true}))]
|
||||||
|
(override-transform-att! node "transform" mtx))))
|
||||||
|
|
||||||
(or (= (dom/get-tag-name node) "mask")
|
(or (= (dom/get-tag-name node) "mask")
|
||||||
(= (dom/get-tag-name node) "filter"))
|
(= (dom/get-tag-name node) "filter"))
|
||||||
(transform-region! node modifiers)
|
(transform-region! node modifiers)
|
||||||
|
|
|
@ -166,7 +166,8 @@
|
||||||
(:name frame)]]))
|
(:name frame)]]))
|
||||||
|
|
||||||
(mf/defc frame-titles
|
(mf/defc frame-titles
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false
|
||||||
|
::mf/wrap [mf/memo]}
|
||||||
[props]
|
[props]
|
||||||
(let [objects (unchecked-get props "objects")
|
(let [objects (unchecked-get props "objects")
|
||||||
zoom (unchecked-get props "zoom")
|
zoom (unchecked-get props "zoom")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue