mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
2b66d0ea06
6 changed files with 26 additions and 20 deletions
|
@ -346,10 +346,12 @@
|
|||
(defn check-num
|
||||
"Function that checks if a number is nil or nan. Will return 0 when not
|
||||
valid and the number otherwise."
|
||||
[v]
|
||||
(if (or (not v)
|
||||
(not (mth/finite? v))
|
||||
(mth/nan? v)) 0 v))
|
||||
([v]
|
||||
(check-num v 0))
|
||||
([v default]
|
||||
(if (or (not v)
|
||||
(not (mth/finite? v))
|
||||
(mth/nan? v)) default v)))
|
||||
|
||||
|
||||
(defmacro export
|
||||
|
|
|
@ -547,8 +547,8 @@
|
|||
(update [_ state]
|
||||
(let [id (get-in state [:workspace-local :edition])]
|
||||
(-> state
|
||||
(update-in [:workspace-local :hover] disj id)
|
||||
(update :workspace-local dissoc :edition))))))
|
||||
(update :workspace-local dissoc :edition)
|
||||
(cond-> (some? id) (update-in [:workspace-local :edit-path] dissoc id)))))))
|
||||
|
||||
(defn get-shape-layer-position
|
||||
[objects selected attrs]
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
(ns app.main.ui.workspace.viewport
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.ui.context :as ctx]
|
||||
|
@ -83,14 +84,15 @@
|
|||
;; STREAMS
|
||||
move-stream (mf/use-memo #(rx/subject))
|
||||
|
||||
zoom (or zoom 1)
|
||||
zoom (d/check-num zoom 1)
|
||||
drawing-tool (:tool drawing)
|
||||
drawing-obj (:object drawing)
|
||||
|
||||
drawing-path? (and edition (= :draw (get-in edit-path [edition :edit-mode])))
|
||||
drawing-path? (or (and edition (= :draw (get-in edit-path [edition :edit-mode])))
|
||||
(and (some? drawing-obj) (= :path (:type drawing-obj))))
|
||||
text-editing? (and edition (= :text (get-in objects [edition :type])))
|
||||
|
||||
on-click (actions/on-click hover selected)
|
||||
on-click (actions/on-click hover selected edition drawing-path?)
|
||||
on-context-menu (actions/on-context-menu hover)
|
||||
on-double-click (actions/on-double-click hover hover-ids drawing-path? objects)
|
||||
on-drag-enter (actions/on-drag-enter)
|
||||
|
@ -115,7 +117,7 @@
|
|||
show-draw-area? drawing-obj
|
||||
show-gradient-handlers? (= (count selected) 1)
|
||||
show-grids? (contains? layout :display-grid)
|
||||
show-outlines? (and (nil? transform) (not edit-path))
|
||||
show-outlines? (and (nil? transform) (not edition) (not drawing-obj))
|
||||
show-pixel-grid? (>= zoom 8)
|
||||
show-presence? page-id
|
||||
show-prototypes? (= options-mode :prototype)
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
(defn on-mouse-down
|
||||
[{:keys [id blocked hidden type]} drawing-tool text-editing? edition edit-path selected]
|
||||
(mf/use-callback
|
||||
(mf/deps id blocked hidden type drawing-tool text-editing? edition selected)
|
||||
(mf/deps id blocked hidden type drawing-tool text-editing? edition edit-path selected)
|
||||
(fn [bevent]
|
||||
(when (dom/class? (dom/get-target bevent) "viewport-controls")
|
||||
(dom/stop-propagation bevent)
|
||||
|
@ -63,14 +63,14 @@
|
|||
(and drawing-tool (not (#{:comments :path} drawing-tool)))
|
||||
(st/emit! (dd/start-drawing drawing-tool))
|
||||
|
||||
edit-path
|
||||
(and edit-path (contains? edit-path edition))
|
||||
;; Handle node select-drawing. NOP at the moment
|
||||
nil
|
||||
|
||||
(or (not id) (and frame? (not selected?)))
|
||||
(st/emit! (dw/handle-selection shift?))
|
||||
|
||||
:else
|
||||
(not drawing-tool)
|
||||
(st/emit! (when (or shift? (not selected?))
|
||||
(dw/select-shape id shift?))
|
||||
(when (not shift?)
|
||||
|
@ -119,9 +119,9 @@
|
|||
(reset! frame-hover nil))))
|
||||
|
||||
(defn on-click
|
||||
[hover selected]
|
||||
[hover selected edition drawing-path?]
|
||||
(mf/use-callback
|
||||
(mf/deps @hover selected)
|
||||
(mf/deps @hover selected edition drawing-path?)
|
||||
(fn [event]
|
||||
(when (dom/class? (dom/get-target event) "viewport-controls")
|
||||
(let [ctrl? (kbd/ctrl? event)
|
||||
|
@ -133,7 +133,7 @@
|
|||
selected? (contains? selected (:id @hover))]
|
||||
(st/emit! (ms/->MouseEvent :click ctrl? shift? alt?))
|
||||
|
||||
(when (and hovering? (not shift?) (not frame?) (not selected?))
|
||||
(when (and hovering? (not shift?) (not frame?) (not selected?) (not edition) (not drawing-path?))
|
||||
(st/emit! (dw/select-shape (:id @hover)))))))))
|
||||
|
||||
(defn on-double-click
|
||||
|
@ -178,7 +178,8 @@
|
|||
(mf/use-callback
|
||||
(mf/deps @hover)
|
||||
(fn [event]
|
||||
(when (dom/class? (dom/get-target event) "viewport-controls")
|
||||
(when (or (dom/class? (dom/get-target event) "viewport-controls")
|
||||
(dom/class? (dom/get-target event) "viewport-selrect"))
|
||||
(dom/prevent-default event)
|
||||
|
||||
(let [position (dom/get-client-position event)]
|
||||
|
|
|
@ -21,8 +21,9 @@
|
|||
(mf/defc outline
|
||||
{::mf/wrap-props false}
|
||||
[props]
|
||||
(let [shape (unchecked-get props "shape")
|
||||
zoom (unchecked-get props "zoom")
|
||||
(let [shape (obj/get props "shape")
|
||||
zoom (obj/get props "zoom" 1)
|
||||
|
||||
color (unchecked-get props "color")
|
||||
transform (gsh/transform-matrix shape)
|
||||
path? (= :path (:type shape))
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
(mf/defc selection-rect [{:keys [transform rect zoom color on-move-selected]}]
|
||||
(when rect
|
||||
(let [{:keys [x y width height]} rect]
|
||||
[:rect.main
|
||||
[:rect.main.viewport-selrect
|
||||
{:x x
|
||||
:y y
|
||||
:width width
|
||||
|
|
Loading…
Add table
Reference in a new issue