atome 0.5.7.4.3 → 0.5.7.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b3bf5cffbab20505060476da1e5f3938270c7a612d6961828860c3fd2682797
4
- data.tar.gz: 6b143b8651c8db90424383494ed5b5ce1d3a211381b42404eb97bfd846a872b9
3
+ metadata.gz: 4307d31fea820f10f0830b00698f327cd08181a864b4440a25a57021fb0ffb7e
4
+ data.tar.gz: 6a66d5336fa6a58eae59571504d92230eb8482bdd44c4821bbf3e79e27a356d2
5
5
  SHA512:
6
- metadata.gz: 9e9d0eebf35dfde29462e19885d4bcb1eccb285eeb0e808381171028e94967d17e9f21c130053b34d31fdc59143c80808a28cf102520cc5cfb14e7c569961d33
7
- data.tar.gz: bf0e01e0a8f0ea7ae821b896fb78e807f4d00848b452f827ebd3d0fb1a07b08b9542b02a87b0c498569f002edc4fca1cdab297c91fd57f974bdb1a4daa4cc119
6
+ metadata.gz: b0a16ea7a7865bc3b13bdc81ce6d57dccf557c25c016446a151eee1203d582e22a246dae317f2531c19cba16fa7c2e3455f64f49ab3966cd526f3ccd2675fff4
7
+ data.tar.gz: c5988d35c2b6af02f6db44e610c0f01ede3d99cd5558db342bbfa186a04cf4669bc0344ad50d187e0208272234c49d2683f0b9ff326082575beeb8177e11490b
@@ -69,6 +69,10 @@ end
69
69
  class Object
70
70
  include ObjectExtension
71
71
 
72
+ def truncate_string(string, max_length)
73
+ string.length > max_length ? string.slice(0, max_length) + '.' : string
74
+ end
75
+
72
76
 
73
77
  def remove_key_pair_but(hash, keys_to_keep)
74
78
  hash.dup.delete_if do |key, value|
@@ -137,7 +141,8 @@ class Object
137
141
 
138
142
  # the method below generate Atome method creation at Object level
139
143
  def atome_method_for_object(element)
140
- Object.define_method element do |params, &user_proc|
144
+
145
+ Object.define_method element do |params=nil, &user_proc|
141
146
  default_parent = Essentials.default_params[element][:attach] || :view
142
147
  grab(default_parent).send(element, params, &user_proc)
143
148
  end
@@ -565,8 +570,14 @@ JS
565
570
  end
566
571
  end
567
572
 
568
- def above(item, margin = 6)
573
+ def above(item, margin = 6, ref=grab(:view))
574
+ # FIXME above is broken when using % in margin
575
+ unless margin.is_a?(Numeric)
576
+ item_height= ref.to_px(:height)
577
+ margin= (margin.to_f*item_height)/100
578
+ end
569
579
  pos = item.to_px(:bottom) + item.height + margin
580
+ item.top(:auto)
570
581
  if item.display == :none
571
582
  33
572
583
  else
@@ -574,7 +585,11 @@ JS
574
585
  end
575
586
  end
576
587
 
577
- def below(item, margin = 6)
588
+ def below(item, margin = 6, ref=grab(:view))
589
+ unless margin.is_a?(Numeric)
590
+ item_height= ref.to_px(:height)
591
+ margin= (margin.to_f*item_height)/100
592
+ end
578
593
  pos = item.to_px(:top) + item.to_px(:height) + margin
579
594
  if item.display == :none
580
595
  0
@@ -584,7 +599,11 @@ JS
584
599
 
585
600
  end
586
601
 
587
- def after(item, margin = 6)
602
+ def after(item, margin = 6, ref=grab(:view))
603
+ unless margin.is_a?(Numeric)
604
+ item_width= ref.to_px(:width)
605
+ margin= (margin.to_f*item_width)/100
606
+ end
588
607
  left_f = if item.left.instance_of?(Integer)
589
608
  item.left
590
609
  else
@@ -604,7 +623,11 @@ JS
604
623
  end
605
624
  end
606
625
 
607
- def before(item, margin = 6)
626
+ def before(item, margin = 6, ref=grab(:view))
627
+ unless margin.is_a?(Numeric)
628
+ item_width= ref.to_px(:width)
629
+ margin= (margin.to_f*item_width)/100
630
+ end
608
631
  pos = item.to_px(:right) + item.width + margin
609
632
  if item.display == :none
610
633
  0
@@ -20,7 +20,7 @@ new({ after: :red }) do |params|
20
20
  a = affect.dup # FIXME we have to dup else some items in the array array other duplicated
21
21
  a.each do |atome_to_refresh|
22
22
  grab(atome_to_refresh).apply(id)
23
- end
23
+ end if a
24
24
  params
25
25
  end
26
26
 
@@ -34,7 +34,7 @@ new({ after: :green }) do |params|
34
34
  a = affect.dup # FIXME we have to dup else some items in the array array other duplicated
35
35
  a.each do |atome_to_refresh|
36
36
  grab(atome_to_refresh).apply(id)
37
- end
37
+ end if a
38
38
  params
39
39
  end
40
40
 
@@ -48,7 +48,7 @@ new({ after: :blue }) do |params|
48
48
  a = affect.dup # FIXME we have to dup else some items in the array array other duplicated
49
49
  a.each do |atome_to_refresh|
50
50
  grab(atome_to_refresh).apply(id)
51
- end
51
+ end if a
52
52
  params
53
53
  end
54
54
  new({ particle: :alpha, category: :property, type: :string }) do
@@ -60,7 +60,7 @@ new({ after: :alpha }) do |params|
60
60
  a = affect.dup # FIXME we have to dup else some items in the array array other duplicated
61
61
  a.each do |atome_to_refresh|
62
62
  grab(atome_to_refresh).apply(id)
63
- end
63
+ end if a
64
64
  params
65
65
  end
66
66
  new({ particle: :diffusion, category: :property, type: :string }) do
@@ -2,24 +2,16 @@
2
2
 
3
3
  # toolbox method here
4
4
  require 'json'
5
-
5
+ # def is_descendant(ancestor, descendant)
6
+ # JS.eval("return isDescendant('#{ancestor}', '#{descendant}')")
7
+ # end
6
8
  class Atome
7
9
  class << self
8
10
  attr_accessor :initialized
9
11
 
12
+
10
13
  def sanitize_data_for_json(data)
11
- data = data.gsub('"', '\\"')
12
- # case data
13
- # when String
14
- # data.gsub('"', '\\"')
15
- # when Hash
16
- # data.transform_values { |value| sanitize_data(value) }
17
- # when Array
18
- # data.map { |value| sanitize_data(value) }
19
- # else
20
- # data
21
- # end
22
- data
14
+ data.gsub('"', '\\"')
23
15
  end
24
16
 
25
17
  def send_localstorage_content
@@ -117,10 +109,105 @@ class Atome
117
109
 
118
110
  @initialized = {}
119
111
 
112
+ def grip(role_wanted)
113
+ gripped_atome = []
114
+
115
+ fasten.each do |child_id|
116
+ child_found = grab(child_id)
117
+ if child_found.role && child_found.role.include?(role_wanted)
118
+ gripped_atome << child_id
119
+ end
120
+ end
121
+ gripped_atome
122
+ end
123
+
124
+ def recursive(_val)
125
+ # dummy method
126
+ end
127
+
128
+
129
+
130
+ def spacing_found(parent_width, child_width, nb_of_children)
131
+ total_child_width = child_width * nb_of_children
132
+ remaining_width = parent_width - total_child_width
133
+ spacing = remaining_width.to_f / (nb_of_children + 1)
134
+ spacing_percentage = (spacing / parent_width) * 100
135
+ spacing_percentage.round(2)
136
+ end
137
+
138
+ def block(params)
139
+ direction = params.delete(:direction) || :vertical
140
+ spacing = params.delete(:spacing) || 3
141
+ width_found = params.delete(:width) || '100%'
142
+ height_found = params.delete(:height) || '100%'
143
+ bloc_params = params.delete(:data) || {}
144
+
145
+ last_id_found = grip(:block).last
120
146
 
121
- def recursive(_val)
122
- #dummy method
147
+ if last_id_found
148
+ last_found = grab(last_id_found)
149
+ case direction
150
+ when :vertical
151
+ box({ top: below(last_found, spacing), role: :block, width: width_found }.merge(params).merge(bloc_params))
152
+ when :horizontal
153
+ width_found = to_px(:width)
154
+ block_left = after(last_found, spacing)
155
+ left_in_percent = (block_left / width_found) * 100
156
+ box({ left: "#{left_in_percent}%", role: :block, height: height_found }.merge(params).merge(bloc_params))
157
+ else
158
+ #
159
+ end
160
+ else
161
+ case direction
162
+ when :vertical
163
+ box({ top: spacing, role: :block, width: width_found }.merge(params).merge(bloc_params))
164
+ when :horizontal
165
+ box({ left: spacing, role: :block, height: height_found }.merge(params).merge(bloc_params))
166
+ else
167
+ #
168
+ end
169
+ end
170
+
171
+ end
172
+
173
+ def blocks(params)
174
+ blocks = params.delete(:blocks)
175
+ distribute = params.delete(:distribute)
176
+ if distribute && params[:direction] == :horizontal
177
+ width_found = to_px(:width)
178
+ params[:spacing] = "#{spacing_found(width_found, params[:width], blocks.length)}%"
179
+ elsif distribute
180
+ height_found = to_px(:height)
181
+ params[:spacing] = spacing_found(height_found, params[:height], blocks.length)
182
+ end
183
+ blocks.each do |bloc_id, block_to_create|
184
+ sanitized_bloc_data = params.merge(block_to_create)
185
+ block({ data: sanitized_bloc_data }.merge({ id: bloc_id }).merge(params))
123
186
  end
187
+ end
188
+
189
+
190
+ def sub_block(sub_params, spacing_found = 3)
191
+ num_blocks = sub_params.size
192
+ parent_width = to_px(:width)
193
+ total_ratios = sub_params.values.sum { |sub_content| sub_content[:width] }
194
+ total_spacing = (num_blocks + 1) * spacing_found
195
+ available_width = parent_width - total_spacing
196
+ left_offset = spacing_found
197
+ sub_params.each do |sub_id, sub_content|
198
+ ratio = sub_content[:width]
199
+ block_width = (available_width * ratio) / total_ratios
200
+ sub_created = box({ id: sub_id, height: '100%', left: left_offset, role: :sub })
201
+ sub_content["width"] = block_width
202
+ sub_created.set(sub_content)
203
+ sub_created.width(block_width)
204
+ left_offset += block_width + spacing_found
205
+ sub_created.width(sub_created.to_percent(:width))
206
+ sub_created.left(sub_created.to_percent(:left))
207
+ end
208
+ end
209
+
210
+
124
211
 
125
212
  def help(particle, &doc)
126
213
  if doc
data/lib/atome/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # return atome version
4
4
 
5
5
  class Atome
6
- VERSION = '0.5.7.4.3'
6
+ VERSION = '0.5.7.4.7'
7
7
  end
@@ -1,9 +1,5 @@
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
-
7
3
  size = 33
8
4
  smooth = 3
9
5
  margin = 3
@@ -62,17 +58,19 @@ class Atome
62
58
  y = event[:clientY]
63
59
  elements = JS.global[:document].elementsFromPoint(x, y)
64
60
  elements.to_a.each do |atome_touched|
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
- puts 'we have to check if operation is a creation or an alteration to include or exclude the view '
61
+ id_found = atome_touched[:id]
62
+ id_found = id_found.to_s.to_sym # keep .to_s to because ruby wasm try may to_sym on on symbol
63
+ atome_found = grab(id_found)
64
+
65
+ is_descendant_of_intuition = atome_found.descendant_of?(:intuition).to_s if atome_found
66
+ # # the condition below is use to exclude the treatment any object in the intuition layer
67
+ unless is_descendant_of_intuition == 'true'
68
+
70
69
  Universe.active_tools.each do |tool|
71
70
  apply_tool(tool, atome_found, event)
72
71
  end
73
-
74
- break
75
72
  end
73
+ break
76
74
  end
77
75
  else
78
76
  Universe.allow_tool_operations = true
@@ -89,11 +87,42 @@ class Atome
89
87
  end
90
88
 
91
89
  def start_click_analysis
92
- # here we capture any touch when usingh tool
90
+ # here we capture any touch when using tool
93
91
  @click_analysis_active = false
94
- JS.global[:document].addEventListener('mouseup') do |native_event|
95
- Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
92
+
93
+ click_timeout = nil
94
+ double_click_delay = 150
95
+
96
+ JS.global[:document].addEventListener('click') do |native_event|
97
+ if @click_analysis
98
+ if click_timeout
99
+ wait(:kill, click_timeout)
100
+ click_timeout = nil
101
+ selected_items = grab(Universe.current_user).selection.collect
102
+ if selected_items.length > 0
103
+ dup_selected_items = selected_items.dup
104
+ dup_selected_items.each do |atome_id_selected|
105
+ atome_selected = grab(atome_id_selected)
106
+ atome_selected.selected(false)
107
+ end
108
+ else
109
+ atomes_in_view= grab(:view).fasten
110
+ atomes_in_view.each do |atome_id_found|
111
+ grab(atome_id_found).selected(true)
112
+ end
113
+ end
114
+
115
+
116
+ else
117
+ click_timeout = wait(double_click_delay / 1000.0) do
118
+ click_timeout = nil
119
+ Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
120
+ end
121
+ end
122
+ end
123
+
96
124
  end
125
+
97
126
  end
98
127
 
99
128
  def alteration(current_tool, tool_actions, atome_touched, a_event)
@@ -152,7 +181,6 @@ class Atome
152
181
  end
153
182
 
154
183
  def apply_tool(tool, atome_touched, a_event)
155
-
156
184
  current_tool = grab(tool)
157
185
  tool_actions = current_tool.data
158
186
  method_found = tool_actions[:method]
@@ -169,10 +197,28 @@ class Atome
169
197
  else
170
198
  atome_touched
171
199
  end
172
- unless method_found == :alteration && target.tag[:system]
200
+ if target && method_found == :alteration && target.tag[:system]
201
+ # in this case (on target touch )we are targeting a system object non alterable so we create an a new atome
202
+ # Ex: if we are on a system color we create a new color that can be altered
203
+ tools_scheme[:particles]&.each do |particle_f, value_f|
204
+ type_to_create = target.type
205
+ if type_to_create
206
+ target = atome_touched.send(type_to_create, { particle_f => value_f })
207
+ tools_scheme[:particles]&.each do |particle_f, value_f|
208
+ target.send(particle_f, value_f)
209
+ end
210
+ end
211
+ end
212
+ else
173
213
 
214
+ # below code trigger when activating the current tool :
174
215
  tools_scheme[:particles]&.each do |particle_f, value_f|
175
- target.send(particle_f, value_f)
216
+ is_descendant_of_intuition = target.descendant_of?(:intuition).to_s
217
+ atome_descendant_of_intuition = atome_touched.descendant_of?(:intuition).to_s
218
+ # the condition below is use to exclude the treatment any object in the intuition layer
219
+ unless is_descendant_of_intuition == 'true' || atome_descendant_of_intuition == 'true'
220
+ target.send(particle_f, value_f)
221
+ end
176
222
  end
177
223
  send(method_found, current_tool, tool_actions, target, a_event)
178
224
  end
@@ -363,15 +409,14 @@ class Atome
363
409
  tool.instance_variable_set('@prevent_action', true)
364
410
  if tool.instance_variable_get('@tool_open') == true
365
411
  tool.instance_variable_set('@tool_open', false)
366
- tool_scheme[:particles].each_key do |particle|
367
- grab("tool_particle_#{particle}").delete({ force: true })
368
- end
412
+ tool_scheme[:particles]&.each_key do |particle|
413
+ grab("tool_particle_#{particle}").delete({ force: true })
414
+ end
369
415
  tool.width(size)
370
416
  else
371
417
  tool.instance_variable_set('@tool_open', true)
372
418
 
373
419
  tool_scheme[:particles]&.each_with_index do |(particle_name, _value_), ind|
374
-
375
420
  particle = tool.box({ id: "tool_particle_#{particle_name}", tag: { system: true }, depth: 1, smooth: smooth,
376
421
  apply: %i[inactive_tool_col tool_box_border tool_shade],
377
422
  width: size, height: size, left: ind * (size + margin) + size })
@@ -402,7 +447,6 @@ class Atome
402
447
  particle_label.top(:auto)
403
448
  particle_label.bottom(0)
404
449
  particle.touch(true) do
405
- puts "1 ======> opening !!!#{particle_name}"
406
450
  tool.instance_variable_set('@prevent_action', true)
407
451
  slider_id = "particle_slider_#{particle_name}"
408
452
  if particle.instance_variable_get('@active')
@@ -431,20 +475,21 @@ class Atome
431
475
  if grab(slider_id).instance_variable_get('@initialised')
432
476
  Atome.selection.each do |atome_id_to_treat|
433
477
 
478
+
434
479
  tool_scheme[:particles][particle_name] = value.to_f / 100
435
480
  atome_found = grab(atome_id_to_treat)
436
481
  target = grab(atome_found.color.last)
482
+ target.send(particle_name, value.to_f / 100) if tool.active
437
483
 
438
- target.send(particle_name, value.to_f / 100)
439
- label_value.data(value.to_f / 100)
440
484
  end
485
+
486
+ label_value.data(value.to_f / 100)
487
+ tool_scheme[:particles][particle_name]=value.to_f / 100
441
488
  end
442
489
  end
443
490
 
444
491
  Atome.selection.each do |atome_id_to_treat|
445
492
  atome_found = grab(atome_id_to_treat)
446
- puts 'here slider treat either the target atome types or current atome'
447
- puts "need to created a list instead of choosing the last atome found of it's kind"
448
493
  target = if tool_scheme[:target]
449
494
  grab(atome_found.send(tool_scheme[:target]).last)
450
495
  else
@@ -465,6 +510,14 @@ class Atome
465
510
  tool.touch(:down) do
466
511
  tool.depth(999)
467
512
  end
513
+ tool.touch(:double) do
514
+ tool_to_deactivate = Universe.active_tools.dup
515
+ tool_to_deactivate.each do |atome_id_found|
516
+ atome_found = grab(atome_id_found)
517
+ atome_found.deactivate_tool
518
+ end
519
+ tool.activate_tool
520
+ end
468
521
  tool.touch(true) do
469
522
  unless tool.instance_variable_get('@prevent_action')
470
523
  # we add all specific tool actions to @tools_actions_to_exec hash
@@ -482,4 +535,4 @@ class Atome
482
535
  end
483
536
  end
484
537
 
485
- end
538
+ end
@@ -505,7 +505,6 @@ new(molecule: :application) do |params, &bloc|
505
505
 
506
506
  menu = buttons({
507
507
  id: "#{id_f}_menu",
508
- # left: 66,
509
508
  depth: 9999,
510
509
  attach: id_f,
511
510
  inactive: { text: { color: :gray }, width: 66, height: 12, spacing: 3, disposition: :horizontal,
@@ -533,11 +532,11 @@ new(molecule: :application) do |params, &bloc|
533
532
  end
534
533
  main_app.define_singleton_method(:extract) do |bloc_to_extract|
535
534
 
536
- bloc_to_extract.each do |page_id, block_id|
537
- grab(block_id).delete({ recursive: true })
538
- @blocks[page_id].delete(block_id)
539
- grab(page_id).reorder_blocs
540
- end
535
+ bloc_to_extract.each do |page_id, block_id|
536
+ grab(block_id).delete({ recursive: true })
537
+ @blocks[page_id].delete(block_id)
538
+ grab(page_id).reorder_blocs
539
+ end
541
540
 
542
541
  end
543
542
 
@@ -601,23 +600,14 @@ new(molecule: :show) do |page_id, &bloc|
601
600
  # now looking for associated blocks
602
601
  blocks_found = params[:blocks]
603
602
  @prev_bloc_height = 0
604
- blocks_found&.each do |bloc_id, bloc_content|
605
603
 
604
+ blocks_found&.each do |bloc_id, bloc_content|
606
605
  new_bloc = new_page.box({ id: bloc_id, role: :block, width: '100%', height: 99, top: spacing + @prev_bloc_height, bottom: 0, left: 0, right: 0, spacing: spacing })
607
-
608
606
  new_bloc.define_singleton_method(:subs) do |sub_params|
609
- @prev_sub_width = 0
610
- sub_params.each do |sub_id, sub_content|
611
- sub_created = new_bloc.box({ id: sub_id, height: '100%', left: @prev_sub_width })
612
- sub_created.set(sub_content)
613
- @prev_sub_width = @prev_sub_width + sub_created.to_px(:width) + spacing
614
- sub_created.width(sub_created.to_percent(:width))
615
- sub_created.left(sub_created.to_percent(:left))
616
- end
617
607
 
608
+ new_bloc.sub_block(sub_params, 3)
618
609
  end
619
610
  new_bloc.set(bloc_content)
620
-
621
611
  @prev_bloc_height = @prev_bloc_height + new_bloc.height + spacing
622
612
  end
623
613
 
@@ -716,5 +706,4 @@ new(molecule: :buttons) do |params, &bloc|
716
706
  main.create_new_button(item_id, index, label, code)
717
707
  end
718
708
  main
719
-
720
709
  end
@@ -9,6 +9,10 @@ class Atome
9
9
  end
10
10
  end
11
11
 
12
+ def descendant_of?(ancestor)
13
+ HTML.is_descendant(ancestor, id)
14
+ end
15
+
12
16
  def to_px(particle)
13
17
  ruby_wasm_code = <<-JS
14
18
  var div = document.getElementById("#{@id}");
@@ -4,6 +4,8 @@
4
4
 
5
5
  class HTML
6
6
 
7
+
8
+
7
9
  def self.locate(selector, base_element = JS.global[:document][:body])
8
10
  return base_element if selector.empty?
9
11
 
@@ -22,6 +24,10 @@ class HTML
22
24
  end
23
25
  end
24
26
 
27
+ def self.is_descendant(ancestor, descendant)
28
+ JS.eval("return isDescendant('#{ancestor}', '#{descendant}')")
29
+ end
30
+
25
31
  def initialize(id_found, current_atome)
26
32
 
27
33
  @element = JS.global[:document].getElementById(id_found.to_s)
@@ -35,6 +41,8 @@ class HTML
35
41
  @element
36
42
  end
37
43
 
44
+
45
+
38
46
  def hypertext(params)
39
47
  current_div = JS.global[:document].getElementById(@id.to_s)
40
48
  current_div[:innerHTML] = params
@@ -7,16 +7,19 @@ b3=box({top: below(b2, margin)})
7
7
  b4=box({top: below(b3, margin)})
8
8
  box({top: below(b4, margin)})
9
9
  i=0
10
- while i< 10 do
11
- b2=box({top: below(b, margin)})
12
- i+=1
13
- end
14
10
 
15
- b = circle(left: 66)
16
- margin = 12
11
+
12
+ b = circle(left: 333, top: 333)
13
+ margin = "2%"
14
+ # margin = 120
17
15
  i = 0
18
16
 
19
17
  while i < 10 do
20
- b = circle({top: below(b, margin), left: 66})
18
+ #below first params is the object after which we place the objet, the second the margin
19
+ # here in percent and the third is the reference object used for the percent
20
+ # b = circle({top: below(b, margin, grab(:view)), left: b.left})
21
+ # b = circle({top: :auto,bottom: above(b, margin, grab(:view)), left: b.left})
22
+ b = circle({top: b.top,left: after(b, margin, grab(:view))})
23
+ # b = circle({left: :auto,right: before(b, margin, grab(:view))})
21
24
  i += 1
22
25
  end
@@ -51,12 +51,13 @@ a.page({ id: :page3,
51
51
  menu_f=a.menu
52
52
  menus_found= menu_f.fasten # replace fasten for entries
53
53
  puts a.pages
54
- puts " pages => #{a.pages}"
55
- puts " menus_found => #{menus_found}"
54
+ puts "pages => #{a.pages}"
55
+ puts "menus_found => #{menus_found}"
56
56
 
57
57
  bloc_to_add= {height: 156, color: :green}
58
58
  bloc_to_add2= {height: 99, color: :blue}
59
- bloc_to_add3= {height: 333, color: :orange, subs:{contact: {width: '33%'}, project: {width: '33%'}, calendar: {width: '33%'}}}
59
+ bloc_to_add3= {height: 333, color: :orange, subs:{contact: {width: 1, color: :black}, project: {width: 1}, calendar: {width: 0.5, color: :green}}}
60
+
60
61
  a.insert({page3: {block1: bloc_to_add , block2: bloc_to_add2, block3: bloc_to_add3}})
61
62
 
62
63
 
@@ -72,3 +73,4 @@ a.show(:page3)
72
73
  # end
73
74
 
74
75
 
76
+ alert(grab(:project).inspect)
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+
5
+ a = application({
6
+ id: :arp,
7
+ margin: 3,
8
+ })
9
+
10
+ page1_code = lambda do
11
+ b = box({ id: :ty, left: 90, top: 90, color: :black })
12
+ b.touch(true) do
13
+ b.color(:red)
14
+ end
15
+ end
16
+
17
+ page1 = {
18
+ run: page1_code,
19
+ menu: false,
20
+ id: :page1,
21
+ color: { red: 0.5, green: 0.5, blue: 0.5 },
22
+ name: :accueil,
23
+ # footer: { color: :green, height: 22 },
24
+ header: { color: { red: 0.3, green: 0.3, blue: 0.3 }, height: 90, shadow: { blur: 12, left: 0, top: 0 } },
25
+
26
+ }
27
+
28
+ a.page(page1)
29
+ c = a.show(:page1)
30
+ c.color(:orange)
31
+ header = grab(:arp_content_header)
32
+ header.color(:orange)
33
+ # header.height(66)
34
+ # header.subs({ "contact" => { "width" => "33%" }, "project" => { "width" => "33%" }, "calendar" => { "width" => "33%" } })
35
+
36
+ bloc_to_add = { height: 33, color: :cyan }
37
+ bloc_to_add2 = { height: 99, color: :blue }
38
+ bloc_to_add3 = { height: 133, color: :red }
39
+ bloc_to_add4 = { height: 33, color: :gray }
40
+ ###########@
41
+ grab(:page1).blocks({ direction: :vertical, color: :blue, height: 55, spacing: 6,
42
+ blocks: { block1: bloc_to_add, block2: bloc_to_add2, block3: bloc_to_add3 } })
43
+
44
+ grab(:block1).blocks({ direction: :horizontal, color: :orange, spacing: 66, width: 120, top: 0,
45
+ blocks: { block12: bloc_to_add4, block22: bloc_to_add2, block32: bloc_to_add3 }, distribute: true })
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ b=box
4
+ b.circle({role: :header, left: 55, id: :first_one})
5
+ b.text({role: [:action], data: "hello", top: 90})
6
+ b.box({role: :header, left: 155, id: :second_one})
7
+
8
+
9
+ puts"header grip : #{ b.grip(:header)}"
10
+ puts "last header grip #{b.grip(:header).last}"
@@ -1,56 +1,56 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # t = text({ data: 'touch me to select all', id: :the_text })
4
- # b = box({ left: 12, id: :the_box })
5
- # c = circle({ left: 230, id: :the_circle, color: { blue: 1, id: :c1 } })
6
- # c.color({ green: 1, id: :c2 })
7
- # # to change default selection style
8
- # Universe.default_selection_style = { border: { thickness: 3, red: 1, green: 0, blue: 1, alpha: 1, pattern: :dotted } }
9
- #
10
- # c.touch(true) do
11
- # if c.selected
12
- # c.selected(false)
13
- # else
14
- # # c.selected(true)
15
- # # example of custom selection style
16
- # c.selected({ shadow: { id: :titi,
17
- # left: 9, top: 3, blur: 9,
18
- # invert: false,
19
- # red: 0, green: 0, blue: 0, alpha: 1
20
- # }, border: { id: :toto, thickness: 5, red: 1, green: 1, blue: 1, alpha: 1,
21
- # pattern: :dotted, inside: true }
22
- # })
23
- # end
24
- # end
25
- #
26
- # image({ path: 'medias/images/red_planet.png', id: :the__red_planet, top: 233 })
27
- #
28
- # t.touch(true) do
29
- # puts "1 current_user - #{grab(Universe.current_user).selection}"
30
- # puts "1 - b selected : #{b.selected}"
31
- # grab(:view).fasten.each do |atome_found|
32
- # grab(atome_found).selected(true)
33
- # end
34
- # puts "2 - current_user : #{grab(Universe.current_user).selection}"
35
- # puts "2 - b selected : #{b.selected}"
36
- # selected_items = grab(Universe.current_user).selection # we create a group
37
- #
38
- # selected_items.each do |atome_id_selected|
39
- # atome_selected = grab(atome_id_selected)
40
- # atome_selected.width = rand(333)
41
- # atome_selected.height = rand(333)
42
- #
43
- # end
44
- # b.selected(false)
45
- # puts "3 current_user- #{grab(Universe.current_user).selection}"
46
- # puts "3 - b selected : #{b.selected}"
47
- #
48
- # grab(Universe.current_user).selection.color(:red)
49
- # grab(Universe.current_user).selection.each do |el|
50
- # puts el
51
- # end
52
- # puts grab(Universe.current_user).selection.collect
53
- # end
54
-
55
- image({ path: "./medias/images/logos/vie.svg", left: :auto, right: 3, top: 0 , size: 30})
3
+ t = text({ data: 'touch me to select all', id: :the_text })
4
+ b = box({ left: 12, id: :the_box })
5
+ c = circle({ left: 230, id: :the_circle, color: { blue: 1, id: :c1 } })
6
+ c.color({ green: 1, id: :c2 })
7
+ # to change default selection style
8
+ Universe.default_selection_style = { border: { thickness: 3, red: 1, green: 0, blue: 1, alpha: 1, pattern: :dotted } }
9
+
10
+ c.touch(true) do
11
+ if c.selected
12
+ c.selected(false)
13
+ else
14
+ # c.selected(true)
15
+ # example of custom selection style
16
+ c.selected({ shadow: { id: :titi,
17
+ left: 9, top: 3, blur: 9,
18
+ invert: false,
19
+ red: 0, green: 0, blue: 0, alpha: 1
20
+ }, border: { id: :toto, thickness: 5, red: 1, green: 1, blue: 1, alpha: 1,
21
+ pattern: :dotted, inside: true }
22
+ })
23
+ end
24
+ end
25
+
26
+ image({ path: 'medias/images/red_planet.png', id: :the__red_planet, top: 233 })
27
+
28
+ t.touch(true) do
29
+ puts "1 current_user - #{grab(Universe.current_user).selection}"
30
+ puts "1 - b selected : #{b.selected}"
31
+ grab(:view).fasten.each do |atome_found|
32
+ grab(atome_found).selected(true)
33
+ end
34
+ puts "2 - current_user : #{grab(Universe.current_user).selection}"
35
+ puts "2 - b selected : #{b.selected}"
36
+ selected_items = grab(Universe.current_user).selection # we create a group
37
+
38
+ selected_items.each do |atome_id_selected|
39
+ atome_selected = grab(atome_id_selected)
40
+ atome_selected.width = rand(333)
41
+ atome_selected.height = rand(333)
42
+
43
+ end
44
+ b.selected(false)
45
+ puts "3 current_user- #{grab(Universe.current_user).selection}"
46
+ puts "3 - b selected : #{b.selected}"
47
+
48
+ grab(Universe.current_user).selection.color(:red)
49
+ grab(Universe.current_user).selection.each do |el|
50
+ puts el
51
+ end
52
+ puts grab(Universe.current_user).selection.collect
53
+ end
54
+
55
+ # image({ path: "./medias/images/logos/vie.svg", left: :auto, right: 3, top: 0 , size: 30})
56
56
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ b=box
4
+ t=text({width: 66, left: 99,top: 66, data: "touch the bow and resize the window"})
5
+
6
+ b.touch(true) do
7
+ b.width(t.to_percent(:width))
8
+ b.left(t.to_percent(:left))
9
+ end
@@ -1,22 +1,52 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
 
4
+ # new({ tool: :color2 }) do
5
+ # active_code = lambda {
6
+ # puts 'color activated1'
7
+ # }
8
+ # color_code2=lambda {
9
+ # puts "object id is : #{id}"
10
+ # # color(:green)
11
+ # }
12
+ # inactive_code = lambda { |data|
13
+ # data[:treated].each do |atome_f|
14
+ # # atome_f.drag(false)
15
+ # # atome_f.color(:green)
16
+ # end
17
+ # }
18
+ #
19
+ # { activation: active_code,
20
+ # alteration: { event: color_code2 },
21
+ # inactivation: inactive_code,
22
+ # target: :color,
23
+ # particles: { red: 0, green: 0.5, blue: 1, alpha: 1 }
24
+ # }
25
+ # end
26
+
27
+ new({ tool: :toolbox1 }) do
28
+ active_code = lambda {
29
+ toolbox({ tools: [:combined], toolbox: { orientation: :ew, left: 90, bottom: 9, spacing: 9 } })
30
+ }
31
+ { activation: active_code }
32
+ end
33
+
4
34
 
5
35
  new({ tool: :combined }) do |params|
6
36
 
7
37
  active_code = lambda {
8
- puts :alteration_tool_code_activated
38
+ # puts :alteration_tool_code_activated
9
39
  }
10
40
 
11
41
  inactive_code = lambda { |param|
12
- puts :alteration_tool_code_inactivated
42
+ # puts :alteration_tool_code_inactivated1
13
43
  }
14
44
  pre_code = lambda { |params|
15
- puts "pre_creation_code,atome_touched: #{:params}"
45
+ # puts "pre_creation_code,atome_touched: #{:params}"
16
46
 
17
47
  }
18
48
  post_code = lambda { |params|
19
- puts "post_creation_code,atome_touched: #{:params}"
49
+ # puts "post_creation_code,atome_touched: #{:params}"
20
50
 
21
51
  }
22
52
 
@@ -36,27 +66,65 @@ new({ tool: :combined }) do |params|
36
66
  post: post_code,
37
67
  zone: zone_spe,
38
68
  icon: :color,
39
- int8: { french: :couleur, english: :color, german: :colorad } }
69
+ int8: { french: :couleur, english: :combined, german: :colorad } }
70
+
71
+ end
72
+
73
+ new({ tool: :rotate }) do |params|
74
+
75
+ active_code = lambda {
76
+ # puts :alteration_tool_code_activated
77
+ }
78
+
79
+ inactive_code = lambda { |param|
80
+ # puts :alteration_tool_code_inactivated2
81
+ }
82
+ pre_code = lambda { |params|
83
+ # puts "pre_creation_code,atome_touched: #{:params}"
84
+
85
+ }
86
+ post_code = lambda { |params|
87
+ # puts "post_creation_code,atome_touched: #{:params}"
88
+
89
+ }
90
+
91
+ zone_spe = lambda { |current_tool|
92
+ # puts "current tool is : #{:current_tool} now creating specific zone"
93
+ # b = box({ width: 33, height: 12 })
94
+ # b.text({ data: :all })
95
+
96
+ }
97
+
98
+ {
99
+ activation: active_code,
100
+ inactivation: inactive_code,
101
+ # alteration: { width: 22, blur: 3 },
102
+ alteration: { rotate: 22 },
103
+ pre: pre_code,
104
+ post: post_code,
105
+ zone: zone_spe,
106
+ icon: :color,
107
+ int8: { french: :couleur, english: :rotate, german: :colorad } }
40
108
 
41
109
  end
42
110
 
43
111
  new({ tool: :box }) do |params|
44
112
 
45
113
  active_code = lambda {
46
- puts :creation_tool_code_activated
114
+ # puts :creation_tool_code_activated
47
115
  }
48
116
 
49
117
  inactive_code = lambda { |atomes_treated|
50
- puts :creation_tool_code_inactivated
118
+ # puts :creation_tool_code_inactivated
51
119
 
52
120
  }
53
121
  pre_creation_code = lambda { |params|
54
- puts "pre_creation_code : atome_touched : #{:params} "
122
+ # puts "pre_creation_code : atome_touched : #{:params} "
55
123
 
56
124
  }
57
125
 
58
126
  post_creation_code = lambda { |params|
59
- puts "post_creation_code,atome_touched: #{:params}"
127
+ # puts "post_creation_code,atome_touched: #{:params}"
60
128
  }
61
129
 
62
130
  { creation: { box: { color: :blue, width: 66, height: 66 } },
@@ -146,7 +214,7 @@ new({ tool: :drag }) do
146
214
  }
147
215
  move_code = lambda {
148
216
  drag(true) do
149
- puts left
217
+ puts "left is : #{left}"
150
218
  end
151
219
  }
152
220
 
@@ -180,16 +248,9 @@ new({ tool: :select }) do
180
248
 
181
249
  end
182
250
 
183
- new({ tool: :toolbox1 }) do
184
- active_code = lambda {
185
- toolbox({ tools: [:combined], toolbox: { orientation: :ew, left: 90, bottom: 9, spacing: 9 } })
186
- }
187
- { activation: active_code }
188
- end
189
-
190
251
  new({ tool: :color }) do
191
252
  active_code = lambda {
192
- puts 'color activated1'
253
+ # puts 'color activated1'
193
254
  }
194
255
  color_code = lambda {
195
256
  # color(:green)
@@ -211,7 +272,7 @@ end
211
272
 
212
273
  new({ tool: :crash_test }) do
213
274
  active_code = lambda {
214
- puts 'color activated1'
275
+ alert grab(Universe.current_user).selection.collect
215
276
  }
216
277
  color_code = lambda {
217
278
  # color(:green)
@@ -222,22 +283,26 @@ new({ tool: :crash_test }) do
222
283
  end
223
284
  }
224
285
 
225
- {
226
- alteration: { width: 22},
286
+ {activation: active_code,
287
+ # alteration: { alert: :good}
227
288
  }
228
289
  end
229
290
 
230
291
  # Universe.tools_root= {tools: [:blur, :box, :test, :toolbox1],toolbox: { orientation: :ew, left:90 , bottom: 9, spacing: 9} }
231
- Universe.tools_root = {id: :root_tools, tools: [:select,:crash_test, :box, :drag, :touch,:color, :move, :toolbox1], toolbox: { orientation: :ew, left: 9, bottom: 9, spacing: 9 } }
232
- puts "above we added an id because each tool may be in many toolbox and have an uniq ID"
292
+ Universe.tools_root = {id: :root_tools, tools: [:select,:crash_test, :box, :drag, :touch,:color, :move, :toolbox1, :rotate], toolbox: { orientation: :ew, left: 9, bottom: 9, spacing: 9 } }
293
+ # puts "above we added an id because each tool may be in many toolbox and have an uniq ID"
233
294
  Atome.init_intuition
234
295
 
235
- b = box({ id: :the_test__box, selected: true })
296
+ b = box({ id: :the_test_box, selected: false, color: :blue })
236
297
  c=circle({ left: 90, id: :the_test_circle, selected: false })
237
298
  c.drag(true) do
238
299
  puts "moving"
239
300
  end
301
+
302
+
240
303
  b.touch(true) do
304
+ # alert b.descendant_of?(:view)
305
+ # alert "#{b.descendant_of?(:intuition)}, then dont treat!"
241
306
  if b.width == 170
242
307
  b.width(55)
243
308
  else
@@ -245,4 +310,15 @@ b.touch(true) do
245
310
  end
246
311
 
247
312
  end
248
-
313
+ text({left: 333, data: :hello, id: :t1})
314
+ circle({left: 333,top: 333, id: :c2})
315
+
316
+ # wait 2 do
317
+ # b= grab('color_tool_icon')
318
+ # grab('color_tool_icon').color(:red)
319
+ #
320
+ # puts b.descendant_of?(:view)
321
+ # puts "#{b.descendant_of?(:intuition)}, then dont treat!"
322
+ #
323
+ # end
324
+ puts 'add tool preview , and maybe allow tool details to be moved'
@@ -504,3 +504,21 @@ function record_content(blob) {
504
504
  }
505
505
 
506
506
 
507
+ function isDescendant(parentId, childId) {
508
+ var parent = document.getElementById(parentId);
509
+ var child = document.getElementById(childId);
510
+
511
+ let node = child;
512
+ while (node !== null) {
513
+ if (node === parent) {
514
+ return true;
515
+ }
516
+ node = node.parentNode;
517
+ }
518
+ return false;
519
+
520
+ }
521
+
522
+ // alert(isDescendant('intuition', 'the_test_box'));
523
+ // alert(isDescendant('view', 'the_test_box'));
524
+
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="53" height="53" xml:space="preserve" id="canvas1">
4
+ <!-- Generated by PaintCode - http://www.paintcodeapp.com -->
5
+ <path id="canvas1-canvasNewCanvascanvas1bezier" stroke="rgb(200, 200, 200)" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" fill="none" d="M 13,26 L 40,26" />
6
+ <path id="canvas1-canvasNewCanvascanvas1bezier3" stroke="rgb(200, 200, 200)" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" fill="none" d="M 26,40 L 26,13" />
7
+ <circle id="canvas1-oval" stroke="rgb(206, 206, 206)" stroke-width="6" stroke-miterlimit="10" fill="none" cx="26.5" cy="26.5" r="23.5" />
8
+ </svg>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7.4.3
4
+ version: 0.5.7.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Eric Godard
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-20 00:00:00.000000000 Z
11
+ date: 2024-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -546,6 +546,7 @@ files:
546
546
  - vendor/assets/application/examples/b64_to_image.rb
547
547
  - vendor/assets/application/examples/basic_understanding.rb
548
548
  - vendor/assets/application/examples/behavior.rb
549
+ - vendor/assets/application/examples/blocks.rb
549
550
  - vendor/assets/application/examples/blur.rb
550
551
  - vendor/assets/application/examples/border.rb
551
552
  - vendor/assets/application/examples/browse.rb
@@ -588,6 +589,7 @@ files:
588
589
  - vendor/assets/application/examples/getter.rb
589
590
  - vendor/assets/application/examples/grab.rb
590
591
  - vendor/assets/application/examples/gradient.rb
592
+ - vendor/assets/application/examples/grip.rb
591
593
  - vendor/assets/application/examples/group.rb
592
594
  - vendor/assets/application/examples/help.rb
593
595
  - vendor/assets/application/examples/hierarchy.rb
@@ -656,6 +658,7 @@ files:
656
658
  - vendor/assets/application/examples/text.rb
657
659
  - vendor/assets/application/examples/text_align.rb
658
660
  - vendor/assets/application/examples/tick.rb
661
+ - vendor/assets/application/examples/to_percent.rb
659
662
  - vendor/assets/application/examples/to_px.rb
660
663
  - vendor/assets/application/examples/tools.rb
661
664
  - vendor/assets/application/examples/touch.rb
@@ -778,6 +781,7 @@ files:
778
781
  - vendor/assets/src/medias/images/green_planet.png
779
782
  - vendor/assets/src/medias/images/icons/Lowpass.svg
780
783
  - vendor/assets/src/medias/images/icons/activate.svg
784
+ - vendor/assets/src/medias/images/icons/add.svg
781
785
  - vendor/assets/src/medias/images/icons/audio.svg
782
786
  - vendor/assets/src/medias/images/icons/band_pass.svg
783
787
  - vendor/assets/src/medias/images/icons/clear.svg