mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 00:10:11 -05:00
✨ Ignore constraints when flipping
This commit is contained in:
parent
c72138d15a
commit
16db31c53c
3 changed files with 24 additions and 12 deletions
|
@ -17,6 +17,7 @@
|
||||||
### :bug: Bugs fixed
|
### :bug: Bugs fixed
|
||||||
|
|
||||||
- Enhance duplicating prototype connections behaviour [Taiga #2093](https://tree.taiga.io/project/penpot/us/2093).
|
- Enhance duplicating prototype connections behaviour [Taiga #2093](https://tree.taiga.io/project/penpot/us/2093).
|
||||||
|
- Ignore constraints in horizontal or vertical flip [Taiga #2038](https://tree.taiga.io/project/penpot/issue/2038).
|
||||||
- Fix color and typographies refs lost when duplicated file [Taiga #2165](https://tree.taiga.io/project/penpot/issue/2165).
|
- Fix color and typographies refs lost when duplicated file [Taiga #2165](https://tree.taiga.io/project/penpot/issue/2165).
|
||||||
- Fix problem with overflow dropdown on stroke-cap [#1216](https://github.com/penpot/penpot/issues/1216).
|
- Fix problem with overflow dropdown on stroke-cap [#1216](https://github.com/penpot/penpot/issues/1216).
|
||||||
- Fix menu context for single element nested in components [#1186](https://github.com/penpot/penpot/issues/1186).
|
- Fix menu context for single element nested in components [#1186](https://github.com/penpot/penpot/issues/1186).
|
||||||
|
|
|
@ -506,7 +506,7 @@
|
||||||
(defn calc-child-modifiers
|
(defn calc-child-modifiers
|
||||||
"Given the modifiers to apply to the parent, calculate the corresponding
|
"Given the modifiers to apply to the parent, calculate the corresponding
|
||||||
modifiers for the child, depending on the child constraints."
|
modifiers for the child, depending on the child constraints."
|
||||||
[parent child parent-modifiers]
|
[parent child parent-modifiers ignore-constraints]
|
||||||
(let [parent-rect (:selrect parent)
|
(let [parent-rect (:selrect parent)
|
||||||
child-rect (:selrect child)
|
child-rect (:selrect child)
|
||||||
|
|
||||||
|
@ -540,8 +540,12 @@
|
||||||
|
|
||||||
;; Calculate the modifiers in the horizontal and vertical directions
|
;; Calculate the modifiers in the horizontal and vertical directions
|
||||||
;; depending on the child constraints.
|
;; depending on the child constraints.
|
||||||
constraints-h (get child :constraints-h (spec/default-constraints-h child))
|
constraints-h (if-not ignore-constraints
|
||||||
constraints-v (get child :constraints-v (spec/default-constraints-v child))
|
(get child :constraints-h (spec/default-constraints-h child))
|
||||||
|
:scale)
|
||||||
|
constraints-v (if-not ignore-constraints
|
||||||
|
(get child :constraints-v (spec/default-constraints-v child))
|
||||||
|
:scale)
|
||||||
|
|
||||||
modifiers-h (case constraints-h
|
modifiers-h (case constraints-h
|
||||||
:left
|
:left
|
||||||
|
|
|
@ -113,8 +113,9 @@
|
||||||
(declare clear-local-transform)
|
(declare clear-local-transform)
|
||||||
|
|
||||||
(defn- set-modifiers
|
(defn- set-modifiers
|
||||||
([ids] (set-modifiers ids nil))
|
([ids] (set-modifiers ids nil false))
|
||||||
([ids modifiers]
|
([ids modifiers] (set-modifiers ids modifiers false))
|
||||||
|
([ids modifiers ignore-constraints]
|
||||||
(us/verify (s/coll-of uuid?) ids)
|
(us/verify (s/coll-of uuid?) ids)
|
||||||
(ptk/reify ::set-modifiers
|
(ptk/reify ::set-modifiers
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
|
@ -132,7 +133,8 @@
|
||||||
(get objects id)
|
(get objects id)
|
||||||
modifiers
|
modifiers
|
||||||
nil
|
nil
|
||||||
nil)))
|
nil
|
||||||
|
ignore-constraints)))
|
||||||
state
|
state
|
||||||
ids))))))
|
ids))))))
|
||||||
|
|
||||||
|
@ -197,7 +199,7 @@
|
||||||
(dwu/commit-undo-transaction))))))
|
(dwu/commit-undo-transaction))))))
|
||||||
|
|
||||||
(defn- set-modifiers-recursive
|
(defn- set-modifiers-recursive
|
||||||
[modif-tree objects shape modifiers root transformed-root]
|
[modif-tree objects shape modifiers root transformed-root ignore-constraints]
|
||||||
(let [children (->> (get shape :shapes [])
|
(let [children (->> (get shape :shapes [])
|
||||||
(map #(get objects %)))
|
(map #(get objects %)))
|
||||||
|
|
||||||
|
@ -211,13 +213,15 @@
|
||||||
set-child (fn [modif-tree child]
|
set-child (fn [modif-tree child]
|
||||||
(let [child-modifiers (gsh/calc-child-modifiers shape
|
(let [child-modifiers (gsh/calc-child-modifiers shape
|
||||||
child
|
child
|
||||||
modifiers)]
|
modifiers
|
||||||
|
ignore-constraints)]
|
||||||
(set-modifiers-recursive modif-tree
|
(set-modifiers-recursive modif-tree
|
||||||
objects
|
objects
|
||||||
child
|
child
|
||||||
child-modifiers
|
child-modifiers
|
||||||
root
|
root
|
||||||
transformed-root)))]
|
transformed-root
|
||||||
|
ignore-constraints)))]
|
||||||
(reduce set-child
|
(reduce set-child
|
||||||
(assoc-in modif-tree [(:id shape) :modifiers] modifiers)
|
(assoc-in modif-tree [(:id shape) :modifiers] modifiers)
|
||||||
children)))
|
children)))
|
||||||
|
@ -410,7 +414,8 @@
|
||||||
shape
|
shape
|
||||||
modifiers
|
modifiers
|
||||||
nil
|
nil
|
||||||
nil))))
|
nil
|
||||||
|
false))))
|
||||||
state
|
state
|
||||||
ids)))
|
ids)))
|
||||||
|
|
||||||
|
@ -715,7 +720,8 @@
|
||||||
(rx/of (set-modifiers selected
|
(rx/of (set-modifiers selected
|
||||||
{:resize-vector (gpt/point -1.0 1.0)
|
{:resize-vector (gpt/point -1.0 1.0)
|
||||||
:resize-origin origin
|
:resize-origin origin
|
||||||
:displacement (gmt/translate-matrix (gpt/point (- (:width selrect)) 0))})
|
:displacement (gmt/translate-matrix (gpt/point (- (:width selrect)) 0))}
|
||||||
|
true)
|
||||||
(apply-modifiers selected))))))
|
(apply-modifiers selected))))))
|
||||||
|
|
||||||
(defn flip-vertical-selected []
|
(defn flip-vertical-selected []
|
||||||
|
@ -731,7 +737,8 @@
|
||||||
(rx/of (set-modifiers selected
|
(rx/of (set-modifiers selected
|
||||||
{:resize-vector (gpt/point 1.0 -1.0)
|
{:resize-vector (gpt/point 1.0 -1.0)
|
||||||
:resize-origin origin
|
:resize-origin origin
|
||||||
:displacement (gmt/translate-matrix (gpt/point 0 (- (:height selrect))))})
|
:displacement (gmt/translate-matrix (gpt/point 0 (- (:height selrect))))}
|
||||||
|
true)
|
||||||
(apply-modifiers selected))))))
|
(apply-modifiers selected))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue