diff --git a/CHANGES.md b/CHANGES.md index 77605a861..1eef88e81 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 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 problem with auto-width/auto-height + lock-proportions ## 1.16.0-beta diff --git a/common/src/app/common/geom/shapes/transforms.cljc b/common/src/app/common/geom/shapes/transforms.cljc index f9bda0dc2..438b5faeb 100644 --- a/common/src/app/common/geom/shapes/transforms.cljc +++ b/common/src/app/common/geom/shapes/transforms.cljc @@ -399,39 +399,42 @@ (empty? (dissoc modifiers :ignore-geometry?))) (defn resize-modifiers - [shape attr value] - (us/assert map? shape) - (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 attr value] + (resize-modifiers shape attr value nil)) - shape-transform (:transform shape) - shape-transform-inv (:transform-inverse shape) - shape-center (gco/center-shape shape) - {sr-width :width sr-height :height} (:selrect shape) + ([shape attr value {:keys [ignore-lock?] :or {ignore-lock? false}}] + (us/assert map? shape) + (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 (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)) - (some? shape-transform) - (transform-point-center shape-center shape-transform)) + shape-transform (:transform shape) + shape-transform-inv (:transform-inverse shape) + shape-center (gco/center-shape shape) + {sr-width :width sr-height :height} (:selrect shape) - scalev (gpt/divide (gpt/point width height) - (gpt/point sr-width sr-height))] - {:resize-vector scalev - :resize-origin origin - :resize-transform shape-transform - :resize-transform-inverse shape-transform-inv})) + origin (cond-> (gpt/point (:selrect shape)) + (some? shape-transform) + (transform-point-center shape-center shape-transform)) + + scalev (gpt/divide (gpt/point width height) + (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 [shape orientation] diff --git a/frontend/src/app/main/data/workspace/texts.cljs b/frontend/src/app/main/data/workspace/texts.cljs index 653b03abc..3f2eef7a9 100644 --- a/frontend/src/app/main/data/workspace/texts.cljs +++ b/frontend/src/app/main/data/workspace/texts.cljs @@ -319,8 +319,11 @@ (letfn [(update-fn [shape] (let [{:keys [selrect grow-type]} shape {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 (and (not-changed? shape-width new-width) (= grow-type :auto-width)) (-> (assoc :modifiers modifier-width) @@ -346,8 +349,8 @@ (defn apply-text-modifier [shape {:keys [width height position-data]}] - (let [modifier-width (when width (gsh/resize-modifiers shape :width width)) - modifier-height (when height (gsh/resize-modifiers shape :height height)) + (let [modifier-width (when width (gsh/resize-modifiers shape :width width {:ignore-lock? true})) + modifier-height (when height (gsh/resize-modifiers shape :height height {:ignore-lock? true})) new-shape (cond-> shape