0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

Merge remote-tracking branch 'origin/main' into staging

This commit is contained in:
Alejandro Alonso 2022-06-09 08:55:05 +02:00
commit 801cdd940a
11 changed files with 73 additions and 15 deletions

View file

@ -15,6 +15,12 @@
- Remove deprecated menu options [Taiga #3333](https://tree.taiga.io/project/penpot/issue/3333)
- Prototype connection should be under the rules [Taiga #3384](https://tree.taiga.io/project/penpot/issue/3384)
## 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

View file

@ -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)

View file

@ -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)]

View file

@ -372,8 +372,8 @@
(assert-page-id changes)
(assert-objects changes)
(let [page-id (::page-id (meta changes))
objects (lookup-objects changes)
objects (lookup-objects changes)
xform (comp
(mapcat #(cons % (cph/get-parent-ids objects %)))
(map (d/getf objects))
@ -409,7 +409,8 @@
resize-parent
(fn [changes parent]
(let [children (->> parent :shapes (map (d/getf objects)))
(let [objects (lookup-objects changes)
children (->> parent :shapes (map (d/getf objects)))
resized-parent (cond
(empty? children) ;; a parent with no children will be deleted,
nil ;; so it does not need resize
@ -434,12 +435,12 @@
(if (seq rops)
(-> changes
(update :redo-changes conj (assoc change :operations rops))
(update :undo-changes d/preconj (assoc change :operations uops)))
(update :undo-changes d/preconj (assoc change :operations uops))
(apply-changes-local))
changes))
changes)))]
(-> (reduce resize-parent changes all-parents)
(apply-changes-local))))
(reduce resize-parent changes all-parents)))
;; Library changes

View file

@ -79,3 +79,6 @@ PENPOT_FLAGS="enable-registration"
# PENPOT_LDAP_ATTRS_FULLNAME=cn
# PENPOT_LDAP_ATTRS_PHOTO=jpegPhoto
# PENPOT_LOGIN_WITH_LDAP=true
# Exporter
PENPOT_DOMAIN_WHITE_LIST=localhost:9001

View file

@ -61,7 +61,7 @@
:page-id page-id
:object-id (mapv :id objects)
:route "objects"}
uri (-> (or uri (cf/get :public-uri))
uri (-> (cf/get :public-uri)
(assoc :path "/render.html")
(assoc :query (u/map->query-string params)))]
(bw/exec! (prepare-options uri) (partial render uri)))))

View file

@ -63,6 +63,6 @@
(on-object (assoc object :path path))
(p/recur (rest objects))))))]
(let [base-uri (or uri (cf/get :public-uri))]
(let [base-uri (cf/get :public-uri)]
(bw/exec! (prepare-options base-uri)
(partial render base-uri)))))

View file

@ -363,7 +363,7 @@
:render-embed true
:object-id (mapv :id objects)
:route "objects"}
uri (-> (or uri (cf/get :public-uri))
uri (-> (cf/get :public-uri)
(assoc :path "/render.html")
(assoc :query (u/map->query-string params)))]
(bw/exec! (prepare-options uri)

View file

@ -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)

View file

@ -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?)

View file

@ -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