mirror of
https://github.com/penpot/penpot.git
synced 2026-09-18 18:06:14 +00:00
WIP
This commit is contained in:
parent
878952f7b5
commit
1b2061021a
@ -701,11 +701,15 @@
|
|||||||
|
|
||||||
(defn select-shape
|
(defn select-shape
|
||||||
([id]
|
([id]
|
||||||
|
(select-shape id false))
|
||||||
|
|
||||||
|
([id toggle?]
|
||||||
|
(.log js/console "select-shape" id toggle?)
|
||||||
(ptk/reify ::select-shape
|
(ptk/reify ::select-shape
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
(assoc-in [:viewer-local :selected] #{id}))))))
|
(update-in [:viewer-local :selected] d/toggle-selection id toggle?))))))
|
||||||
|
|
||||||
(defn toggle-selection
|
(defn toggle-selection
|
||||||
[id]
|
[id]
|
||||||
|
|||||||
@ -133,28 +133,29 @@
|
|||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(-> state
|
(-> state
|
||||||
|
(js/console.log "select-shape" id toggle?)
|
||||||
(update-in [:workspace-local :selected] d/toggle-selection id toggle?)
|
(update-in [:workspace-local :selected] d/toggle-selection id toggle?)
|
||||||
(assoc-in [:workspace-local :last-selected] id)))
|
(assoc-in [:workspace-local :last-selected] id)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (dsh/lookup-page-objects state page-id)
|
objects (dsh/lookup-page-objects state page-id)
|
||||||
selected-id (dsh/lookup-selected state)
|
selected-id (dsh/lookup-selected state)
|
||||||
selected (dsh/lookup-shapes state selected-id)
|
selected (dsh/lookup-shapes state selected-id)
|
||||||
frame-ids (map (fn [item] (let [parent (cfh/get-frame objects (:id item))]
|
frame-ids (map (fn [item] (let [parent (cfh/get-frame objects (:id item))]
|
||||||
(:id parent))) selected)
|
(:id parent))) selected)
|
||||||
params-without-board (-> (rt/get-params state)
|
params-without-board (-> (rt/get-params state)
|
||||||
(dissoc :board-id))
|
(dissoc :board-id))
|
||||||
params-board (-> (rt/get-params state)
|
params-board (-> (rt/get-params state)
|
||||||
(assoc :board-id frame-ids))]
|
(assoc :board-id frame-ids))]
|
||||||
|
|
||||||
(rx/of (dwc/expand-all-parents [id] objects)
|
(rx/of (dwc/expand-all-parents [id] objects)
|
||||||
:interrupt
|
:interrupt
|
||||||
::dwsp/interrupt
|
::dwsp/interrupt
|
||||||
(if (some #(= % uuid/zero) frame-ids)
|
(if (some #(= % uuid/zero) frame-ids)
|
||||||
(rt/nav :workspace params-without-board {::rt/replace true})
|
(rt/nav :workspace params-without-board {::rt/replace true})
|
||||||
(rt/nav :workspace params-board {::rt/replace true}))))))))
|
(rt/nav :workspace params-board {::rt/replace true}))))))))
|
||||||
|
|
||||||
(defn select-prev-shape
|
(defn select-prev-shape
|
||||||
([]
|
([]
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.main.data.viewer :as dv]
|
[app.main.data.viewer :as dv]
|
||||||
|
[app.main.data.workspace.selection :as dws]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.inspect.selection-feedback :refer [selection-feedback]]
|
[app.main.ui.inspect.selection-feedback :refer [selection-feedback]]
|
||||||
[app.main.ui.shapes.bool :as bool]
|
[app.main.ui.shapes.bool :as bool]
|
||||||
@ -30,6 +31,9 @@
|
|||||||
|
|
||||||
(declare shape-container-factory)
|
(declare shape-container-factory)
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; TODO: Aquí está el tema del hover de shapes.
|
||||||
|
;;
|
||||||
(defn handle-hover-shape
|
(defn handle-hover-shape
|
||||||
[shape hover?]
|
[shape hover?]
|
||||||
(fn [event]
|
(fn [event]
|
||||||
@ -39,7 +43,8 @@
|
|||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(st/emit! (dv/hover-shape (:id shape) hover?)))))
|
(st/emit! (dv/hover-shape (:id shape) hover?)))))
|
||||||
|
|
||||||
(defn select-shape [shape]
|
(defn handle-select-shape
|
||||||
|
[shape]
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(when-not (or (cfh/group-shape? shape)
|
(when-not (or (cfh/group-shape? shape)
|
||||||
(cfh/root-frame? shape))
|
(cfh/root-frame? shape))
|
||||||
@ -67,7 +72,7 @@
|
|||||||
[:> shape-container {:shape shape
|
[:> shape-container {:shape shape
|
||||||
:on-pointer-enter (handle-hover-shape shape true)
|
:on-pointer-enter (handle-hover-shape shape true)
|
||||||
:on-pointer-leave (handle-hover-shape shape false)
|
:on-pointer-leave (handle-hover-shape shape false)
|
||||||
:on-click (select-shape shape)}
|
:on-click (handle-select-shape shape)}
|
||||||
[:& component {:shape shape
|
[:& component {:shape shape
|
||||||
:frame frame
|
:frame frame
|
||||||
:childs childs
|
:childs childs
|
||||||
|
|||||||
@ -33,7 +33,9 @@
|
|||||||
|
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
|
|
||||||
(st/emit! (dv/select-shape frame-id))
|
(st/emit! (dv/select-shape frame-id))
|
||||||
|
|
||||||
(when over-section?
|
(when over-section?
|
||||||
(if has-force?
|
(if has-force?
|
||||||
(dom/remove-class! layout "force-visible")
|
(dom/remove-class! layout "force-visible")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user