Renamed modifiers functions

This commit is contained in:
alonso.torres 2022-11-07 12:25:22 +01:00
parent b5df7bbfc5
commit a2e26210d1
17 changed files with 201 additions and 200 deletions

View file

@ -47,9 +47,9 @@
(-> shape
(assoc :click-draw? false)
(gsh/transform-shape (-> (ctm/empty-modifiers)
(ctm/set-resize scalev (gpt/point x y))
(ctm/set-move movev))))))
(gsh/transform-shape (-> (ctm/empty)
(ctm/resize scalev (gpt/point x y))
(ctm/move movev))))))
(defn update-drawing [state initial point lock?]
(update-in state [:workspace-drawing :object] resize-shape initial point lock?))

View file

@ -51,7 +51,7 @@
(and click-draw? (not text?))
(-> (assoc :width min-side :height min-side)
(gsh/transform-shape (ctm/move (- (/ min-side 2)) (- (/ min-side 2)))))
(gsh/transform-shape (ctm/move-modifiers (- (/ min-side 2)) (- (/ min-side 2)))))
(and click-draw? text?)
(assoc :height 17 :width 4 :grow-type :auto-width)

View file

@ -159,11 +159,11 @@
(filterv #(contains? child-set %)))]
(cond-> modif-tree
(not= original-frame target-frame)
(-> (update-in [original-frame :modifiers] ctm/set-remove-children shapes)
(update-in [target-frame :modifiers] ctm/set-add-children shapes drop-index))
(-> (update-in [original-frame :modifiers] ctm/remove-children shapes)
(update-in [target-frame :modifiers] ctm/add-children shapes drop-index))
(and layout? (= original-frame target-frame))
(update-in [target-frame :modifiers] ctm/set-add-children shapes drop-index))))]
(update-in [target-frame :modifiers] ctm/add-children shapes drop-index))))]
(reduce update-frame-modifiers modif-tree origin-frame-ids)))
@ -214,7 +214,7 @@
get-modifier
(fn [shape]
(ctm/rotation shape center angle))
(ctm/rotation-modifiers shape center angle))
modif-tree
(-> (build-modif-tree ids objects get-modifier)

View file

@ -52,7 +52,7 @@
(let [objects (wsh/lookup-page-objects state)
ids (->> ids (filter (partial ctl/layout? objects)))]
(if (d/not-empty? ids)
(let [modif-tree (dwm/create-modif-tree ids (ctm/reflow))]
(let [modif-tree (dwm/create-modif-tree ids (ctm/reflow-modifiers))]
(rx/of (dwm/set-modifiers modif-tree)
(dwm/apply-modifiers)))
(rx/empty))))))

View file

@ -322,11 +322,11 @@
{shape-width :width shape-height :height} selrect]
(cond-> shape
(and (not-changed? shape-width new-width) (= grow-type :auto-width))
(gsh/transform-shape (ctm/change-dimensions shape :width new-width))
(gsh/transform-shape (ctm/change-dimensions-modifiers shape :width new-width))
(and (not-changed? shape-height new-height)
(or (= grow-type :auto-height) (= grow-type :auto-width)))
(gsh/transform-shape (ctm/change-dimensions shape :height new-height)))))]
(gsh/transform-shape (ctm/change-dimensions-modifiers shape :height new-height)))))]
(rx/of (dch/update-shapes [id] update-fn {:reg-objects? true :save-undo? false}))))))
@ -346,10 +346,10 @@
(let [new-shape
(cond-> shape
(some? width)
(gsh/transform-shape (ctm/change-dimensions shape :width width))
(gsh/transform-shape (ctm/change-dimensions-modifiers shape :width width))
(some? height)
(gsh/transform-shape (ctm/change-dimensions shape :height height))
(gsh/transform-shape (ctm/change-dimensions-modifiers shape :height height))
(some? position-data)
(assoc :position-data position-data))

View file

@ -185,19 +185,19 @@
(and layout-child? fill-height?)))
modifiers
(-> (ctm/empty-modifiers)
(-> (ctm/empty)
(cond-> displacement
(ctm/set-move displacement))
(ctm/set-resize scalev resize-origin shape-transform shape-transform-inverse)
(ctm/move displacement))
(ctm/resize scalev resize-origin shape-transform shape-transform-inverse)
(cond-> set-fix-width?
(ctm/set-change-property :layout-item-h-sizing :fix))
(ctm/change-property :layout-item-h-sizing :fix))
(cond-> set-fix-height?
(ctm/set-change-property :layout-item-v-sizing :fix))
(ctm/change-property :layout-item-v-sizing :fix))
(cond-> scale-text
(ctm/set-scale-content (:x scalev))))
(ctm/scale-content (:x scalev))))
modif-tree (dwm/create-modif-tree ids modifiers)]
(rx/of (dwm/set-modifiers modif-tree))))
@ -251,7 +251,7 @@
snap-pixel? (and (contains? (:workspace-layout state) :snap-pixel-grid)
(int? value))
get-modifier
(fn [shape] (ctm/change-dimensions shape attr value))
(fn [shape] (ctm/change-dimensions-modifiers shape attr value))
modif-tree
(-> (dwm/build-modif-tree ids objects get-modifier)
@ -486,7 +486,7 @@
(->> move-stream
(rx/map
(fn [[move-vector target-frame drop-index]]
(-> (dwm/create-modif-tree ids (ctm/move move-vector))
(-> (dwm/create-modif-tree ids (ctm/move-modifiers move-vector))
(dwm/build-change-frame-modifiers objects selected target-frame drop-index)
(dwm/set-modifiers)))))
@ -540,7 +540,7 @@
(rx/merge
(->> move-events
(rx/scan #(gpt/add %1 mov-vec) (gpt/point 0 0))
(rx/map #(dwm/create-modif-tree selected (ctm/move %)))
(rx/map #(dwm/create-modif-tree selected (ctm/move-modifiers %)))
(rx/map (partial dwm/set-modifiers))
(rx/take-until stopper))
(rx/of (move-selected direction shift?)))
@ -573,7 +573,7 @@
(or (:y position) (:y bbox)))
delta (gpt/subtract pos cpos)
modif-tree (dwm/create-modif-tree [id] (ctm/move delta))]
modif-tree (dwm/create-modif-tree [id] (ctm/move-modifiers delta))]
(rx/of (dwm/set-modifiers modif-tree)
(dwm/apply-modifiers))))))
@ -633,9 +633,9 @@
modif-tree (dwm/create-modif-tree
selected
(-> (ctm/empty-modifiers)
(ctm/set-resize (gpt/point -1.0 1.0) origin)
(ctm/set-move (gpt/point (:width selrect) 0))))]
(-> (ctm/empty)
(ctm/resize (gpt/point -1.0 1.0) origin)
(ctm/move (gpt/point (:width selrect) 0))))]
(rx/of (dwm/set-modifiers modif-tree true)
(dwm/apply-modifiers))))))
@ -652,9 +652,9 @@
modif-tree (dwm/create-modif-tree
selected
(-> (ctm/empty-modifiers)
(ctm/set-resize (gpt/point 1.0 -1.0) origin)
(ctm/set-move (gpt/point 0 (:height selrect)))))]
(-> (ctm/empty)
(ctm/resize (gpt/point 1.0 -1.0) origin)
(ctm/move (gpt/point 0 (:height selrect)))))]
(rx/of (dwm/set-modifiers modif-tree true)
(dwm/apply-modifiers))))))

View file

@ -187,7 +187,7 @@
mod-ids (cons object-id (cph/get-children-ids objects object-id))
updt-fn #(update %1 %2 gsh/transform-shape (ctm/move vector))]
updt-fn #(update %1 %2 gsh/transform-shape (ctm/move-modifiers vector))]
(reduce updt-fn objects mod-ids)))
@ -254,14 +254,14 @@
objects
(mf/with-memo [frame-id objects vector]
(let [update-fn #(update %1 %2 gsh/transform-shape (ctm/move vector))]
(let [update-fn #(update %1 %2 gsh/transform-shape (ctm/move-modifiers vector))]
(->> children-ids
(into [frame-id])
(reduce update-fn objects))))
frame
(mf/with-memo [vector]
(gsh/transform-shape frame (ctm/move vector)))
(gsh/transform-shape frame (ctm/move-modifiers vector)))
frame
(cond-> frame
@ -313,7 +313,7 @@
(mf/deps vector objects group-id)
(fn []
(let [children-ids (cons group-id (cph/get-children-ids objects group-id))
update-fn #(update %1 %2 gsh/transform-shape (ctm/move vector))]
update-fn #(update %1 %2 gsh/transform-shape (ctm/move-modifiers vector))]
(reduce update-fn objects children-ids))))
group (get objects group-id)

View file

@ -33,7 +33,7 @@
(let [frame-id (:id frame)
vector (-> (gpt/point (:x size) (:y size))
(gpt/negate))
update-fn #(d/update-when %1 %2 gsh/transform-shape (ctm/move vector))]
update-fn #(d/update-when %1 %2 gsh/transform-shape (ctm/move-modifiers vector))]
(->> (cph/get-children-ids objects frame-id)
(into [frame-id])
(reduce update-fn objects))))

View file

@ -188,7 +188,7 @@
(/ (:height shape) (:height shape')))]
;; Reverse the change in size so we can recalculate the layout
(-> modifiers
(ctm/set-resize scalev (-> shape' :points first) (:transform shape') (:transform-inverse shape')))))
(ctm/resize scalev (-> shape' :points first) (:transform shape') (:transform-inverse shape')))))
(defn use-dynamic-modifiers
[objects node modifiers]
@ -205,7 +205,7 @@
(ctm/modifiers->transform modifiers)))
modifiers))))
add-children (mf/use-memo (mf/deps modifiers) #(ctm/get-frame-add-children modifiers))
add-children (mf/use-memo (mf/deps modifiers) #(ctm/added-children-frames modifiers))
add-children (hooks/use-equal-memo add-children)
add-children-prev (hooks/use-previous add-children)

View file

@ -42,7 +42,7 @@
deltav (gpt/to-vec (gpt/point (:selrect shape'))
(gpt/point (:selrect shape)))]
(gsh/transform-shape shape' (ctm/move deltav))))
(gsh/transform-shape shape' (ctm/move-modifiers deltav))))
(defn process-shape [modifiers {:keys [id] :as shape}]
(let [modifier (dm/get-in modifiers [id :modifiers])]