mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 08:50:57 -05:00
✨ Changes in selection feedback
This commit is contained in:
parent
aa584e6d35
commit
688ec2589a
5 changed files with 41 additions and 27 deletions
|
@ -1224,8 +1224,8 @@
|
|||
;; (+ (get z-index %)
|
||||
;; (get z-index (get-in objects [% :frame-id]))))))
|
||||
|
||||
selected (-> (cph/sort-z-index objects selected)
|
||||
(into (d/ordered-set)))]
|
||||
selected (->> (cph/sort-z-index objects selected)
|
||||
(into (d/ordered-set)))]
|
||||
|
||||
(assoc data :selected selected)))
|
||||
|
||||
|
|
|
@ -306,8 +306,11 @@
|
|||
(fn [{:keys [modifiers objects]}]
|
||||
(let [keys (->> modifiers
|
||||
(keys)
|
||||
(filter #(or (= frame-id %)
|
||||
(= frame-id (get-in objects [% :frame-id])))))]
|
||||
(filter (fn [id]
|
||||
(let [shape (get objects id)]
|
||||
(or (= frame-id id)
|
||||
(and (= frame-id (:frame-id shape))
|
||||
(not (= :frame (:type shape)))))))))]
|
||||
(select-keys modifiers keys)))
|
||||
workspace-modifiers-with-objects
|
||||
=))
|
||||
|
|
|
@ -155,7 +155,12 @@
|
|||
show-draw-area? drawing-obj
|
||||
show-gradient-handlers? (= (count selected) 1)
|
||||
show-grids? (contains? layout :display-grid)
|
||||
show-outlines? (and (nil? transform) (not edition) (not drawing-obj) (not (#{:comments :path :curve} drawing-tool)))
|
||||
|
||||
show-outlines? (and (nil? transform)
|
||||
(not edition)
|
||||
(not drawing-obj)
|
||||
(not (#{:comments :path :curve} drawing-tool)))
|
||||
|
||||
show-pixel-grid? (and (contains? layout :show-pixel-grid)
|
||||
(>= zoom 8))
|
||||
show-text-editor? (and editing-shape (= :text (:type editing-shape)))
|
||||
|
@ -279,12 +284,7 @@
|
|||
[:& outline/shape-outlines
|
||||
{:objects base-objects
|
||||
:selected selected
|
||||
:hover (cond
|
||||
(and @hover (or @mod? (not= :frame (:type @hover))))
|
||||
#{(:id @hover)}
|
||||
|
||||
@frame-hover
|
||||
#{@frame-hover})
|
||||
:hover #{(:id @hover) @frame-hover}
|
||||
:edition edition
|
||||
:zoom zoom}])
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
left-click? (and (not panning) (= 1 (.-which event)))
|
||||
middle-click? (and (not panning) (= 2 (.-which event)))
|
||||
|
||||
frame? (= :frame type)
|
||||
selected? (contains? selected id)]
|
||||
|
||||
(cond
|
||||
|
@ -96,7 +95,7 @@
|
|||
drawing-tool
|
||||
(st/emit! (dd/start-drawing drawing-tool))
|
||||
|
||||
(or (not id) (and frame? (not selected?)) mod?)
|
||||
(or (not id) mod?)
|
||||
(st/emit! (dw/handle-area-selection shift? mod?))
|
||||
|
||||
(not drawing-tool)
|
||||
|
@ -157,12 +156,10 @@
|
|||
alt? (kbd/alt? event)
|
||||
meta? (kbd/meta? event)
|
||||
mod? (kbd/mod? event)
|
||||
hovering? (some? @hover)
|
||||
frame? (= :frame (:type @hover))]
|
||||
hovering? (some? @hover)]
|
||||
(st/emit! (ms/->MouseEvent :click ctrl? shift? alt? meta?))
|
||||
|
||||
(when (and hovering?
|
||||
(or (not frame?) mod?)
|
||||
(not @space?)
|
||||
(not edition)
|
||||
(not drawing-path?)
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
[app.common.pages :as cp]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.common.data :as d]
|
||||
[app.main.data.shortcuts :as dsc]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.path.shortcuts :as psc]
|
||||
|
@ -112,6 +113,9 @@
|
|||
hover-disabled-ref (mf/use-ref hover-disabled?)
|
||||
focus-ref (mf/use-ref focus)
|
||||
|
||||
last-point-ref (mf/use-var nil)
|
||||
mod-str (mf/use-memo #(rx/subject))
|
||||
|
||||
query-point
|
||||
(mf/use-callback
|
||||
(mf/deps page-id)
|
||||
|
@ -133,15 +137,23 @@
|
|||
(mf/use-memo
|
||||
(fn []
|
||||
(rx/merge
|
||||
;; This stream works to "refresh" the outlines when the control is pressed
|
||||
;; but the mouse has not been moved from its position.
|
||||
(->> mod-str
|
||||
(rx/observe-on :async)
|
||||
(rx/map #(deref last-point-ref)))
|
||||
|
||||
(->> move-stream
|
||||
;; When transforming shapes we stop querying the worker
|
||||
(rx/filter #(not (some? (mf/ref-val transform-ref))))
|
||||
(rx/merge-map query-point))
|
||||
(rx/merge-map query-point)
|
||||
(rx/tap #(reset! last-point-ref %)))
|
||||
|
||||
(->> move-stream
|
||||
;; When transforming shapes we stop querying the worker
|
||||
(rx/filter #(some? (mf/ref-val transform-ref)))
|
||||
(rx/map (constantly nil))))))]
|
||||
(rx/map (constantly nil))
|
||||
(rx/tap #(reset! last-point-ref %))))))]
|
||||
|
||||
;; Refresh the refs on a value change
|
||||
(mf/use-effect
|
||||
|
@ -154,7 +166,9 @@
|
|||
|
||||
(mf/use-effect
|
||||
(mf/deps @mod?)
|
||||
#(mf/set-ref-val! mod-ref @mod?))
|
||||
(fn []
|
||||
(rx/push! mod-str :update)
|
||||
(mf/set-ref-val! mod-ref @mod?)))
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps selected)
|
||||
|
@ -172,10 +186,11 @@
|
|||
over-shapes-stream
|
||||
(mf/deps page-id objects)
|
||||
(fn [ids]
|
||||
#_(prn "??hover-ids" (->> ids (map #(get-in objects [% :name]))))
|
||||
(let [is-group?
|
||||
(fn [id]
|
||||
(contains? #{:group :bool} (get-in objects [id :type])))
|
||||
(let [ids (into
|
||||
(d/ordered-set)
|
||||
(cph/sort-z-index objects ids))
|
||||
|
||||
grouped? (fn [id] (contains? #{:group :bool} (get-in objects [id :type])))
|
||||
|
||||
selected (mf/ref-val selected-ref)
|
||||
focus (mf/ref-val focus-ref)
|
||||
|
@ -188,12 +203,11 @@
|
|||
(into (filter #(group-empty-space? % objects ids)) ids)
|
||||
|
||||
mod?
|
||||
(into (filter is-group?) ids))
|
||||
(into (filter grouped?) ids))
|
||||
|
||||
hover-shape (->> ids
|
||||
(filter (comp not remove-id?))
|
||||
(filter #(or (empty? focus)
|
||||
(cp/is-in-focus? objects focus %)))
|
||||
(remove remove-id?)
|
||||
(filter #(or (empty? focus) (cp/is-in-focus? objects focus %)))
|
||||
(first)
|
||||
(get objects))]
|
||||
(reset! hover hover-shape)
|
||||
|
|
Loading…
Reference in a new issue