atome 0.5.7.1.8 → 0.5.7.3.1

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.
@@ -1,32 +1,48 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ def truncate_string(string, max_length)
4
+ string.length > max_length ? string.slice(0, max_length) + "." : string
5
+ end
6
+
3
7
  size = 33
4
8
  smooth = 3
9
+ margin = 3
10
+ text_color = { alpha: 0.3, red: 1, green: 1, blue: 1 }
5
11
  shadow({
6
12
  id: :tool_shade,
7
13
  left: 3, top: 3, blur: 3,
8
14
  invert: false,
9
15
  red: 0, green: 0, blue: 0, alpha: 0.6
10
16
  })
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 })
17
+ color({ id: :active_tool_col, alpha: 1, red: 1, green: 1, blue: 1 })
18
+ color({ id: :inactive_tool_col, alpha: 0.1 })
14
19
  border({ id: :tool_box_border, thickness: 1, red: 1, green: 1, blue: 1, alpha: 0.06, pattern: :solid, inside: true })
15
20
  # Tool's style object container below
16
21
  element({ aid: :toolbox_style, id: :toolbox_style, data: {
17
22
  color: :gray,
18
23
  size: size,
19
- smooth: smooth
24
+ margin: margin,
25
+ smooth: smooth,
26
+ text_color: text_color,
20
27
  } })
21
28
 
22
29
  class Atome
30
+
31
+ def toolbox(tool_list)
32
+ @toolbox = tool_list[:tools]
33
+ tool_list[:tools].each_with_index do |root_tool, index|
34
+ tools_scheme = Universe.tools[root_tool]
35
+ build_tool({ name: root_tool, scheme: tools_scheme, index: index, toolbox: tool_list[:toolbox] })
36
+ end
37
+ end
38
+
23
39
  class << self
24
40
  def init_intuition
25
41
  Atome.start_click_analysis
26
42
  toolbox_root = Universe.tools_root
27
43
  toolbox_root[:tools].each_with_index do |root_tool, index|
28
44
  tools_scheme = Universe.tools[root_tool]
29
- A.build_tool({ name: root_tool, scheme: tools_scheme, index: index ,toolbox: toolbox_root[:toolbox] })
45
+ A.build_tool({ name: root_tool, scheme: tools_scheme, index: index, toolbox: toolbox_root[:toolbox] })
30
46
  end
31
47
  end
32
48
 
@@ -35,7 +51,6 @@ class Atome
35
51
  end
36
52
 
37
53
  def activate_click_analysis
38
-
39
54
  # the condition below avoid touchdown analysis accumulation
40
55
  unless @click_analysis_active
41
56
  # this method analyse all object under the touchdown to find the first user objet and return it's id
@@ -47,14 +62,16 @@ class Atome
47
62
  y = event[:clientY]
48
63
  elements = JS.global[:document].elementsFromPoint(x, y)
49
64
  elements.to_a.each do |atome_touched|
50
- id_found = atome_touched[:id].to_s
51
- atome_found = grab(id_found)
52
- unless atome_found && atome_found.tag[:system]
53
-
54
- # if atome_found
55
- Universe.active_tools.each do |tool|
56
- apply_tool(tool, atome_found, event)
65
+ unless atome_touched.to_s == 'html'
66
+ id_found = atome_touched[:id].to_s
67
+ atome_found = grab(id_found)
68
+ # unless (atome_found && atome_found.tag[:system])
69
+ if atome_found && !atome_found.tag[:system]
70
+ Universe.active_tools.each do |tool|
71
+ apply_tool(tool, atome_found, event)
72
+ end
57
73
  end
74
+
58
75
  break
59
76
  end
60
77
  end
@@ -83,24 +100,18 @@ class Atome
83
100
  if atome_touched
84
101
  storage_allowed = Universe.allow_localstorage
85
102
  action_found = tool_actions[:action]
86
- pre = tool_actions[:pre]
87
103
  post = tool_actions[:post]
88
104
  params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
89
105
  action_found.each do |part, val|
90
106
  Universe.allow_localstorage = false
91
- #################################
92
- touch_found = atome_touched.touch
93
- touch_procs = atome_touched.instance_variable_get("@touch_code")
94
- resize_found = atome_touched.resize
95
- resize_procs = atome_touched.instance_variable_get("@resize_code")
96
- current_tool.data[:prev_states][atome_touched] = { events: { touch: touch_found, resize: resize_found },
97
- procs: { touch_code: touch_procs, resize_code: resize_procs } }
98
- #################################
99
- current_tool.instance_exec(params, &pre) if pre.is_a? Proc
100
107
  Universe.allow_localstorage = storage_allowed
101
108
  if current_tool.data[:allow_alteration]
102
- atome_touched.send(part, val)
103
- current_tool.data[:treated] << atome_touched
109
+ if val.instance_of?(Proc)
110
+ atome_touched.instance_exec(&val)
111
+ else
112
+ atome_touched.send(part, val)
113
+ end
114
+ current_tool.data[:treated] << atome_touched if current_tool.data[:treated]
104
115
  end
105
116
  current_tool.instance_exec(params, &post) if post.is_a? Proc
106
117
  end
@@ -124,11 +135,11 @@ class Atome
124
135
  temp_val = particle.merge({ resize: true, drag: true, top: a_event[:pageY].to_i, left: a_event[:pageX].to_i })
125
136
  if current_tool.data[:allow_creation]
126
137
  # uncomment the line below if you want to attach to current atome
127
- if atome_touched
128
- new_atome = atome_touched.send(atome, temp_val)
129
- else
130
- new_atome = grab(:view).send(atome, temp_val)
131
- end
138
+ new_atome = if atome_touched
139
+ atome_touched.send(atome, temp_val)
140
+ else
141
+ grab(:view).send(atome, temp_val)
142
+ end
132
143
  # current_tool.data[:treated] << new_atome
133
144
  current_tool.data[:created] << new_atome
134
145
  params.delete(:atome_touched)
@@ -152,8 +163,20 @@ class Atome
152
163
  tool_actions[:action] = { noop: true }
153
164
  current_tool.data = tool_actions
154
165
  end
155
-
156
- send(method_found, current_tool, tool_actions, atome_touched, a_event)
166
+ tool_name = tool.to_s.sub('_tool', '')
167
+ tools_scheme = Universe.tools[tool_name.to_sym]
168
+ puts "1 - here slider treat either the target atome types or current atome"
169
+ puts "2 - need to created a list instead of choosing the last atome found of it's kind"
170
+
171
+ target = if tools_scheme[:target]
172
+ grab(atome_touched.send(tools_scheme[:target]).last)
173
+ else
174
+ atome_touched
175
+ end
176
+ tools_scheme[:particles]&.each do |particle_f, value_f|
177
+ target.send(particle_f, value_f)
178
+ end
179
+ send(method_found, current_tool, tool_actions, target, a_event)
157
180
  end
158
181
 
159
182
  end
@@ -164,13 +187,102 @@ class Atome
164
187
 
165
188
  def set_action_on_touch(&action)
166
189
  @touch_action = action
167
-
168
190
  end
169
191
 
170
192
  def remove_get_atome_on_touch
171
193
  @touch_action = nil
172
194
  end
173
195
 
196
+ def activate_tool
197
+ tool_name = id
198
+ tool_scheme = @tool_scheme
199
+ tool = self
200
+
201
+ alterations = tool_scheme[:alteration] ? tool_scheme[:alteration].keys : []
202
+ creations = tool_scheme[:creation] ? tool_scheme[:creation].keys : []
203
+ prev_auth = Universe.allow_localstorage ||= []
204
+ events_allow = %i[top left right bottom width height]
205
+ storage_allowed = events_allow.concat(alterations).concat(creations).concat(prev_auth).uniq
206
+
207
+ Universe.allow_localstorage = storage_allowed
208
+ # we set edit mode to true (this allow to prevent user atome to respond from click)
209
+
210
+ Universe.edit_mode = true
211
+ # init the tool
212
+ tool.data[:treated] = []
213
+ tool.data[:created] = []
214
+ tool.data[:prev_states] = {}
215
+ # generic behavior
216
+ # tool.apply(:active_tool_col)
217
+ grab("#{tool_name}_icon").color(:white)
218
+ grab("#{tool_name}_label").color(:white)
219
+ Universe.active_tools << tool_name
220
+ # activation code
221
+ activation_code = tool_scheme[:activation]
222
+ tool.instance_exec(&activation_code) if activation_code.is_a? Proc
223
+ # below we the particles of selected atomes to feed tools values
224
+ # possibility 1 (pipette like):
225
+ # now we get the values from selected atomes
226
+ Atome.selection.each do |atome_id_to_treat|
227
+ tool.data[:action]&.each_key do |particle_req|
228
+ unless Universe.atome_preset
229
+ value_found = grab(atome_id_to_treat).send(particle_req)
230
+ if value_found
231
+ tool.data[:action][particle_req] = value_found
232
+ else
233
+ end
234
+ end
235
+ end
236
+ end
237
+ # possibility 2 (immediate apply):
238
+ allow_creation = tool.data[:allow_creation]
239
+ allow_alteration = tool.data[:allow_alteration]
240
+ unless tool_name.to_sym == :select_tool || !allow_creation || !allow_alteration
241
+ Atome.selection.each do |atome_id_to_treat|
242
+ atome_found = grab(atome_id_to_treat)
243
+ event = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }
244
+ Atome.apply_tool(tool_name, atome_found, event)
245
+ end
246
+ end
247
+
248
+ # # activate tool analysis test
249
+ Atome.activate_click_analysis
250
+ tool.active(true)
251
+ end
252
+
253
+ def deactivate_tool
254
+ tool_name = id
255
+ tool_scheme = @tool_scheme
256
+ tool = self
257
+ tool.active(false)
258
+ tool.instance_variable_get("@toolbox")&.each do |sub_tool_id|
259
+ toolbox_tool = grab("#{sub_tool_id}_tool")
260
+ toolbox_tool.deactivate_tool
261
+ # we delete the attached toolbox if it exist
262
+ toolbox_tool.delete({ force: true })
263
+ end
264
+ grab("#{tool_name}_icon").color(grab(:toolbox_style).data[:text_color])
265
+ grab("#{tool_name}_label").color(grab(:toolbox_style).data[:text_color])
266
+ # when closing delete tools action from tool_actions_to_exec
267
+ Universe.active_tools.delete(tool_name)
268
+ # we check if all tools are inactive if so we set edit_mode to false
269
+ if Universe.active_tools.length == 0
270
+ Atome.de_activate_click_analysis
271
+ Universe.edit_mode = false
272
+ Universe.allow_localstorage = false
273
+ end
274
+
275
+ inactivation_code = tool_scheme[:inactivation]
276
+ tool.instance_exec(tool.data, &inactivation_code) if inactivation_code.is_a? Proc
277
+ # generic behavior
278
+ # we remove touch and resize binding on newly created atomes
279
+ tool.apply(:inactive_tool_col)
280
+ tool.data[:created]&.each do |new_atome|
281
+ new_atome.drag(false)
282
+ new_atome.resize(:remove)
283
+ end
284
+ end
285
+
174
286
  def build_tool(params)
175
287
  # here is the main entry for tool creation
176
288
  language ||= grab(:view).language
@@ -179,20 +291,22 @@ class Atome
179
291
  tool_name = "#{params[:name]}_tool"
180
292
  index = params[:index]
181
293
  tool_scheme = params[:scheme]
182
- toolbox=params[:toolbox] || {}
294
+ # @tool_scheme=params[:scheme]
295
+ toolbox = params[:toolbox] || {}
183
296
  orientation_wanted = tool_scheme[:orientation] || :sn
184
- color({ id: :active_tool_col, alpha: 1, red: 1, green: 1, blue: 1 })
185
- color({ id: :inactive_tool_col, alpha: 0.6 })
297
+
186
298
  grab(:intuition).storage[:tool_open] ||= []
187
299
  grab(:intuition).storage[:tool_open] << tool_name
188
300
  size = grab(:toolbox_style).data[:size]
301
+ margin = grab(:toolbox_style).data[:margin]
189
302
  smooth = grab(:toolbox_style).data[:smooth]
303
+ text_color = grab(:toolbox_style).data[:text_color]
190
304
  case orientation_wanted
191
305
  when :sn
192
306
  top = :auto
193
- bottom_offset=toolbox[:bottom] || 3
307
+ bottom_offset = toolbox[:bottom] || 3
194
308
  spacing = toolbox[:spacing] || 3
195
- bottom = index * (size + spacing)+bottom_offset
309
+ bottom = index * (size + spacing) + bottom_offset
196
310
  left = toolbox[:left] || 3
197
311
  right = :auto
198
312
  when :ns
@@ -217,12 +331,13 @@ class Atome
217
331
  # orientation: orientation_wanted,
218
332
  top: top,
219
333
  bottom: bottom,
334
+ depth: 0,
220
335
  left: left,
221
336
  right: right,
222
337
  width: size,
223
338
  height: size,
224
339
  smooth: smooth,
225
- apply: [:tool_inactive_color, :tool_box_border, :tool_shade],
340
+ apply: %i[inactive_tool_col tool_box_border tool_shade],
226
341
  state: :closed,
227
342
  data: { method: method,
228
343
  action: action,
@@ -235,125 +350,155 @@ class Atome
235
350
  }
236
351
 
237
352
  })
353
+
354
+ tool.instance_variable_set("@tool_scheme", tool_scheme)
238
355
  edition = "M257.7 752c2 0 4-0.2 6-0.5L431.9 722c2-0.4 3.9-1.3 5.3-2.8l423.9-423.9c3.9-3.9 3.9-10.2 0-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2c-1.9 11.1 1.5 21.9 9.4 29.8 6.6 6.4 14.9 9.9 23.8 9.9z m67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"
356
+ icon = tool.vector({ tag: { system: true }, left: 9, top: :auto, bottom: 9, width: 18, height: 18, id: "#{tool_name}_icon",
357
+ data: { path: { d: edition, id: "p1_#{tool_name}_icon", stroke: :black, 'stroke-width' => 37, fill: :white } } })
358
+
359
+ icon.color(text_color)
360
+
361
+ tool.text({ tag: { system: true }, data: truncate_string(label, 5), component: { size: 9 }, center: { x: 0 }, top: :auto, bottom: 0,
362
+ color: text_color, id: "#{tool_name}_label", width: size, position: :absolute })
239
363
 
240
- icon= tool.vector({ tag: { system: true }, left: 9, top: :auto, bottom: 9, width: 18, height: 18, id: "#{tool_name}_icon",
241
- data: { path: { d: edition, id: :p1, stroke: :black, 'stroke-width' => 37, fill: :white } }})
242
- # wait 2 do
243
- # alert "#{tool_name}_icon"
244
- # alert "current vector : #{grab("#{tool_name}_icon").id}"
245
- grab("#{tool_name}_icon").color(:blue)
246
- # icon.color(:red)
247
- # end
248
- # icon= tool_scheme[:icon] || params[:name]
249
- # tool.image({path: "medias/images/icons/#{icon}.svg"})
250
- tool.text({ tag: { system: true }, data: label, component: { size: 9 }, color: :grey, id: "#{tool_name}_label" })
251
364
  code_for_zone = tool_scheme[:zone]
252
365
  tool.instance_exec(tool, &code_for_zone) if code_for_zone.is_a? Proc
253
- tool.touch(true) do
254
- # we add all specific tool actions to @tools_actions_to_exec hash
255
- # we set allow_tool_operations to false to ignore tool operation when clicking on a tool
256
- Universe.allow_tool_operations = false
257
- # we create the creation_layer if not already exist
258
- tick(tool_name)
259
- # active code exec
260
- if tick[tool_name] == 1 # first click
261
- events_allow = [:top, :left, :right, :bottom, :width, :height]
262
- alterations = tool_scheme[:alteration] ? tool_scheme[:alteration].keys : []
263
- creations = tool_scheme[:creation] ? tool_scheme[:creation].keys : []
264
- prev_auth = Universe.allow_localstorage ||= []
265
- storage_allowed = events_allow.concat(alterations).concat(creations).concat(prev_auth).uniq
266
- Universe.allow_localstorage = storage_allowed
267
- # we set edit mode to true (this allow to prevent user atome to respond from click)
268
- Universe.edit_mode = true
269
- Universe.active_tools << tool_name
270
- # init the tool
271
- tool.data[:treated] = []
272
- tool.data[:created] = []
273
- tool.data[:prev_states] = {}
274
- # generic behavior
275
- tool.apply(:active_tool_col)
276
- # activation code
277
- activation_code = tool_scheme[:activation]
278
- tool.instance_exec(&activation_code) if activation_code.is_a? Proc
279
- # below we the particles of selected atomes to feed tools values
280
- # possibility 1 (pipette like):
281
- # now we get the values from selected atomes
282
- Atome.selection.each do |atome_id_to_treat|
283
- tool.data[:action].each do |particle_req, value_f|
284
- unless Universe.atome_preset
285
- value_found = grab(atome_id_to_treat).send(particle_req)
286
- if value_found
287
- tool.data[:action][particle_req] = value_found
288
- else
366
+ tool.active(false)
367
+ tool.touch(:long) do
368
+ tool.instance_variable_set('@prevent_action', true)
369
+ if tool.instance_variable_get('@tool_open') == true
370
+ tool.instance_variable_set('@tool_open', false)
371
+ tool_scheme[:particles].each do |particle, value|
372
+ grab("tool_particle_#{particle}").delete({ force: true })
373
+ end
374
+ tool.width(size)
375
+ else
376
+ tool.instance_variable_set('@tool_open', true)
377
+
378
+ tool_scheme[:particles].each_with_index do |(particle_name, _value_), ind|
379
+
380
+ particle = tool.box({ id: "tool_particle_#{particle_name}", tag: { system: true }, depth: 1, smooth: smooth,
381
+ apply: %i[inactive_tool_col tool_box_border tool_shade],
382
+ width: size, height: size, left: ind * (size + margin) + size })
383
+ particle_label = particle.text({
384
+ id: "tool_particle_name_#{particle_name}",
385
+ tag: { system: true },
386
+ data: truncate_string(particle_name, 5),
387
+ center: { x: 0 },
388
+ position: :absolute,
389
+ component: { size: 9 },
390
+ color: text_color,
391
+ top: :auto,
392
+ }
393
+
394
+ )
395
+ label_value = particle.text({
396
+ id: "tool_particle_value_#{particle_name}",
397
+ data: 0.00,
398
+ tag: { system: true },
399
+ center: { x: 0 },
400
+ position: :absolute,
401
+ component: { size: 9 },
402
+ color: text_color,
403
+ top: margin,
404
+
405
+ })
406
+ particle_label.center({ x: 0 })
407
+ particle_label.top(:auto)
408
+ particle_label.bottom(0)
409
+ particle.touch(true) do
410
+ puts "1 ======> opening !!!#{particle_name}"
411
+ tool.instance_variable_set('@prevent_action', true)
412
+ slider_id = "particle_slider_#{particle_name}"
413
+ if particle.instance_variable_get('@active')
414
+ grab(slider_id).delete({ force: true })
415
+ particle.instance_variable_set('@active', false)
416
+ # particle.top(:auto)
417
+ # particle.top(:bottom)
418
+ particle.height(size)
419
+ particle.top(0)
420
+ else
421
+ particle.height(139 + size / 2)
422
+ particle.top(-139 + size)
423
+ # particle.top(:auto)
424
+ # particle.top(:bottom)
425
+ # particle.color(:green)
426
+ slider_id = "particle_slider_#{particle_name}"
427
+ slider_f = particle.slider({ orientation: :vertical,
428
+ id: slider_id,
429
+ range: { color: { alpha: 0 } },
430
+ value: 55,
431
+ depth: 2,
432
+ center: { x: 0 },
433
+ width: 18, height: 123, smooth: 1,
434
+ left: 0,
435
+ top: size / 2,
436
+ color: { alpha: 0 },
437
+ cursor:
438
+ { color: { alpha: 1, red: 0.9, green: 0.9, blue: 0.0 },
439
+ width: 18, height: 12, smooth: 3 } }) do |value|
440
+ # Slider actions below:
441
+ if grab(slider_id).instance_variable_get('@initialised')
442
+ Atome.selection.each do |atome_id_to_treat|
443
+
444
+ # puts "-------> #{tool_scheme[:particles][particle_name]} , #{value }"
445
+ tool_scheme[:particles][particle_name] = value.to_f / 100
446
+ # tools_scheme[:particles]
447
+ atome_found = grab(atome_id_to_treat)
448
+ target = grab(atome_found.color.last)
449
+
450
+ target.send(particle_name, value.to_f / 100)
451
+ label_value.data(value.to_f / 100)
452
+ # puts "+++++++> #{tool_scheme[:particles]} }"
453
+ end
454
+ end
289
455
  end
456
+ puts "2 ======> opening !!!#{particle_name}"
457
+
458
+ Atome.selection.each do |atome_id_to_treat|
459
+ atome_found = grab(atome_id_to_treat)
460
+ puts "here slider treat either the target atome types or current atome"
461
+ puts "need to created a list instead of choosing the last atome found of it's kind"
462
+ target = if tool_scheme[:target]
463
+ grab(atome_found.send(tool_scheme[:target]).last)
464
+ else
465
+ atome_found
466
+ end
467
+ value_found = target.send(particle_name)
468
+ slider_f.value(value_found * 100)
469
+ end
470
+ slider_f.instance_variable_set('@initialised', true)
471
+ particle.instance_variable_set('@active', true)
290
472
  end
473
+
291
474
  end
292
- end
293
- # possibility 2 (immediate apply):
294
- allow_creation = tool.data[:allow_creation]
295
- allow_alteration = tool.data[:allow_alteration]
296
- Atome.selection.each do |atome_id_to_treat|
297
- atome_found = grab(atome_id_to_treat)
298
- event = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }
299
- Atome.apply_tool(tool_name, atome_found, event)
300
- end unless tool_name.to_sym == :select_tool || !allow_creation || !allow_alteration
301
-
302
- # activate tool analysis test
303
- Atome.activate_click_analysis
304
- else
305
- Universe.allow_localstorage = false
306
- # when closing delete tools action from tool_actions_to_exec
307
- Universe.active_tools.delete(tool_name)
308
- # we check if all tools are inactive if so we set edit_mode to false
309
- if Universe.active_tools.length == 0
310
- Atome.de_activate_click_analysis
311
- Universe.edit_mode = false
312
- end
475
+ end if tool_scheme[:particles]
476
+ # tool.width(((size + margin) * (tool_scheme[:particles].length + 1)))
477
+ end
313
478
 
314
- inactivation_code = tool_scheme[:inactivation]
315
- tool.instance_exec(tool.data, &inactivation_code) if inactivation_code.is_a? Proc
316
- # end if tool_content && tool_content[:inactive]
479
+ end
480
+ tool.touch(:down) do
481
+ tool.depth(999)
482
+ end
483
+ tool.touch(true) do
317
484
 
318
- # generic behavior
319
- # we remove touch and resize binding on newly created atomes
320
- tool.apply(:inactive_tool_col)
321
- tool.data[:created].each do |new_atome|
322
- new_atome.drag(false)
323
- new_atome.resize(:remove)
324
- end
325
- ################################
326
- # we restore prev touch and resize
327
- tool.data[:prev_states].each do |atome_f, prev_par|
328
- puts prev_par
329
- # params[:events].each do |part_f, val_f|
330
- # # alert "@#{part_f}, #{part_f}"
331
- # atome_f.send(part_f, val_f)
332
- # end
333
- # alert "--> params : #{params[:events]}"
334
- # alert "--> procs : #{params[:procs][params[:events]]}"
335
- # atome_f.touch(false)
336
- # atome_f.touch(true) do
337
- # alert :kool
338
- # end
339
- # alert params[:procs]
340
- # params[:procs].each do |var_n, procs_f|
341
- # # procs_f.each do |action_f, proc|
342
- # # # puts "#{var_n}==> #{action_f}, #{proc}"
343
- # # end
344
- # puts "==> #{var_n}, #{proc_f}"
345
- # # atome_f.instance_variable_set("@#{var_n}", proc_f)
346
- # end
347
- # atome_f.touch(false)
348
- # alert "#{atome_f.touch} : #{atome_f.instance_variable_get("@touch_code")}"
485
+ # puts "==> prevent : #{tool.instance_variable_get('@prevent_action')}"
486
+ unless tool.instance_variable_get('@prevent_action')
487
+ # we add all specific tool actions to @tools_actions_to_exec hash
488
+ # we set allow_tool_operations to false to ignore tool operation when clicking on a tool
489
+ Universe.allow_tool_operations = false
490
+ # we create the creation_layer if not already exist
491
+ if tool.active == false # first click
492
+ tool.activate_tool
493
+ else
494
+ tool.deactivate_tool
495
+ tick[tool_name] = 0
349
496
  end
350
-
351
- # atome_f.touch(touch_found)
352
- # atome_f.resize(resize_found)
353
- # inactivation code
354
- #################################
355
- tick[tool_name] = 0
356
497
  end
498
+ puts 'reactivation'
499
+ tool.instance_variable_set('@prevent_action', false)
357
500
  end
501
+
358
502
  end
503
+
359
504
  end
@@ -154,12 +154,13 @@ new({ molecule: :slider }) do |params, bloc|
154
154
  new_id = params.delete(:id) || identity_generator
155
155
 
156
156
  default_smooth = 9
157
- default_slider_particles = { id: new_id, color: color_found, width: 333, height: 33, left: 0, top: 0, smooth: default_smooth }
158
- default_cursor_particles = { color: color_found, width: 29, height: 29, left: 0, smooth: '100%' }
157
+ default_slider_particles = { id: new_id, color: color_found, width: 333, height: 33, left: 0, top: 0,
158
+ smooth: default_smooth, tag: { system: true } }
159
+ default_cursor_particles = { color: color_found, width: 29, height: 29, left: 0, smooth: '100%', tag: { system: true } }
159
160
  cursor_found = params.delete(:cursor)
160
161
  slider_particle = default_slider_particles.merge(params)
161
162
  slider = box(slider_particle)
162
-
163
+ slider.remove(:box_color)
163
164
  slider_shadow = slider.shadow({
164
165
  id: :s2,
165
166
  left: 3, top: 3, blur: 9,
@@ -167,8 +168,8 @@ new({ molecule: :slider }) do |params, bloc|
167
168
  red: 0, green: 0, blue: 0, alpha: 0.7
168
169
  })
169
170
 
170
- range = slider.box({ id: "#{slider.id}_range", top: :auto, bottom: 0 })
171
-
171
+ range = slider.box({ id: "#{slider.id}_range", top: :auto, bottom: 0,tag: { system: true } })
172
+ range.remove(:box_color)
172
173
  if range_found
173
174
  range.apply(slider_shadow.id,)
174
175
  range_found.each do |part, val|
@@ -179,6 +180,7 @@ new({ molecule: :slider }) do |params, bloc|
179
180
  end
180
181
  cursor_particle = default_cursor_particles.merge(cursor_found).merge({ id: "#{slider.id}_cursor" })
181
182
  cursor = slider.box(cursor_particle)
183
+ cursor.remove(:box_color)
182
184
  cursor_left = (slider_particle[:width] - cursor_particle[:width]) / 2.0
183
185
  cursor_top = (slider_particle[:height] - cursor_particle[:height]) / 2.0
184
186
 
@@ -305,9 +307,9 @@ new(molecule: :button) do |params, bloc|
305
307
  button = box(
306
308
  { renderers: renderer_found, id: new_id, type: :shape, color: back_col,
307
309
  left: 0, top: 0, data: '', attach: attach_to,
308
- smooth: 3, overflow: :hidden,
310
+ smooth: 3, overflow: :hidden,tag: { system: true }
309
311
  })
310
-
312
+ button.remove(:box_color)
311
313
  button.touch(:down) do
312
314
  button.tick(:button)
313
315
  bloc.call((button.tick[:button] - 1) % states)
@@ -362,7 +364,7 @@ class Atome
362
364
  end
363
365
 
364
366
  new(molecule: :matrix) do |params, &bloc|
365
- params ||= {}
367
+ params ||= {}
366
368
  # We test if self is main if so we attach the matrix to the view
367
369
  parent_found = if self == self
368
370
  grab(:view)
@@ -391,7 +393,7 @@ new(molecule: :matrix) do |params, &bloc|
391
393
  view_width = parent_found.to_px(:width)
392
394
  view_height = parent_found.to_px(:height)
393
395
  matrix_back = box({ id: "#{id}_background", width: size, height: size, color: { alpha: 0 } })
394
-
396
+ matrix_back.remove(:box_color)
395
397
  if view_width > view_height
396
398
  full_size = view_height * size_coefficient
397
399
  available_width = full_size - total_spacing_x
@@ -427,12 +429,13 @@ new(molecule: :matrix) do |params, &bloc|
427
429
  end
428
430
  new(molecule: :page) do |params, &bloc|
429
431
  b = box({ color: :red, left: 99, drag: true })
432
+ b.remove(:box_color)
430
433
  b.text(params)
431
434
  end
432
435
  new(molecule: :application) do |params, &bloc|
433
436
 
434
437
  main_page = box({ drag: true, width: :auto, height: :auto, top: 0, bottom: 0, left: 0, right: 0 })
435
-
438
+ main_page.remove(:box_color)
436
439
  main_page
437
440
 
438
441
  # def new(params, &bloc)