atome 0.5.7.1.4 → 0.5.7.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/atome.gemspec +2 -2
- data/lib/atome/extensions/atome.rb +48 -0
- data/lib/atome/genesis/particles/event.rb +24 -2
- data/lib/atome/utilities/utilities.rb +0 -10
- data/lib/atome/version.rb +1 -1
- data/lib/atome.rb +2 -1
- data/lib/atome_relative.rb +2 -1
- data/lib/molecules/intuition/tools.rb +344 -0
- data/lib/renderers/html/html.rb +25 -32
- data/vendor/assets/application/examples/above_below_before_after.rb +22 -0
- data/vendor/assets/application/examples/animation.rb +29 -1
- data/vendor/assets/application/examples/audio.rb +10 -26
- data/vendor/assets/application/examples/test.rb +1 -157
- data/vendor/assets/application/examples/tools.rb +7 -384
- metadata +19 -17
- /data/lib/molecules/intuition/{utillities.rb → utilities.rb} +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
a = audio({ path: 'medias/audios/clap.wav', id: :
|
2
|
+
|
3
|
+
# audio tag
|
4
|
+
a = audio({ path: 'medias/audios/clap.wav', id: :basic_audio })
|
5
5
|
b=box({id: :playButton})
|
6
6
|
b.text(:audio_tag)
|
7
7
|
a.left(333)
|
@@ -10,26 +10,21 @@ b.touch(:down) do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
|
13
|
-
|
14
|
-
#
|
13
|
+
|
15
14
|
### Web Audio
|
16
|
-
|
15
|
+
audio({ path: 'medias/audios/clap.wav', id: :audioElement })
|
17
16
|
@audio_context = JS.eval('return new AudioContext()')
|
18
17
|
@audio_element = JS.global[:document].getElementById('audioElement')
|
19
18
|
@track = @audio_context.createMediaElementSource(@audio_element)
|
20
19
|
|
21
|
-
# Ajout d'un nœud de gain (volume)
|
22
20
|
@gain_node = @audio_context.createGain()
|
23
|
-
@gain_node[:gain][:value] = 0.5
|
24
|
-
|
25
|
-
|
26
|
-
@
|
27
|
-
@gain_node.connect(@audio_context[:destination]) # Connecte le nœud de gain à la sortie
|
21
|
+
@gain_node[:gain][:value] = 0.5
|
22
|
+
|
23
|
+
@track.connect(@gain_node)
|
24
|
+
@gain_node.connect(@audio_context[:destination])
|
28
25
|
|
29
26
|
def play_audio
|
30
|
-
# Réactive l'AudioContext s'il est suspendu
|
31
27
|
@audio_context[:resume].to_s if @audio_context[:state].to_s == 'suspended'
|
32
|
-
# Joue l'audio
|
33
28
|
@audio_element.play
|
34
29
|
end
|
35
30
|
b2=box({left: 166})
|
@@ -45,7 +40,6 @@ bb.text(:wadjs)
|
|
45
40
|
init_code = "window.snare = new Wad({source : 'medias/audios/clap.wav'});"
|
46
41
|
JS.eval(init_code)
|
47
42
|
|
48
|
-
# Code JavaScript pour jouer le son et l'arrêter après 300 ms, dans un bloc indépendant
|
49
43
|
play_code = <<~STRDEL
|
50
44
|
window.snare.play();
|
51
45
|
setTimeout(function() {
|
@@ -53,17 +47,7 @@ play_code = <<~STRDEL
|
|
53
47
|
}, 300);
|
54
48
|
STRDEL
|
55
49
|
|
56
|
-
|
57
|
-
# JS.eval(play_code)
|
58
|
-
# snare=JS.eval("return new Wad({source : 'medias/audios/clap.wav'})")
|
59
|
-
# js_code=<<STRDEL
|
60
|
-
# snare = #{snare};
|
61
|
-
# snare =new Wad({source : 'medias/audios/clap.wav'})
|
62
|
-
# snare.play();
|
63
|
-
# setTimeout(() => {
|
64
|
-
# snare.stop();
|
65
|
-
# }, "300");
|
66
|
-
# STRDEL
|
50
|
+
|
67
51
|
bb.touch(:down) do
|
68
52
|
JS.eval(play_code)
|
69
53
|
end
|
@@ -1,158 +1,2 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# # m = table({ renderers: [:html], attach: :view, id: :my_test_box, type: :table, apply: [:shape_color],
|
4
|
-
# # left: 333, top: 0, width: 900, smooth: 15, height: 900, overflow: :scroll, option: { header: false },
|
5
|
-
# # component: {
|
6
|
-
# # # border: { thickness: 5, color: :blue, pattern: :dotted },
|
7
|
-
# # # overflow: :auto,
|
8
|
-
# # # color: "red",
|
9
|
-
# # shadow: {
|
10
|
-
# # id: :s4,
|
11
|
-
# # left: 20, top: 0, blur: 9,
|
12
|
-
# # option: :natural,
|
13
|
-
# # red: 0, green: 0, blue: 0, alpha: 1
|
14
|
-
# # },
|
15
|
-
# # height: 5,
|
16
|
-
# # width: 12,
|
17
|
-
# # component: { size: 12, color: :black }
|
18
|
-
# # },
|
19
|
-
# # # data: [
|
20
|
-
# # # { titi: :toto },
|
21
|
-
# # # { dfgdf: 1, name: 'Alice', age: 30, no: 'oko', t: 123, r: 654 },
|
22
|
-
# # # { id: 2, name: 'Bob', age: 22 },
|
23
|
-
# # # { dfg: 4, name: 'Vincent', age: 33, no: grab(:my_circle) },
|
24
|
-
# # # { dfgd: 3, name: 'Roger', age: 18, no: image(:red_planet), now: :nothing }
|
25
|
-
# # #
|
26
|
-
# # # ]
|
27
|
-
# # })
|
28
|
-
# b=box({top: 120})
|
29
|
-
# box({top: 190, id: :the_box})
|
30
|
-
#
|
31
|
-
# b.touch(true) do
|
32
|
-
# a=JS.eval("return performance.now()")
|
33
|
-
# z=Time.now
|
34
|
-
# circle
|
35
|
-
# columns = []
|
36
|
-
#
|
37
|
-
# 96.times do
|
38
|
-
# line = {}
|
39
|
-
# 128.times do |index|
|
40
|
-
# line[:"vel#{index}"] = nil
|
41
|
-
# end
|
42
|
-
# columns << line
|
43
|
-
# end
|
44
|
-
# columns.each_with_index do |a, index|
|
45
|
-
# b= box({left: index*30, width: 12})
|
46
|
-
# # b.touch(true) do
|
47
|
-
# # alert b.id
|
48
|
-
# # end
|
49
|
-
# end
|
50
|
-
# z2=Time.now
|
51
|
-
# x=JS.eval("return performance.now();")
|
52
|
-
# alert "#{x.to_f-a.to_f} : #{(z2-z)*1000}"
|
53
|
-
#
|
54
|
-
# end
|
55
|
-
#
|
56
|
-
#
|
57
|
-
# # m.data(columns)
|
58
|
-
# # # tests
|
59
|
-
# # m.color(:orange)
|
60
|
-
# # m.border({ thickness: 5, color: :blue, pattern: :dotted })
|
61
|
-
# #
|
62
|
-
# # m.get({ cell: [1, 2]}).class
|
63
|
-
# # wait 2 do
|
64
|
-
# # m.insert({ cell: [2, 2], content: 999 })
|
65
|
-
# # m.insert({ row: 1 })
|
66
|
-
# # wait 1 do
|
67
|
-
# # m.remove({ row: 2 })
|
68
|
-
# # end
|
69
|
-
# # wait 2 do
|
70
|
-
# # m.remove({ column: 1 })
|
71
|
-
# # end
|
72
|
-
# # wait 3 do
|
73
|
-
# # m.insert({ column: 3 })
|
74
|
-
# # end
|
75
|
-
# #
|
76
|
-
# # wait 4 do
|
77
|
-
# # m.sort({ column: 1, method: :alphabetic })
|
78
|
-
# # puts 1
|
79
|
-
# # wait 1 do
|
80
|
-
# # puts 2
|
81
|
-
# # m.sort({ column: 2, method: :numeric })
|
82
|
-
# # wait 1 do
|
83
|
-
# # puts 3
|
84
|
-
# # m.sort({ column: 3, method: :numeric })
|
85
|
-
# # wait 1 do
|
86
|
-
# # puts 4
|
87
|
-
# # m.sort({ column: 1, method: :numeric })
|
88
|
-
# # end
|
89
|
-
# # end
|
90
|
-
# # end
|
91
|
-
# # end
|
92
|
-
# #
|
93
|
-
# # end
|
94
|
-
# #
|
95
|
-
# # # cell.fusion() # to be implemented later
|
96
|
-
#
|
97
|
-
#
|
98
|
-
# # b=box({width: 1200, height: 900, color: {alpha: 0},top: -50})
|
99
|
-
# # grab(:black_matter).image({id: :kb,path: 'medias/images/utils/keyboard.svg', width: 66, left: 55})
|
100
|
-
# # # grab(:black_matter).image({id: :planet,path: 'medias/images/red_planet.png', width: 66,height: 66, left: 555, top: 180})
|
101
|
-
# # b.fill([atome: :kb, repeat: {x: 8, y: 1}])
|
102
|
-
# # b.drag(true)
|
103
|
-
# #
|
104
|
-
# #
|
105
|
-
# # b2=box({width: 1200, height: 298, top: -100})
|
106
|
-
# # grab(:black_matter).image({id: :notes,path: 'medias/images/utils/notes.svg', width: 166, left: 55})
|
107
|
-
# # # grab(:black_matter).image({id: :planet,path: 'medias/images/red_planet.png', width: 66,height: 66, left: 555, top: 180})
|
108
|
-
# # b2.fill([atome: :notes, repeat: {x: 8, y: 5}])
|
109
|
-
# # b2.drag(true)
|
110
|
-
#
|
111
|
-
#
|
112
|
-
# JS.eval("
|
113
|
-
# // Fonction pour créer les divs
|
114
|
-
# function createDivs() {
|
115
|
-
# // Démarrer le chronomètre
|
116
|
-
# const startTime = performance.now();
|
117
|
-
#
|
118
|
-
# const view = document.getElementById('view');
|
119
|
-
# //view.innerHTML = ''; // Nettoyer le contenu précédent de 'view' si nécessaire
|
120
|
-
#
|
121
|
-
# // Boucle pour créer 98 divs sur l'axe X
|
122
|
-
# for (let i = 0; i < 98; i++) {
|
123
|
-
# const xDiv = document.createElement('div');
|
124
|
-
# xDiv.style.display = 'flex';
|
125
|
-
# xDiv.style.flexDirection = 'column';
|
126
|
-
# xDiv.style.margin = '2px'; // Marge entre les divs de l'axe X
|
127
|
-
#
|
128
|
-
# // Boucle pour créer 128 divs sur l'axe Y
|
129
|
-
# for (let j = 0; j < 128; j++) {
|
130
|
-
# const yDiv = document.createElement('div');
|
131
|
-
# yDiv.style.width = '10px'; // Largeur de chaque div sur l'axe Y
|
132
|
-
# yDiv.style.height = '10px'; // Hauteur de chaque div sur l'axe Y
|
133
|
-
# yDiv.style.border = '1px solid black'; // Bordure pour rendre les divs visibles
|
134
|
-
# yDiv.style.boxSizing = 'border-box'; // Inclure la bordure dans les dimensions
|
135
|
-
# xDiv.appendChild(yDiv);
|
136
|
-
# }
|
137
|
-
#
|
138
|
-
# view.appendChild(xDiv);
|
139
|
-
# }
|
140
|
-
#
|
141
|
-
# // Arrêter le chronomètre
|
142
|
-
# const endTime = performance.now();
|
143
|
-
# const timeTaken = endTime - startTime;
|
144
|
-
#
|
145
|
-
# // Afficher le temps écoulé en console
|
146
|
-
# alert(`Temps écoulé pour créer les divs : ${timeTaken.toFixed(2)} ms`);
|
147
|
-
# }
|
148
|
-
#
|
149
|
-
# // Ajouter un écouteur d'événements au div 'the_box'
|
150
|
-
# document.getElementById('the_box').addEventListener('click', createDivs);
|
151
|
-
# ``
|
152
|
-
#
|
153
|
-
# ")
|
1
|
+
# frozen_string_literal: true
|
154
2
|
|
155
|
-
new({particle: :merge})
|
156
|
-
a=box
|
157
|
-
c=box
|
158
|
-
d=a.merge(c)
|
@@ -1,379 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
size = 33
|
4
|
-
smooth = 3
|
5
|
-
shadow({
|
6
|
-
id: :tool_shade,
|
7
|
-
left: 3, top: 3, blur: 3,
|
8
|
-
invert: false,
|
9
|
-
red: 0, green: 0, blue: 0, alpha: 0.6
|
10
|
-
})
|
11
|
-
|
12
|
-
color({ id: :tool_inactive_color, red: 1, green: 1, blue: 1, alpha: 0.12 })
|
13
|
-
color({ id: :tool_active_color, red: 1, green: 1, blue: 1, alpha: 0.3 })
|
14
|
-
border({ id: :tool_box_border, thickness: 1, red: 1, green: 1, blue: 1, alpha: 0.06, pattern: :solid, inside: true })
|
15
|
-
# Tool's style object container below
|
16
|
-
element({ aid: :toolbox_style, id: :toolbox_style, data: {
|
17
|
-
color: :gray,
|
18
|
-
size: size,
|
19
|
-
smooth: smooth
|
20
|
-
} })
|
21
|
-
|
22
|
-
class Atome
|
23
|
-
class << self
|
24
|
-
def init_intuition
|
25
|
-
Atome.start_click_analysis
|
26
|
-
root = Universe.tools_root
|
27
|
-
root.each_with_index do |root_tool, index|
|
28
|
-
tools_scheme = Universe.tools[root_tool]
|
29
|
-
A.build_tool({ name: root_tool, scheme: tools_scheme, index: index })
|
30
|
-
end
|
31
|
-
|
32
|
-
# Universe.tools.each_with_index do |(tool_name, bloc), index|
|
33
|
-
#
|
34
|
-
# A.build_tool({ name: tool_name, index: index }, &bloc)
|
35
|
-
# end
|
36
|
-
end
|
37
|
-
|
38
|
-
def selection
|
39
|
-
grab(Universe.current_user).selection.collect
|
40
|
-
end
|
41
|
-
|
42
|
-
def activate_click_analysis
|
43
|
-
|
44
|
-
# the condition below avoid touchdown analysis accumulation
|
45
|
-
unless @click_analysis_active
|
46
|
-
# this method analyse all object under the touchdown to find the first user objet and return it's id
|
47
|
-
@click_analysis = lambda { |native_event|
|
48
|
-
# the instance variable below check if we can apply tool (cf: if the atome we don't want to apply tool)
|
49
|
-
if Universe.allow_tool_operations
|
50
|
-
event = Native(native_event)
|
51
|
-
x = event[:clientX]
|
52
|
-
y = event[:clientY]
|
53
|
-
elements = JS.global[:document].elementsFromPoint(x, y)
|
54
|
-
elements.to_a.each do |atome_touched|
|
55
|
-
id_found = atome_touched[:id].to_s
|
56
|
-
atome_found = grab(id_found)
|
57
|
-
unless atome_found && atome_found.tag[:system]
|
58
|
-
|
59
|
-
# if atome_found
|
60
|
-
Universe.active_tools.each do |tool|
|
61
|
-
apply_tool(tool, atome_found, event)
|
62
|
-
end
|
63
|
-
break
|
64
|
-
end
|
65
|
-
end
|
66
|
-
else
|
67
|
-
Universe.allow_tool_operations = true
|
68
|
-
end
|
69
|
-
}
|
70
|
-
@click_analysis_active = true
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
def de_activate_click_analysis
|
76
|
-
@click_analysis = nil
|
77
|
-
@click_analysis_active = false
|
78
|
-
end
|
79
|
-
|
80
|
-
def start_click_analysis
|
81
|
-
@click_analysis_active = false
|
82
|
-
JS.global[:document].addEventListener('mouseup') do |native_event|
|
83
|
-
Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def alteration(current_tool, tool_actions, atome_touched, a_event)
|
88
|
-
if atome_touched
|
89
|
-
storage_allowed = Universe.allow_localstorage
|
90
|
-
action_found = tool_actions[:action]
|
91
|
-
pre = tool_actions[:pre]
|
92
|
-
post = tool_actions[:post]
|
93
|
-
params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
|
94
|
-
action_found.each do |part, val|
|
95
|
-
Universe.allow_localstorage = false
|
96
|
-
#################################
|
97
|
-
touch_found = atome_touched.touch
|
98
|
-
touch_procs=atome_touched.instance_variable_get("@touch_code")
|
99
|
-
resize_found = atome_touched.resize
|
100
|
-
resize_procs=atome_touched.instance_variable_get("@resize_code")
|
101
|
-
current_tool.data[:prev_states][atome_touched] = {events: { touch: touch_found, resize: resize_found },
|
102
|
-
procs: {touch_code: touch_procs, resize_code: resize_procs } }
|
103
|
-
|
104
|
-
#################################
|
105
|
-
current_tool.instance_exec(params, &pre) if pre.is_a? Proc
|
106
|
-
Universe.allow_localstorage = storage_allowed
|
107
|
-
if current_tool.data[:allow_alteration]
|
108
|
-
atome_touched.send(part, val)
|
109
|
-
current_tool.data[:treated] << atome_touched
|
110
|
-
end
|
111
|
-
current_tool.instance_exec(params, &post) if post.is_a? Proc
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def creation(current_tool, tool_actions, atome_touched, a_event)
|
118
|
-
# we store prev_local_storage prior to lock it to prevent unwanted logs
|
119
|
-
# prev_local_storage=Universe.allow_localstorage()
|
120
|
-
storage_allowed = Universe.allow_localstorage
|
121
|
-
Universe.allow_localstorage = false
|
122
|
-
|
123
|
-
action_found = tool_actions[:action]
|
124
|
-
pre = tool_actions[:pre]
|
125
|
-
post = tool_actions[:post]
|
126
|
-
params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
|
127
|
-
|
128
|
-
action_found.each do |atome, particle|
|
129
|
-
current_tool.instance_exec(params, &pre) if pre.is_a? Proc
|
130
|
-
temp_val = particle.merge({ resize: true, drag: true, top: a_event[:pageY].to_i, left: a_event[:pageX].to_i })
|
131
|
-
if current_tool.data[:allow_creation]
|
132
|
-
# uncomment the line below if you want to attach to current atome
|
133
|
-
if atome_touched
|
134
|
-
new_atome = atome_touched.send(atome, temp_val)
|
135
|
-
else
|
136
|
-
new_atome = grab(:view).send(atome, temp_val)
|
137
|
-
end
|
138
|
-
# current_tool.data[:treated] << new_atome
|
139
|
-
current_tool.data[:created] << new_atome
|
140
|
-
params.delete(:atome_touched)
|
141
|
-
params[new_atome: new_atome]
|
142
|
-
Universe.allow_localstorage = [atome]
|
143
|
-
Universe.historicize(new_atome.aid, :write, atome, particle)
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|
147
|
-
current_tool.instance_exec(params, &post) if post.is_a? Proc
|
148
|
-
# we restore prev_local_storage to allow logs of drag and resize ...
|
149
|
-
Universe.allow_localstorage = storage_allowed
|
150
|
-
end
|
151
|
-
|
152
|
-
def apply_tool(tool, atome_touched, a_event)
|
153
|
-
current_tool = grab(tool)
|
154
|
-
tool_actions = current_tool.data
|
155
|
-
method_found = tool_actions[:method]
|
156
|
-
unless method_found
|
157
|
-
method_found = :alteration
|
158
|
-
tool_actions[:action] = { noop: true }
|
159
|
-
current_tool.data = tool_actions
|
160
|
-
end
|
161
|
-
|
162
|
-
send(method_found, current_tool, tool_actions, atome_touched, a_event)
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
def noop(_p)
|
168
|
-
# this method is used by tools when no treatment is needed
|
169
|
-
end
|
170
|
-
|
171
|
-
def set_action_on_touch(&action)
|
172
|
-
@touch_action = action
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
def remove_get_atome_on_touch
|
177
|
-
@touch_action = nil
|
178
|
-
end
|
179
|
-
|
180
|
-
def build_tool(params)
|
181
|
-
label = params[:name]
|
182
|
-
tool_name = "#{params[:name]}_tool"
|
183
|
-
index = params[:index]
|
184
|
-
orientation_wanted = :sn
|
185
|
-
tool_scheme = params[:scheme]
|
186
|
-
color({ id: :active_tool_col, alpha: 1, red: 1, green: 1, blue: 1 })
|
187
|
-
color({ id: :inactive_tool_col, alpha: 0.6 })
|
188
|
-
grab(:intuition).storage[:tool_open] ||= []
|
189
|
-
grab(:intuition).storage[:tool_open] << tool_name
|
190
|
-
size = grab(:toolbox_style).data[:size]
|
191
|
-
smooth = grab(:toolbox_style).data[:smooth]
|
192
|
-
case orientation_wanted
|
193
|
-
when :sn
|
194
|
-
top = :auto
|
195
|
-
bottom = index * (size + 3)
|
196
|
-
left = 0
|
197
|
-
right = :auto
|
198
|
-
when :ns
|
199
|
-
when :ew
|
200
|
-
when :we
|
201
|
-
else
|
202
|
-
#
|
203
|
-
end
|
204
|
-
|
205
|
-
# tool creation
|
206
|
-
if tool_scheme[:creation]
|
207
|
-
action = tool_scheme[:creation]
|
208
|
-
method = :creation
|
209
|
-
end
|
210
|
-
if tool_scheme[:alteration]
|
211
|
-
action = tool_scheme[:alteration]
|
212
|
-
method = :alteration
|
213
|
-
end
|
214
|
-
|
215
|
-
tool = grab(:intuition).box({ id: tool_name,
|
216
|
-
tag: { system: true },
|
217
|
-
# orientation: orientation_wanted,
|
218
|
-
top: top,
|
219
|
-
bottom: bottom,
|
220
|
-
left: left,
|
221
|
-
right: right,
|
222
|
-
width: size,
|
223
|
-
height: size,
|
224
|
-
smooth: smooth,
|
225
|
-
apply: [:tool_inactive_color, :tool_box_border, :tool_shade],
|
226
|
-
state: :closed,
|
227
|
-
data: { method: method,
|
228
|
-
action: action,
|
229
|
-
allow_alteration: true,
|
230
|
-
allow_creation: true,
|
231
|
-
# activation: tool_scheme[:activation],
|
232
|
-
# inactivation: tool_scheme[:inactivation], zone: tool_scheme[:zone],
|
233
|
-
post: tool_scheme[:post],
|
234
|
-
pre: tool_scheme[:pre],
|
235
|
-
}
|
236
|
-
|
237
|
-
})
|
238
|
-
tool.vector({ tag: { system: true }, left: 9, top: :auto, bottom: 9, width: 18, height: 18, id: "#{tool_name}_icon" })
|
239
|
-
tool.text({ tag: { system: true }, data: label, component: { size: 9 }, color: :grey, id: "#{tool_name}_label" })
|
240
|
-
code_for_zone = tool_scheme[:zone]
|
241
|
-
tool.instance_exec(tool, &code_for_zone) if code_for_zone.is_a? Proc
|
242
|
-
tool.touch(true) do
|
243
|
-
# we add all specific tool actions to @tools_actions_to_exec hash
|
244
|
-
# we set allow_tool_operations to false to ignore tool operation when clicking on a tool
|
245
|
-
Universe.allow_tool_operations = false
|
246
|
-
# we create the creation_layer if not already exist
|
247
|
-
tick(tool_name)
|
248
|
-
# active code exec
|
249
|
-
if tick[tool_name] == 1 # first click
|
250
|
-
events_allow = [:top, :left, :right, :bottom, :width, :height]
|
251
|
-
alterations = tool_scheme[:alteration] ? tool_scheme[:alteration].keys : []
|
252
|
-
creations = tool_scheme[:creation] ? tool_scheme[:creation].keys : []
|
253
|
-
prev_auth = Universe.allow_localstorage ||= []
|
254
|
-
storage_allowed = events_allow.concat(alterations).concat(creations).concat(prev_auth).uniq
|
255
|
-
Universe.allow_localstorage = storage_allowed
|
256
|
-
# we set edit mode to true (this allow to prevent user atome to respond from click)
|
257
|
-
Universe.edit_mode = true
|
258
|
-
Universe.active_tools << tool_name
|
259
|
-
# init the tool
|
260
|
-
tool.data[:treated] = []
|
261
|
-
tool.data[:created] = []
|
262
|
-
tool.data[:prev_states] = {}
|
263
|
-
# generic behavior
|
264
|
-
tool.apply(:active_tool_col)
|
265
|
-
# activation code
|
266
|
-
activation_code = tool_scheme[:activation]
|
267
|
-
tool.instance_exec(&activation_code) if activation_code.is_a? Proc
|
268
|
-
# below we the particles of selected atomes to feed tools values
|
269
|
-
# possibility 1 (pipette like):
|
270
|
-
# now we get the values from selected atomes
|
271
|
-
Atome.selection.each do |atome_id_to_treat|
|
272
|
-
tool.data[:action].each do |particle_req, value_f|
|
273
|
-
unless Universe.atome_preset
|
274
|
-
value_found = grab(atome_id_to_treat).send(particle_req)
|
275
|
-
if value_found
|
276
|
-
tool.data[:action][particle_req] = value_found
|
277
|
-
else
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
# possibility 2 (immediate apply):
|
283
|
-
allow_creation = tool.data[:allow_creation]
|
284
|
-
allow_alteration = tool.data[:allow_alteration]
|
285
|
-
Atome.selection.each do |atome_id_to_treat|
|
286
|
-
atome_found = grab(atome_id_to_treat)
|
287
|
-
event = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }
|
288
|
-
Atome.apply_tool(tool_name, atome_found, event)
|
289
|
-
end unless tool_name.to_sym == :select_tool || !allow_creation || !allow_alteration
|
290
|
-
|
291
|
-
# activate tool analysis test
|
292
|
-
Atome.activate_click_analysis
|
293
|
-
else
|
294
|
-
Universe.allow_localstorage = false
|
295
|
-
# when closing delete tools action from tool_actions_to_exec
|
296
|
-
Universe.active_tools.delete(tool_name)
|
297
|
-
# we check if all tools are inactive if so we set edit_mode to false
|
298
|
-
if Universe.active_tools.length == 0
|
299
|
-
Atome.de_activate_click_analysis
|
300
|
-
Universe.edit_mode = false
|
301
|
-
end
|
302
|
-
|
303
|
-
inactivation_code = tool_scheme[:inactivation]
|
304
|
-
tool.instance_exec(tool.data, &inactivation_code) if inactivation_code.is_a? Proc
|
305
|
-
# end if tool_content && tool_content[:inactive]
|
306
|
-
|
307
|
-
# generic behavior
|
308
|
-
# we remove touch and resize binding on newly created atomes
|
309
|
-
tool.apply(:inactive_tool_col)
|
310
|
-
tool.data[:created].each do |new_atome|
|
311
|
-
new_atome.drag(false)
|
312
|
-
new_atome.resize(:remove)
|
313
|
-
end
|
314
|
-
################################
|
315
|
-
# we restore prev touch and resize
|
316
|
-
tool.data[:prev_states].each do |atome_f, prev_par|
|
317
|
-
puts prev_par
|
318
|
-
|
319
|
-
# params[:events].each do |part_f, val_f|
|
320
|
-
# # alert "@#{part_f}, #{part_f}"
|
321
|
-
# atome_f.send(part_f, val_f)
|
322
|
-
# end
|
323
|
-
# alert "--> params : #{params[:events]}"
|
324
|
-
# alert "--> procs : #{params[:procs][params[:events]]}"
|
325
|
-
# atome_f.touch(false)
|
326
|
-
# atome_f.touch(true) do
|
327
|
-
# alert :kool
|
328
|
-
# end
|
329
|
-
# alert params[:procs]
|
330
|
-
# params[:procs].each do |var_n, procs_f|
|
331
|
-
# # procs_f.each do |action_f, proc|
|
332
|
-
# # # puts "#{var_n}==> #{action_f}, #{proc}"
|
333
|
-
# # end
|
334
|
-
# puts "==> #{var_n}, #{proc_f}"
|
335
|
-
# # atome_f.instance_variable_set("@#{var_n}", proc_f)
|
336
|
-
# end
|
337
|
-
# atome_f.touch(false)
|
338
|
-
# alert "#{atome_f.touch} : #{atome_f.instance_variable_get("@touch_code")}"
|
339
|
-
end
|
340
|
-
|
341
|
-
# atome_f.touch(touch_found)
|
342
|
-
# atome_f.resize(resize_found)
|
343
|
-
# inactivation code
|
344
|
-
#################################
|
345
|
-
tick[tool_name] = 0
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
module Intuition
|
352
|
-
class << self
|
353
|
-
@toolbox = { impulse: [:capture_tool, :communication_tool, :creation_tool, :view_tool, :time_tool, :find_tool, :home_tool],
|
354
|
-
capture_tool: [:microphone_tool, :camera_tool,]
|
355
|
-
}
|
356
|
-
|
357
|
-
def intuition_int8
|
358
|
-
# tool taxonomy and list
|
359
|
-
{
|
360
|
-
capture: { int8: { french: :enregistrement, english: :record, german: :datensatz } },
|
361
|
-
communication: { french: :communication, english: :communication, german: :communication },
|
362
|
-
tool: { french: :outils, english: :tools, german: :werkzeuge },
|
363
|
-
view: { french: :vue, english: :view, german: :aussicht },
|
364
|
-
time: { french: :horloge, english: :clock, german: :Uhr },
|
365
|
-
find: { french: :trouve, english: :find, german: :finden },
|
366
|
-
home: { french: :accueil, english: :home, german: :zuhause },
|
367
|
-
code: { french: :code, english: :code, german: :code },
|
368
|
-
impulse: { french: :impulse, english: :impulse, german: :impulse },
|
369
|
-
}
|
370
|
-
end
|
371
|
-
|
372
|
-
end
|
373
|
-
|
374
|
-
end
|
375
|
-
|
376
|
-
# ##############################################################################################
|
377
3
|
|
378
4
|
new({ tool: :blur }) do |params|
|
379
5
|
|
@@ -518,8 +144,8 @@ new({ tool: :move }) do |params|
|
|
518
144
|
# if Atome.selection.instance_of? Array
|
519
145
|
# end
|
520
146
|
Atome.selection.each do |atome_id_to_treat|
|
521
|
-
|
522
|
-
|
147
|
+
# # # reinit first to avoid multiple drag event
|
148
|
+
# # grab(atome_id_to_treat).drag(false)
|
523
149
|
end
|
524
150
|
# drag_remove
|
525
151
|
# puts :alteration_tool_code_activated
|
@@ -585,11 +211,9 @@ end
|
|
585
211
|
|
586
212
|
new({tool: :test}) do
|
587
213
|
active_code = lambda {
|
588
|
-
|
589
|
-
b=Object.box
|
590
|
-
# b=grab(:view).box
|
214
|
+
b=grab(:view).box({})
|
591
215
|
b.touch(true) do
|
592
|
-
|
216
|
+
alert :kool
|
593
217
|
end
|
594
218
|
}
|
595
219
|
# active_code=:tito
|
@@ -597,10 +221,9 @@ new({tool: :test}) do
|
|
597
221
|
end
|
598
222
|
|
599
223
|
|
600
|
-
|
601
|
-
Universe.tools_root=[:test]
|
602
|
-
|
603
|
-
|
224
|
+
Universe.tools_root=[:box, :blur, :drag, :rotate, :select, :move,:project]
|
225
|
+
# Universe.tools_root=[:test]
|
226
|
+
Atome.init_intuition
|
604
227
|
|
605
228
|
|
606
229
|
|