mirror of
https://github.com/penpot/penpot.git
synced 2025-05-31 22:31:40 +02:00
🐛 Change behavior of auto cells
This commit is contained in:
parent
e3ed198ba1
commit
9e52cdb75e
9 changed files with 129 additions and 32 deletions
|
@ -15,6 +15,7 @@
|
|||
[app.common.logging :as log]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
|
@ -87,6 +88,8 @@
|
|||
(cond-> undo-group
|
||||
(pcb/set-undo-group undo-group)))
|
||||
ids)
|
||||
grid-ids (->> ids (filter (partial ctl/grid-layout? objects)))
|
||||
changes (pcb/update-shapes changes grid-ids ctl/assign-cell-positions {:with-objects? true})
|
||||
changes (pcb/reorder-grid-children changes ids)
|
||||
changes (add-undo-group changes state)]
|
||||
(rx/concat
|
||||
|
|
|
@ -500,7 +500,6 @@
|
|||
(pcb/amend-last-change #(assoc % :old-id (:id obj)))
|
||||
(cond-> (ctl/grid-layout? objects (:parent-id obj))
|
||||
(-> (pcb/update-shapes [(:parent-id obj)] ctl/assign-cells {:with-objects? true})
|
||||
(pcb/update-shapes [(:parent-id obj)] ctl/check-deassigned-cells {:with-objects? true})
|
||||
(pcb/reorder-grid-children [(:parent-id obj)]))))
|
||||
|
||||
changes (cond-> changes
|
||||
|
|
|
@ -342,12 +342,13 @@
|
|||
(-> changes
|
||||
(pcb/update-shapes
|
||||
ids
|
||||
(fn [shape]
|
||||
(fn [shape objects]
|
||||
;; The duplication could have altered the grid so we restore the values, we'll calculate the good ones now
|
||||
(let [shape (merge shape (select-keys base-shape [:layout-grid-cells :layout-grid-columns :layout-grid-rows]))]
|
||||
(case type
|
||||
:row (ctl/duplicate-row shape index ids-map)
|
||||
:column (ctl/duplicate-column shape index ids-map))))))
|
||||
:row (ctl/duplicate-row shape objects index ids-map)
|
||||
:column (ctl/duplicate-column shape objects index ids-map))))
|
||||
{:with-objects? true}))
|
||||
|
||||
undo-id (js/Symbol)]
|
||||
(rx/of (dwu/start-undo-transaction undo-id)
|
||||
|
|
|
@ -559,8 +559,8 @@
|
|||
(fn [[_ target-frame drop-index]]
|
||||
(let [undo-id (js/Symbol)]
|
||||
(rx/of (dwu/start-undo-transaction undo-id)
|
||||
(dwm/apply-modifiers {:undo-transation? false})
|
||||
(move-shapes-to-frame ids target-frame drop-index)
|
||||
(dwm/apply-modifiers {:undo-transation? false})
|
||||
(finish-transform)
|
||||
(dwu/commit-undo-transaction undo-id))))))))))))))
|
||||
|
||||
|
@ -872,7 +872,9 @@
|
|||
(pcb/update-shapes moving-shapes-ids #(cond-> % (cfh/frame-shape? %) (assoc :hide-in-viewer true)))
|
||||
(pcb/update-shapes shape-ids-to-detach ctk/detach-shape)
|
||||
(pcb/change-parent frame-id moving-shapes drop-index)
|
||||
(pcb/reorder-grid-children [frame-id])
|
||||
(cond-> (ctl/grid-layout? objects frame-id)
|
||||
(-> (pcb/update-shapes [frame-id] ctl/assign-cell-positions {:with-objects? true})
|
||||
(pcb/reorder-grid-children [frame-id])))
|
||||
(pcb/remove-objects empty-parents))]
|
||||
|
||||
(when (and (some? frame-id) (d/not-empty? changes))
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
[app.main.ui.hooks :as hooks]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.main.ui.workspace.viewport.viewport-ref :as uwvv]
|
||||
[app.util.debug :as dbg]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.keyboard :as kbd]
|
||||
|
@ -347,6 +348,29 @@
|
|||
(st/emit! (dw/show-grid-cell-context-menu {:position position :grid-id (:id shape)})))))]
|
||||
|
||||
[:g.cell-editor
|
||||
;; DEBUG OVERLAY
|
||||
(when (dbg/enabled? :grid-cells)
|
||||
[:g.debug-cell {:pointer-events "none"
|
||||
:transform (dm/str (gmt/transform-in cell-center (:transform shape)))}
|
||||
|
||||
[:rect
|
||||
{:x (:x cell-origin)
|
||||
:y (:y cell-origin)
|
||||
:width cell-width
|
||||
:height cell-height
|
||||
:fill (cond
|
||||
(= (:position cell) :auto) "green"
|
||||
(= (:position cell) :manual) "red"
|
||||
(= (:position cell) :area) "yellow"
|
||||
:else "black")
|
||||
:fill-opacity 0.2}]
|
||||
|
||||
(when (seq (:shapes cell))
|
||||
[:circle
|
||||
{:cx (+ (:x cell-origin) cell-width (- (/ 7 zoom)))
|
||||
:cy (+ (:y cell-origin) (/ 7 zoom))
|
||||
:r (/ 5 zoom)
|
||||
:fill "red"}])])
|
||||
[:rect
|
||||
{:transform (dm/str (gmt/transform-in cell-center (:transform shape)))
|
||||
:class (dom/classnames (stl/css :grid-cell-outline) true
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
|
||||
;;
|
||||
:grid-layout
|
||||
|
||||
;; Show an overlay to the grid cells to know its properties
|
||||
:grid-cells
|
||||
})
|
||||
|
||||
(defn enable!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue