mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 19:06:36 +02:00
🐛 Fix align options on rotated frames
This commit is contained in:
parent
905e1eea7b
commit
f57c5b4da2
2 changed files with 20 additions and 2 deletions
|
@ -8,7 +8,8 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.rect :as grc]
|
[app.common.geom.rect :as grc]
|
||||||
[app.common.geom.shapes :as gsh]))
|
[app.common.geom.shapes :as gsh]
|
||||||
|
[app.common.geom.shapes.points :as gpo]))
|
||||||
|
|
||||||
;; --- Alignment
|
;; --- Alignment
|
||||||
|
|
||||||
|
@ -30,6 +31,23 @@
|
||||||
(- (:y align-pos) (:y wrapper-rect)))]
|
(- (:y align-pos) (:y wrapper-rect)))]
|
||||||
(gsh/move shape delta)))
|
(gsh/move shape delta)))
|
||||||
|
|
||||||
|
(defn align-to-parent
|
||||||
|
"Does the same calc as align-to-rect but relative to a parent shape."
|
||||||
|
[shape parent axis]
|
||||||
|
(let [parent-bounds (:points parent)
|
||||||
|
wrapper-rect
|
||||||
|
(-> (gsh/transform-points (:points shape) (gsh/shape->center parent) (:transform-inverse parent))
|
||||||
|
(grc/points->rect))
|
||||||
|
|
||||||
|
align-pos (calc-align-pos wrapper-rect (:selrect parent) axis)
|
||||||
|
|
||||||
|
xv #(gpo/start-hv parent-bounds %)
|
||||||
|
yv #(gpo/start-vv parent-bounds %)
|
||||||
|
|
||||||
|
delta (-> (xv (- (:x align-pos) (:x wrapper-rect)))
|
||||||
|
(gpt/add (yv (- (:y align-pos) (:y wrapper-rect)))))]
|
||||||
|
(gsh/move shape delta)))
|
||||||
|
|
||||||
(defn calc-align-pos
|
(defn calc-align-pos
|
||||||
[wrapper-rect rect axis]
|
[wrapper-rect rect axis]
|
||||||
(case axis
|
(case axis
|
||||||
|
|
|
@ -1080,7 +1080,7 @@
|
||||||
(let [object (get objects object-id)
|
(let [object (get objects object-id)
|
||||||
parent-id (:parent-id (get objects object-id))
|
parent-id (:parent-id (get objects object-id))
|
||||||
parent (get objects parent-id)]
|
parent (get objects parent-id)]
|
||||||
[(gal/align-to-rect object parent axis)]))
|
[(gal/align-to-parent object parent axis)]))
|
||||||
|
|
||||||
(defn align-objects-list
|
(defn align-objects-list
|
||||||
[objects selected axis]
|
[objects selected axis]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue