Skip to content

Commit e0f2ba4

Browse files
committed
rename tools
1 parent b6cb9e3 commit e0f2ba4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+442
-441
lines changed

src/renderer/attribute/views.cljs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[re-frame.core :as rf]
1010
[renderer.attribute.hierarchy :as hierarchy]
1111
[renderer.components :as comp]
12-
[renderer.tools.base :as tools]
12+
[renderer.tool.base :as tool]
1313
[renderer.utils.keyboard :as keyb]
1414
[renderer.utils.spec :as spec]))
1515

@@ -52,7 +52,7 @@
5252
[{:keys [tag attr]}]
5353
(let [data (if attr (spec/compat-data tag attr) (spec/compat-data tag))
5454
support-data (:support data)
55-
animation? (isa? tag ::tools/animation)]
55+
animation? (isa? tag ::tool/animation)]
5656
(when (or support-data animation?)
5757
[:div.flex.flex-col
5858
(when (some :version_added (vals support-data))
@@ -235,10 +235,10 @@
235235
:align "end"}
236236
[:div.p-6
237237
[:h2.mb-4.text-lg tag]
238-
(when-let [description (:description (tools/properties tag))]
238+
(when-let [description (:description (tool/properties tag))]
239239
[:p description])
240240
[caniusethis {:tag tag}]
241-
(when-let [url (:url (tools/properties tag))]
241+
(when-let [url (:url (tool/properties tag))]
242242
[:a.button.px-3.bg-primary.w-full
243243
{:href url
244244
:target "_blank"}

src/renderer/core.cljs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
[renderer.subs]
3131
[renderer.theme.core]
3232
[renderer.timeline.core]
33-
[renderer.tools.core]
33+
[renderer.tool.core]
3434
[renderer.utils.dom :as dom]
3535
[renderer.utils.error :as error]
3636
[renderer.utils.keyboard :as keyb]

src/renderer/element/handlers.cljs

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
[reagent.dom.server :as dom.server]
1111
[renderer.attribute.hierarchy :as hierarchy]
1212
[renderer.document.handlers :as document.h]
13-
[renderer.tools.base :as tools]
14-
[renderer.tools.shape.path :as path]
13+
[renderer.tool.base :as tool]
14+
[renderer.tool.shape.path :as path]
1515
[renderer.utils.bounds :as bounds]
1616
[renderer.utils.element :as element]
1717
[renderer.utils.map :as map]
@@ -420,7 +420,7 @@
420420
(let [svgs (reverse (root-svgs db))
421421
pointer-pos (:adjusted-pointer-pos db)]
422422
(or
423-
(some #(when (bounds/contain-point? (tools/bounds %) pointer-pos) %) svgs)
423+
(some #(when (bounds/contain-point? (tool/bounds %) pointer-pos) %) svgs)
424424
(element db :canvas))))
425425

426426
(defn translate
@@ -442,24 +442,24 @@
442442
([db el offset]
443443
(cond-> db
444444
(not (:locked? el))
445-
(update-el el tools/translate offset))))
445+
(update-el el tool/translate offset))))
446446

447447
(defn position
448448
([db pos]
449449
(reduce #(position %1 %2 pos) db (top-selected-ancestors db)))
450450
([db el pos]
451451
(cond-> db
452452
(not (:locked? el))
453-
(update-el el tools/position pos))))
453+
(update-el el tool/position pos))))
454454

455455
(defn scale
456456
([db ratio pivot-point]
457457
(reduce #(scale %1 %2 ratio pivot-point) db (selected db)))
458458
([db el ratio pivot-point]
459459
(cond-> db
460460
(not (:locked? el))
461-
(update-el el tools/scale ratio (let [[x1 y1] (:bounds el)]
462-
(mat/sub pivot-point [x1 y1]))))))
461+
(update-el el tool/scale ratio (let [[x1 y1] (:bounds el)]
462+
(mat/sub pivot-point [x1 y1]))))))
463463

464464
(defn align
465465
([db direction]
@@ -502,10 +502,10 @@
502502
(defn overlapping-svg
503503
[db el]
504504
(let [svgs (reverse (root-svgs db)) ; Reverse to select top svgs first.
505-
el-bounds (tools/bounds el)]
505+
el-bounds (tool/bounds el)]
506506
(or
507-
(some #(when (bounds/contained? el-bounds (tools/bounds %)) %) svgs)
508-
(some #(when (bounds/intersected? el-bounds (tools/bounds %)) %) svgs)
507+
(some #(when (bounds/contained? el-bounds (tool/bounds %)) %) svgs)
508+
(some #(when (bounds/intersected? el-bounds (tool/bounds %)) %) svgs)
509509
(element db :canvas))))
510510

511511
(defn create
@@ -515,7 +515,7 @@
515515
page (overlapping-svg db el)
516516
parent (or (:parent el) (if (element/svg? el) :canvas (:key page)))
517517
children (vals (select-keys (elements db) (:children el)))
518-
[x1 y1] (tools/bounds (element db parent))
518+
[x1 y1] (tool/bounds (element db parent))
519519
children (concat children (:content el))
520520
new-el (map/deep-merge el default-props {:key key :parent parent})
521521
add-children (fn [db children]
@@ -587,7 +587,7 @@
587587
offset (mat/sub el-center center)
588588
el (dissoc el :bounds)
589589
svg (hovered-svg db)
590-
[s-x1 s-y1] (tools/bounds svg)
590+
[s-x1 s-y1] (tool/bounds svg)
591591
pointer-pos (:adjusted-pointer-pos db)
592592
selected (selected-keys db)]
593593
(reduce
@@ -686,7 +686,7 @@
686686

687687
(defn ->string
688688
[elements]
689-
(reduce #(-> (tools/render-to-string %2)
689+
(reduce #(-> (tool/render-to-string %2)
690690
dom.server/render-to-static-markup
691691
(str "\n" %)) "" elements))
692692

src/renderer/element/subs.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[kdtree]
55
[re-frame.core :as rf]
66
[renderer.attribute.utils :as attr.utils]
7-
[renderer.tools.base :as tools]
7+
[renderer.tool.base :as tool]
88
[renderer.utils.element :as utils.el]
99
[renderer.utils.map :as map]
1010
[renderer.element.handlers :as h]))
@@ -102,7 +102,7 @@
102102
(sort-by (fn [[k _]]
103103
(-> (first selected-elements)
104104
:tag
105-
tools/properties
105+
tool/properties
106106
:attrs
107107
(.indexOf k)))
108108
attrs))]
@@ -118,7 +118,7 @@
118118
:element/area
119119
:<- [:element/selected]
120120
(fn [selected-elements _]
121-
(reduce #(+ %1 (tools/area %2)) 0 selected-elements)))
121+
(reduce #(+ %1 (tool/area %2)) 0 selected-elements)))
122122

123123
(rf/reg-sub
124124
:element/ancestor-keys

src/renderer/events.cljs

+16-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[re-frame.core :as rf]
66
[renderer.db :as db]
77
[renderer.frame.handlers :as frame-h]
8-
[renderer.tools.base :as tools]
8+
[renderer.tool.base :as tool]
99
[renderer.utils.drop :as drop]
1010
[renderer.utils.local-storage :as local-storage]
1111
[renderer.utils.pointer :as pointer]))
@@ -51,7 +51,7 @@
5151
(rf/reg-event-db
5252
:set-tool
5353
(fn [db [_ tool]]
54-
(tools/set-tool db tool)))
54+
(tool/set-tool db tool)))
5555

5656
(rf/reg-event-db
5757
:clear-restored
@@ -116,44 +116,44 @@
116116
pointer-offset)
117117

118118
(not drag?)
119-
(-> (tools/drag-start e element)
119+
(-> (tool/drag-start e element)
120120
(assoc :drag? true))
121121

122122
:always
123-
(tools/drag e element))
123+
(tool/drag e element))
124124
db)
125-
(tools/pointer-move db e element))
125+
(tool/pointer-move db e element))
126126
(assoc :pointer-pos pointer-pos
127127
:adjusted-pointer-pos adjusted-pointer-pos)))
128128

129129
:pointerdown
130130
(cond-> db
131131
(= button :middle)
132132
(-> (assoc :primary-tool tool)
133-
(tools/set-tool :pan))
133+
(tool/set-tool :pan))
134134

135135
(and (= button :right) (not= (:key element) :bounding-box))
136-
(tools/pointer-up e element)
136+
(tool/pointer-up e element)
137137

138138
:always
139-
(-> (tools/pointer-down e element)
139+
(-> (tool/pointer-down e element)
140140
(assoc :pointer-offset pointer-pos
141141
:adjusted-pointer-offset adjusted-pointer-pos)))
142142

143143
:pointerup
144144
(cond-> (if drag?
145-
(tools/drag-end db e element)
146-
(cond-> db (not= button :right) (tools/pointer-up e element)))
145+
(tool/drag-end db e element)
146+
(cond-> db (not= button :right) (tool/pointer-up e element)))
147147
(and primary-tool (= button :middle))
148-
(-> (tools/set-tool primary-tool)
148+
(-> (tool/set-tool primary-tool)
149149
(dissoc :primary-tool))
150150

151151
:always
152152
(-> (dissoc :pointer-offset :drag?)
153153
(update :snap dissoc :nearest-neighbor)))
154154

155155
:dblclick
156-
(tools/double-click db e element)
156+
(tool/double-click db e element)
157157

158158
:wheel
159159
(if (some modifiers [:ctrl :alt])
@@ -176,20 +176,20 @@
176176
(and (= code "Space")
177177
(not= tool :pan))
178178
(-> (assoc :primary-tool tool)
179-
(tools/set-tool :pan))
179+
(tool/set-tool :pan))
180180

181181
:always
182-
(tools/key-down e))
182+
(tool/key-down e))
183183

184184
:keyup
185185
(cond-> db
186186
(and (= code "Space")
187187
(:primary-tool db))
188-
(-> (tools/set-tool (:primary-tool db))
188+
(-> (tool/set-tool (:primary-tool db))
189189
(dissoc :primary-tool))
190190

191191
:always
192-
(tools/key-up e))
192+
(tool/key-up e))
193193

194194
db)))
195195

src/renderer/frame/views.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[reagent.core :as ra]
88
[reagent.dom.server :as server]
99
[renderer.components :as comp]
10-
[renderer.tools.base :as tools]
10+
[renderer.tool.base :as tool]
1111
[renderer.utils.pointer :as pointer]))
1212

1313
(defn pointer-handler
@@ -98,7 +98,7 @@
9898
[:f> inner-component]
9999
[:> ContextMenu/Root
100100
[:> ContextMenu/Trigger
101-
[tools/render canvas]]
101+
[tool/render canvas]]
102102
[:> ContextMenu/Portal
103103
(into [:> ContextMenu/Content
104104
{:class "menu-content context-menu-content"

src/renderer/history/events.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[re-frame.core :as rf]
44
[renderer.element.handlers :as element.h]
55
[renderer.history.handlers :as h]
6-
[renderer.tools.base :as tools]))
6+
[renderer.tool.base :as tool]))
77

88
(rf/reg-event-db
99
:history/undo
@@ -70,7 +70,7 @@
7070
(element.h/clear-hovered)
7171

7272
(= (:state db) :default)
73-
(tools/set-tool :select)))) ; FIXME
73+
(tool/set-tool :select)))) ; FIXME
7474

7575
(rf/reg-event-fx
7676
:history/restore
@@ -82,7 +82,7 @@
8282
(dissoc :restored?))
8383
(-> db
8484
element.h/clear-hovered
85-
(tools/set-tool :select)
85+
(tool/set-tool :select)
8686
(dissoc :pointer-offset)
8787
(dissoc :clicked-element)
8888
(dissoc :drag?)

src/renderer/timeline/subs.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
(:require
33
[clojure.string :as str]
44
[re-frame.core :as rf]
5-
[renderer.tools.base :as tools]))
5+
[renderer.tool.base :as tool]))
66

77
(rf/reg-sub
88
:animations
99
:<- [:document/elements]
1010
(fn [elements]
11-
(filter #(contains? (descendants ::tools/animation) (:tag %)) (vals elements))))
11+
(filter #(contains? (descendants ::tool/animation) (:tag %)) (vals elements))))
1212

1313
(defn effect-id
1414
[el]

src/renderer/tool/animation/animate.cljs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
(ns renderer.tools.animation.animate
1+
(ns renderer.tool.animation.animate
22
"https://svgwg.org/specs/animations/#AnimateElement"
33
(:require
4-
[renderer.tools.base :as tools]))
4+
[renderer.tool.base :as tool]))
55

6-
(derive :animate ::tools/animation)
6+
(derive :animate ::tool/animation)
77

8-
(defmethod tools/properties :animate
8+
(defmethod tool/properties :animate
99
[]
1010
{:description "The SVG <animate> element provides a way to animate an
1111
attribute of an element over time."

src/renderer/tool/animation/animate_motion.cljs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
(ns renderer.tools.animation.animate-motion
1+
(ns renderer.tool.animation.animate-motion
22
"https://svgwg.org/specs/animations/#AnimateMotionElement"
33
(:require
4-
[renderer.tools.base :as tools]))
4+
[renderer.tool.base :as tool]))
55

6-
(derive :animateMotion ::tools/animation)
6+
(derive :animateMotion ::tool/animation)
77

8-
(defmethod tools/properties :animateMotion
8+
(defmethod tool/properties :animateMotion
99
[]
1010
{:description "The SVG <animateMotion> element let define how an element
1111
moves along a motion path."

src/renderer/tool/animation/animate_transform.cljs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
(ns renderer.tools.animation.animate-transform
1+
(ns renderer.tool.animation.animate-transform
22
"https://svgwg.org/specs/animations/#AnimateTransformElement"
33
(:require
4-
[renderer.tools.base :as tools]))
4+
[renderer.tool.base :as tool]))
55

6-
(derive :animateTransform ::tools/animation)
6+
(derive :animateTransform ::tool/animation)
77

8-
(defmethod tools/properties :animateTransform
8+
(defmethod tool/properties :animateTransform
99
[]
1010
{:description "The animateTransform element animates a transformation
1111
attribute on its target element, thereby allowing animations
+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
(ns renderer.tools.animation.animation
1+
(ns renderer.tool.animation.animation
22
"https://svgwg.org/specs/animations/#AnimationElements"
33
(:require
44
[re-frame.core :as rf]
5-
[renderer.tools.base :as tools]))
5+
[renderer.tool.base :as tool]))
66

7-
(derive ::tools/animation ::tools/descriptive)
7+
(derive ::tool/animation ::tool/descriptive)
88

9-
(defmethod tools/render ::tools/animation
9+
(defmethod tool/render ::tool/animation
1010
[{:keys [children tag attrs]}]
1111
(let [child-elements @(rf/subscribe [:element/filter-visible children])]
1212
[tag
1313
attrs
1414
(for [el child-elements]
15-
^{:key (:key el)} [tools/render el])]))
15+
^{:key (:key el)} [tool/render el])]))
1616

17-
(defmethod tools/bounds ::tools/animation [] nil)
17+
(defmethod tool/bounds ::tool/animation [] nil)

src/renderer/tool/base.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
(ns renderer.tools.base)
1+
(ns renderer.tool.base)
2+
23
(derive ::renderable ::element)
34
(derive ::shape ::renderable)
45
(derive ::graphics ::renderable)

0 commit comments

Comments
 (0)