mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 08:11:30 -05:00
🐛 Fix problem when resizing a group with texts with auto-width/height
This commit is contained in:
parent
c7e23c1b58
commit
8b3062be0b
3 changed files with 52 additions and 29 deletions
|
@ -97,6 +97,7 @@
|
|||
- Fix error when drawing curves with only one point [Taiga #3282](https://tree.taiga.io/project/penpot/issue/3282)
|
||||
- Fix issue with paste ordering sometimes not being respected [Taiga #3268](https://tree.taiga.io/project/penpot/issue/3268)
|
||||
- Fix problem when export/importing guides attached to frame [#1838](https://github.com/penpot/penpot/issues/1838)
|
||||
- Fix problem when resizing a group with texts with auto-width/height [#3171](https://tree.taiga.io/project/penpot/issue/3171)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
|
|
@ -384,6 +384,11 @@
|
|||
(defn commit-position-data
|
||||
[]
|
||||
(ptk/reify ::commit-position-data
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [ids (keys (::update-position-data state))]
|
||||
(update state :workspace-text-modifiers #(apply dissoc % ids))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [position-data (::update-position-data state)]
|
||||
|
@ -404,9 +409,10 @@
|
|||
(ptk/reify ::update-position-data
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(if (nil? (::update-position-data-debounce state))
|
||||
(assoc state ::update-position-data-debounce start)
|
||||
(assoc-in state [::update-position-data id] position-data)))
|
||||
(let [state (assoc-in state [:workspace-text-modifier id :position-data] position-data)]
|
||||
(if (nil? (::update-position-data-debounce state))
|
||||
(assoc state ::update-position-data-debounce start)
|
||||
(assoc-in state [::update-position-data id] position-data))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
|
|
|
@ -166,6 +166,20 @@
|
|||
|
||||
(update state :workspace-modifiers #(reduce update-shape % shapes)))))))
|
||||
|
||||
(defn- update-grow-type
|
||||
[shape old-shape]
|
||||
(let [auto-width? (= :auto-width (:grow-type shape))
|
||||
auto-height? (= :auto-height (:grow-type shape))
|
||||
|
||||
changed-width? (not (mth/close? (:width shape) (:width old-shape)))
|
||||
changed-height? (not (mth/close? (:height shape) (:height old-shape)))
|
||||
|
||||
change-to-fixed? (or (and auto-width? (or changed-height? changed-width?))
|
||||
(and auto-height? changed-height?))]
|
||||
(cond-> shape
|
||||
change-to-fixed?
|
||||
(assoc :grow-type :fixed))))
|
||||
|
||||
(defn- apply-modifiers
|
||||
[ids]
|
||||
(us/verify (s/coll-of uuid?) ids)
|
||||
|
@ -182,27 +196,33 @@
|
|||
(rx/of (dwu/start-undo-transaction)
|
||||
(dwg/move-frame-guides ids-with-children)
|
||||
(dch/update-shapes
|
||||
ids-with-children
|
||||
(fn [shape]
|
||||
(let [modif (get object-modifiers (:id shape))]
|
||||
(gsh/transform-shape (merge shape modif))))
|
||||
{:reg-objects? true
|
||||
:ignore-tree ignore-tree
|
||||
;; Attributes that can change in the transform. This way we don't have to check
|
||||
;; all the attributes
|
||||
:attrs [:selrect
|
||||
:points
|
||||
:x
|
||||
:y
|
||||
:width
|
||||
:height
|
||||
:content
|
||||
:transform
|
||||
:transform-inverse
|
||||
:rotation
|
||||
:position-data
|
||||
:flip-x
|
||||
:flip-y]})
|
||||
ids-with-children
|
||||
(fn [shape]
|
||||
(let [modif (get object-modifiers (:id shape))
|
||||
text-shape? (cph/text-shape? shape)]
|
||||
(-> shape
|
||||
(merge modif)
|
||||
(gsh/transform-shape)
|
||||
(cond-> text-shape?
|
||||
(update-grow-type shape)))))
|
||||
{:reg-objects? true
|
||||
:ignore-tree ignore-tree
|
||||
;; Attributes that can change in the transform. This way we don't have to check
|
||||
;; all the attributes
|
||||
:attrs [:selrect
|
||||
:points
|
||||
:x
|
||||
:y
|
||||
:width
|
||||
:height
|
||||
:content
|
||||
:transform
|
||||
:transform-inverse
|
||||
:rotation
|
||||
:position-data
|
||||
:flip-x
|
||||
:flip-y
|
||||
:grow-type]})
|
||||
(clear-local-transform)
|
||||
(dwu/commit-undo-transaction))))))
|
||||
|
||||
|
@ -483,12 +503,8 @@
|
|||
focus (:workspace-focus-selected state)
|
||||
zoom (get-in state [:workspace-local :zoom] 1)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
resizing-shapes (map #(get objects %) ids)
|
||||
text-shapes-ids (->> resizing-shapes
|
||||
(filter #(= :text (:type %)))
|
||||
(map :id))]
|
||||
resizing-shapes (map #(get objects %) ids)]
|
||||
(rx/concat
|
||||
(rx/of (dch/update-shapes text-shapes-ids #(assoc % :grow-type :fixed)))
|
||||
(->> ms/mouse-position
|
||||
(rx/with-latest-from ms/mouse-position-shift ms/mouse-position-alt)
|
||||
(rx/map normalize-proportion-lock)
|
||||
|
|
Loading…
Add table
Reference in a new issue