atome 0.5.7.3.5 → 0.5.7.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -1
  3. data/documentation/deep learning/architecture.txt +4 -4
  4. data/documentation/deep learning/basic_infos.txt +2 -2
  5. data/documentation/deep learning/example_of_users_code.rb +43 -43
  6. data/documentation/installation/buiding_atome.md +2 -2
  7. data/lib/atome/atome.rb +1 -1
  8. data/lib/atome/extensions/atome.rb +28 -19
  9. data/lib/atome/genesis/atomes.rb +1 -1
  10. data/lib/atome/genesis/genesis.rb +19 -19
  11. data/lib/atome/genesis/particles/geometry.rb +3 -3
  12. data/lib/atome/genesis/particles/hierarchy.rb +56 -21
  13. data/lib/atome/genesis/particles/material.rb +13 -1
  14. data/lib/atome/genesis/particles/property.rb +27 -0
  15. data/lib/atome/genesis/particles/utility.rb +199 -91
  16. data/lib/atome/genesis/sparkle.rb +1 -1
  17. data/lib/atome/kernel/black_matter.rb +3 -0
  18. data/lib/atome/utilities/utilities.rb +19 -8
  19. data/lib/atome/version.rb +2 -1
  20. data/lib/molecules/intuition/tools.rb +30 -30
  21. data/lib/molecules/intuition/utilities.rb +272 -109
  22. data/lib/platform_specific/opal/extensions/object.rb +1 -1
  23. data/lib/renderers/html/html.rb +26 -1
  24. data/vendor/assets/application/examples/account.rb +35 -0
  25. data/vendor/assets/application/examples/actor&role.rb +23 -0
  26. data/vendor/assets/application/examples/animation.rb +1 -1
  27. data/vendor/assets/application/examples/applications.rb +121 -0
  28. data/vendor/assets/application/examples/atome.rb +1 -1
  29. data/vendor/assets/application/examples/attach.rb +7 -7
  30. data/vendor/assets/application/examples/attached.rb +13 -15
  31. data/vendor/assets/application/examples/basic_understanding.rb +1 -1
  32. data/vendor/assets/application/examples/buttons.rb +47 -0
  33. data/vendor/assets/application/examples/clear.rb +12 -12
  34. data/vendor/assets/application/examples/clones&monitoring.rb +1 -1
  35. data/vendor/assets/application/examples/delete.rb +19 -14
  36. data/vendor/assets/application/examples/detach.rb +8 -0
  37. data/vendor/assets/application/examples/dig.rb +1 -1
  38. data/vendor/assets/application/examples/display.rb +6 -6
  39. data/vendor/assets/application/examples/drag.rb +1 -1
  40. data/vendor/assets/application/examples/duplicate.rb +6 -6
  41. data/vendor/assets/application/examples/exchange.rb +17 -0
  42. data/vendor/assets/application/examples/generator_and_build.rb +3 -3
  43. data/vendor/assets/application/examples/hierarchy.rb +5 -5
  44. data/vendor/assets/application/examples/layout.rb +1 -1
  45. data/vendor/assets/application/examples/preset.rb +3 -3
  46. data/vendor/assets/application/examples/scheduler.rb +0 -1
  47. data/vendor/assets/application/examples/selected.rb +1 -1
  48. data/vendor/assets/application/examples/shapes.rb +1 -1
  49. data/vendor/assets/application/examples/size.rb +1 -1
  50. data/vendor/assets/application/examples/test.rb +0 -320
  51. data/vendor/assets/application/examples/tools.rb +136 -192
  52. data/vendor/assets/application/examples/unfasten.rb +17 -0
  53. data/vendor/assets/server/atome_server.rb +1 -0
  54. data/vendor/assets/server/eDen.rb +68 -71
  55. data/vendor/assets/src/index_server_wasm.html +4 -0
  56. data/vendor/assets/src/js/atome/specific/wasm.js +22 -4
  57. data/vendor/assets/src/js/third_parties/three.min.js +1 -1
  58. data/vendor/assets/src/medias/fonts/Roboto/LICENSE.txt +1 -1
  59. data/vendor/assets/src/medias/fonts/Roboto_Slab/LICENSE.txt +1 -1
  60. metadata +9 -2
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  def truncate_string(string, max_length)
4
- string.length > max_length ? string.slice(0, max_length) + "." : string
4
+ string.length > max_length ? string.slice(0, max_length) + '.' : string
5
5
  end
6
6
 
7
7
  size = 33
@@ -53,7 +53,7 @@ class Atome
53
53
  def activate_click_analysis
54
54
  # the condition below avoid touchdown analysis accumulation
55
55
  unless @click_analysis_active
56
- # this method analyse all object under the touchdown to find the first user objet and return it's id
56
+ # this method analyse all object under the touchdown to find the first user object and return it's id
57
57
  @click_analysis = lambda { |native_event|
58
58
  # the instance variable below check if we can apply tool (cf: if the atome we don't want to apply tool)
59
59
  if Universe.allow_tool_operations
@@ -66,11 +66,12 @@ class Atome
66
66
  id_found = atome_touched[:id].to_s
67
67
  atome_found = grab(id_found)
68
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
73
- end
69
+ puts 'we have to check if operation is a creation or an alteration to include or exclude the view '
70
+ # alert atome_touched
71
+ Universe.active_tools.each do |tool|
72
+ # alert "#{tool}, #{atome_found.id}"
73
+ apply_tool(tool, atome_found, event)
74
+ end # if atome_found #&& !atome_found.tag[:system]
74
75
 
75
76
  break
76
77
  end
@@ -90,6 +91,7 @@ class Atome
90
91
  end
91
92
 
92
93
  def start_click_analysis
94
+ # here we capture any touch when usingh tool
93
95
  @click_analysis_active = false
94
96
  JS.global[:document].addEventListener('mouseup') do |native_event|
95
97
  Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
@@ -122,9 +124,9 @@ class Atome
122
124
  def creation(current_tool, tool_actions, atome_touched, a_event)
123
125
  # we store prev_local_storage prior to lock it to prevent unwanted logs
124
126
  # prev_local_storage=Universe.allow_localstorage()
127
+ @creation_mode = true
125
128
  storage_allowed = Universe.allow_localstorage
126
129
  Universe.allow_localstorage = false
127
-
128
130
  action_found = tool_actions[:action]
129
131
  pre = tool_actions[:pre]
130
132
  post = tool_actions[:post]
@@ -155,6 +157,7 @@ class Atome
155
157
  end
156
158
 
157
159
  def apply_tool(tool, atome_touched, a_event)
160
+
158
161
  current_tool = grab(tool)
159
162
  tool_actions = current_tool.data
160
163
  method_found = tool_actions[:method]
@@ -165,18 +168,22 @@ class Atome
165
168
  end
166
169
  tool_name = tool.to_s.sub('_tool', '')
167
170
  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
 
171
172
  target = if tools_scheme[:target]
172
173
  grab(atome_touched.send(tools_scheme[:target]).last)
173
174
  else
174
175
  atome_touched
175
176
  end
176
- tools_scheme[:particles]&.each do |particle_f, value_f|
177
- target.send(particle_f, value_f)
177
+ # unless method_found == :alteration && (target.id == :view_color || target.id == :view)
178
+ unless method_found == :alteration && target.tag[:system]
179
+
180
+
181
+ tools_scheme[:particles]&.each do |particle_f, value_f|
182
+ target.send(particle_f, value_f)
183
+ end
184
+ send(method_found, current_tool, tool_actions, target, a_event)
178
185
  end
179
- send(method_found, current_tool, tool_actions, target, a_event)
186
+
180
187
  end
181
188
 
182
189
  end
@@ -255,10 +262,10 @@ class Atome
255
262
  tool_scheme = @tool_scheme
256
263
  tool = self
257
264
  tool.active(false)
258
- tool.instance_variable_get("@toolbox")&.each do |sub_tool_id|
265
+ tool.instance_variable_get('@toolbox')&.each do |sub_tool_id|
259
266
  toolbox_tool = grab("#{sub_tool_id}_tool")
260
267
  toolbox_tool.deactivate_tool
261
- # we delete the attached toolbox if it exist
268
+ # we delete the fasten toolbox if it exist
262
269
  toolbox_tool.delete({ force: true })
263
270
  end
264
271
  grab("#{tool_name}_icon").color(grab(:toolbox_style).data[:text_color])
@@ -277,6 +284,7 @@ class Atome
277
284
  # generic behavior
278
285
  # we remove touch and resize binding on newly created atomes
279
286
  tool.apply(:inactive_tool_col)
287
+ # alert tool.data[:created]
280
288
  tool.data[:created]&.each do |new_atome|
281
289
  new_atome.drag(false)
282
290
  new_atome.resize(:remove)
@@ -351,8 +359,8 @@ class Atome
351
359
 
352
360
  })
353
361
 
354
- tool.instance_variable_set("@tool_scheme", tool_scheme)
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"
362
+ tool.instance_variable_set('@tool_scheme', tool_scheme)
363
+ 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
364
  icon = tool.vector({ tag: { system: true }, left: 9, top: :auto, bottom: 9, width: 18, height: 18, id: "#{tool_name}_icon",
357
365
  data: { path: { d: edition, id: "p1_#{tool_name}_icon", stroke: :black, 'stroke-width' => 37, fill: :white } } })
358
366
 
@@ -368,14 +376,14 @@ class Atome
368
376
  tool.instance_variable_set('@prevent_action', true)
369
377
  if tool.instance_variable_get('@tool_open') == true
370
378
  tool.instance_variable_set('@tool_open', false)
371
- tool_scheme[:particles].each do |particle, value|
379
+ tool_scheme[:particles].each_key do |particle|
372
380
  grab("tool_particle_#{particle}").delete({ force: true })
373
381
  end
374
382
  tool.width(size)
375
383
  else
376
384
  tool.instance_variable_set('@tool_open', true)
377
385
 
378
- tool_scheme[:particles].each_with_index do |(particle_name, _value_), ind|
386
+ tool_scheme[:particles]&.each_with_index do |(particle_name, _value_), ind|
379
387
 
380
388
  particle = tool.box({ id: "tool_particle_#{particle_name}", tag: { system: true }, depth: 1, smooth: smooth,
381
389
  apply: %i[inactive_tool_col tool_box_border tool_shade],
@@ -420,9 +428,6 @@ class Atome
420
428
  else
421
429
  particle.height(139 + size / 2)
422
430
  particle.top(-139 + size)
423
- # particle.top(:auto)
424
- # particle.top(:bottom)
425
- # particle.color(:green)
426
431
  slider_id = "particle_slider_#{particle_name}"
427
432
  slider_f = particle.slider({ orientation: :vertical,
428
433
  id: slider_id,
@@ -449,15 +454,13 @@ class Atome
449
454
 
450
455
  target.send(particle_name, value.to_f / 100)
451
456
  label_value.data(value.to_f / 100)
452
- # puts "+++++++> #{tool_scheme[:particles]} }"
453
457
  end
454
458
  end
455
459
  end
456
- puts "2 ======> opening !!!#{particle_name}"
457
460
 
458
461
  Atome.selection.each do |atome_id_to_treat|
459
462
  atome_found = grab(atome_id_to_treat)
460
- puts "here slider treat either the target atome types or current atome"
463
+ puts 'here slider treat either the target atome types or current atome'
461
464
  puts "need to created a list instead of choosing the last atome found of it's kind"
462
465
  target = if tool_scheme[:target]
463
466
  grab(atome_found.send(tool_scheme[:target]).last)
@@ -472,8 +475,7 @@ class Atome
472
475
  end
473
476
 
474
477
  end
475
- end if tool_scheme[:particles]
476
- # tool.width(((size + margin) * (tool_scheme[:particles].length + 1)))
478
+ end
477
479
  end
478
480
 
479
481
  end
@@ -481,8 +483,6 @@ class Atome
481
483
  tool.depth(999)
482
484
  end
483
485
  tool.touch(true) do
484
-
485
- # puts "==> prevent : #{tool.instance_variable_get('@prevent_action')}"
486
486
  unless tool.instance_variable_get('@prevent_action')
487
487
  # we add all specific tool actions to @tools_actions_to_exec hash
488
488
  # we set allow_tool_operations to false to ignore tool operation when clicking on a tool
@@ -495,7 +495,7 @@ class Atome
495
495
  tick[tool_name] = 0
496
496
  end
497
497
  end
498
- puts 'reactivation'
498
+ # puts 'reactivation'
499
499
  tool.instance_variable_set('@prevent_action', false)
500
500
  end
501
501
 
@@ -1,5 +1,114 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ class Atome
4
+
5
+ def create_new_button(button_id, position_in_menu, label, code)
6
+ essential_keys = [:inactive, :active]
7
+ buttons_style = data.select { |key, value| essential_keys.include?(key) }
8
+ menu_item = box({ id: button_id })
9
+ menu_item.text({ data: label, id: "#{button_id}_label" })
10
+ menu_item.code({ button_code: code })
11
+
12
+ inactive_style = buttons_style[:inactive]
13
+ active_style = buttons_style[:active]
14
+ if active_style
15
+ active_state_text = active_style[:text]
16
+ keys_to_exclude = [:margin, :spacing, :disposition, :text]
17
+ active_style = active_style.reject { |key, _| keys_to_exclude.include?(key) }
18
+ end
19
+
20
+ if inactive_style
21
+ inactive_state_text = inactive_style[:text]
22
+ margin = inactive_style[:margin]
23
+ spacing = inactive_style[:spacing]
24
+ disposition = inactive_style[:disposition]
25
+ keys_to_exclude = [:margin, :spacing, :disposition, :text]
26
+ inactive_style = inactive_style.reject { |key, _| keys_to_exclude.include?(key) }
27
+ menu_item.set(inactive_style)
28
+
29
+ if disposition == :horizontal
30
+ menu_item.left = margin[:left] + (inactive_style[:width] + spacing) * position_in_menu
31
+ menu_item.top = margin[:top]
32
+ else
33
+ menu_item.top = margin[:top] + (inactive_style[:height] + spacing) * position_in_menu
34
+ menu_item.left = margin[:left]
35
+ end
36
+
37
+ menu_item.text.each do |text_f|
38
+ grab(text_f).set(inactive_state_text)
39
+ end
40
+
41
+ end
42
+
43
+ menu_item.touch(:down) do
44
+ unless @active_item == menu_item.id
45
+ menu_item.set(active_style)
46
+ menu_item.text.each do |text_f|
47
+ grab(text_f).set(active_state_text)
48
+ end
49
+ fasten.each do |item_id|
50
+ unless button_id == item_id
51
+ grab(item_id).remove({ all: :shadow })
52
+ grab(item_id).set(inactive_style)
53
+ grab("#{item_id}_label").remove({ all: :shadow })
54
+ grab("#{item_id}_label").set(inactive_state_text)
55
+ end
56
+ end
57
+ code.call if code
58
+ end
59
+ @active_item = menu_item.id
60
+ end
61
+ end
62
+
63
+ def add_button(params)
64
+ params.each do |button_id, params|
65
+ label = params[:text]
66
+ code = params[:code]
67
+ # {"new_button"=>{"text"=>"button1", "code"=>#<Proc:0xafe>}}
68
+ index = fasten.length
69
+ create_new_button(button_id, index, label, code)
70
+ end
71
+ false
72
+ end
73
+
74
+ def resize_matrix(params)
75
+
76
+ width(params[:width])
77
+ height(params[:height])
78
+ current_matrix = self
79
+ real_width = current_matrix.to_px(:width)
80
+ real_height = current_matrix.to_px(:height)
81
+ spacing = current_matrix.data[:spacing]
82
+ matrix_cells = current_matrix.data[:matrix]
83
+
84
+ total_spacing_x = spacing * (matrix_cells.collect.length ** (0.5) + 1)
85
+ total_spacing_y = spacing * (matrix_cells.collect.length ** (0.5) + 1)
86
+
87
+ if real_width > real_height
88
+ full_size = real_width
89
+ available_width = full_size - total_spacing_x
90
+ available_height = full_size - total_spacing_y
91
+ else
92
+ full_size = real_width
93
+ available_width = full_size - total_spacing_x
94
+ available_height = full_size - total_spacing_y
95
+ end
96
+
97
+ box_width = available_width / matrix_cells.collect.length ** (0.5)
98
+ box_height = available_height / matrix_cells.collect.length ** (0.5)
99
+
100
+ matrix_cells.collect.each_with_index do |box_id, index|
101
+ box = grab(box_id)
102
+ box.width(box_width)
103
+ box.height(box_height)
104
+ box.left((box_width + spacing) * (index % matrix_cells.collect.length ** (0.5)) + spacing)
105
+ box.top((box_height + spacing) * (index / matrix_cells.collect.length ** (0.5)).floor + spacing)
106
+ end
107
+
108
+ end
109
+
110
+ end
111
+
3
112
  new(molecule: :input) do |params, bloc|
4
113
  params[:height] ||= 15
5
114
  params[:width] ||= 222
@@ -168,7 +277,7 @@ new({ molecule: :slider }) do |params, bloc|
168
277
  red: 0, green: 0, blue: 0, alpha: 0.7
169
278
  })
170
279
 
171
- range = slider.box({ id: "#{slider.id}_range", top: :auto, bottom: 0,tag: { system: true } })
280
+ range = slider.box({ id: "#{slider.id}_range", top: :auto, bottom: 0, tag: { system: true } })
172
281
  range.remove(:box_color)
173
282
  if range_found
174
283
  range.apply(slider_shadow.id,)
@@ -288,81 +397,9 @@ new({ molecule: :slider }) do |params, bloc|
288
397
  slider
289
398
 
290
399
  end
291
- new(molecule: :button) do |params, bloc|
292
- params[:height] ||= 25
293
- params[:width] ||= 25
294
- states = params.delete(:states) || 1
295
- new_id = params.delete(:id) || identity_generator
296
-
297
- back_col = params.delete(:back)
298
- back_col ||= :grey
299
-
300
- default_parent = if self.instance_of?(Atome)
301
- id
302
- else
303
- :view
304
- end
305
- attach_to = params[:attach] || default_parent
306
- renderer_found = grab(attach_to).renderers
307
- button = box(
308
- { renderers: renderer_found, id: new_id, type: :shape, color: back_col,
309
- left: 0, top: 0, data: '', attach: attach_to,
310
- smooth: 3, overflow: :hidden,tag: { system: true }
311
- })
312
- button.remove(:box_color)
313
- button.touch(:down) do
314
- button.tick(:button)
315
- bloc.call((button.tick[:button] - 1) % states)
316
-
317
- end
318
-
319
- params.each do |part_f, val_f|
320
- button.send(part_f, val_f)
321
- end
322
-
323
- button
324
- end
325
400
 
326
401
  new({ particle: :cells })
327
402
 
328
- class Atome
329
- def resize_matrix(params)
330
-
331
- width(params[:width])
332
- height(params[:height])
333
- current_matrix = self
334
- real_width = current_matrix.to_px(:width)
335
- real_height = current_matrix.to_px(:height)
336
- spacing = current_matrix.data[:spacing]
337
- matrix_cells = current_matrix.data[:matrix]
338
-
339
- total_spacing_x = spacing * (matrix_cells.collect.length ** (0.5) + 1)
340
- total_spacing_y = spacing * (matrix_cells.collect.length ** (0.5) + 1)
341
-
342
- if real_width > real_height
343
- full_size = real_width
344
- available_width = full_size - total_spacing_x
345
- available_height = full_size - total_spacing_y
346
- else
347
- full_size = real_width
348
- available_width = full_size - total_spacing_x
349
- available_height = full_size - total_spacing_y
350
- end
351
-
352
- box_width = available_width / matrix_cells.collect.length ** (0.5)
353
- box_height = available_height / matrix_cells.collect.length ** (0.5)
354
-
355
- matrix_cells.collect.each_with_index do |box_id, index|
356
- box = grab(box_id)
357
- box.width(box_width)
358
- box.height(box_height)
359
- box.left((box_width + spacing) * (index % matrix_cells.collect.length ** (0.5)) + spacing)
360
- box.top((box_height + spacing) * (index / matrix_cells.collect.length ** (0.5)).floor + spacing)
361
- end
362
-
363
- end
364
- end
365
-
366
403
  new(molecule: :matrix) do |params, &bloc|
367
404
  params ||= {}
368
405
  # We test if self is main if so we attach the matrix to the view
@@ -428,46 +465,172 @@ new(molecule: :matrix) do |params, &bloc|
428
465
  matrix_back
429
466
  end
430
467
 
431
- new(molecule: :page) do |params, &bloc|
432
- b = box({ color: :red, left: 99, drag: true })
433
- b.remove(:box_color)
434
- b.text(params)
468
+ new(molecule: :application) do |params, &bloc|
469
+ params ||= {}
470
+
471
+ color({ id: :app_color, red: 0.1, green: 0.3, blue: 0.1 })
472
+ # TODO : remove the patch below when possible
473
+ id_f = if params[:id]
474
+ params.delete(:id)
475
+ else
476
+ identity_generator
477
+ end
478
+ main_app = box({ id: id_f, width: :auto, height: :auto, top: 0, bottom: 0, left: 0, right: 0, apply: :app_color,
479
+ category: :application })
480
+ main_app.remove(:box_color)
481
+ main_app.instance_variable_set('@pages', {})
482
+
483
+ buttons({
484
+ id: "#{id_f}_menu",
485
+ attach: id_f,
486
+ inactive: { text: { color: :gray }, width: 66, height: 12, spacing: 3, disposition: :horizontal,
487
+ color: :orange, margin: { left: 33, top: 12 } },
488
+ active: { text: { color: :white, shadow: {} }, color: :blue, shadow: {} },
489
+ })
490
+ main_app
435
491
  end
436
492
 
437
- new(molecule: :application) do |params, &bloc|
493
+ new(molecule: :page) do |params, &bloc|
494
+ allow_menu = params.delete(:menu)
495
+ if params[:id]
496
+ id_f = params.delete(:id)
497
+ page_name = params.delete(:name)
498
+ @pages[id_f.to_sym] = params
499
+ else
500
+ puts "must send an id"
501
+ end
502
+ page_name = page_name || id_f
503
+ item_code = lambda do
504
+ show(id_f)
505
+ end
506
+ unless allow_menu == false
507
+ menu_f = grab("#{@id}_menu")
508
+ menu_f.add_button({ "#{@id}_menu_item_#{page_name}" => {
509
+ text: page_name,
510
+ code: item_code
511
+ } })
512
+ actor({ "#{@id}_menu_item_#{page_name}" => :buttons })
513
+ menu_f.role([:button])
514
+ end
515
+ end
438
516
 
439
- main_page = box({ drag: true, width: :auto, height: :auto, top: 0, bottom: 0, left: 0, right: 0 })
517
+ new(molecule: :show) do |page_id, &bloc|
518
+ params = @pages[page_id.to_sym]
519
+ params ||= {}
520
+ footer = params.delete(:footer)
521
+ header = params.delete(:header)
522
+ left_side_bar = params.delete(:left_side_bar)
523
+ right_side_bar = params.delete(:right_side_bar)
524
+ # modules = params.delete(:modules)
525
+ basic_size = 30
526
+ fasten.each do |page_id_found|
527
+ page_found = grab(page_id_found)
528
+ page_found.delete({ recursive: true }) if page_found && page_found.category.include?(:page)
529
+ end
530
+ color({ id: :page_color, red: 0.1, green: 0.1, blue: 0.1 })
531
+ # TODO : remove the patch below when possible
532
+ id_f = if params[:id]
533
+ params.delete(:id)
534
+ else
535
+ "#{id_f}_#{identity_generator}"
536
+ end
537
+ main_page = box({ width: :auto, depth: -1, height: :auto, id: id_f, top: 0, bottom: 0, left: 0, right: 0, apply: :page_color, category: :page })
440
538
  main_page.remove(:box_color)
539
+
540
+ main_page.set(params)
541
+
542
+ if footer
543
+ new_footer = box({ left: 0, depth: -1, right: 0, width: :auto, top: :auto, bottom: 0, height: basic_size, category: :footer, id: "#{id_f}_footer" })
544
+ new_footer.remove(:box_color)
545
+ new_footer.set(footer)
546
+ end
547
+
548
+ if header
549
+ new_header = box({ left: 0, right: 0, depth: -1, width: :auto, top: 0, height: basic_size, category: :header, id: "#{id_f}_header" })
550
+ new_header.remove(:box_color)
551
+ new_header.set(header)
552
+ end
553
+
554
+ if right_side_bar
555
+ new_right_side_bar = box({ left: :auto, depth: -1, right: 0, width: basic_size, top: 0, bottom: 0, height: :auto, category: :right_side_bar, id: "#{id_f}_right_side_bar" })
556
+ new_right_side_bar.remove(:box_color)
557
+ new_right_side_bar.set(right_side_bar)
558
+ end
559
+
560
+ if left_side_bar
561
+ new_left_side_bar = box({ left: 0, right: :auto, depth: -1, width: basic_size, top: 0, bottom: 0, height: :auto, category: :left_side_bar, id: "#{id_f}_left_side_bar" })
562
+ new_left_side_bar.remove(:box_color)
563
+ new_left_side_bar.set(left_side_bar)
564
+ end
565
+
566
+ fasten.each do |item_id_found|
567
+ item_found = grab(item_id_found)
568
+ if item_found&.category&.include?(:footer)
569
+ main_page.height(:auto)
570
+ main_page.bottom(item_found.height)
571
+ end
572
+ if item_found&.category&.include?(:header)
573
+ main_page.height(:auto)
574
+ main_page.top(item_found.height)
575
+ end
576
+
577
+ if item_found&.category&.include?(:right_side_bar)
578
+ main_page.width(:auto)
579
+ main_page.left(item_found.width)
580
+ if footer
581
+ grab("#{id_f}_footer").right(basic_size)
582
+ end
583
+ if header
584
+ grab("#{id_f}_header").right(basic_size)
585
+ end
586
+ end
587
+
588
+ if item_found&.category&.include?(:left_side_bar)
589
+ main_page.width(:auto)
590
+ main_page.right(item_found.width)
591
+ if footer
592
+ grab("#{id_f}_footer").left(basic_size)
593
+ end
594
+ if header
595
+ grab("#{id_f}_header").left(basic_size)
596
+ end
597
+ end
598
+ end
441
599
  main_page
600
+ end
601
+
602
+ new(molecule: :buttons) do |params, &bloc|
603
+ role_f = params.delete(:role)
604
+ actor_f = params.delete(:actor)
605
+ params_saf = deep_copy(params)
606
+ context = params.delete(:attach) || :view
607
+ id = params.delete(:id) || identity_generator
608
+ main = grab(context).box({ id: id })
609
+ main.role(role_f) || main.role(:buttons)
610
+ main.actor(actor_f) if actor_f
611
+ main.color({ blue: 0.5, red: 1, green: 1, alpha: 0 })
612
+ main.data(params_saf)
613
+ default = params.delete(:inactive) || {}
614
+ main.data[:default] = default
615
+ default_text = default.delete(:text)
616
+ main.data[:default_text] = default_text
617
+ active = params.delete(:active) || {}
618
+ active_text = active.delete(:text)
619
+ inactive = {}
620
+ active.each_key do |part_f|
621
+ inactive[part_f] = default[part_f]
622
+ end
623
+ inactive_text = {}
624
+ active.each_key do |part_f|
625
+ inactive_text[part_f] = default_text[part_f]
626
+ end
627
+
628
+ params.each_with_index do |(item_id, part_f), index|
629
+ label = part_f[:text]
630
+ code = part_f[:code]
631
+ main.create_new_button(item_id, index, label, code)
632
+
633
+ end
634
+ main
442
635
 
443
- # def new(params, &bloc)
444
- # if params[:page]
445
- # site_found = grab(params[:page][:application])
446
- # site_found.clear(true)
447
- # page_id = params[:page][:name]
448
- # site_found.box({ id: page_id })
449
- # elsif params[:application]
450
- #
451
- # footer_header_size = 33
452
- # footer_header_color = color({ red: 0, green: 0, blue: 0, id: :footer_header_color })
453
- #
454
- # if params[:header]
455
- # top = footer_header_size
456
- # header = box({ left: 0, right: 0, width: :auto, top: 0, height: top, id: :header })
457
- # # header.attach(:footer_header_color)
458
- # else
459
- # top = 0
460
- # end
461
- # if params[:footer]
462
- # bottom = footer_header_size
463
- # box({ left: 0, right: 0, width: :auto, top: :auto, bottom: 0, height: bottom, id: :footer })
464
- # else
465
- # bottom = 0
466
- # end
467
- # box({ left: 0, right: 0, width: :auto, top: top, bottom: bottom, height: :auto, id: params[:application] })
468
- # elsif params[:module]
469
- #
470
- # end
471
- # super if defined?(super)
472
- # end
473
636
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # main add on
4
4
  def alert(val)
5
- JS.eval("alert('#{val}')")
5
+ JS.eval("alert('#{val.to_s}')")
6
6
  end
@@ -247,7 +247,19 @@ class HTML
247
247
  # JS.eval("atomeJS.connect('ws://#{server}')")
248
248
  end
249
249
 
250
+ def transform_to_string_keys_and_values(hash)
251
+ hash.transform_keys(&:to_s).transform_values do |value|
252
+ if value.is_a?(Hash)
253
+ transform_to_string_keys_and_values(value)
254
+ else
255
+ value.to_s
256
+ end
257
+ end
258
+ end
259
+
250
260
  def send_message(message)
261
+ # FIXME : find why we have to sanitize this message when using ruby wams
262
+ message = transform_to_string_keys_and_values(message)
251
263
  JS.eval("atomeJS.ws_sender('#{message}')")
252
264
  end
253
265
 
@@ -779,6 +791,7 @@ class HTML
779
791
  end
780
792
 
781
793
  def drag_remove(option)
794
+
782
795
  @draggable = nil
783
796
  interact = JS.eval("return interact('##{@id}')")
784
797
 
@@ -1380,6 +1393,7 @@ class HTML
1380
1393
  end
1381
1394
 
1382
1395
  def touch_remove(option)
1396
+
1383
1397
  @element[:style][:cursor] = 'default'
1384
1398
  case option
1385
1399
  when :double
@@ -1407,7 +1421,18 @@ class HTML
1407
1421
  else
1408
1422
  # interact = JS.eval("return interact('##{@id}')")
1409
1423
  # interact.unset
1410
- @original_atome.instance_variable_set('@touch_code', nil)
1424
+ touch_remove(:double)
1425
+ touch_remove(:down)
1426
+ touch_remove(:long)
1427
+ touch_remove(:tap)
1428
+ touch_remove(:touch)
1429
+ touch_remove(:up)
1430
+
1431
+ # @element.removeEventListener('touchstart', onTouchStart);
1432
+ # @element.removeEventListener('touchmove', onTouchMove);
1433
+ # @element.removeEventListener('touchend', onTouchEnd);
1434
+ # console.log("Touch events removed");
1435
+ # @original_atome.instance_variable_set('@touch_code', nil)
1411
1436
  end
1412
1437
 
1413
1438
  end