atome 0.5.7.4.6 → 0.5.7.4.8

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: 5696cf0c628b8e6986d2ddff3b4494bdbfaed55ca0acf2f880f0d420d6738825
4
- data.tar.gz: ec98989c2130c4616ce68ae3820a2b2c13fb174f9155ba0196539a35d13537a0
3
+ metadata.gz: adbf3e2dbe9b01956856270d1789ebae1205be44b00b4038cf1c709c0f7d7f2e
4
+ data.tar.gz: a01c1c6b62cd322949d94b44b6b1952f2c331ad1dd9ed55cdf9d46b3a1053627
5
5
  SHA512:
6
- metadata.gz: 0d2530c93180e30d715a73f1e5f0906634826c286c5a377e7e1d4cbf87d1370f4b41a13ea210df29dd8597fa9d3aa3ca0d843ae1921da3a7ebfec098aa59a803
7
- data.tar.gz: 560f821e10b447a07dc82479bef098b2c995f074c0d5eb75372aac6b307b1040fcc042fcf0096c6539be0c79a56d24856f08d2b99ba7ee76db7835f58bc579a0
6
+ metadata.gz: 8613255d625a6d457a0e280253cbcf1317cb6210bded5482eb4eee67c6c7f9e5d513fd93938da916bfeeeb45ad5ab646d234d7596f20a736c071e4bd940df1df
7
+ data.tar.gz: 39f6697c368a0558648eb649268f151626d0aa06ef9ccdd21a67dffb40a97409daca0bef111648f11d08ae85d5757121c014cc953f44f7067db65f85fb21997a
@@ -69,6 +69,16 @@ end
69
69
  class Object
70
70
  include ObjectExtension
71
71
 
72
+ def refresh
73
+ grab(:view).retrieve do |child|
74
+ child.refresh
75
+ end
76
+ # atomes_to_treat=grab(:view).fasten.dup
77
+ # atomes_to_treat.each do |atome_found|
78
+ # grab(atome_found).refresh
79
+ # end
80
+ end
81
+
72
82
  def truncate_string(string, max_length)
73
83
  string.length > max_length ? string.slice(0, max_length) + '.' : string
74
84
  end
@@ -570,8 +580,14 @@ JS
570
580
  end
571
581
  end
572
582
 
573
- def above(item, margin = 6)
583
+ def above(item, margin = 6, ref=grab(:view))
584
+ # FIXME above is broken when using % in margin
585
+ unless margin.is_a?(Numeric)
586
+ item_height= ref.to_px(:height)
587
+ margin= (margin.to_f*item_height)/100
588
+ end
574
589
  pos = item.to_px(:bottom) + item.height + margin
590
+ item.top(:auto)
575
591
  if item.display == :none
576
592
  33
577
593
  else
@@ -579,7 +595,11 @@ JS
579
595
  end
580
596
  end
581
597
 
582
- def below(item, margin = 6)
598
+ def below(item, margin = 6, ref=grab(:view))
599
+ unless margin.is_a?(Numeric)
600
+ item_height= ref.to_px(:height)
601
+ margin= (margin.to_f*item_height)/100
602
+ end
583
603
  pos = item.to_px(:top) + item.to_px(:height) + margin
584
604
  if item.display == :none
585
605
  0
@@ -589,7 +609,11 @@ JS
589
609
 
590
610
  end
591
611
 
592
- def after(item, margin = 6)
612
+ def after(item, margin = 6, ref=grab(:view))
613
+ unless margin.is_a?(Numeric)
614
+ item_width= ref.to_px(:width)
615
+ margin= (margin.to_f*item_width)/100
616
+ end
593
617
  left_f = if item.left.instance_of?(Integer)
594
618
  item.left
595
619
  else
@@ -609,7 +633,11 @@ JS
609
633
  end
610
634
  end
611
635
 
612
- def before(item, margin = 6)
636
+ def before(item, margin = 6, ref=grab(:view))
637
+ unless margin.is_a?(Numeric)
638
+ item_width= ref.to_px(:width)
639
+ margin= (margin.to_f*item_width)/100
640
+ end
613
641
  pos = item.to_px(:right) + item.width + margin
614
642
  if item.display == :none
615
643
  0
@@ -786,4 +814,7 @@ class CssProxy
786
814
  end
787
815
 
788
816
 
817
+
818
+
819
+
789
820
  end
@@ -24,10 +24,10 @@ end
24
24
 
25
25
  new({ particle: :int8, category: :communication, type: :int })
26
26
 
27
- new({ particle: :language, category: :communication, type: :string }) do |params|
28
- @data = int8[params]
29
- params
30
- end
27
+ # new({ particle: :language, category: :communication, type: :string }) do |params|
28
+ # @data = int8[params]
29
+ # params
30
+ # end
31
31
  # method below are used for communication with native core
32
32
  def receptor(msg)
33
33
  parsed = JSON.parse(msg)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ Universe.language=:english
4
+
3
5
  # now let's get the default render engine
4
6
 
5
7
  # Lets create the U.I.
@@ -64,7 +66,7 @@ Atome.new(
64
66
  Atome.new(
65
67
  { renderers: default_render, aid: :view,type: :shape, attach: :user_view, apply: [:view_color],
66
68
  tag: { system: true }, left: 0, right: 0, top: 0, bottom: 0, width: :auto, height: :auto, overflow: :auto,
67
- language: :english
69
+ # language: :english
68
70
  }
69
71
 
70
72
  )
@@ -126,8 +128,12 @@ puts b.left
126
128
  b.left(155)
127
129
  puts b.left
128
130
  STR
129
- example = text({ int8: { english: english, french: french }, language: :english, width: 666 })
130
- code_text = text({ int8: { english: code }, language: :english, width: 666, top: 33 })
131
+ example = text({ int8: { english: english, french: french },
132
+ # language: :english,
133
+ width: 666 })
134
+ code_text = text({ int8: { english: code },
135
+ # language: :english,
136
+ width: 666, top: 33 })
131
137
  example.touch(true) do
132
138
  example.delete(true)
133
139
  help(:left)
@@ -28,6 +28,7 @@ class Universe
28
28
  @allow_tool_operations = false
29
29
  @active_tools = []
30
30
  @atome_preset = []
31
+ @translation={}
31
32
  @default_selection_style = { border: { thickness: 1, red: 1, green: 0, blue: 0, alpha: 1, pattern: :dotted } }
32
33
  @applicable_atomes = %i[color shadow border paint animation]
33
34
  # @historicize=false
@@ -35,7 +36,8 @@ class Universe
35
36
  attr_reader :atomes, :atomes_ids, :renderer_list, :molecule_list, :atome_list, :particle_list, :classes, :counter,
36
37
  :atomes_specificities
37
38
  attr_accessor :connected, :allow_sync, :allow_localstorage, :database_ready, :edit_mode, :tools, :tools_root,
38
- :allow_tool_operations, :active_tools, :atome_preset, :applicable_atomes, :default_selection_style
39
+ :allow_tool_operations, :active_tools, :atome_preset, :applicable_atomes, :default_selection_style,
40
+ :translation, :language
39
41
 
40
42
  def messages
41
43
  @messages
@@ -38,7 +38,9 @@ module Essentials
38
38
  left: 0, top: 0 },
39
39
  text: { type: :text, component: { size: 12 },left: 0, top: 0,
40
40
  apply: [:text_color],
41
- width: :auto, height: :auto, language: :english },
41
+ width: :auto, height: :auto,
42
+ # language: :english
43
+ },
42
44
  drm: { type: :drm, attach: :black_matter },
43
45
  shadow: { type: :shadow, red: 0, green: 0, blue: 0, alpha: 1, blur: 3, left: 3, top: 3 },
44
46
  border: { type: :border, red: 0, green: 0, blue: 0, alpha: 0, pattern: :solid, thickness: 6 },
@@ -9,10 +9,6 @@ class Atome
9
9
  class << self
10
10
  attr_accessor :initialized
11
11
 
12
- # def descendant_of?(ancestor)
13
- # is_descendant(ancestor, id)
14
- # end
15
-
16
12
  def sanitize_data_for_json(data)
17
13
  data.gsub('"', '\\"')
18
14
  end
@@ -89,7 +85,9 @@ class Atome
89
85
  end
90
86
  args = args[0]
91
87
  end
92
- instance_exec({ original: value_before, altered: args, particle: monitored_particle }, &bloc) if bloc.is_a?(Proc)
88
+ if bloc.is_a?(Proc)
89
+ instance_exec({ original: value_before, altered: args, particle: monitored_particle }, &bloc)
90
+ end
93
91
  original_method.call(*args)
94
92
  end
95
93
  end
@@ -112,51 +110,125 @@ class Atome
112
110
 
113
111
  @initialized = {}
114
112
 
113
+ def grip(role_wanted)
114
+ gripped_atome = []
115
+
116
+ fasten.each do |child_id|
117
+ child_found = grab(child_id)
118
+ gripped_atome << child_id if child_found.role && child_found.role.include?(role_wanted)
119
+ end
120
+ gripped_atome
121
+ end
122
+
115
123
  def recursive(_val)
116
124
  # dummy method
117
125
  end
118
126
 
119
- # def sub_block(sub_params, spacing_found = 3)
120
- # total_width = 0
121
- # sub_params.each_value do |sub_content|
122
- # sub_width = sub_content["width"].to_i
123
- # total_width += sub_width + spacing_found
124
- # end
125
- # left_offset = spacing_found
126
- # sub_params.each do |(sub_id, sub_content)|
127
- # sub_created = box({ id: sub_id, height: '100%'})
128
- # sub_created.set(sub_content)
129
- # sub_width = sub_created.to_px(:width)
130
- # left_offset += sub_width + spacing_found
131
- # sub_created.width(sub_width)
132
- # sub_created.left(left_offset - sub_width - spacing_found)
133
- # sub_created.width(sub_created.to_percent(:width))
134
- # sub_created.left(sub_created.to_percent(:left))
135
- # end
136
- # end
127
+ def retrieve(params = {}, &block)
128
+ closest_first = true, include_self = false
129
+ if params[:ascending] == false
130
+ closest_first = :inverted
131
+ end
132
+ if params[:self] == true
133
+ include_self = true
134
+ end
137
135
 
138
- # def sub_block(sub_params, spacing_found = 3)
139
- # num_blocks = sub_params.size
140
- # parent_width = to_px(:width) # Supposons que la largeur du parent est en pixels
141
- # total_spacing = (num_blocks + 1) * spacing_found
142
- # available_width = parent_width - total_spacing
143
- # block_width = available_width / num_blocks
144
- # left_offset = spacing_found
145
- # sub_params.each do |sub_id, sub_content|
146
- # alert sub_content[:width]
147
- # sub_created = box({ id: sub_id, height: '100%', left: left_offset })
148
- # sub_content["width"] = block_width
149
- # sub_created.set(sub_content)
150
- # sub_created.width(block_width)
151
- # left_offset += block_width + spacing_found
152
- # sub_created.width(sub_created.to_percent(:width))
153
- # sub_created.left(sub_created.to_percent(:left))
154
- # end
155
- # end
136
+ # this method allow to retrieve all children of an atome recursively, beginning from the closet child or inverted
137
+
138
+ all_children = []
139
+ fetch_children_recursively = lambda do |parent, depth|
140
+ children_ids = parent.fasten
141
+ if children_ids.any?
142
+ children_ids.each do |child_id|
143
+ child = grab(child_id)
144
+ fetch_children_recursively.call(child, depth + 1)
145
+ end
146
+ end
147
+ if include_self
148
+ all_children << { depth: depth, child: parent }
149
+ else
150
+ all_children << { depth: depth, child: parent } unless parent == self
151
+ end
152
+
153
+ end
154
+
155
+ fetch_children_recursively.call(self, 0)
156
+
157
+ sorted_children = if closest_first != :inverted
158
+ all_children.sort_by { |entry| entry[:depth] }
159
+ else
160
+ all_children.sort_by { |entry| -entry[:depth] }
161
+ end
162
+
163
+ sorted_children.each do |entry|
164
+ block.call(entry[:child])
165
+ end
166
+ end
167
+
168
+ def found_spacing_in_percent(parent_width, child_width, nb_of_children)
169
+ total_child_width = child_width * nb_of_children
170
+ remaining_width = parent_width - total_child_width
171
+ spacing = remaining_width.to_f / (nb_of_children + 1)
172
+ spacing_percentage = (spacing / parent_width) * 100
173
+ spacing_percentage.round(2)
174
+ end
175
+
176
+ def block(params)
177
+ direction = params.delete(:direction) || :vertical
178
+ spacing = params.delete(:spacing) || 3
179
+ width_found = params.delete(:width) || '100%'
180
+ height_found = params.delete(:height) || '100%'
181
+ bloc_params = params.delete(:data) || {}
182
+
183
+ last_id_found = grip(:block).last
184
+
185
+ if last_id_found
186
+ last_found = grab(last_id_found)
187
+ case direction
188
+ when :vertical
189
+ box({ top: below(last_found, spacing), role: :block, width: width_found }.merge(params).merge(bloc_params))
190
+ when :horizontal
191
+ width_found = to_px(:width)
192
+ block_left = after(last_found, spacing)
193
+ left_in_percent = (block_left / width_found) * 100
194
+ box({ left: "#{left_in_percent}%", role: :block, height: height_found }.merge(params).merge(bloc_params))
195
+ else
196
+ #
197
+ end
198
+ else
199
+ case direction
200
+ when :vertical
201
+ box({ top: spacing, role: :block, width: width_found }.merge(params).merge(bloc_params))
202
+ when :horizontal
203
+ box({ left: spacing, role: :block, height: height_found }.merge(params).merge(bloc_params))
204
+ else
205
+ #
206
+ end
207
+ end
208
+
209
+ end
210
+
211
+ def blocks(params)
212
+ # alert 'blocks case'
213
+
214
+ blocks = params.delete(:blocks)
215
+ distribute = params.delete(:distribute)
216
+ if distribute && params[:direction] == :horizontal
217
+ width_found = to_px(:width)
218
+ params[:spacing] = "#{found_spacing_in_percent(width_found, params[:width], blocks.length)}%"
219
+ elsif distribute
220
+ height_found = to_px(:height)
221
+ params[:spacing] = found_spacing_in_percent(height_found, params[:height], blocks.length)
222
+ end
223
+ blocks.each do |bloc_id, block_to_create|
224
+ sanitized_bloc_data = params.merge(block_to_create)
225
+ block({ data: sanitized_bloc_data }.merge({ id: bloc_id }).merge(params))
226
+ end
227
+ end
156
228
 
157
229
  def sub_block(sub_params, spacing_found = 3)
158
230
  num_blocks = sub_params.size
159
- parent_width = to_px(:width) # Supposons que la largeur du parent est en pixels
231
+ parent_width = to_px(:width)
160
232
  total_ratios = sub_params.values.sum { |sub_content| sub_content[:width] }
161
233
  total_spacing = (num_blocks + 1) * spacing_found
162
234
  available_width = parent_width - total_spacing
@@ -164,18 +236,16 @@ class Atome
164
236
  sub_params.each do |sub_id, sub_content|
165
237
  ratio = sub_content[:width]
166
238
  block_width = (available_width * ratio) / total_ratios
167
- sub_created = box({ id: sub_id, height: '100%', left: left_offset })
239
+ sub_created = box({ id: sub_id, height: '100%', left: left_offset, role: :sub })
168
240
  sub_content["width"] = block_width
169
241
  sub_created.set(sub_content)
170
242
  sub_created.width(block_width)
171
243
  left_offset += block_width + spacing_found
172
- sub_created.width(sub_created.to_percent(:width))
173
- sub_created.left(sub_created.to_percent(:left))
244
+ sub_created.width(sub_created.to_percent(:width))
245
+ sub_created.left(sub_created.to_percent(:left))
174
246
  end
175
247
  end
176
248
 
177
-
178
-
179
249
  def help(particle, &doc)
180
250
  if doc
181
251
  Universe.set_help(particle, &doc)
@@ -375,7 +445,7 @@ class Atome
375
445
  # This method is used to automatically create a callback method suffixed by '_callback'. For example: shell => shell_callback.
376
446
  # it can be override if you create a method like:
377
447
  # new({callback: :shell}) do |params, bloc|
378
- # # write what you want …
448
+ # # write what you want …
379
449
  # end
380
450
  def particle_callback(element)
381
451
  Atome.define_method("#{element}_callback") do |return_params|
@@ -442,31 +512,62 @@ class Atome
442
512
  hash
443
513
  end
444
514
 
445
- def refresh
446
- # we get the current color because they will be removed
447
- particles_found = particles_to_hash
448
- particles_found.each do |particle_found, value_found|
449
- puts "refresh : #{particle_found}, #{value_found}"
450
- send(particle_found, value_found)
451
- end
452
- Universe.applicable_atomes.each do |atome_type|
453
- send(atome_type).each do |col|
454
- apply(col)
515
+ # def refresh
516
+ #
517
+ # # we get the current color because they will be removed
518
+ # particles_found = particles_to_hash.dup
519
+ # # id_found=id
520
+ # data_found=particles_found.delete(:data)
521
+ # attach_found=particles_found.delete(:attach)
522
+ # apply_found=particles_found.delete(:apply)
523
+ # particles_found.each do |particle_found, value_found|
524
+ # send(particle_found, value_found)
525
+ # end
526
+ # # Universe.applicable_atomes.each do |atome_type|
527
+ # #
528
+ # # send(atome_type).each do |col|
529
+ # # apply(col)
530
+ # # end
531
+ # # end
532
+ # # alert id_found
533
+ # # grab(attach_found).fasten(id_found)
534
+ # data(data_found)
535
+ #
536
+ # apply_found.delete(:text_color) #TODO : patch here : the array is not correctly ordered so default color are apply over the next
537
+ # apply_found.delete(:box_color) ##TODO : patch here : the array is not correctly ordered so default color are apply over the next
538
+ # apply(apply_found)
539
+ # # attach(attach_found)
540
+ # end
541
+
542
+ def refresh_atome
543
+ id_found = id.dup
544
+ id(:temporary)
545
+ fasten_atomes = []
546
+ fasten_found = fasten.dup
547
+ fasten_found.each do |child_id_found|
548
+ child_found = grab(child_id_found)
549
+ if child_found
550
+ new_child = child_found.duplicate({})
551
+ fasten_atomes << new_child.id
455
552
  end
456
553
  end
457
- end
458
554
 
459
- def each(&proc)
460
- collect.each do |val|
461
- instance_exec(val, &proc) if proc.is_a?(Proc)
462
- end
555
+ infos_found = infos.dup
556
+ data_found = infos_found.delete(:data)
557
+ keys_to_delete = %i[history callback duplicate copy paste touch_code html fasten aid]
558
+ keys_to_delete.each { |key| infos_found.delete(key) }
559
+ new_atome_id = id_found
560
+ infos_found[:id] = new_atome_id
561
+ new_atome = Atome.new(infos_found)
562
+ @duplicate ||= {}
563
+ @duplicate[new_atome_id] = new_atome
564
+ new_atome.data(data_found) # needed because if atome type is a text we need add type at the end
565
+ new_atome
463
566
  end
464
567
 
465
- def each_with_index(&proc)
466
- index = 0
467
- collect.each do |val|
468
- instance_exec(val, index, &proc) if proc.is_a?(Proc)
469
- index += 1
568
+ def refresh(&bloc)
569
+ retrieve({ self: true }) do |child|
570
+ child.refresh_atome
470
571
  end
471
572
  end
472
573
 
@@ -515,9 +616,7 @@ class Atome
515
616
  category(:atome)
516
617
  attach(grand_parent)
517
618
  # we delete the parent (the layout) if it no more children fasten
518
- if parent_found.fasten.length == 0
519
- parent_found.delete(true)
520
- end
619
+ parent_found.delete(true) if parent_found.fasten.length == 0
521
620
  end
522
621
 
523
622
  def server(server_params = nil)
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.6'
6
+ VERSION = '0.5.7.4.8'
7
7
  end
@@ -91,7 +91,7 @@ class Atome
91
91
  @click_analysis_active = false
92
92
 
93
93
  click_timeout = nil
94
- double_click_delay = 150
94
+ double_click_delay = 222
95
95
 
96
96
  JS.global[:document].addEventListener('click') do |native_event|
97
97
  if @click_analysis
@@ -115,7 +115,7 @@ class Atome
115
115
 
116
116
  else
117
117
  click_timeout = wait(double_click_delay / 1000.0) do
118
- click_timeout = nil
118
+ click_timeout = nil # important do not remove !
119
119
  Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
120
120
  end
121
121
  end
@@ -201,7 +201,6 @@ class Atome
201
201
  # in this case (on target touch )we are targeting a system object non alterable so we create an a new atome
202
202
  # Ex: if we are on a system color we create a new color that can be altered
203
203
  tools_scheme[:particles]&.each do |particle_f, value_f|
204
- # if target.type
205
204
  type_to_create = target.type
206
205
  if type_to_create
207
206
  target = atome_touched.send(type_to_create, { particle_f => value_f })
@@ -209,20 +208,15 @@ class Atome
209
208
  target.send(particle_f, value_f)
210
209
  end
211
210
  end
212
- # end
213
-
214
211
  end
215
212
  else
216
213
 
217
214
  # below code trigger when activating the current tool :
218
215
  tools_scheme[:particles]&.each do |particle_f, value_f|
219
-
220
216
  is_descendant_of_intuition = target.descendant_of?(:intuition).to_s
221
217
  atome_descendant_of_intuition = atome_touched.descendant_of?(:intuition).to_s
222
218
  # the condition below is use to exclude the treatment any object in the intuition layer
223
- # puts "1 target is : #{target.id}, atome_touched is : #{atome_touched}"
224
219
  unless is_descendant_of_intuition == 'true' || atome_descendant_of_intuition == 'true'
225
- # puts "2 target is : #{target.id}, atome_touched is : #{atome_touched}"
226
220
  target.send(particle_f, value_f)
227
221
  end
228
222
  end
@@ -415,15 +409,14 @@ class Atome
415
409
  tool.instance_variable_set('@prevent_action', true)
416
410
  if tool.instance_variable_get('@tool_open') == true
417
411
  tool.instance_variable_set('@tool_open', false)
418
- tool_scheme[:particles].each_key do |particle|
419
- grab("tool_particle_#{particle}").delete({ force: true })
420
- end if tool_scheme[:particles]
412
+ tool_scheme[:particles]&.each_key do |particle|
413
+ grab("tool_particle_#{particle}").delete({ force: true })
414
+ end
421
415
  tool.width(size)
422
416
  else
423
417
  tool.instance_variable_set('@tool_open', true)
424
418
 
425
419
  tool_scheme[:particles]&.each_with_index do |(particle_name, _value_), ind|
426
-
427
420
  particle = tool.box({ id: "tool_particle_#{particle_name}", tag: { system: true }, depth: 1, smooth: smooth,
428
421
  apply: %i[inactive_tool_col tool_box_border tool_shade],
429
422
  width: size, height: size, left: ind * (size + margin) + size })
@@ -454,7 +447,6 @@ class Atome
454
447
  particle_label.top(:auto)
455
448
  particle_label.bottom(0)
456
449
  particle.touch(true) do
457
- # puts "1 ======> opening !!!#{particle_name}"
458
450
  tool.instance_variable_set('@prevent_action', true)
459
451
  slider_id = "particle_slider_#{particle_name}"
460
452
  if particle.instance_variable_get('@active')
@@ -482,22 +474,22 @@ class Atome
482
474
  # Slider actions below:
483
475
  if grab(slider_id).instance_variable_get('@initialised')
484
476
  Atome.selection.each do |atome_id_to_treat|
477
+
478
+
485
479
  tool_scheme[:particles][particle_name] = value.to_f / 100
486
480
  atome_found = grab(atome_id_to_treat)
487
481
  target = grab(atome_found.color.last)
488
- if tool.active
489
- target.send(particle_name, value.to_f / 100)
490
- end
491
- label_value.data(value.to_f / 100)
482
+ target.send(particle_name, value.to_f / 100) if tool.active
483
+
492
484
  end
493
485
 
486
+ label_value.data(value.to_f / 100)
487
+ tool_scheme[:particles][particle_name]=value.to_f / 100
494
488
  end
495
489
  end
496
490
 
497
491
  Atome.selection.each do |atome_id_to_treat|
498
492
  atome_found = grab(atome_id_to_treat)
499
- # puts 'here slider treat either the target atome types or current atome'
500
- # puts "need to created a list instead of choosing the last atome found of it's kind"
501
493
  target = if tool_scheme[:target]
502
494
  grab(atome_found.send(tool_scheme[:target]).last)
503
495
  else
@@ -521,22 +513,9 @@ class Atome
521
513
  tool.touch(:double) do
522
514
  tool_to_deactivate = Universe.active_tools.dup
523
515
  tool_to_deactivate.each do |atome_id_found|
524
-
525
516
  atome_found = grab(atome_id_found)
526
- puts "deactivate #{atome_id_found}"
527
517
  atome_found.deactivate_tool
528
- # if atome_found.activated
529
- # # atome_found.deactivate_tool
530
- # end
531
- # puts "#{atome_found}, #{atome_found.class}"
532
518
  end
533
- # Universe.tools.each do |tool_id_found, _tool_content|
534
- # # tool_found=grab(tool_id_found)
535
- # puts tool_id_found
536
- # # if tool_found.activated
537
- # # tool.deactivate_tool
538
- # # end
539
- # end
540
519
  tool.activate_tool
541
520
  end
542
521
  tool.touch(true) do
@@ -184,7 +184,7 @@ new(molecule: :input) do |params, bloc|
184
184
  position: :absolute
185
185
  }.merge(text_params)
186
186
  )
187
- text_input.touch(:down) do
187
+ input_back.touch(:down) do
188
188
  input_back.tick(:input)
189
189
  text_input.edit(true)
190
190
  end
@@ -532,11 +532,11 @@ new(molecule: :application) do |params, &bloc|
532
532
  end
533
533
  main_app.define_singleton_method(:extract) do |bloc_to_extract|
534
534
 
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
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
540
540
 
541
541
  end
542
542
 
@@ -664,7 +664,7 @@ new(molecule: :show) do |page_id, &bloc|
664
664
  grab("#{id_f}_header").left(basic_size) if header
665
665
  end
666
666
  end
667
- main_page
667
+ new_page
668
668
  end
669
669
 
670
670
 
@@ -732,7 +732,14 @@ class HTML
732
732
  end
733
733
  end
734
734
 
735
+ def drag_code(params=nil)
736
+ #FIXME : this method is an ugly patch when refreshing an atome twice, else it crash
737
+ # and lose it's drag
738
+ drag_move(params)
739
+ end
740
+
735
741
  def event(action, variance, option = nil)
742
+ # puts " remove 'if option', if unable ti unbind# : #{action} _ #{variance}"
736
743
  send("#{action}_#{variance}", option)
737
744
  end
738
745
 
@@ -46,11 +46,18 @@ end
46
46
 
47
47
  new({ method: :data, type: :string, specific: :text, renderer: :html }) do |params|
48
48
 
49
- js[:innerHTML] = if int8[language]
50
- int8[language].to_s
51
- else
52
- params.to_s
53
- end
49
+ # js[:innerHTML] = if int8[language]
50
+ # int8[language].to_s
51
+ # else
52
+ # params.to_s
53
+ # end
54
+
55
+ # alert "#{Universe.translation} /// #{params} /// #{Universe.language}"
56
+ if Universe.translation[params]
57
+ params= Universe.translation[params][Universe.language]
58
+ end
59
+ js[:innerHTML] = params.to_s
60
+
54
61
  end
55
62
 
56
63
  new({ method: :data, type: :string, specific: :vector, renderer: :html }) do |value|
@@ -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
@@ -41,7 +41,6 @@ page0 = { id: :page0,
41
41
 
42
42
  a.page(page0)
43
43
  a.page(page1)
44
- a.page(page2)
45
44
  a.page({ id: :page3,
46
45
  color: :red,
47
46
  })
@@ -51,12 +50,13 @@ a.page({ id: :page3,
51
50
  menu_f=a.menu
52
51
  menus_found= menu_f.fasten # replace fasten for entries
53
52
  puts a.pages
54
- puts " pages => #{a.pages}"
55
- puts " menus_found => #{menus_found}"
53
+ puts "pages => #{a.pages}"
54
+ puts "menus_found => #{menus_found}"
56
55
 
57
56
  bloc_to_add= {height: 156, color: :green}
58
57
  bloc_to_add2= {height: 99, color: :blue}
59
58
  bloc_to_add3= {height: 333, color: :orange, subs:{contact: {width: 1, color: :black}, project: {width: 1}, calendar: {width: 0.5, color: :green}}}
59
+
60
60
  a.insert({page3: {block1: bloc_to_add , block2: bloc_to_add2, block3: bloc_to_add3}})
61
61
 
62
62
 
@@ -65,10 +65,17 @@ wait 1 do
65
65
  a.extract({page3: :block1})
66
66
  end
67
67
 
68
- a.show(:page3)
68
+ page_3=a.show(:page3)
69
+
70
+ wait 1 do
71
+ page_3.color(:cyan)
72
+ end
73
+
74
+
69
75
  # how access blocks
70
76
  # wait 3 do
71
77
  # grab(:block2).color(:black)
72
78
  # end
73
79
 
74
80
 
81
+ puts(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,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ wait 1 do
4
+ flash(:msg)
5
+ end
@@ -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,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  t = text({ left: 33, top: 33, data: 'data collected', id: :infos })
3
- b=box({drag: true, id: :titi})
3
+ b=box({drag: true, id: :the_b})
4
+ # Important to trigger on 'return' add the parameter : {trigger: :return}
4
5
  inp=b.input({ width: 166,
5
6
  trigger: :up,
6
7
  back: :orange,
@@ -11,7 +12,6 @@ inp=b.input({ width: 166,
11
12
  red: 0, green: 0, blue: 0, alpha: 0.9
12
13
  },
13
14
  component: {size: 8},
14
- # attach: :intuition,
15
15
  text: { color: :black , top: 5, left: 6},
16
16
  smooth: 3,
17
17
  left: 66,
@@ -33,4 +33,9 @@ inp.top(12)
33
33
  end
34
34
 
35
35
 
36
+ c=circle({top: 99})
37
+ c.touch(true) do
38
+ alert b.fasten
39
+ end
40
+
36
41
 
@@ -1,17 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- t = text({ int8: { english: :hello, french: :salut, deutch: :halo } })
4
-
5
- wait 1 do
6
- t.language(:french)
7
- wait 1 do
8
- t.language(:english)
9
- # data is updated to the latest choice
10
- puts t.data
11
- end
12
- end
3
+ # t = text({ int8: { english: :hello, french: :salut, deutch: :halo } })
4
+
5
+ # wait 1 do
6
+ # t.language(:french)
7
+ # wait 1 do
8
+ # t.language(:english)
9
+ # # data is updated to the latest choice
10
+ # puts t.data
11
+ # wait 1 do
12
+ # t.data(:hi)
13
+ # end
14
+ # end
15
+ # end
16
+
17
+ Universe.translation[:hello] = { english: :hello, french: :salut, deutch: :halo }
13
18
 
14
- puts t.data
19
+ b = box({ left: 155,
20
+ drag: true,
21
+ id: :boxy })
15
22
 
16
23
 
24
+ b.text({ data: :hello, id: :t1, position: :absolute, color: :black })
25
+ t2 = b.text({ data: :hello, id: :t2, left: 9, top: 33, position: :absolute })
17
26
 
27
+
28
+
29
+ Universe.language = :french
30
+ wait 2 do
31
+ t2.refresh
32
+ Universe.language = :deutch
33
+ wait 2 do
34
+ grab(:boxy).refresh
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ b = box({ left: 155, drag: true, id: :boxy })
4
+
5
+ t=b.text({ data: :hello, id: :t1, position: :absolute, color: :black })
6
+ t2 = b.text({ data: :hello, id: :t2, left: 9, top: 33, position: :absolute })
7
+
8
+
9
+ wait 1 do
10
+ grab(:view).retrieve do |child|
11
+ child.left(33)
12
+ end
13
+ wait 1 do
14
+ grab(:boxy).retrieve do |child|
15
+ child.color(:green)
16
+ end
17
+ wait 1 do
18
+ grab(:view).retrieve({ ascending: false, self: false }) do |child|
19
+ child.delete(true)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+
5
+ def format_time
6
+ time = Time.now
7
+ {
8
+ year: time.year,
9
+ month: time.month,
10
+ day: time.day,
11
+ hour: time.hour,
12
+ minute: time.min,
13
+ second: time.sec
14
+ }
15
+ end
16
+
17
+ # Exemple d'utilisation
18
+
19
+ t=text({data: "message here", id: :messenger})
20
+
21
+ schedule_task('every_minute_task', format_time[:year], format_time[:month], format_time[:day], format_time[:hour], format_time[:minute], format_time[:second]+5, recurrence: :minutely) do
22
+ t.data("every minute i change from :#{format_time}, now : #{format_time[:minute]} , #{format_time[:second]}")
23
+ end
@@ -35,18 +35,18 @@ end
35
35
  new({ tool: :combined }) do |params|
36
36
 
37
37
  active_code = lambda {
38
- puts :alteration_tool_code_activated
38
+ # puts :alteration_tool_code_activated
39
39
  }
40
40
 
41
41
  inactive_code = lambda { |param|
42
- puts :alteration_tool_code_inactivated1
42
+ # puts :alteration_tool_code_inactivated1
43
43
  }
44
44
  pre_code = lambda { |params|
45
- puts "pre_creation_code,atome_touched: #{:params}"
45
+ # puts "pre_creation_code,atome_touched: #{:params}"
46
46
 
47
47
  }
48
48
  post_code = lambda { |params|
49
- puts "post_creation_code,atome_touched: #{:params}"
49
+ # puts "post_creation_code,atome_touched: #{:params}"
50
50
 
51
51
  }
52
52
 
@@ -73,18 +73,18 @@ end
73
73
  new({ tool: :rotate }) do |params|
74
74
 
75
75
  active_code = lambda {
76
- puts :alteration_tool_code_activated
76
+ # puts :alteration_tool_code_activated
77
77
  }
78
78
 
79
79
  inactive_code = lambda { |param|
80
- puts :alteration_tool_code_inactivated2
80
+ # puts :alteration_tool_code_inactivated2
81
81
  }
82
82
  pre_code = lambda { |params|
83
- puts "pre_creation_code,atome_touched: #{:params}"
83
+ # puts "pre_creation_code,atome_touched: #{:params}"
84
84
 
85
85
  }
86
86
  post_code = lambda { |params|
87
- puts "post_creation_code,atome_touched: #{:params}"
87
+ # puts "post_creation_code,atome_touched: #{:params}"
88
88
 
89
89
  }
90
90
 
@@ -111,20 +111,20 @@ end
111
111
  new({ tool: :box }) do |params|
112
112
 
113
113
  active_code = lambda {
114
- puts :creation_tool_code_activated
114
+ # puts :creation_tool_code_activated
115
115
  }
116
116
 
117
117
  inactive_code = lambda { |atomes_treated|
118
- puts :creation_tool_code_inactivated
118
+ # puts :creation_tool_code_inactivated
119
119
 
120
120
  }
121
121
  pre_creation_code = lambda { |params|
122
- puts "pre_creation_code : atome_touched : #{:params} "
122
+ # puts "pre_creation_code : atome_touched : #{:params} "
123
123
 
124
124
  }
125
125
 
126
126
  post_creation_code = lambda { |params|
127
- puts "post_creation_code,atome_touched: #{:params}"
127
+ # puts "post_creation_code,atome_touched: #{:params}"
128
128
  }
129
129
 
130
130
  { creation: { box: { color: :blue, width: 66, height: 66 } },
@@ -214,7 +214,7 @@ new({ tool: :drag }) do
214
214
  }
215
215
  move_code = lambda {
216
216
  drag(true) do
217
- puts left
217
+ puts "left is : #{left}"
218
218
  end
219
219
  }
220
220
 
@@ -250,7 +250,7 @@ end
250
250
 
251
251
  new({ tool: :color }) do
252
252
  active_code = lambda {
253
- puts 'color activated1'
253
+ # puts 'color activated1'
254
254
  }
255
255
  color_code = lambda {
256
256
  # color(:green)
@@ -272,7 +272,7 @@ end
272
272
 
273
273
  new({ tool: :crash_test }) do
274
274
  active_code = lambda {
275
- puts 'color activated1'
275
+ alert grab(Universe.current_user).selection.collect
276
276
  }
277
277
  color_code = lambda {
278
278
  # color(:green)
@@ -283,14 +283,14 @@ new({ tool: :crash_test }) do
283
283
  end
284
284
  }
285
285
 
286
- {
287
- alteration: { width: 22},
286
+ {activation: active_code,
287
+ # alteration: { alert: :good}
288
288
  }
289
289
  end
290
290
 
291
291
  # Universe.tools_root= {tools: [:blur, :box, :test, :toolbox1],toolbox: { orientation: :ew, left:90 , bottom: 9, spacing: 9} }
292
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"
293
+ # puts "above we added an id because each tool may be in many toolbox and have an uniq ID"
294
294
  Atome.init_intuition
295
295
 
296
296
  b = box({ id: :the_test_box, selected: false, color: :blue })
@@ -310,8 +310,8 @@ b.touch(true) do
310
310
  end
311
311
 
312
312
  end
313
- text({left: 333, data: :hello})
314
- circle({left: 333,top: 333})
313
+ text({left: 333, data: :hello, id: :t1})
314
+ circle({left: 333,top: 333, id: :c2})
315
315
 
316
316
  # wait 2 do
317
317
  # b= grab('color_tool_icon')
@@ -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.6
4
+ version: 0.5.7.4.8
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-21 00:00:00.000000000 Z
11
+ date: 2024-07-06 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
@@ -583,11 +584,13 @@ files:
583
584
  - vendor/assets/application/examples/fill.rb
584
585
  - vendor/assets/application/examples/find.rb
585
586
  - vendor/assets/application/examples/fit.rb
587
+ - vendor/assets/application/examples/flash.rb
586
588
  - vendor/assets/application/examples/fonts.rb
587
589
  - vendor/assets/application/examples/generator_and_build.rb
588
590
  - vendor/assets/application/examples/getter.rb
589
591
  - vendor/assets/application/examples/grab.rb
590
592
  - vendor/assets/application/examples/gradient.rb
593
+ - vendor/assets/application/examples/grip.rb
591
594
  - vendor/assets/application/examples/group.rb
592
595
  - vendor/assets/application/examples/help.rb
593
596
  - vendor/assets/application/examples/hierarchy.rb
@@ -629,8 +632,10 @@ files:
629
632
  - vendor/assets/application/examples/remove.rb
630
633
  - vendor/assets/application/examples/repeat.rb
631
634
  - vendor/assets/application/examples/resize.rb
635
+ - vendor/assets/application/examples/retreive.rb
632
636
  - vendor/assets/application/examples/rotate.rb
633
637
  - vendor/assets/application/examples/run.rb
638
+ - vendor/assets/application/examples/schedule.rb
634
639
  - vendor/assets/application/examples/scheduler.rb
635
640
  - vendor/assets/application/examples/security.rb
636
641
  - vendor/assets/application/examples/select_text.rb
@@ -779,6 +784,7 @@ files:
779
784
  - vendor/assets/src/medias/images/green_planet.png
780
785
  - vendor/assets/src/medias/images/icons/Lowpass.svg
781
786
  - vendor/assets/src/medias/images/icons/activate.svg
787
+ - vendor/assets/src/medias/images/icons/add.svg
782
788
  - vendor/assets/src/medias/images/icons/audio.svg
783
789
  - vendor/assets/src/medias/images/icons/band_pass.svg
784
790
  - vendor/assets/src/medias/images/icons/clear.svg