|
32 | 32 | "pointermove"
|
33 | 33 | (-> (if pointer-offset
|
34 | 34 | (if (significant-drag? pointer-pos pointer-offset drag-threshold)
|
35 |
| - (-> (cond-> db |
36 |
| - (not= tool :pan) |
37 |
| - (tool.handlers/pan-out-of-canvas dom-rect pointer-pos pointer-offset) |
38 |
| - |
39 |
| - (not drag) |
40 |
| - (-> (assoc :drag true) |
41 |
| - (tool.hierarchy/on-drag-start e) |
42 |
| - (tool.handlers/add-fx [::event.effects/set-pointer-capture |
43 |
| - pointer-id]))) |
44 |
| - (tool.hierarchy/on-drag e)) |
| 35 | + (cond-> db |
| 36 | + (not= tool :pan) |
| 37 | + (tool.handlers/pan-out-of-canvas dom-rect pointer-pos pointer-offset) |
| 38 | + |
| 39 | + (not drag) |
| 40 | + (-> (assoc :drag true) |
| 41 | + (tool.hierarchy/on-drag-start e) |
| 42 | + (tool.handlers/add-fx [::event.effects/set-pointer-capture |
| 43 | + pointer-id])) |
| 44 | + |
| 45 | + :always |
| 46 | + (tool.hierarchy/on-drag e)) |
45 | 47 | db)
|
46 | 48 | (tool.hierarchy/on-pointer-move db e))
|
47 | 49 | (assoc :pointer-pos pointer-pos
|
48 | 50 | :adjusted-pointer-pos adjusted-pointer-pos))
|
49 | 51 |
|
50 | 52 | "pointerdown"
|
51 |
| - (-> (cond-> db |
52 |
| - (= button :middle) |
53 |
| - (-> (assoc :cached-tool tool |
54 |
| - :cached-state state) |
55 |
| - (tool.handlers/activate :pan)) |
| 53 | + (cond-> db |
| 54 | + (= button :middle) |
| 55 | + (-> (assoc :cached-tool tool |
| 56 | + :cached-state state) |
| 57 | + (tool.handlers/activate :pan)) |
56 | 58 |
|
57 |
| - (not= button :right) |
58 |
| - (-> (update :active-pointers conj pointer-id) |
59 |
| - (assoc :pointer-offset pointer-pos |
60 |
| - :adjusted-pointer-offset adjusted-pointer-pos |
61 |
| - :nearest-neighbor-offset (:point nearest-neighbor)))) |
62 |
| - |
63 |
| - (tool.hierarchy/on-pointer-down e) |
64 |
| - (tool.handlers/add-fx [::effects/focus nil])) |
| 59 | + (not= button :right) |
| 60 | + (-> (update :active-pointers conj pointer-id) |
| 61 | + (assoc :pointer-offset pointer-pos |
| 62 | + :adjusted-pointer-offset adjusted-pointer-pos |
| 63 | + :nearest-neighbor-offset (:point nearest-neighbor))) |
| 64 | + :always |
| 65 | + (-> (tool.hierarchy/on-pointer-down e) |
| 66 | + (tool.handlers/add-fx [::effects/focus nil]))) |
65 | 67 |
|
66 | 68 | "pointerup"
|
67 | 69 | (if (contains? active-pointers pointer-id)
|
68 |
| - (-> (cond-> (if drag |
69 |
| - (-> (tool.hierarchy/on-drag-end db e) |
70 |
| - (tool.handlers/add-fx [::event.effects/release-pointer-capture |
71 |
| - pointer-id])) |
72 |
| - (if (= button :right) |
73 |
| - db |
74 |
| - (if (< 0 (- timestamp event-timestamp) double-click-delta) |
75 |
| - (-> (dissoc db :event-timestamp) |
76 |
| - (tool.hierarchy/on-double-click e)) |
77 |
| - (-> (assoc db :event-timestamp timestamp) |
78 |
| - (tool.hierarchy/on-pointer-up e))))) |
79 |
| - (and cached-tool (= button :middle)) |
80 |
| - (-> (tool.handlers/activate cached-tool) |
81 |
| - (tool.handlers/set-state cached-state) |
82 |
| - (dissoc :cached-tool :cached-state))) |
83 |
| - (update :active-pointers disj pointer-id) |
84 |
| - (dissoc :pointer-offset :drag :nearest-neighbor)) |
| 70 | + (cond-> (if drag |
| 71 | + (-> (tool.hierarchy/on-drag-end db e) |
| 72 | + (tool.handlers/add-fx [::event.effects/release-pointer-capture |
| 73 | + pointer-id])) |
| 74 | + (if (= button :right) |
| 75 | + db |
| 76 | + (if (< 0 (- timestamp event-timestamp) double-click-delta) |
| 77 | + (-> (dissoc db :event-timestamp) |
| 78 | + (tool.hierarchy/on-double-click e)) |
| 79 | + (-> (assoc db :event-timestamp timestamp) |
| 80 | + (tool.hierarchy/on-pointer-up e))))) |
| 81 | + (and cached-tool (= button :middle)) |
| 82 | + (-> (tool.handlers/activate cached-tool) |
| 83 | + (tool.handlers/set-state cached-state) |
| 84 | + (dissoc :cached-tool :cached-state)) |
| 85 | + |
| 86 | + :always |
| 87 | + (-> (update :active-pointers disj pointer-id) |
| 88 | + (dissoc :pointer-offset :drag :nearest-neighbor))) |
85 | 89 | db)
|
86 | 90 | db)))
|
87 | 91 |
|
|
90 | 94 | [db e]
|
91 | 95 | (case (:type e)
|
92 | 96 | "keydown"
|
93 |
| - (-> (cond-> db |
94 |
| - (and (= (:code e) "Space") |
95 |
| - (not= (:tool db) :pan) |
96 |
| - (= (:state db) :idle)) |
97 |
| - (-> (assoc :cached-tool (:tool db)) |
98 |
| - (tool.handlers/activate :pan)) |
99 |
| - |
100 |
| - (= (:key e) "Shift") |
101 |
| - (-> (assoc-in [:snap :transient-active] true) |
102 |
| - (cond-> (not (-> db :snap :active)) |
103 |
| - (-> (dissoc :nearest-neighbor) |
104 |
| - (snap.handlers/rebuild-tree))))) |
105 |
| - (tool.hierarchy/on-key-down e)) |
| 97 | + (cond-> db |
| 98 | + (and (= (:code e) "Space") |
| 99 | + (not= (:tool db) :pan) |
| 100 | + (= (:state db) :idle)) |
| 101 | + (-> (assoc :cached-tool (:tool db)) |
| 102 | + (tool.handlers/activate :pan)) |
| 103 | + |
| 104 | + (= (:key e) "Shift") |
| 105 | + (-> (assoc-in [:snap :transient-active] true) |
| 106 | + (cond-> (not (-> db :snap :active)) |
| 107 | + (-> (dissoc :nearest-neighbor) |
| 108 | + (snap.handlers/rebuild-tree)))) |
| 109 | + |
| 110 | + :always |
| 111 | + (tool.hierarchy/on-key-down e)) |
106 | 112 |
|
107 | 113 | "keyup"
|
108 |
| - (-> (cond-> db |
109 |
| - (and (= (:code e) "Space") |
110 |
| - (:cached-tool db)) |
111 |
| - (-> (tool.handlers/activate (:cached-tool db)) |
112 |
| - (dissoc :cached-tool)) |
113 |
| - |
114 |
| - (= (:key e) "Shift") |
115 |
| - (-> (assoc-in [:snap :transient-active] false) |
116 |
| - (cond-> |
117 |
| - (not (-> db :snap :active)) |
118 |
| - (dissoc :nearest-neighbor)))) |
119 |
| - (tool.hierarchy/on-key-up e)) |
| 114 | + (cond-> db |
| 115 | + (and (= (:code e) "Space") |
| 116 | + (:cached-tool db)) |
| 117 | + (-> (tool.handlers/activate (:cached-tool db)) |
| 118 | + (dissoc :cached-tool)) |
| 119 | + |
| 120 | + (= (:key e) "Shift") |
| 121 | + (-> (assoc-in [:snap :transient-active] false) |
| 122 | + (cond-> |
| 123 | + (not (-> db :snap :active)) |
| 124 | + (dissoc :nearest-neighbor))) |
| 125 | + |
| 126 | + :always |
| 127 | + (tool.hierarchy/on-key-up e)) |
120 | 128 | db))
|
121 | 129 |
|
122 | 130 | (m/=> wheel [:-> App WheelEvent App])
|
|
0 commit comments