atome 0.5.7.4.7 → 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: 4307d31fea820f10f0830b00698f327cd08181a864b4440a25a57021fb0ffb7e
4
- data.tar.gz: 6a66d5336fa6a58eae59571504d92230eb8482bdd44c4821bbf3e79e27a356d2
3
+ metadata.gz: adbf3e2dbe9b01956856270d1789ebae1205be44b00b4038cf1c709c0f7d7f2e
4
+ data.tar.gz: a01c1c6b62cd322949d94b44b6b1952f2c331ad1dd9ed55cdf9d46b3a1053627
5
5
  SHA512:
6
- metadata.gz: b0a16ea7a7865bc3b13bdc81ce6d57dccf557c25c016446a151eee1203d582e22a246dae317f2531c19cba16fa7c2e3455f64f49ab3966cd526f3ccd2675fff4
7
- data.tar.gz: c5988d35c2b6af02f6db44e610c0f01ede3d99cd5558db342bbfa186a04cf4669bc0344ad50d187e0208272234c49d2683f0b9ff326082575beeb8177e11490b
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
@@ -804,4 +814,7 @@ class CssProxy
804
814
  end
805
815
 
806
816
 
817
+
818
+
819
+
807
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,7 +9,6 @@ class Atome
9
9
  class << self
10
10
  attr_accessor :initialized
11
11
 
12
-
13
12
  def sanitize_data_for_json(data)
14
13
  data.gsub('"', '\\"')
15
14
  end
@@ -86,7 +85,9 @@ class Atome
86
85
  end
87
86
  args = args[0]
88
87
  end
89
- 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
90
91
  original_method.call(*args)
91
92
  end
92
93
  end
@@ -114,9 +115,7 @@ class Atome
114
115
 
115
116
  fasten.each do |child_id|
116
117
  child_found = grab(child_id)
117
- if child_found.role && child_found.role.include?(role_wanted)
118
- gripped_atome << child_id
119
- end
118
+ gripped_atome << child_id if child_found.role && child_found.role.include?(role_wanted)
120
119
  end
121
120
  gripped_atome
122
121
  end
@@ -125,9 +124,48 @@ class Atome
125
124
  # dummy method
126
125
  end
127
126
 
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
135
+
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)
128
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
129
162
 
130
- def spacing_found(parent_width, child_width, nb_of_children)
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)
131
169
  total_child_width = child_width * nb_of_children
132
170
  remaining_width = parent_width - total_child_width
133
171
  spacing = remaining_width.to_f / (nb_of_children + 1)
@@ -171,14 +209,16 @@ class Atome
171
209
  end
172
210
 
173
211
  def blocks(params)
212
+ # alert 'blocks case'
213
+
174
214
  blocks = params.delete(:blocks)
175
215
  distribute = params.delete(:distribute)
176
216
  if distribute && params[:direction] == :horizontal
177
217
  width_found = to_px(:width)
178
- params[:spacing] = "#{spacing_found(width_found, params[:width], blocks.length)}%"
218
+ params[:spacing] = "#{found_spacing_in_percent(width_found, params[:width], blocks.length)}%"
179
219
  elsif distribute
180
220
  height_found = to_px(:height)
181
- params[:spacing] = spacing_found(height_found, params[:height], blocks.length)
221
+ params[:spacing] = found_spacing_in_percent(height_found, params[:height], blocks.length)
182
222
  end
183
223
  blocks.each do |bloc_id, block_to_create|
184
224
  sanitized_bloc_data = params.merge(block_to_create)
@@ -186,7 +226,6 @@ class Atome
186
226
  end
187
227
  end
188
228
 
189
-
190
229
  def sub_block(sub_params, spacing_found = 3)
191
230
  num_blocks = sub_params.size
192
231
  parent_width = to_px(:width)
@@ -202,13 +241,11 @@ class Atome
202
241
  sub_created.set(sub_content)
203
242
  sub_created.width(block_width)
204
243
  left_offset += block_width + spacing_found
205
- sub_created.width(sub_created.to_percent(:width))
206
- 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))
207
246
  end
208
247
  end
209
248
 
210
-
211
-
212
249
  def help(particle, &doc)
213
250
  if doc
214
251
  Universe.set_help(particle, &doc)
@@ -408,7 +445,7 @@ class Atome
408
445
  # This method is used to automatically create a callback method suffixed by '_callback'. For example: shell => shell_callback.
409
446
  # it can be override if you create a method like:
410
447
  # new({callback: :shell}) do |params, bloc|
411
- # # write what you want …
448
+ # # write what you want …
412
449
  # end
413
450
  def particle_callback(element)
414
451
  Atome.define_method("#{element}_callback") do |return_params|
@@ -475,31 +512,62 @@ class Atome
475
512
  hash
476
513
  end
477
514
 
478
- def refresh
479
- # we get the current color because they will be removed
480
- particles_found = particles_to_hash
481
- particles_found.each do |particle_found, value_found|
482
- puts "refresh : #{particle_found}, #{value_found}"
483
- send(particle_found, value_found)
484
- end
485
- Universe.applicable_atomes.each do |atome_type|
486
- send(atome_type).each do |col|
487
- 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
488
552
  end
489
553
  end
490
- end
491
554
 
492
- def each(&proc)
493
- collect.each do |val|
494
- instance_exec(val, &proc) if proc.is_a?(Proc)
495
- 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
496
566
  end
497
567
 
498
- def each_with_index(&proc)
499
- index = 0
500
- collect.each do |val|
501
- instance_exec(val, index, &proc) if proc.is_a?(Proc)
502
- index += 1
568
+ def refresh(&bloc)
569
+ retrieve({ self: true }) do |child|
570
+ child.refresh_atome
503
571
  end
504
572
  end
505
573
 
@@ -548,9 +616,7 @@ class Atome
548
616
  category(:atome)
549
617
  attach(grand_parent)
550
618
  # we delete the parent (the layout) if it no more children fasten
551
- if parent_found.fasten.length == 0
552
- parent_found.delete(true)
553
- end
619
+ parent_found.delete(true) if parent_found.fasten.length == 0
554
620
  end
555
621
 
556
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.7'
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
@@ -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
@@ -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|
@@ -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
  })
@@ -66,11 +65,17 @@ wait 1 do
66
65
  a.extract({page3: :block1})
67
66
  end
68
67
 
69
- a.show(:page3)
68
+ page_3=a.show(:page3)
69
+
70
+ wait 1 do
71
+ page_3.color(:cyan)
72
+ end
73
+
74
+
70
75
  # how access blocks
71
76
  # wait 3 do
72
77
  # grab(:block2).color(:black)
73
78
  # end
74
79
 
75
80
 
76
- alert(grab(:project).inspect)
81
+ puts(grab(:project).inspect)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ wait 1 do
4
+ flash(:msg)
5
+ end
@@ -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
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.7
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-07-02 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
@@ -584,6 +584,7 @@ files:
584
584
  - vendor/assets/application/examples/fill.rb
585
585
  - vendor/assets/application/examples/find.rb
586
586
  - vendor/assets/application/examples/fit.rb
587
+ - vendor/assets/application/examples/flash.rb
587
588
  - vendor/assets/application/examples/fonts.rb
588
589
  - vendor/assets/application/examples/generator_and_build.rb
589
590
  - vendor/assets/application/examples/getter.rb
@@ -631,8 +632,10 @@ files:
631
632
  - vendor/assets/application/examples/remove.rb
632
633
  - vendor/assets/application/examples/repeat.rb
633
634
  - vendor/assets/application/examples/resize.rb
635
+ - vendor/assets/application/examples/retreive.rb
634
636
  - vendor/assets/application/examples/rotate.rb
635
637
  - vendor/assets/application/examples/run.rb
638
+ - vendor/assets/application/examples/schedule.rb
636
639
  - vendor/assets/application/examples/scheduler.rb
637
640
  - vendor/assets/application/examples/security.rb
638
641
  - vendor/assets/application/examples/select_text.rb