mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 08:50:57 -05:00
commit
d33e3de8f1
5 changed files with 18 additions and 42 deletions
|
@ -434,6 +434,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
.grid-option .custom-select {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.color-th {
|
||||
background-color: $color-gray-10;
|
||||
border: 1px solid $color-gray-10;
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
|
||||
(def handle-drawing-path
|
||||
(letfn [(stoper-event? [{:keys [type shift] :as event}]
|
||||
(or (= event ::end-path-drawing)
|
||||
(or (= event :path/end-path-drawing)
|
||||
(and (ms/mouse-event? event)
|
||||
(or (and (= type :double-click) shift)
|
||||
(= type :context-menu)))
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
(dom/stop-propagation event)
|
||||
(st/emit! (dw/assign-cursor-tooltip nil)
|
||||
dd/close-drawing-path
|
||||
::end-path-drawing))
|
||||
:path/end-path-drawing))
|
||||
|
||||
on-mouse-enter
|
||||
(fn [event]
|
||||
|
|
|
@ -60,15 +60,10 @@
|
|||
(fn [event attr]
|
||||
(let [cval (-> (dom/get-target event)
|
||||
(dom/get-value)
|
||||
(d/parse-integer))
|
||||
pval (get shape attr)
|
||||
delta (if (= attr :x)
|
||||
(gpt/point (math/neg (- pval cval)) 0)
|
||||
(gpt/point 0 (math/neg (- pval cval))))]
|
||||
|
||||
(d/parse-integer 0))]
|
||||
;; TODO: Change so not apply the modifiers until blur
|
||||
(st/emit! (udw/set-modifiers #{(:id shape)} {:displacement delta})
|
||||
(udw/apply-modifiers #{(:id shape)}))))
|
||||
(when cval
|
||||
(st/emit! (udw/update-position (:id shape) {attr cval})))))
|
||||
|
||||
on-width-change #(on-size-change % :width)
|
||||
on-height-change #(on-size-change % :height)
|
||||
|
|
|
@ -23,28 +23,6 @@
|
|||
|
||||
;; -- User/drawing coords
|
||||
|
||||
(defn user-coords-vector
|
||||
[shape]
|
||||
(let [oldselrec (-> shape gsh/shape->path (gsh/center-transform (:transform shape)) gsh/shape->rect-shape)
|
||||
{sel-x :x sel-y :y :as selrec} #_(:selrect shape) oldselrec
|
||||
{rec-x :x rec-y :y} (-> shape gsh/shape->rect-shape)
|
||||
dx (- rec-x sel-x)
|
||||
dy (- rec-y sel-y)]
|
||||
(-> (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))))
|
||||
|
||||
(defn draw->user
|
||||
[{:keys [x y width height] :as shape}]
|
||||
(let [dv (user-coords-vector shape)]
|
||||
(-> shape
|
||||
(gsh/move (gpt/negate dv)))))
|
||||
|
||||
(mf/defc measures-menu
|
||||
[{:keys [shape options] :as props}]
|
||||
(let [options (or options #{:size :position :rotation :radius})
|
||||
|
@ -52,8 +30,7 @@
|
|||
frame (deref (refs/object-by-id (:frame-id shape)))
|
||||
old-shape shape
|
||||
shape (->> shape
|
||||
(gsh/transform-shape frame)
|
||||
(draw->user))
|
||||
(gsh/transform-shape frame))
|
||||
|
||||
on-size-change
|
||||
(fn [event attr]
|
||||
|
@ -70,12 +47,12 @@
|
|||
(fn [event attr]
|
||||
(let [value (-> (dom/get-target event)
|
||||
(dom/get-value)
|
||||
(d/parse-integer 0))
|
||||
new-shape (-> shape
|
||||
(assoc attr value)
|
||||
(gsh/translate-from-frame frame)
|
||||
(user->draw))]
|
||||
(st/emit! (udw/update-position (:id shape) (select-keys new-shape [attr])))))
|
||||
(d/parse-integer 0))]
|
||||
(when value
|
||||
(let [from (-> shape :selrect attr)
|
||||
to (+ value (attr frame))
|
||||
target (+ (attr shape) (- to from))]
|
||||
(st/emit! (udw/update-position (:id shape) {attr target}))))))
|
||||
|
||||
on-rotation-change
|
||||
(fn [event]
|
||||
|
@ -137,13 +114,13 @@
|
|||
:type "number"
|
||||
:no-validate true
|
||||
:on-change on-pos-x-change
|
||||
:value (-> shape :x (math/precision 2))}]]
|
||||
:value (-> shape :selrect :x (math/precision 2))}]]
|
||||
[:div.input-element.Yaxis
|
||||
[:input.input-text {:placeholder "y"
|
||||
:type "number"
|
||||
:no-validate true
|
||||
:on-change on-pos-y-change
|
||||
:value (-> shape :y (math/precision 2))}]]])
|
||||
:value (-> shape :selrect :y (math/precision 2))}]]])
|
||||
|
||||
(when (options :rotation)
|
||||
[:div.row-flex
|
||||
|
|
Loading…
Reference in a new issue