mirror of
https://github.com/penpot/penpot.git
synced 2025-06-01 04:31:38 +02:00
🐛 Fix problem with auto-width/auto-height + lock-proportions
This commit is contained in:
parent
ca7ebdcc8f
commit
7507a3b74f
3 changed files with 41 additions and 34 deletions
|
@ -21,6 +21,7 @@
|
||||||
- Fix bad behaviour on hovering and click nested artboards [Taiga #4018](https://tree.taiga.io/project/penpot/issue/4018) and [Taiga #4269](https://tree.taiga.io/project/penpot/us/4269)
|
- Fix bad behaviour on hovering and click nested artboards [Taiga #4018](https://tree.taiga.io/project/penpot/issue/4018) and [Taiga #4269](https://tree.taiga.io/project/penpot/us/4269)
|
||||||
- Fix lang autodetect issue [Taiga #4277](https://tree.taiga.io/project/penpot/issue/4277)
|
- Fix lang autodetect issue [Taiga #4277](https://tree.taiga.io/project/penpot/issue/4277)
|
||||||
- Fix colorpicker does not close upon switching to Dashboard [Taiga #4408](https://tree.taiga.io/project/penpot/issue/4408)
|
- Fix colorpicker does not close upon switching to Dashboard [Taiga #4408](https://tree.taiga.io/project/penpot/issue/4408)
|
||||||
|
- Fix problem with auto-width/auto-height + lock-proportions
|
||||||
|
|
||||||
## 1.16.0-beta
|
## 1.16.0-beta
|
||||||
|
|
||||||
|
|
|
@ -399,39 +399,42 @@
|
||||||
(empty? (dissoc modifiers :ignore-geometry?)))
|
(empty? (dissoc modifiers :ignore-geometry?)))
|
||||||
|
|
||||||
(defn resize-modifiers
|
(defn resize-modifiers
|
||||||
[shape attr value]
|
([shape attr value]
|
||||||
(us/assert map? shape)
|
(resize-modifiers shape attr value nil))
|
||||||
(us/assert #{:width :height} attr)
|
|
||||||
(us/assert number? value)
|
|
||||||
(let [{:keys [proportion proportion-lock]} shape
|
|
||||||
size (select-keys (:selrect shape) [:width :height])
|
|
||||||
new-size (if-not proportion-lock
|
|
||||||
(assoc size attr value)
|
|
||||||
(if (= attr :width)
|
|
||||||
(-> size
|
|
||||||
(assoc :width value)
|
|
||||||
(assoc :height (/ value proportion)))
|
|
||||||
(-> size
|
|
||||||
(assoc :height value)
|
|
||||||
(assoc :width (* value proportion)))))
|
|
||||||
width (:width new-size)
|
|
||||||
height (:height new-size)
|
|
||||||
|
|
||||||
shape-transform (:transform shape)
|
([shape attr value {:keys [ignore-lock?] :or {ignore-lock? false}}]
|
||||||
shape-transform-inv (:transform-inverse shape)
|
(us/assert map? shape)
|
||||||
shape-center (gco/center-shape shape)
|
(us/assert #{:width :height} attr)
|
||||||
{sr-width :width sr-height :height} (:selrect shape)
|
(us/assert number? value)
|
||||||
|
(let [{:keys [proportion proportion-lock]} shape
|
||||||
|
size (select-keys (:selrect shape) [:width :height])
|
||||||
|
new-size (if-not (and (not ignore-lock?) proportion-lock)
|
||||||
|
(assoc size attr value)
|
||||||
|
(if (= attr :width)
|
||||||
|
(-> size
|
||||||
|
(assoc :width value)
|
||||||
|
(assoc :height (/ value proportion)))
|
||||||
|
(-> size
|
||||||
|
(assoc :height value)
|
||||||
|
(assoc :width (* value proportion)))))
|
||||||
|
width (:width new-size)
|
||||||
|
height (:height new-size)
|
||||||
|
|
||||||
origin (cond-> (gpt/point (:selrect shape))
|
shape-transform (:transform shape)
|
||||||
(some? shape-transform)
|
shape-transform-inv (:transform-inverse shape)
|
||||||
(transform-point-center shape-center shape-transform))
|
shape-center (gco/center-shape shape)
|
||||||
|
{sr-width :width sr-height :height} (:selrect shape)
|
||||||
|
|
||||||
scalev (gpt/divide (gpt/point width height)
|
origin (cond-> (gpt/point (:selrect shape))
|
||||||
(gpt/point sr-width sr-height))]
|
(some? shape-transform)
|
||||||
{:resize-vector scalev
|
(transform-point-center shape-center shape-transform))
|
||||||
:resize-origin origin
|
|
||||||
:resize-transform shape-transform
|
scalev (gpt/divide (gpt/point width height)
|
||||||
:resize-transform-inverse shape-transform-inv}))
|
(gpt/point sr-width sr-height))]
|
||||||
|
{:resize-vector scalev
|
||||||
|
:resize-origin origin
|
||||||
|
:resize-transform shape-transform
|
||||||
|
:resize-transform-inverse shape-transform-inv})))
|
||||||
|
|
||||||
(defn change-orientation-modifiers
|
(defn change-orientation-modifiers
|
||||||
[shape orientation]
|
[shape orientation]
|
||||||
|
|
|
@ -319,8 +319,11 @@
|
||||||
(letfn [(update-fn [shape]
|
(letfn [(update-fn [shape]
|
||||||
(let [{:keys [selrect grow-type]} shape
|
(let [{:keys [selrect grow-type]} shape
|
||||||
{shape-width :width shape-height :height} selrect
|
{shape-width :width shape-height :height} selrect
|
||||||
modifier-width (gsh/resize-modifiers shape :width new-width)
|
|
||||||
modifier-height (gsh/resize-modifiers shape :height new-height)]
|
;; Ignore lock proportions otherwise the auto-width/auto-height cannot correctly set
|
||||||
|
;; the sizes
|
||||||
|
modifier-width (gsh/resize-modifiers shape :width new-width {:ignore-lock? true})
|
||||||
|
modifier-height (gsh/resize-modifiers shape :height new-height {:ignore-lock? true})]
|
||||||
(cond-> shape
|
(cond-> shape
|
||||||
(and (not-changed? shape-width new-width) (= grow-type :auto-width))
|
(and (not-changed? shape-width new-width) (= grow-type :auto-width))
|
||||||
(-> (assoc :modifiers modifier-width)
|
(-> (assoc :modifiers modifier-width)
|
||||||
|
@ -346,8 +349,8 @@
|
||||||
(defn apply-text-modifier
|
(defn apply-text-modifier
|
||||||
[shape {:keys [width height position-data]}]
|
[shape {:keys [width height position-data]}]
|
||||||
|
|
||||||
(let [modifier-width (when width (gsh/resize-modifiers shape :width width))
|
(let [modifier-width (when width (gsh/resize-modifiers shape :width width {:ignore-lock? true}))
|
||||||
modifier-height (when height (gsh/resize-modifiers shape :height height))
|
modifier-height (when height (gsh/resize-modifiers shape :height height {:ignore-lock? true}))
|
||||||
|
|
||||||
new-shape
|
new-shape
|
||||||
(cond-> shape
|
(cond-> shape
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue