mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05:00
🐛 Fix orientation artboard preset does not work with differently sized artboards
This commit is contained in:
parent
c3486c566a
commit
ba85dcf1a3
6 changed files with 61 additions and 7 deletions
|
@ -8,6 +8,12 @@
|
|||
### :arrow_up: Deps updates
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
||||
|
||||
## 1.13.5-beta
|
||||
|
||||
### :bug: Bugs fixed
|
||||
- Fix orientation artboard preset not working with differently sized artboards [Taiga #3548](https://tree.taiga.io/project/penpot/issue/3548)
|
||||
|
||||
## 1.13.4-beta
|
||||
|
||||
### :bug: Bugs fixed
|
||||
|
|
|
@ -166,6 +166,7 @@
|
|||
(dm/export gtr/update-group-selrect)
|
||||
(dm/export gtr/update-mask-selrect)
|
||||
(dm/export gtr/resize-modifiers)
|
||||
(dm/export gtr/change-orientation-modifiers)
|
||||
(dm/export gtr/rotation-modifiers)
|
||||
(dm/export gtr/merge-modifiers)
|
||||
(dm/export gtr/transform-shape)
|
||||
|
|
|
@ -426,6 +426,31 @@
|
|||
:resize-transform shape-transform
|
||||
:resize-transform-inverse shape-transform-inv}))
|
||||
|
||||
(defn change-orientation-modifiers
|
||||
[shape orientation]
|
||||
(us/assert map? shape)
|
||||
(us/verify #{:horiz :vert} orientation)
|
||||
(let [width (:width shape)
|
||||
height (:height shape)
|
||||
new-width (if (= orientation :horiz) (max width height) (min width height))
|
||||
new-height (if (= orientation :horiz) (min width height) (max width height))
|
||||
|
||||
shape-transform (:transform shape)
|
||||
shape-transform-inv (:transform-inverse shape)
|
||||
shape-center (gco/center-shape shape)
|
||||
{sr-width :width sr-height :height} (:selrect shape)
|
||||
|
||||
origin (cond-> (gpt/point (:selrect shape))
|
||||
(some? shape-transform)
|
||||
(transform-point-center shape-center shape-transform))
|
||||
|
||||
scalev (gpt/divide (gpt/point new-width new-height)
|
||||
(gpt/point sr-width sr-height))]
|
||||
{:resize-vector scalev
|
||||
:resize-origin origin
|
||||
:resize-transform shape-transform
|
||||
:resize-transform-inverse shape-transform-inv}))
|
||||
|
||||
(defn rotation-modifiers
|
||||
[shape center angle]
|
||||
(let [displacement (let [shape-center (gco/center-shape shape)]
|
||||
|
|
|
@ -1698,6 +1698,7 @@
|
|||
|
||||
(dm/export dwt/start-resize)
|
||||
(dm/export dwt/update-dimensions)
|
||||
(dm/export dwt/change-orientation)
|
||||
(dm/export dwt/start-rotate)
|
||||
(dm/export dwt/increase-rotation)
|
||||
(dm/export dwt/start-move-selected)
|
||||
|
|
|
@ -556,6 +556,32 @@
|
|||
(watch [_ _ _]
|
||||
(rx/of (apply-modifiers ids)))))
|
||||
|
||||
(defn change-orientation
|
||||
"Change orientation of shapes, from the sidebar options form.
|
||||
Will ignore pixel snap used in the options side panel"
|
||||
[ids orientation]
|
||||
(us/verify (s/coll-of ::us/uuid) ids)
|
||||
(us/verify #{:horiz :vert} orientation)
|
||||
(ptk/reify ::change-orientation
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
layout (get state :workspace-layout)
|
||||
snap-pixel? (contains? layout :snap-pixel-grid)
|
||||
|
||||
update-modifiers
|
||||
(fn [state id]
|
||||
(let [shape (get objects id)
|
||||
modifiers (gsh/change-orientation-modifiers shape orientation)]
|
||||
(-> state
|
||||
(update :workspace-modifiers
|
||||
#(set-objects-modifiers % objects shape modifiers false snap-pixel?)))))]
|
||||
(reduce update-modifiers state ids)))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of (apply-modifiers ids)))))
|
||||
|
||||
;; -- Rotate --------------------------------------------------------
|
||||
|
||||
(defn start-rotate
|
||||
|
@ -786,7 +812,7 @@
|
|||
|
||||
(rx/of (apply-modifiers selected)
|
||||
(finish-transform))))
|
||||
(rx/empty))))))
|
||||
(rx/empty))))))
|
||||
|
||||
(s/def ::x number?)
|
||||
(s/def ::y number?)
|
||||
|
|
|
@ -110,12 +110,7 @@
|
|||
|
||||
on-orientation-clicked
|
||||
(fn [orientation]
|
||||
(let [width (:width values)
|
||||
height (:height values)
|
||||
new-width (if (= orientation :horiz) (max width height) (min width height))
|
||||
new-height (if (= orientation :horiz) (min width height) (max width height))]
|
||||
(st/emit! (udw/update-dimensions ids :width new-width)
|
||||
(udw/update-dimensions ids :height new-height))))
|
||||
(st/emit! (udw/change-orientation ids orientation)))
|
||||
|
||||
on-size-change
|
||||
(mf/use-callback
|
||||
|
|
Loading…
Add table
Reference in a new issue