0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-16 01:31:22 -05:00

🐛 Fixes problem with rotation input

This commit is contained in:
alonso.torres 2020-05-18 15:32:34 +02:00
parent 82baaae593
commit 06cebbc527
2 changed files with 38 additions and 39 deletions

View file

@ -357,7 +357,10 @@
;; Set-rotation is custom because applies different modifiers to each shape adjusting their position
(defn set-rotation
[delta-rotation shapes center]
([delta-rotation shapes]
(set-rotation delta-rotation shapes (-> shapes gsh/selection-rect gsh/center)))
([delta-rotation shapes center]
(ptk/reify ::set-rotation
dwc/IUpdateGroup
(get-ids [_] (map :id shapes))
@ -379,7 +382,7 @@
id->obj #(get objects %)
get-children (fn [shape] (map id->obj (cp/get-children (:id shape) objects)))
shapes (concat shapes (mapcat get-children shapes))]
(rotate-around-center state delta-rotation center shapes)))))))
(rotate-around-center state delta-rotation center shapes))))))))
(defn apply-modifiers
[ids]

View file

@ -34,24 +34,27 @@
dx (- rec-x sel-x)
dy (- rec-y sel-y)]
(gpt/point dx dy)))
(-> (gpt/point dx dy)
(gpt/round 2))))
(defn user->draw
[{:keys [x y width height] :as shape}]
(let [dv (user-coords-vector shape)]
(-> shape (gsh/move dv))))
(-> shape
(gsh/move dv))))
(defn draw->user
[{:keys [x y width height] :as shape}]
(let [dv (user-coords-vector shape)]
(-> shape (gsh/move (gpt/negate dv)))))
(-> shape
(gsh/move (gpt/negate dv)))))
(mf/defc measures-menu
[{:keys [shape options] :as props}]
(let [options (or options #{:size :position :rotation :radius})
locale (i18n/use-locale)
frame (deref (refs/object-by-id (:frame-id shape)))
old-shape shape
shape (->> shape
(gsh/transform-shape frame)
(draw->user))
@ -83,7 +86,7 @@
(let [value (-> (dom/get-target event)
(dom/get-value)
(d/parse-integer 0))]
(st/emit! (udw/set-rotation (- value (:rotation shape)) [shape])
(st/emit! (udw/set-rotation (- value (:rotation shape)) [old-shape])
(udw/apply-modifiers #{(:id shape)}))))
on-radius-change
@ -138,21 +141,13 @@
:type "number"
:no-validate true
:on-change on-pos-x-change
:value (:x shape)
;;:value (str (-> (- (x shape) (:x parent)) ; Show to user position relative to frame
;; (d/coalesce 0)
;; (math/round)))
}]]
:value (:x shape)}]]
[:div.input-element.Yaxis
[:input.input-text {:placeholder "y"
:type "number"
:no-validate true
:on-change on-pos-y-change
:value (:y shape)
;;:value (str (-> (- (y shape) (:y parent))
;; (d/coalesce 0)
;; (math/round)))
}]]])
:value (:y shape)}]]])
(when (options :rotation)
[:div.row-flex
@ -163,7 +158,7 @@
:type "number"
:no-validate true
:min "0"
:max "360"
:max "359"
:on-change on-rotation-change
:value (str (-> (:rotation shape)
(d/coalesce 0)
@ -171,12 +166,13 @@
[:input.slidebar
{:type "range"
:min "0"
:max "360"
:step "1"
:max "359"
:step "10"
:no-validate true
:on-change on-rotation-change
:value (str (-> (:rotation shape)
(d/coalesce 0)))}]])
(d/coalesce 0)
(math/round)))}]])
(when (options :radius)
[:div.row-flex