mirror of
https://github.com/penpot/penpot.git
synced 2025-06-16 14:31:39 +02:00
commit
cda2dade95
11 changed files with 168 additions and 95 deletions
|
@ -317,11 +317,20 @@
|
||||||
modif-tree)))
|
modif-tree)))
|
||||||
|
|
||||||
(defn set-objects-modifiers
|
(defn set-objects-modifiers
|
||||||
[modif-tree objects ignore-constraints snap-pixel?]
|
([modif-tree objects ignore-constraints snap-pixel?]
|
||||||
|
(set-objects-modifiers nil modif-tree objects ignore-constraints snap-pixel?))
|
||||||
|
|
||||||
(let [objects (apply-structure-modifiers objects modif-tree)
|
([old-modif-tree modif-tree objects ignore-constraints snap-pixel?]
|
||||||
|
(let [objects (-> objects
|
||||||
|
(cond-> (some? old-modif-tree)
|
||||||
|
(apply-structure-modifiers old-modif-tree))
|
||||||
|
(apply-structure-modifiers modif-tree))
|
||||||
|
|
||||||
bounds (d/lazy-map (keys objects) #(dm/get-in objects [% :points]))
|
bounds (d/lazy-map (keys objects) #(dm/get-in objects [% :points]))
|
||||||
|
bounds (cond-> bounds
|
||||||
|
(some? old-modif-tree)
|
||||||
|
(transform-bounds objects old-modif-tree))
|
||||||
|
|
||||||
shapes-tree (resolve-tree-sequence (-> modif-tree keys set) objects)
|
shapes-tree (resolve-tree-sequence (-> modif-tree keys set) objects)
|
||||||
|
|
||||||
;; Calculate the input transformation and constraints
|
;; Calculate the input transformation and constraints
|
||||||
|
@ -340,10 +349,15 @@
|
||||||
(-> modif-tree
|
(-> modif-tree
|
||||||
(sizing-auto-modifiers sizing-auto-layouts objects bounds ignore-constraints))
|
(sizing-auto-modifiers sizing-auto-layouts objects bounds ignore-constraints))
|
||||||
|
|
||||||
|
modif-tree
|
||||||
|
(if old-modif-tree
|
||||||
|
(merge-modif-tree old-modif-tree modif-tree)
|
||||||
|
modif-tree)
|
||||||
|
|
||||||
modif-tree
|
modif-tree
|
||||||
(cond-> modif-tree
|
(cond-> modif-tree
|
||||||
snap-pixel? (gpp/adjust-pixel-precision objects))]
|
snap-pixel? (gpp/adjust-pixel-precision objects))]
|
||||||
|
|
||||||
;;#?(:cljs
|
;;#?(:cljs
|
||||||
;; (.log js/console ">result" (modif->js modif-tree objects)))
|
;; (.log js/console ">result" (modif->js modif-tree objects)))
|
||||||
modif-tree))
|
modif-tree)))
|
||||||
|
|
|
@ -111,10 +111,10 @@
|
||||||
(cond-> (some? transform)
|
(cond-> (some? transform)
|
||||||
(gmt/multiply transform))
|
(gmt/multiply transform))
|
||||||
|
|
||||||
(cond-> (and flip-x (not no-flip))
|
(cond-> (and flip-x no-flip)
|
||||||
(gmt/scale (gpt/point -1 1)))
|
(gmt/scale (gpt/point -1 1)))
|
||||||
|
|
||||||
(cond-> (and flip-y (not no-flip))
|
(cond-> (and flip-y no-flip)
|
||||||
(gmt/scale (gpt/point 1 -1)))
|
(gmt/scale (gpt/point 1 -1)))
|
||||||
|
|
||||||
(gmt/translate (gpt/negate shape-center)))))
|
(gmt/translate (gpt/negate shape-center)))))
|
||||||
|
@ -126,8 +126,8 @@
|
||||||
([{:keys [transform flip-x flip-y] :as shape} {:keys [no-flip] :as params}]
|
([{:keys [transform flip-x flip-y] :as shape} {:keys [no-flip] :as params}]
|
||||||
(if (and (some? shape)
|
(if (and (some? shape)
|
||||||
(or (some? transform)
|
(or (some? transform)
|
||||||
(and (not no-flip) flip-x)
|
(and no-flip flip-x)
|
||||||
(and (not no-flip) flip-y)))
|
(and no-flip flip-y)))
|
||||||
(dm/str (transform-matrix shape params))
|
(dm/str (transform-matrix shape params))
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
funcool/beicon {:mvn/version "2021.07.05-1"}
|
funcool/beicon {:mvn/version "2021.07.05-1"}
|
||||||
funcool/okulary {:mvn/version "2022.04.11-16"}
|
funcool/okulary {:mvn/version "2022.04.11-16"}
|
||||||
funcool/potok {:mvn/version "2022.04.28-67"}
|
funcool/potok {:mvn/version "2022.12.16-71"}
|
||||||
funcool/tubax {:mvn/version "2021.05.20-0"}
|
funcool/tubax {:mvn/version "2021.05.20-0"}
|
||||||
|
|
||||||
funcool/rumext
|
funcool/rumext
|
||||||
|
|
|
@ -190,9 +190,7 @@
|
||||||
[(get-in objects [k :name]) v]))
|
[(get-in objects [k :name]) v]))
|
||||||
modif-tree)))
|
modif-tree)))
|
||||||
|
|
||||||
(defn apply-text-modifiers
|
(defn apply-text-modifier
|
||||||
[objects text-modifiers]
|
|
||||||
(letfn [(apply-text-modifier
|
|
||||||
[shape {:keys [width height]}]
|
[shape {:keys [width height]}]
|
||||||
(cond-> shape
|
(cond-> shape
|
||||||
(some? width)
|
(some? width)
|
||||||
|
@ -202,14 +200,17 @@
|
||||||
(assoc :height height)
|
(assoc :height height)
|
||||||
|
|
||||||
(or (some? width) (some? height))
|
(or (some? width) (some? height))
|
||||||
(cts/setup-rect-selrect)))]
|
(cts/setup-rect-selrect)))
|
||||||
|
|
||||||
|
(defn apply-text-modifiers
|
||||||
|
[objects text-modifiers]
|
||||||
(loop [modifiers (seq text-modifiers)
|
(loop [modifiers (seq text-modifiers)
|
||||||
result objects]
|
result objects]
|
||||||
(if (empty? modifiers)
|
(if (empty? modifiers)
|
||||||
result
|
result
|
||||||
(let [[id text-modifier] (first modifiers)]
|
(let [[id text-modifier] (first modifiers)]
|
||||||
(recur (rest modifiers)
|
(recur (rest modifiers)
|
||||||
(update objects id apply-text-modifier text-modifier)))))))
|
(update objects id apply-text-modifier text-modifier))))))
|
||||||
|
|
||||||
#_(defn apply-path-modifiers
|
#_(defn apply-path-modifiers
|
||||||
[objects path-modifiers]
|
[objects path-modifiers]
|
||||||
|
@ -242,6 +243,33 @@
|
||||||
;;(apply-path-modifiers $ (get-in state [:workspace-local :edit-path]))
|
;;(apply-path-modifiers $ (get-in state [:workspace-local :edit-path]))
|
||||||
(gsh/set-objects-modifiers modif-tree $ ignore-constraints snap-pixel?)))))
|
(gsh/set-objects-modifiers modif-tree $ ignore-constraints snap-pixel?)))))
|
||||||
|
|
||||||
|
(defn- calculate-update-modifiers
|
||||||
|
[old-modif-tree state ignore-constraints ignore-snap-pixel modif-tree]
|
||||||
|
(let [objects
|
||||||
|
(wsh/lookup-page-objects state)
|
||||||
|
|
||||||
|
snap-pixel?
|
||||||
|
(and (not ignore-snap-pixel) (contains? (:workspace-layout state) :snap-pixel-grid))
|
||||||
|
|
||||||
|
objects
|
||||||
|
(-> objects
|
||||||
|
(apply-text-modifiers (get state :workspace-text-modifier)))]
|
||||||
|
|
||||||
|
(gsh/set-objects-modifiers old-modif-tree modif-tree objects ignore-constraints snap-pixel?)))
|
||||||
|
|
||||||
|
(defn update-modifiers
|
||||||
|
([modif-tree]
|
||||||
|
(update-modifiers modif-tree false))
|
||||||
|
|
||||||
|
([modif-tree ignore-constraints]
|
||||||
|
(update-modifiers modif-tree ignore-constraints false))
|
||||||
|
|
||||||
|
([modif-tree ignore-constraints ignore-snap-pixel]
|
||||||
|
(ptk/reify ::update-modifiers
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(update state :workspace-modifiers calculate-update-modifiers state ignore-constraints ignore-snap-pixel modif-tree)))))
|
||||||
|
|
||||||
(defn set-modifiers
|
(defn set-modifiers
|
||||||
([modif-tree]
|
([modif-tree]
|
||||||
(set-modifiers modif-tree false))
|
(set-modifiers modif-tree false))
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
(declare persist-changes)
|
(declare persist-changes)
|
||||||
(declare persist-synchronous-changes)
|
(declare persist-synchronous-changes)
|
||||||
(declare shapes-changes-persisted)
|
(declare shapes-changes-persisted)
|
||||||
|
(declare shapes-changes-persisted-finished)
|
||||||
(declare update-persistence-status)
|
(declare update-persistence-status)
|
||||||
|
|
||||||
;; --- Persistence
|
;; --- Persistence
|
||||||
|
@ -42,6 +43,7 @@
|
||||||
(log/debug :hint "initialize persistence")
|
(log/debug :hint "initialize persistence")
|
||||||
(let [stoper (rx/filter (ptk/type? ::initialize-persistence) stream)
|
(let [stoper (rx/filter (ptk/type? ::initialize-persistence) stream)
|
||||||
commits (l/atom [])
|
commits (l/atom [])
|
||||||
|
saving? (l/atom false)
|
||||||
|
|
||||||
local-file?
|
local-file?
|
||||||
#(as-> (:file-id %) event-file-id
|
#(as-> (:file-id %) event-file-id
|
||||||
|
@ -61,13 +63,15 @@
|
||||||
|
|
||||||
on-saving
|
on-saving
|
||||||
(fn []
|
(fn []
|
||||||
|
(reset! saving? true)
|
||||||
(st/emit! (update-persistence-status {:status :saving})))
|
(st/emit! (update-persistence-status {:status :saving})))
|
||||||
|
|
||||||
on-saved
|
on-saved
|
||||||
(fn []
|
(fn []
|
||||||
;; Disable reload stoper
|
;; Disable reload stoper
|
||||||
(swap! st/ongoing-tasks disj :workspace-change)
|
(swap! st/ongoing-tasks disj :workspace-change)
|
||||||
(st/emit! (update-persistence-status {:status :saved})))]
|
(st/emit! (update-persistence-status {:status :saved}))
|
||||||
|
(reset! saving? false))]
|
||||||
|
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> stream
|
(->> stream
|
||||||
|
@ -88,12 +92,15 @@
|
||||||
|
|
||||||
(->> (rx/from-atom commits)
|
(->> (rx/from-atom commits)
|
||||||
(rx/filter (complement empty?))
|
(rx/filter (complement empty?))
|
||||||
(rx/sample-when (rx/merge
|
(rx/sample-when
|
||||||
|
(->> (rx/merge
|
||||||
(rx/interval 5000)
|
(rx/interval 5000)
|
||||||
(rx/filter #(= ::force-persist %) stream)
|
(rx/filter #(= ::force-persist %) stream)
|
||||||
(->> (rx/from-atom commits)
|
(->> (rx/from-atom commits)
|
||||||
(rx/filter (complement empty?))
|
(rx/filter (complement empty?))
|
||||||
(rx/debounce 2000))))
|
(rx/debounce 2000)))
|
||||||
|
;; Not sample while saving so there are no race conditions
|
||||||
|
(rx/filter #(not @saving?))))
|
||||||
(rx/tap #(reset! commits []))
|
(rx/tap #(reset! commits []))
|
||||||
(rx/tap on-saving)
|
(rx/tap on-saving)
|
||||||
(rx/mapcat (fn [changes]
|
(rx/mapcat (fn [changes]
|
||||||
|
@ -101,9 +108,11 @@
|
||||||
;; next persistence before this one is
|
;; next persistence before this one is
|
||||||
;; finished.
|
;; finished.
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(rx/of (persist-changes file-id changes))
|
(->> (rx/of (persist-changes file-id changes commits))
|
||||||
|
(rx/observe-on :async))
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter (ptk/type? ::changes-persisted))
|
;; We wait for every change to be persisted
|
||||||
|
(rx/filter (ptk/type? ::shapes-changes-persisted-finished))
|
||||||
(rx/take 1)
|
(rx/take 1)
|
||||||
(rx/tap on-saved)
|
(rx/tap on-saved)
|
||||||
(rx/ignore)))))
|
(rx/ignore)))))
|
||||||
|
@ -123,7 +132,7 @@
|
||||||
(log/debug :hint "finalize persistence: synchronous save loop")))))))))
|
(log/debug :hint "finalize persistence: synchronous save loop")))))))))
|
||||||
|
|
||||||
(defn persist-changes
|
(defn persist-changes
|
||||||
[file-id changes]
|
[file-id changes pending-commits]
|
||||||
(log/debug :hint "persist changes" :changes (count changes))
|
(log/debug :hint "persist changes" :changes (count changes))
|
||||||
(us/verify ::us/uuid file-id)
|
(us/verify ::us/uuid file-id)
|
||||||
(ptk/reify ::persist-changes
|
(ptk/reify ::persist-changes
|
||||||
|
@ -150,20 +159,29 @@
|
||||||
(log/debug :hint "changes persisted" :lagged (count lagged))
|
(log/debug :hint "changes persisted" :lagged (count lagged))
|
||||||
(let [frame-updates
|
(let [frame-updates
|
||||||
(-> (group-by :page-id changes)
|
(-> (group-by :page-id changes)
|
||||||
(update-vals #(into #{} (mapcat :frames) %)))]
|
(update-vals #(into #{} (mapcat :frames) %)))
|
||||||
|
|
||||||
|
commits
|
||||||
|
(->> @pending-commits
|
||||||
|
(map #(assoc % :revn (:revn file))))]
|
||||||
|
|
||||||
|
(rx/concat
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(->> (rx/from frame-updates)
|
(->> (rx/from frame-updates)
|
||||||
(rx/mapcat (fn [[page-id frames]]
|
(rx/mapcat (fn [[page-id frames]]
|
||||||
(->> frames (map #(vector page-id %)))))
|
(->> frames (map #(vector page-id %)))))
|
||||||
(rx/map (fn [[page-id frame-id]] (dwt/update-thumbnail (:id file) page-id frame-id))))
|
(rx/map (fn [[page-id frame-id]] (dwt/update-thumbnail (:id file) page-id frame-id))))
|
||||||
(->> (rx/from lagged)
|
|
||||||
(rx/merge-map (fn [{:keys [changes] :as entry}]
|
(->> (rx/from (concat lagged commits))
|
||||||
|
(rx/merge-map
|
||||||
|
(fn [{:keys [changes] :as entry}]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(rx/from
|
(rx/from
|
||||||
(for [[page-id changes] (group-by :page-id changes)]
|
(for [[page-id changes] (group-by :page-id changes)]
|
||||||
(dch/update-indices page-id changes)))
|
(dch/update-indices page-id changes)))
|
||||||
(rx/of (shapes-changes-persisted file-id entry))))))))))
|
(rx/of (shapes-changes-persisted file-id entry)))))))
|
||||||
|
|
||||||
|
(rx/of (shapes-changes-persisted-finished))))))
|
||||||
(rx/catch (fn [cause]
|
(rx/catch (fn [cause]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(if (= :authentication (:type cause))
|
(if (= :authentication (:type cause))
|
||||||
|
@ -171,6 +189,11 @@
|
||||||
(rx/of (rt/assign-exception cause)))
|
(rx/of (rt/assign-exception cause)))
|
||||||
(rx/throw cause))))))))))
|
(rx/throw cause))))))))))
|
||||||
|
|
||||||
|
;; Event to be thrown after the changes have been persisted
|
||||||
|
(defn shapes-changes-persisted-finished
|
||||||
|
[]
|
||||||
|
(ptk/reify ::shapes-changes-persisted-finished))
|
||||||
|
|
||||||
(defn persist-synchronous-changes
|
(defn persist-synchronous-changes
|
||||||
[{:keys [file-id changes]}]
|
[{:keys [file-id changes]}]
|
||||||
(us/verify ::us/uuid file-id)
|
(us/verify ::us/uuid file-id)
|
||||||
|
|
|
@ -408,8 +408,7 @@
|
||||||
(not (mth/close? (:height props) current-height))))
|
(not (mth/close? (:height props) current-height))))
|
||||||
|
|
||||||
(let [modif-tree (dwm/create-modif-tree [id] (ctm/reflow-modifiers))]
|
(let [modif-tree (dwm/create-modif-tree [id] (ctm/reflow-modifiers))]
|
||||||
(->> (rx/of (dwm/set-modifiers modif-tree))
|
(rx/of (dwm/update-modifiers modif-tree)))
|
||||||
(rx/observe-on :async)))
|
|
||||||
(rx/empty)))))))
|
(rx/empty)))))))
|
||||||
|
|
||||||
(defn clean-text-modifier
|
(defn clean-text-modifier
|
||||||
|
|
|
@ -23,8 +23,22 @@
|
||||||
[type data]
|
[type data]
|
||||||
(ptk/data-event type data))
|
(ptk/data-event type data))
|
||||||
|
|
||||||
|
;;(def debug-exclude-events
|
||||||
|
;; #{:app.main.data.workspace.notifications/handle-pointer-update
|
||||||
|
;; :app.main.data.workspace.notifications/handle-pointer-send
|
||||||
|
;; :app.main.data.workspace.persistence/update-persistence-status
|
||||||
|
;; :app.main.data.workspace.changes/update-indices
|
||||||
|
;; :app.main.data.websocket/send-message
|
||||||
|
;; :app.main.data.workspace.selection/change-hover-state})
|
||||||
|
;; (def ^:dynamic *debug-events* false)
|
||||||
|
|
||||||
(defonce state
|
(defonce state
|
||||||
(ptk/store {:resolve ptk/resolve
|
(ptk/store {:resolve ptk/resolve
|
||||||
|
;;:on-event (fn [e]
|
||||||
|
;; (when (and *debug-events*
|
||||||
|
;; (ptk/event? e)
|
||||||
|
;; (not (debug-exclude-events (ptk/type e))))
|
||||||
|
;; (.log js/console (str "[stream]: " (ptk/repr-event e)) )))
|
||||||
:on-error (fn [e] (@on-error e))}))
|
:on-error (fn [e] (@on-error e))}))
|
||||||
|
|
||||||
(defonce stream
|
(defonce stream
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
(: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.matrix :as gmt]
|
|
||||||
[app.common.geom.point :as gpt]
|
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.ui.context :as muc]
|
[app.main.ui.context :as muc]
|
||||||
|
@ -32,23 +30,6 @@
|
||||||
(d/update-when :position-data #(mapv update-color %))
|
(d/update-when :position-data #(mapv update-color %))
|
||||||
(assoc :stroke-color "#FFFFFF" :stroke-opacity 1))))
|
(assoc :stroke-color "#FFFFFF" :stroke-opacity 1))))
|
||||||
|
|
||||||
(defn position-data-transform
|
|
||||||
[shape {:keys [x y width height]}]
|
|
||||||
(let [rect (gsh/make-rect x (- y height) width height)
|
|
||||||
center (gsh/center-rect rect)]
|
|
||||||
(when (or (:flip-x shape) (:flip-y shape))
|
|
||||||
(-> (gmt/matrix)
|
|
||||||
(gmt/translate center)
|
|
||||||
|
|
||||||
(cond-> (:flip-x shape)
|
|
||||||
(gmt/scale (gpt/point -1 1))
|
|
||||||
|
|
||||||
(:flip-y shape)
|
|
||||||
(gmt/scale (gpt/point 1 -1)))
|
|
||||||
|
|
||||||
(gmt/translate (gpt/negate center))
|
|
||||||
(dm/str)))))
|
|
||||||
|
|
||||||
(mf/defc text-shape
|
(mf/defc text-shape
|
||||||
{::mf/wrap-props false
|
{::mf/wrap-props false
|
||||||
::mf/wrap [mf/memo]}
|
::mf/wrap [mf/memo]}
|
||||||
|
@ -60,7 +41,7 @@
|
||||||
|
|
||||||
{:keys [x y width height position-data]} shape
|
{:keys [x y width height position-data]} shape
|
||||||
|
|
||||||
transform (gsh/transform-str shape {:no-flip true})
|
transform (gsh/transform-str shape)
|
||||||
|
|
||||||
;; These position attributes are not really necessary but they are convenient for for the export
|
;; These position attributes are not really necessary but they are convenient for for the export
|
||||||
group-props (-> #js {:transform transform
|
group-props (-> #js {:transform transform
|
||||||
|
@ -96,7 +77,6 @@
|
||||||
:y (- (:y data) (:height data))
|
:y (- (:y data) (:height data))
|
||||||
:textLength (:width data)
|
:textLength (:width data)
|
||||||
:lengthAdjust "spacingAndGlyphs"
|
:lengthAdjust "spacingAndGlyphs"
|
||||||
:transform (position-data-transform shape data)
|
|
||||||
:alignmentBaseline alignment-bl
|
:alignmentBaseline alignment-bl
|
||||||
:dominantBaseline dominant-bl
|
:dominantBaseline dominant-bl
|
||||||
:style (-> #js {:fontFamily (:font-family data)
|
:style (-> #js {:fontFamily (:font-family data)
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
[:& text/text-shape {:shape shape}]]
|
[:& text/text-shape {:shape shape}]]
|
||||||
|
|
||||||
(when (and (debug? :text-outline) (d/not-empty? (:position-data shape)))
|
(when (and (debug? :text-outline) (d/not-empty? (:position-data shape)))
|
||||||
[:g {:transform (gsh/transform-str shape {:no-flip true})}
|
[:g {:transform (gsh/transform-str shape)}
|
||||||
(let [bounding-box (gsht/position-data-selrect shape)]
|
(let [bounding-box (gsht/position-data-selrect shape)]
|
||||||
[:rect {
|
[:rect {
|
||||||
:x (:x bounding-box)
|
:x (:x bounding-box)
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
(some? text-modifier)
|
(some? text-modifier)
|
||||||
(dwt/apply-text-modifier text-modifier))
|
(dwt/apply-text-modifier text-modifier))
|
||||||
|
|
||||||
transform (gsh/transform-str shape {:no-flip true})
|
transform (gsh/transform-str shape)
|
||||||
{:keys [x y width height]} shape]
|
{:keys [x y width height]} shape]
|
||||||
|
|
||||||
[:rect.main.viewport-selrect
|
[:rect.main.viewport-selrect
|
||||||
|
|
|
@ -272,7 +272,7 @@
|
||||||
current-transform (mf/deref refs/current-transform)
|
current-transform (mf/deref refs/current-transform)
|
||||||
|
|
||||||
selrect (:selrect shape)
|
selrect (:selrect shape)
|
||||||
transform (gsh/transform-str shape {:no-flip true})]
|
transform (gsh/transform-str shape)]
|
||||||
|
|
||||||
(when (not (#{:move :rotate} current-transform))
|
(when (not (#{:move :rotate} current-transform))
|
||||||
[:g.controls {:pointer-events (if disable-handlers "none" "visible")}
|
[:g.controls {:pointer-events (if disable-handlers "none" "visible")}
|
||||||
|
@ -297,7 +297,7 @@
|
||||||
workspace-read-only? (mf/use-ctx ctx/workspace-read-only?)
|
workspace-read-only? (mf/use-ctx ctx/workspace-read-only?)
|
||||||
|
|
||||||
selrect (:selrect shape)
|
selrect (:selrect shape)
|
||||||
transform (gsh/transform-matrix shape {:no-flip true})
|
transform (gsh/transform-matrix shape)
|
||||||
|
|
||||||
rotation (-> (gpt/point 1 0)
|
rotation (-> (gpt/point 1 0)
|
||||||
(gpt/transform (:transform shape))
|
(gpt/transform (:transform shape))
|
||||||
|
@ -309,7 +309,22 @@
|
||||||
[:g.controls {:pointer-events (if disable-handlers "none" "visible")}
|
[:g.controls {:pointer-events (if disable-handlers "none" "visible")}
|
||||||
;; Handlers
|
;; Handlers
|
||||||
(for [{:keys [type position props]} (handlers-for-selection selrect shape zoom)]
|
(for [{:keys [type position props]} (handlers-for-selection selrect shape zoom)]
|
||||||
(let [common-props {:key (dm/str (name type) "-" (name position))
|
(let [rotation
|
||||||
|
(cond
|
||||||
|
(and (#{:top-left :bottom-right} position)
|
||||||
|
(or (and (:flip-x shape) (not (:flip-y shape)))
|
||||||
|
(and (:flip-y shape) (not (:flip-x shape)))))
|
||||||
|
(- rotation 90)
|
||||||
|
|
||||||
|
(and (#{:top-right :bottom-left} position)
|
||||||
|
(or (and (:flip-x shape) (not (:flip-y shape)))
|
||||||
|
(and (:flip-y shape) (not (:flip-x shape)))))
|
||||||
|
(+ rotation 90)
|
||||||
|
|
||||||
|
:else
|
||||||
|
rotation)
|
||||||
|
|
||||||
|
common-props {:key (dm/str (name type) "-" (name position))
|
||||||
:zoom zoom
|
:zoom zoom
|
||||||
:position position
|
:position position
|
||||||
:on-rotate on-rotate
|
:on-rotate on-rotate
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue