mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 18:48:37 -05:00
Merge pull request #177 from uxbox/246/show-relative-pos-in-options
✨ Use relative coords in options panel
This commit is contained in:
commit
55c85c0d5c
2 changed files with 19 additions and 4 deletions
|
@ -82,6 +82,7 @@
|
||||||
:frame (absolute-move-rect shape position)
|
:frame (absolute-move-rect shape position)
|
||||||
:image (absolute-move-rect shape position)
|
:image (absolute-move-rect shape position)
|
||||||
:rect (absolute-move-rect shape position)
|
:rect (absolute-move-rect shape position)
|
||||||
|
:text (absolute-move-rect shape position)
|
||||||
:group (absolute-move-rect shape position)
|
:group (absolute-move-rect shape position)
|
||||||
:circle (absolute-move-circle shape position)
|
:circle (absolute-move-circle shape position)
|
||||||
shape))
|
shape))
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.common.data :as d]
|
[uxbox.common.data :as d]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
|
@ -23,6 +24,17 @@
|
||||||
(let [options (or options #{:size :position :rotation :radius})
|
(let [options (or options #{:size :position :rotation :radius})
|
||||||
locale (i18n/use-locale)
|
locale (i18n/use-locale)
|
||||||
|
|
||||||
|
data (deref refs/workspace-data)
|
||||||
|
parent (get-in data [:objects (:frame-id shape)])
|
||||||
|
|
||||||
|
x (cond
|
||||||
|
(:x shape) :x
|
||||||
|
(:cx shape) :cx)
|
||||||
|
|
||||||
|
y (cond
|
||||||
|
(:y shape) :y
|
||||||
|
(:cy shape) :cy)
|
||||||
|
|
||||||
on-size-change
|
on-size-change
|
||||||
(fn [event attr]
|
(fn [event attr]
|
||||||
(let [value (-> (dom/get-target event)
|
(let [value (-> (dom/get-target event)
|
||||||
|
@ -45,8 +57,10 @@
|
||||||
(fn [event attr]
|
(fn [event attr]
|
||||||
(let [value (-> (dom/get-target event)
|
(let [value (-> (dom/get-target event)
|
||||||
(dom/get-value)
|
(dom/get-value)
|
||||||
(d/parse-integer 0))]
|
(d/parse-integer 0))
|
||||||
(st/emit! (udw/update-position (:id shape) {attr value}))))
|
; Convert back to absolute position before update
|
||||||
|
abs-value (+ value (attr parent))]
|
||||||
|
(st/emit! (udw/update-position (:id shape) {attr abs-value}))))
|
||||||
|
|
||||||
on-rotation-change
|
on-rotation-change
|
||||||
(fn [event]
|
(fn [event]
|
||||||
|
@ -133,7 +147,7 @@
|
||||||
:type "number"
|
:type "number"
|
||||||
:no-validate true
|
:no-validate true
|
||||||
:on-change on-pos-x-change
|
:on-change on-pos-x-change
|
||||||
:value (str (-> (:x shape)
|
:value (str (-> (- (x shape) (:x parent)) ; Show to user position relative to frame
|
||||||
(d/coalesce 0)
|
(d/coalesce 0)
|
||||||
(math/round)))}]]
|
(math/round)))}]]
|
||||||
[:div.input-element.pixels
|
[:div.input-element.pixels
|
||||||
|
@ -141,7 +155,7 @@
|
||||||
:type "number"
|
:type "number"
|
||||||
:no-validate true
|
:no-validate true
|
||||||
:on-change on-pos-y-change
|
:on-change on-pos-y-change
|
||||||
:value (str (-> (:y shape)
|
:value (str (-> (- (y shape) (:y parent))
|
||||||
(d/coalesce 0)
|
(d/coalesce 0)
|
||||||
(math/round)))}]]])
|
(math/round)))}]]])
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue