0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 23:31:21 -05:00

Small fixes for flex layout

This commit is contained in:
alonso.torres 2022-11-07 18:21:36 +01:00
parent e61e76a074
commit cdaba395c4
10 changed files with 11 additions and 40 deletions

View file

@ -81,7 +81,6 @@
cp (gsi/line-line-intersect c3 (gpt/add c3 dir-v) p0 p3)]
(gpt/to-vec c3 cp)))
(defn top-vector
[child-points parent-points]

View file

@ -16,6 +16,7 @@
[app.common.types.shape.layout :as ctl]))
(defn layout-drop-areas
"Retrieve the layout drop areas to move shapes inside layouts"
[{:keys [margin-x margin-y] :as frame} layout-data children]
(let [col? (ctl/col? frame)
@ -84,14 +85,7 @@
(-> (gsr/make-rect x (+ y half-point-height) width (- height half-point-height))
(assoc :index (if reverse? index (inc index))))]))
result (conj result line-area-1 line-area-2)
;;line-area
;;(-> (gsr/make-rect x y width height)
;; (assoc :index (if reverse? (inc index) index)))
;;result (conj result line-area)
;;result (conj result (gsr/make-rect box-x box-y box-width box-height))
]
result (conj result line-area-1 line-area-2)]
[result parent-rect (+ x width) (+ y height)]))
@ -158,10 +152,6 @@
children (subvec children from-idx (+ from-idx num-children))
;; To debug the lines
;;result (conj result line-area)
result (first (reduce redfn-child [result line-area] (d/with-next children)))]
[result (+ from-idx num-children) (+ x width) (+ y height)]))]

View file

@ -249,7 +249,6 @@
(some? margin-y)
(gpt/add (vv margin-y)))
;; Fix position when layout is flipped
corner-p
(cond-> corner-p

View file

@ -33,12 +33,6 @@
([{:keys [type]}]
(= type :frame)))
(defn layout-shape?
([objects id]
(layout-shape? (get objects id)))
([{:keys [type layout]}]
(and (= type :frame) layout)))
(defn group-shape?
[{:keys [type]}]
(= type :group))

View file

@ -171,12 +171,11 @@
(t/testing "Transform shape with invalid selrect fails gracefully"
(t/are [type selrect]
(let [modifiers (ctm/move-modifiers 0 0)
shape-before (-> (create-test-shape type {:modifiers modifiers})
(assoc :selrect selrect))
shape-after (gsh/transform-shape shape-before)]
shape-before (-> (create-test-shape type) (assoc :selrect selrect))
shape-after (gsh/transform-shape shape-before modifiers)]
(t/is (not= (:selrect shape-before)
(:selrect shape-after))))
(t/is (= (:selrect shape-before)
(:selrect shape-after))))
:rect {:x 0.0 :y 0.0 :x1 0.0 :y1 0.0 :x2 ##Inf :y2 ##Inf :width ##Inf :height ##Inf}
:path {:x 0.0 :y 0.0 :x1 0.0 :y1 0.0 :x2 ##Inf :y2 ##Inf :width ##Inf :height ##Inf}

View file

@ -16,6 +16,7 @@
[app.common.types.shape :as cts]
[app.common.types.shape-tree :as ctst]
[app.common.types.shape.interactions :as ctsi]
[app.common.types.shape.layout :as ctl]
[app.common.uuid :as uuid]
[app.main.data.comments :as dc]
[app.main.data.workspace.changes :as dch]
@ -148,7 +149,7 @@
layout-ids (->> ids
(mapcat (partial cph/get-parent-ids objects))
(filter (partial cph/layout-shape? objects)))
(filter (partial ctl/layout? objects)))
components-v2 (features/active-feature? state :components-v2)

View file

@ -81,9 +81,7 @@
[{:keys [shape] :as props}]
(let [render-thumbnails? (mf/use-ctx muc/render-thumbnails)
childs (mapv #(get objects %) (:shapes shape))
;;shape (gsh/transform-shape shape)
]
childs (mapv #(get objects %) (:shapes shape))]
(if (and render-thumbnails? (some? (:thumbnail shape)))
[:& frame/frame-thumbnail {:shape shape :bounds (:children-bounds shape)}]
[:& frame-shape {:shape shape :childs childs}])))))
@ -136,8 +134,7 @@
bool-wrapper (mf/use-memo (mf/deps objects) #(bool-wrapper-factory objects))
frame-wrapper (mf/use-memo (mf/deps objects) #(frame-wrapper-factory objects))]
(when (and shape (not (:hidden shape)))
(let [;;shape (gsh/transform-shape shape)
opts #js {:shape shape}
(let [opts #js {:shape shape}
svg-raw? (= :svg-raw (:type shape))]
(if-not svg-raw?
[:> shape-container {:shape shape}
@ -167,9 +164,7 @@
[objects object]
(let [shapes (cph/get-immediate-children objects)
srect (gsh/selection-rect shapes)
object (merge object (select-keys srect [:x :y :width :height]))
;; object (gsh/transform-shape object)
]
object (merge object (select-keys srect [:x :y :width :height]))]
(assoc object :fill-color "#f0f0f0")))
(defn adapt-objects-for-shape

View file

@ -88,8 +88,6 @@
[props]
(let [shape (unchecked-get props "shape")
childs (mapv #(get objects %) (:shapes shape))
;;shape (gsh/transform-shape shape)
props (-> (obj/create)
(obj/merge! props)
(obj/merge! #js {:shape shape

View file

@ -350,7 +350,6 @@
[props]
(let [shape (obj/get props "shape")
childs (mapv #(get objects %) (:shapes shape))
;;shape (gsh/transform-shape shape)
props (obj/merge! #js {} props
#js {:shape shape
:childs childs

View file

@ -341,7 +341,6 @@
(let [shape (mf/use-memo
(mf/deps shapes)
#(->> shapes
#_(map gsh/transform-shape)
(gsh/selection-rect)
(cts/setup-shape)))
on-resize
@ -369,7 +368,6 @@
(let [shape (mf/use-memo
(mf/deps shapes)
#(->> shapes
#_(map gsh/transform-shape)
(gsh/selection-rect)
(cts/setup-shape)))]
@ -384,7 +382,6 @@
(mf/defc single-handlers
[{:keys [shape zoom color disable-handlers] :as props}]
(let [shape-id (:id shape)
;;shape (gsh/transform-shape shape)
on-resize
(fn [current-position _initial-position event]