mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 08:06:38 +02: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 z-index (get-in objects [% :frame-id]))))))
|
;; (get z-index (get-in objects [% :frame-id]))))))
|
||||||
|
|
||||||
selected (-> (cph/sort-z-index objects selected)
|
selected (->> (cph/sort-z-index objects selected)
|
||||||
(into (d/ordered-set)))]
|
(into (d/ordered-set)))]
|
||||||
|
|
||||||
(assoc data :selected selected)))
|
(assoc data :selected selected)))
|
||||||
|
|
||||||
|
|
|
@ -306,8 +306,11 @@
|
||||||
(fn [{:keys [modifiers objects]}]
|
(fn [{:keys [modifiers objects]}]
|
||||||
(let [keys (->> modifiers
|
(let [keys (->> modifiers
|
||||||
(keys)
|
(keys)
|
||||||
(filter #(or (= frame-id %)
|
(filter (fn [id]
|
||||||
(= frame-id (get-in objects [% :frame-id])))))]
|
(let [shape (get objects id)]
|
||||||
|
(or (= frame-id id)
|
||||||
|
(and (= frame-id (:frame-id shape))
|
||||||
|
(not (= :frame (:type shape)))))))))]
|
||||||
(select-keys modifiers keys)))
|
(select-keys modifiers keys)))
|
||||||
workspace-modifiers-with-objects
|
workspace-modifiers-with-objects
|
||||||
=))
|
=))
|
||||||
|
|
|
@ -155,7 +155,12 @@
|
||||||
show-draw-area? drawing-obj
|
show-draw-area? drawing-obj
|
||||||
show-gradient-handlers? (= (count selected) 1)
|
show-gradient-handlers? (= (count selected) 1)
|
||||||
show-grids? (contains? layout :display-grid)
|
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)
|
show-pixel-grid? (and (contains? layout :show-pixel-grid)
|
||||||
(>= zoom 8))
|
(>= zoom 8))
|
||||||
show-text-editor? (and editing-shape (= :text (:type editing-shape)))
|
show-text-editor? (and editing-shape (= :text (:type editing-shape)))
|
||||||
|
@ -279,12 +284,7 @@
|
||||||
[:& outline/shape-outlines
|
[:& outline/shape-outlines
|
||||||
{:objects base-objects
|
{:objects base-objects
|
||||||
:selected selected
|
:selected selected
|
||||||
:hover (cond
|
:hover #{(:id @hover) @frame-hover}
|
||||||
(and @hover (or @mod? (not= :frame (:type @hover))))
|
|
||||||
#{(:id @hover)}
|
|
||||||
|
|
||||||
@frame-hover
|
|
||||||
#{@frame-hover})
|
|
||||||
:edition edition
|
:edition edition
|
||||||
:zoom zoom}])
|
:zoom zoom}])
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
left-click? (and (not panning) (= 1 (.-which event)))
|
left-click? (and (not panning) (= 1 (.-which event)))
|
||||||
middle-click? (and (not panning) (= 2 (.-which event)))
|
middle-click? (and (not panning) (= 2 (.-which event)))
|
||||||
|
|
||||||
frame? (= :frame type)
|
|
||||||
selected? (contains? selected id)]
|
selected? (contains? selected id)]
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
|
@ -96,7 +95,7 @@
|
||||||
drawing-tool
|
drawing-tool
|
||||||
(st/emit! (dd/start-drawing 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?))
|
(st/emit! (dw/handle-area-selection shift? mod?))
|
||||||
|
|
||||||
(not drawing-tool)
|
(not drawing-tool)
|
||||||
|
@ -157,12 +156,10 @@
|
||||||
alt? (kbd/alt? event)
|
alt? (kbd/alt? event)
|
||||||
meta? (kbd/meta? event)
|
meta? (kbd/meta? event)
|
||||||
mod? (kbd/mod? event)
|
mod? (kbd/mod? event)
|
||||||
hovering? (some? @hover)
|
hovering? (some? @hover)]
|
||||||
frame? (= :frame (:type @hover))]
|
|
||||||
(st/emit! (ms/->MouseEvent :click ctrl? shift? alt? meta?))
|
(st/emit! (ms/->MouseEvent :click ctrl? shift? alt? meta?))
|
||||||
|
|
||||||
(when (and hovering?
|
(when (and hovering?
|
||||||
(or (not frame?) mod?)
|
|
||||||
(not @space?)
|
(not @space?)
|
||||||
(not edition)
|
(not edition)
|
||||||
(not drawing-path?)
|
(not drawing-path?)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
[app.common.data :as d]
|
||||||
[app.main.data.shortcuts :as dsc]
|
[app.main.data.shortcuts :as dsc]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.path.shortcuts :as psc]
|
[app.main.data.workspace.path.shortcuts :as psc]
|
||||||
|
@ -112,6 +113,9 @@
|
||||||
hover-disabled-ref (mf/use-ref hover-disabled?)
|
hover-disabled-ref (mf/use-ref hover-disabled?)
|
||||||
focus-ref (mf/use-ref focus)
|
focus-ref (mf/use-ref focus)
|
||||||
|
|
||||||
|
last-point-ref (mf/use-var nil)
|
||||||
|
mod-str (mf/use-memo #(rx/subject))
|
||||||
|
|
||||||
query-point
|
query-point
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(mf/deps page-id)
|
(mf/deps page-id)
|
||||||
|
@ -133,15 +137,23 @@
|
||||||
(mf/use-memo
|
(mf/use-memo
|
||||||
(fn []
|
(fn []
|
||||||
(rx/merge
|
(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
|
(->> move-stream
|
||||||
;; When transforming shapes we stop querying the worker
|
;; When transforming shapes we stop querying the worker
|
||||||
(rx/filter #(not (some? (mf/ref-val transform-ref))))
|
(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
|
(->> move-stream
|
||||||
;; When transforming shapes we stop querying the worker
|
;; When transforming shapes we stop querying the worker
|
||||||
(rx/filter #(some? (mf/ref-val transform-ref)))
|
(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
|
;; Refresh the refs on a value change
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
|
@ -154,7 +166,9 @@
|
||||||
|
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps @mod?)
|
(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/use-effect
|
||||||
(mf/deps selected)
|
(mf/deps selected)
|
||||||
|
@ -172,10 +186,11 @@
|
||||||
over-shapes-stream
|
over-shapes-stream
|
||||||
(mf/deps page-id objects)
|
(mf/deps page-id objects)
|
||||||
(fn [ids]
|
(fn [ids]
|
||||||
#_(prn "??hover-ids" (->> ids (map #(get-in objects [% :name]))))
|
(let [ids (into
|
||||||
(let [is-group?
|
(d/ordered-set)
|
||||||
(fn [id]
|
(cph/sort-z-index objects ids))
|
||||||
(contains? #{:group :bool} (get-in objects [id :type])))
|
|
||||||
|
grouped? (fn [id] (contains? #{:group :bool} (get-in objects [id :type])))
|
||||||
|
|
||||||
selected (mf/ref-val selected-ref)
|
selected (mf/ref-val selected-ref)
|
||||||
focus (mf/ref-val focus-ref)
|
focus (mf/ref-val focus-ref)
|
||||||
|
@ -188,12 +203,11 @@
|
||||||
(into (filter #(group-empty-space? % objects ids)) ids)
|
(into (filter #(group-empty-space? % objects ids)) ids)
|
||||||
|
|
||||||
mod?
|
mod?
|
||||||
(into (filter is-group?) ids))
|
(into (filter grouped?) ids))
|
||||||
|
|
||||||
hover-shape (->> ids
|
hover-shape (->> ids
|
||||||
(filter (comp not remove-id?))
|
(remove remove-id?)
|
||||||
(filter #(or (empty? focus)
|
(filter #(or (empty? focus) (cp/is-in-focus? objects focus %)))
|
||||||
(cp/is-in-focus? objects focus %)))
|
|
||||||
(first)
|
(first)
|
||||||
(get objects))]
|
(get objects))]
|
||||||
(reset! hover hover-shape)
|
(reset! hover hover-shape)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue