mirror of
https://github.com/penpot/penpot.git
synced 2025-07-02 14:27:16 +02:00
🐛 Fix problem when changing group size with decimal values
This commit is contained in:
parent
c3be87ed30
commit
2a1ca07554
3 changed files with 44 additions and 38 deletions
|
@ -93,6 +93,7 @@
|
||||||
- Fix resize rotated shape with top&down constraints [Taiga #3167](https://tree.taiga.io/project/penpot/issue/3167)
|
- Fix resize rotated shape with top&down constraints [Taiga #3167](https://tree.taiga.io/project/penpot/issue/3167)
|
||||||
- Fix multi user not working [Taiga #3195](https://tree.taiga.io/project/penpot/issue/3195)
|
- Fix multi user not working [Taiga #3195](https://tree.taiga.io/project/penpot/issue/3195)
|
||||||
- Fix guides are not duplicated with the artboard [Taiga #3072](https://tree.taiga.io/project/penpot/issue/3072)
|
- Fix guides are not duplicated with the artboard [Taiga #3072](https://tree.taiga.io/project/penpot/issue/3072)
|
||||||
|
- Fix problem when changing group size with decimal values [Taiga #3203](https://tree.taiga.io/project/penpot/issue/3203)
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
### :heart: Community contributions by (Thank you!)
|
### :heart: Community contributions by (Thank you!)
|
||||||
|
|
|
@ -103,25 +103,25 @@
|
||||||
(defmethod constraint-modifier :scale
|
(defmethod constraint-modifier :scale
|
||||||
[_ axis _ _ modifiers _]
|
[_ axis _ _ modifiers _]
|
||||||
(let [{:keys [resize-vector resize-vector-2 displacement]} modifiers]
|
(let [{:keys [resize-vector resize-vector-2 displacement]} modifiers]
|
||||||
(cond-> {}
|
(cond-> {}
|
||||||
(and (some? resize-vector)
|
(and (some? resize-vector)
|
||||||
(not (mth/close? (axis resize-vector) 1)))
|
(not= (axis resize-vector) 1))
|
||||||
(assoc :resize-origin (:resize-origin modifiers)
|
(assoc :resize-origin (:resize-origin modifiers)
|
||||||
:resize-vector (if (= :x axis)
|
:resize-vector (if (= :x axis)
|
||||||
(gpt/point (:x resize-vector) 1)
|
(gpt/point (:x resize-vector) 1)
|
||||||
(gpt/point 1 (:y resize-vector))))
|
(gpt/point 1 (:y resize-vector))))
|
||||||
|
|
||||||
(and (= :y axis) (some? resize-vector-2)
|
(and (= :y axis) (some? resize-vector-2)
|
||||||
(not (mth/close? (:y resize-vector-2) 1)))
|
(not (mth/close? (:y resize-vector-2) 1)))
|
||||||
(assoc :resize-origin (:resize-origin-2 modifiers)
|
(assoc :resize-origin (:resize-origin-2 modifiers)
|
||||||
:resize-vector (gpt/point 1 (:y resize-vector-2)))
|
:resize-vector (gpt/point 1 (:y resize-vector-2)))
|
||||||
|
|
||||||
(some? displacement)
|
(some? displacement)
|
||||||
(assoc :displacement
|
(assoc :displacement
|
||||||
(get-displacement axis (-> (gpt/point 0 0)
|
(get-displacement axis (-> (gpt/point 0 0)
|
||||||
(gpt/transform displacement)
|
(gpt/transform displacement)
|
||||||
(gpt/transform (:resize-transform-inverse modifiers (gmt/matrix)))
|
(gpt/transform (:resize-transform-inverse modifiers (gmt/matrix)))
|
||||||
axis))))))
|
axis))))))
|
||||||
|
|
||||||
(defmethod constraint-modifier :default [_ _ _ _ _]
|
(defmethod constraint-modifier :default [_ _ _ _ _]
|
||||||
{})
|
{})
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
;; geometric attributes of the shapes.
|
;; geometric attributes of the shapes.
|
||||||
|
|
||||||
(declare clear-local-transform)
|
(declare clear-local-transform)
|
||||||
(declare set-modifiers-recursive)
|
(declare set-objects-modifiers)
|
||||||
(declare get-ignore-tree)
|
(declare get-ignore-tree)
|
||||||
|
|
||||||
(defn- set-modifiers
|
(defn- set-modifiers
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
(fn [state id]
|
(fn [state id]
|
||||||
(let [shape (get objects id)]
|
(let [shape (get objects id)]
|
||||||
(update state :workspace-modifiers
|
(update state :workspace-modifiers
|
||||||
#(set-modifiers-recursive % objects shape modifiers ignore-constraints snap-pixel?))))]
|
#(set-objects-modifiers % objects shape modifiers ignore-constraints snap-pixel?))))]
|
||||||
|
|
||||||
(reduce setup-modifiers state ids))))))
|
(reduce setup-modifiers state ids))))))
|
||||||
|
|
||||||
|
@ -330,25 +330,28 @@
|
||||||
(assoc :displacement (gmt/translate-matrix delta-v))))]
|
(assoc :displacement (gmt/translate-matrix delta-v))))]
|
||||||
modifiers)))
|
modifiers)))
|
||||||
|
|
||||||
(defn- set-modifiers-recursive
|
(defn- set-objects-modifiers
|
||||||
[modif-tree objects shape modifiers ignore-constraints snap-pixel?]
|
[modif-tree objects shape modifiers ignore-constraints snap-pixel?]
|
||||||
|
(letfn [(set-modifiers-rec
|
||||||
|
[modif-tree shape modifiers]
|
||||||
|
|
||||||
(let [children (map (d/getf objects) (:shapes shape))
|
(let [children (map (d/getf objects) (:shapes shape))
|
||||||
modifiers (cond-> modifiers snap-pixel? (set-pixel-precision shape))
|
modifiers (cond-> modifiers snap-pixel? (set-pixel-precision shape))
|
||||||
transformed-rect (gsh/transform-selrect (:selrect shape) modifiers)
|
transformed-rect (gsh/transform-selrect (:selrect shape) modifiers)
|
||||||
|
|
||||||
set-child
|
set-child
|
||||||
(fn [modif-tree child]
|
(fn [modif-tree child]
|
||||||
(let [child-modifiers (gsh/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect)]
|
(let [child-modifiers (gsh/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect)]
|
||||||
(cond-> modif-tree
|
(cond-> modif-tree
|
||||||
(not (gsh/empty-modifiers? child-modifiers))
|
(not (gsh/empty-modifiers? child-modifiers))
|
||||||
(set-modifiers-recursive objects child child-modifiers ignore-constraints snap-pixel?))))
|
(set-modifiers-rec child child-modifiers))))
|
||||||
|
|
||||||
modif-tree
|
modif-tree
|
||||||
(-> modif-tree
|
(-> modif-tree
|
||||||
(assoc-in [(:id shape) :modifiers] modifiers))]
|
(assoc-in [(:id shape) :modifiers] modifiers))]
|
||||||
|
|
||||||
(reduce set-child modif-tree children)))
|
(reduce set-child modif-tree children)))]
|
||||||
|
(set-modifiers-rec modif-tree shape modifiers)))
|
||||||
|
|
||||||
(defn- get-ignore-tree
|
(defn- get-ignore-tree
|
||||||
"Retrieves a map with the flag `ignore-geometry?` given a tree of modifiers"
|
"Retrieves a map with the flag `ignore-geometry?` given a tree of modifiers"
|
||||||
|
@ -507,15 +510,17 @@
|
||||||
(ptk/reify ::update-dimensions
|
(ptk/reify ::update-dimensions
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [page-id (:current-page-id state)
|
(let [objects (wsh/lookup-page-objects state)
|
||||||
objects (get-in state [:workspace-data :pages-index page-id :objects])
|
layout (get state :workspace-layout)
|
||||||
|
snap-pixel? (contains? layout :snap-pixel-grid)
|
||||||
|
|
||||||
update-modifiers
|
update-modifiers
|
||||||
(fn [state id]
|
(fn [state id]
|
||||||
(let [shape (get objects id)
|
(let [shape (get objects id)
|
||||||
modifiers (gsh/resize-modifiers shape attr value)]
|
modifiers (gsh/resize-modifiers shape attr value)]
|
||||||
(update state :workspace-modifiers
|
(-> state
|
||||||
#(set-modifiers-recursive % objects shape modifiers false false))))]
|
(update :workspace-modifiers
|
||||||
|
#(set-objects-modifiers % objects shape modifiers false (and snap-pixel? (int? value)))))))]
|
||||||
(reduce update-modifiers state ids)))
|
(reduce update-modifiers state ids)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue