mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
🐛 Fixes problems with measurment distances
This commit is contained in:
parent
5f7f88d299
commit
faff32203c
3 changed files with 31 additions and 34 deletions
|
@ -234,17 +234,18 @@
|
|||
:stroke-dasharray (/ select-guide-dasharray zoom)}}])])
|
||||
|
||||
(mf/defc measurement [{:keys [bounds frame selected-shapes hover-shape zoom]}]
|
||||
(let [selected-ids (into #{} (map :id) selected-shapes)
|
||||
selected-selrect (gsh/selection-rect selected-shapes)
|
||||
hover-selrect (:selrect hover-shape)
|
||||
bounds-selrect (bound->selrect bounds)]
|
||||
(let [selected-ids (into #{} (map :id) selected-shapes)
|
||||
selected-selrect (gsh/selection-rect selected-shapes)
|
||||
hover-selrect (:selrect hover-shape)
|
||||
bounds-selrect (bound->selrect bounds)
|
||||
hover-selected-shape? (not (contains? selected-ids (:id hover-shape)))]
|
||||
|
||||
(when (and (seq selected-shapes) (not (contains? selected-ids (:id hover-shape))))
|
||||
(when (seq selected-shapes)
|
||||
[:g.measurement-feedback {:pointer-events "none"}
|
||||
[:& selection-guides {:selrect selected-selrect :bounds bounds :zoom zoom}]
|
||||
[:& size-display {:selrect selected-selrect :zoom zoom}]
|
||||
|
||||
(if (not hover-shape)
|
||||
(if (or (not hover-shape) (not hover-selected-shape?))
|
||||
(when frame
|
||||
[:g.hover-shapes
|
||||
[:& distance-display {:from (:selrect frame)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
[app.main.refs :as refs]
|
||||
[app.main.ui.context :as ctx]
|
||||
[app.main.ui.context :as muc]
|
||||
[app.main.ui.measurements :as msr]
|
||||
[app.main.ui.workspace.shapes :as shapes]
|
||||
[app.main.ui.workspace.shapes.text.editor :as editor]
|
||||
[app.main.ui.workspace.viewport.actions :as actions]
|
||||
|
@ -87,6 +88,11 @@
|
|||
zoom (d/check-num zoom 1)
|
||||
drawing-tool (:tool drawing)
|
||||
drawing-obj (:object drawing)
|
||||
selected-shapes (->> selected (mapv #(get objects %)))
|
||||
selected-frames (into #{} (map :frame-id) selected-shapes)
|
||||
|
||||
;; Only when we have all the selected shapes in one frame
|
||||
selected-frame (when (= (count selected-frames) 1) (get objects (first selected-frames)))
|
||||
|
||||
drawing-path? (or (and edition (= :draw (get-in edit-path [edition :edit-mode])))
|
||||
(and (some? drawing-obj) (= :path (:type drawing-obj))))
|
||||
|
@ -213,10 +219,17 @@
|
|||
{:selected selected
|
||||
:zoom zoom
|
||||
:edition edition
|
||||
:show-distances (and (not transform) show-distances?)
|
||||
:disable-handlers (or drawing-tool edition)
|
||||
:on-move-selected on-move-selected}])
|
||||
|
||||
(when (and (not transform) show-distances?)
|
||||
[:& msr/measurement
|
||||
{:bounds vbox
|
||||
:selected-shapes selected-shapes
|
||||
:frame selected-frame
|
||||
:hover-shape @hover
|
||||
:zoom zoom}])
|
||||
|
||||
(when text-editing?
|
||||
[:& editor/text-shape-edit {:shape (get objects edition)}])
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
[app.main.streams :as ms]
|
||||
[app.main.ui.cursors :as cur]
|
||||
[app.main.ui.hooks :as hooks]
|
||||
[app.main.ui.measurements :as msr]
|
||||
[app.main.ui.workspace.viewport.outline :refer [outline]]
|
||||
[app.main.ui.workspace.shapes.path.editor :refer [path-editor]]
|
||||
[app.util.data :as d]
|
||||
|
@ -295,7 +294,7 @@
|
|||
:fill "transparent"}}]]))
|
||||
|
||||
(mf/defc multiple-selection-handlers
|
||||
[{:keys [shapes selected zoom color show-distances disable-handlers on-move-selected] :as props}]
|
||||
[{:keys [shapes selected zoom color disable-handlers on-move-selected] :as props}]
|
||||
(let [shape (mf/use-memo
|
||||
(mf/deps shapes)
|
||||
#(->> shapes
|
||||
|
@ -327,17 +326,11 @@
|
|||
:on-resize on-resize
|
||||
:on-rotate on-rotate}]
|
||||
|
||||
(when show-distances
|
||||
[:& msr/measurement {:bounds vbox
|
||||
:selected-shapes shapes
|
||||
:hover-shape hover-shape
|
||||
:zoom zoom}])
|
||||
|
||||
(when (debug? :selection-center)
|
||||
[:circle {:cx (:x shape-center) :cy (:y shape-center) :r 5 :fill "yellow"}])]))
|
||||
|
||||
(mf/defc single-selection-handlers
|
||||
[{:keys [shape zoom color show-distances disable-handlers on-move-selected] :as props}]
|
||||
[{:keys [shape zoom color disable-handlers on-move-selected] :as props}]
|
||||
(let [shape-id (:id shape)
|
||||
shape (geom/transform-shape shape)
|
||||
|
||||
|
@ -357,25 +350,17 @@
|
|||
on-rotate
|
||||
#(do (dom/stop-propagation %)
|
||||
(st/emit! (dw/start-rotate [shape])))]
|
||||
[:*
|
||||
[:& controls {:shape shape'
|
||||
:zoom zoom
|
||||
:color color
|
||||
:on-rotate on-rotate
|
||||
:on-resize on-resize
|
||||
:disable-handlers disable-handlers
|
||||
:on-move-selected on-move-selected}]
|
||||
|
||||
(when show-distances
|
||||
[:& msr/measurement {:bounds vbox
|
||||
:frame frame
|
||||
:selected-shapes [shape]
|
||||
:hover-shape hover-shape
|
||||
:zoom zoom}])]))
|
||||
[:& controls {:shape shape'
|
||||
:zoom zoom
|
||||
:color color
|
||||
:on-rotate on-rotate
|
||||
:on-resize on-resize
|
||||
:disable-handlers disable-handlers
|
||||
:on-move-selected on-move-selected}]))
|
||||
|
||||
(mf/defc selection-handlers
|
||||
{::mf/wrap [mf/memo]}
|
||||
[{:keys [selected edition zoom show-distances disable-handlers on-move-selected] :as props}]
|
||||
[{:keys [selected edition zoom disable-handlers on-move-selected] :as props}]
|
||||
(let [;; We need remove posible nil values because on shape
|
||||
;; deletion many shape will reamin selected and deleted
|
||||
;; in the same time for small instant of time
|
||||
|
@ -396,7 +381,6 @@
|
|||
:selected selected
|
||||
:zoom zoom
|
||||
:color color
|
||||
:show-distances show-distances
|
||||
:disable-handlers disable-handlers
|
||||
:on-move-selected on-move-selected}]
|
||||
|
||||
|
@ -415,6 +399,5 @@
|
|||
[:& single-selection-handlers {:shape shape
|
||||
:zoom zoom
|
||||
:color color
|
||||
:show-distances show-distances
|
||||
:disable-handlers disable-handlers
|
||||
:on-move-selected on-move-selected}])))
|
||||
|
|
Loading…
Add table
Reference in a new issue