Skip to content

Commit

Permalink
fix debug dom rect and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Nov 23, 2024
1 parent d906cad commit 41ca663
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
18 changes: 10 additions & 8 deletions src/renderer/app/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@
[coll]
(str "[" (str/join " " (map #(.toFixed % 2) coll)) "]"))

(defn map->str
[m]
(interpose ", " (map (fn [[k v]]
^{:key k}
[:span (str (name k) ": " (if (number? v)
(.toFixed v 2)
(coll->str v)))]) m)))

(defn debug-rows
[]
[["Dom rect" @(rf/subscribe [::app.s/dom-rect])]
[["Dom rect" (map->str @(rf/subscribe [::app.s/dom-rect]))]
["Viewbox" (coll->str @(rf/subscribe [::frame.s/viewbox]))]
["Pointer position" (coll->str @(rf/subscribe [::app.s/pointer-pos]))]
["Adjusted pointer position" (coll->str @(rf/subscribe [::app.s/adjusted-pointer-pos]))]
Expand All @@ -55,13 +63,7 @@
["State" @(rf/subscribe [::tool.s/state])]
["Clicked element" (:id @(rf/subscribe [::app.s/clicked-element]))]
["Ignored elements" @(rf/subscribe [::document.s/ignored-ids])]
["Snap" (into (map (fn [[k v]]
^{:key k}
[:div (str (name k)
" "
(if (number? v)
(.toFixed v 2)
(coll->str v)))]) @(rf/subscribe [::snap.s/nearest-neighbor])))]])
["Snap" (map->str @(rf/subscribe [::snap.s/nearest-neighbor]))]])

(defn debug-info
[]
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/tool/impl/base/transform.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
(dissoc :clicked-element)
(element.h/unignore :bounding-box)
(element.h/toggle-selection (:id element) (pointer/shift? e))
(history.h/finalize (if (:selected element) "Deselect element" "Select element"))))
(history.h/finalize (if (:selected element)
"Deselect element"
"Select element"))))

(defmethod hierarchy/on-double-click :transform
[db e]
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/tool/impl/base/zoom.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
(let [factor (if (pointer/shift? e)
(:zoom-sensitivity db)
(/ 1 (:zoom-sensitivity db)))]
(-> db
(frame.h/zoom-at-pointer factor)
(-> (frame.h/zoom-at-pointer db factor)
(snap.h/update-viewport-tree)
(h/add-fx [::app.fx/persist]))))

0 comments on commit 41ca663

Please sign in to comment.