atome 0.5.5.6.4 → 0.5.5.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b31290fc95efc0a70d4679d5354bcef415b2366fd11c2daee3821de259d7cc9
4
- data.tar.gz: b0fd13de4867f9f139682d786405049097b975e7afe619dcf14781f538db27e6
3
+ metadata.gz: c5e9aa478d329311763c85b34cbd9a9a24e22cb9179e596e2e66d0701f091005
4
+ data.tar.gz: 58a73fce3f81a4f00a8d0948167be1686538bb3cf8fb4144b05876406c30e8f7
5
5
  SHA512:
6
- metadata.gz: 94cf7f832e676b8b26c9ee2441ecbe3dc08eee174f6eb3bec92b68869de9d9bd1c1b81408fbacfd0c12fe7de25b682fd67458263fca0c2bc078704e0f0d285e9
7
- data.tar.gz: ecf1425bda14c78a0047a514e84d5ac2ed017f95c05b37598045d8ea6b3f878bc27e560bfe5b2b02884f15a9996f0c2cc3c0505e72170222e0ded5126fd6f829
6
+ metadata.gz: a6c686bfaf93676f69a7dd20af421bb6751f2ab21f971a5658c3ad6da3b4f8fd5a3ceab28cbf0ef71032a1c125729226c1cda3640fa7f5ac4545d9e657c52b39
7
+ data.tar.gz: 6752436669092cf5f741ff202fc3815c0897524ee4f85f7746cb6dd4cfdea9164cb4248bfa116a22b46d30e8989f2e3d19336b5a9ebaebf3ad23ed65a1e500bd
data/lib/atome/atome.rb CHANGED
@@ -6,7 +6,6 @@ class Atome
6
6
 
7
7
  def initialize(new_atome = {}, &atomes_proc)
8
8
  # the keys :renderers, :type and :id should be placed in the first position in the hash
9
- #@broadcast = {}
10
9
  @history = {}
11
10
  @callback = {}
12
11
  @tag = {}
@@ -17,8 +16,8 @@ class Atome
17
16
  @type = new_atome[:type] || :element
18
17
  @attached = []
19
18
  @category = []
20
- @display = { mode: :default, default: {} }
21
- # @copy = []
19
+ # @display = { mode: :default }
20
+ # @backup={} # mainly used to restore particle when using grid /table /list display mode
22
21
  @html = HTML.new(@id, self)
23
22
  @headless = Headless.new(@id, self)
24
23
  # now we store the proc in a an atome's property called :bloc
@@ -53,7 +53,7 @@ new(particle: :selected) do |params|
53
53
  if params == true
54
54
  grab(Universe.current_user).selection << @id
55
55
  elsif params == false
56
- grab(Universe.current_user).selection.delete(@id)
56
+ grab(Universe.current_user).selection.collect.delete(@id)
57
57
  else
58
58
  # TODO: for future use
59
59
  end
@@ -9,3 +9,93 @@ new({ particle: :direction, type: :string })
9
9
  new({ particle: :center, type: :string})
10
10
  new({particle: :depth, type: :integer})
11
11
  new({ particle: :position })
12
+ new({ particle: :organise })
13
+ new({ particle: :spacing })
14
+ new({ particle: :display }) do |params|
15
+ unless params.instance_of? Hash
16
+ params = { mode: params }
17
+ end
18
+ params
19
+ end
20
+ new({ particle: :layout }) do |params|
21
+
22
+ mode_found = params.delete(:mode) || :list
23
+ elements_style = params.delete(:element) || {}
24
+ # now we get the list of the atome to layout
25
+ atomes_to_organise = []
26
+ if type == :group
27
+ atomes_to_organise = collect
28
+ end
29
+ # if params[:listing] is specified group collection is override
30
+ atomes_to_organise = params[:listing] if params[:listing]
31
+ if mode_found == :default
32
+ # the user want to revert the layout to the default
33
+ atomes_to_organise.each do |atome_id_to_organise|
34
+ atome_found = grab(atome_id_to_organise)
35
+ # now restoring
36
+ if atome_found.backup
37
+ atome_found.backup.each do |particle, value|
38
+ atome_found.send(:delete, particle)
39
+ atome_found.send(particle, value)
40
+ end
41
+ atome_found.remove_layout
42
+ end
43
+
44
+ end
45
+ else
46
+
47
+ if params[:id]
48
+ container_name = params[:id]
49
+ container = grab(:view).box({ id: container_name })
50
+ container_class = container_name
51
+ else
52
+ container = grab(:view).box
53
+ id_found = container.id
54
+ params[:id] = id_found
55
+ container_class = id_found
56
+ end
57
+ container.remove({ category: :atome })
58
+ container.category(:matrix)
59
+ if mode_found == :list
60
+ params[:organise] = '1fr'
61
+ end
62
+ params.each do |particle, value|
63
+ container.send(particle, value)
64
+ end
65
+ # now we add user wanted particles
66
+ atomes_to_organise.each do |atome_id_to_organise|
67
+ atome_found = grab(atome_id_to_organise)
68
+ # now restoring
69
+ if atome_found.backup
70
+ atome_found.backup.each do |particle, value|
71
+ atome_found.send(:delete, particle)
72
+ atome_found.send(particle, value)
73
+ end
74
+ # atome_found.remove_layout
75
+ end
76
+ # we remove previous display mode
77
+ atome_found.remove_layout
78
+ atome_found.display[:mode] = mode_found
79
+ atome_found.display[:layout] = id_found
80
+ atome_found.attach(container_class)
81
+ atome_found.remove({ category: :atome })
82
+ atome_found.category(container_class)
83
+ # the hash below is used to restore element state
84
+
85
+ # we only store the state if atome_found.display[:default]== {} it means this is the original state
86
+ elements_style.each do |particle, value|
87
+ # we have to store all elements particle to restore it later
88
+ atome_found.backup({}) unless atome_found.backup
89
+ unless atome_found.backup[particle]
90
+ particle_to_save = atome_found.send(particle) || 0
91
+ atome_found.backup[particle] = particle_to_save
92
+ end
93
+
94
+ atome_found.send(particle, value)
95
+ end
96
+ end
97
+ end
98
+ params
99
+ end
100
+
101
+
@@ -197,7 +197,6 @@ new({ particle: :copy }) do |items_id|
197
197
  grab(:copy).collect << items_id
198
198
  end
199
199
 
200
-
201
200
  new({ particle: :paste }) do |params|
202
201
 
203
202
  all_copies = grab(:copy).collect
@@ -211,7 +210,7 @@ new({ particle: :paste }) do |params|
211
210
  new_atomes = []
212
211
  applies_found = []
213
212
  copies_found.each do |copy_found|
214
- new_atome = grab(copy_found).duplicate({attach: @id })
213
+ new_atome = grab(copy_found).duplicate({ attach: @id })
215
214
  new_atomes << new_atome.id
216
215
  # FIXME: below start to patch because apply is not apply , so we store it and apply it again
217
216
  applies_found << new_atome.apply
@@ -226,4 +225,6 @@ end
226
225
 
227
226
  new({ read: :paste }) do |p|
228
227
  @copy
229
- end
228
+ end
229
+
230
+ new({ particle: :backup })
@@ -87,6 +87,9 @@ Universe.current_machine = machine_id
87
87
  A = Atome.new(
88
88
  { renderers: default_render, id: :atome, type: :element, tag: { system: true } }
89
89
  )
90
+ # atome selector / collector
91
+ Atome.new({ renderers: [:html], id: :selector, collect: [], type: :group, tag: { system: true } })
92
+
90
93
  # atome infos
91
94
  def atome_infos
92
95
  puts "atome version: #{Atome::VERSION}"
@@ -280,4 +280,22 @@ class Atome
280
280
  debug "#{user_id} not found"
281
281
  end
282
282
  end
283
+ def remove_layout
284
+ display(:default)
285
+ # we get the current parent (the previous layout)
286
+ parent_found = grab(attach)
287
+ # we get the parent of the parent
288
+ grand_parent = parent_found.attach
289
+ # and attach the item to the grand parent
290
+ # we remove the parent category and restore atome category
291
+ remove({ category: attach })
292
+ category(:atome)
293
+ attach(grand_parent)
294
+ # we delete the parent (the layout) if it no more children attached
295
+ if parent_found.attached.length == 0
296
+ parent_found.delete(true)
297
+ end
298
+ end
299
+
300
+
283
301
  end
data/lib/atome/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  # return atome version
4
4
  class Atome
5
- VERSION = '0.5.5.6.4'
5
+ VERSION = '0.5.5.6.5'
6
6
  end
@@ -1096,7 +1096,7 @@ class HTML
1096
1096
  end
1097
1097
 
1098
1098
  def play_animation(properties)
1099
- alert 'change for standard method : action'
1099
+ puts 'change for standard method : action'
1100
1100
  required_keys = [:from, :to, :duration]
1101
1101
  if properties.is_a?(Hash) && (required_keys - properties.keys).empty?
1102
1102
  animate(properties)
@@ -43,4 +43,16 @@ end
43
43
 
44
44
  new({renderer: :html, method: :depth }) do |params|
45
45
  html.style("z-index", params)
46
+ end
47
+
48
+ new({ method: :organise, renderer: :html }) do |params|
49
+ html.style(:gridTemplateColumns, params)
50
+ end
51
+
52
+ new({ method: :spacing, renderer: :html }) do |params|
53
+ html.style(:gap, "#{params}px")
54
+ end
55
+
56
+ new({ method: :display, renderer: :html }) do |params|
57
+ html.style(:display, params)
46
58
  end
@@ -57,8 +57,10 @@ b = circle({ id: :the_cirlce })
57
57
  b.text(:hello)
58
58
  bb = b.duplicate({ width: 33, left: 234, top: 222 })
59
59
  bb.color(:red)
60
+ wait 1 do
60
61
  bb2 = b.duplicate({ width: 33, left: 12 })
61
62
  bb3 = b.duplicate({ width: 33, left: 444 })
62
63
  bb3.color(:green)
63
64
  bb2.color(:orange)
65
+ end
64
66
 
@@ -1,179 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # class HTML
4
- #
5
- # def layout_style(option = {})
6
- # element_style = {
7
- # backgroundColor: 'rebeccapurple',
8
- # width: '100%',remove_layout
9
- # height: '29px',
10
- # borderRadius: '59px',
11
- # display: 'flex',
12
- # justifyContent: 'center',
13
- # alignItems: 'center',
14
- # flexDirection: 'column',
15
- # marginBottom: '20px',
16
- # padding: '0px',
17
- # # transform: 'rotate(22deg)',
18
- #
19
- # }
20
- #
21
- # container_style = {
22
- # display: :grid,
23
- # gridTemplateColumns: 'repeat(4, 1fr)',
24
- # overflow: :scroll,
25
- # flexDirection: 'column',
26
- # gap: '20px',
27
- # padding: '0px',
28
- #
29
- # }
30
- # element_style = element_style.merge(option[:element]) if option[:element]
31
- # container_style = container_style.merge(option[:container]) if option[:container]
32
- # @layout_style = { element: element_style, container: container_style }
33
- # end
34
- #
35
- # def remove_webview_layout(element, container)
36
- # element[:classList].add('atome')
37
- # element[:classList].remove('matrix_element')
38
- # end
39
- #
40
- # def layout(params)
41
- #
42
- # id_found = params[:id]
43
- # mode_found = params[:mode]
44
- # width_found = params[:width]
45
- # height_found = params[:height]
46
- # layout_container = JS.global[:document].getElementById(id_found.to_s)
47
- # layout_elements = JS.global[:document].querySelectorAll(".#{id_found}")
48
- # if mode_found == :default
49
- # # we revert all elements to default state / layout
50
- # layout_elements.to_a.each do |element|
51
- # element[:classList].remove('matrix_element')
52
- # element[:classList].add('atome')
53
- # end
54
- # else
55
- # # we apply new layout to elements
56
- # layout_style({ element: { backgroundColor: :purple } })
57
- # layout_container[:classList].remove('atome')
58
- # layout_container[:classList].add('matrix')
59
- # layout_elements.to_a.each do |element|
60
- # # we check if current state is default if yes we store the layout to be able to restore it
61
- # element[:style][:borderRadius] = '59px'
62
- # element[:classList].remove('atome')
63
- # # element[:classList].add('matrix_element')
64
- # end
65
- # end
66
- #
67
- # end
68
- # end
69
-
70
- class Atome
71
- def remove_layout
72
- display[:mode] = :default
73
- # we get the current parent (the previous layout)
74
- parent_found = grab(attach)
75
- # we get the parent of the parent
76
- grand_parent = parent_found.attach
77
- # and attach the item to the grand parent
78
- # we remove the parent category and restore atome category
79
- remove({ category: attach})
80
- category(:atome)
81
- attach(grand_parent)
82
- # we delete the parent (the layout) if it no more children attached
83
- if parent_found.attached.length == 0
84
- parent_found.delete(true)
85
- end
86
- end
87
- end
88
-
89
- new({ particle: :layout }) do |params|
90
- mode_found = params.delete(:mode) || :list
91
- elements_style= params.delete(:element) || {}
92
- # layout_width = params[:width] ||= 333
93
- # layout_height = params[:height] ||= 333
94
- # now we get the list of the atome to layout
95
- atomes_to_layout = []
96
- if type == :group
97
- atomes_to_layout = collect
98
- end
99
- # if params[:list] is specified group collection is override
100
- atomes_to_layout = params[:list] if params[:list]
101
-
102
- if mode_found == :default
103
- # the user want to revert the layout to the default
104
- atomes_to_layout.each do |atome_id_to_layout|
105
- atome_to_layout = grab(atome_id_to_layout)
106
- unless params[:id]
107
- params[:id] = atome_to_layout.display[:layout]
108
- end
109
- # now we get the default particles and restore it
110
- atome_to_layout.display[:default].each do |particle, value|
111
- atome_to_layout.send(:delete,particle)
112
- atome_to_layout.send(particle,value)
113
- end
114
-
115
- atome_to_layout.remove_layout
116
- end
117
- else
118
- if params[:id]
119
- container_name = params[:id]
120
- container = grab(:view).box({ id: container_name })
121
- container_class = container_name
122
- else
123
- container = grab(:view).box
124
- id_found = container.id
125
- params[:id] = id_found
126
- container_class = id_found
127
- end
128
- # container.width = layout_width
129
- # container.height = layout_height
130
- container.remove({ category: :atome})
131
- container.category(:matrix)
132
- alert ">> #{mode_found}"
133
- params.each do |particle, value|
134
- container.send(particle, value)
135
- end
136
- # now we add user wanted particles
137
- alert params
138
-
139
- atomes_to_layout.each do |atome_id_to_layout|
140
- atome_to_layout = grab(atome_id_to_layout)
141
- # we remove previous display mode
142
- atome_to_layout.remove_layout
143
- atome_to_layout.display[:mode] = mode_found
144
- atome_to_layout.display[:layout] = id_found
145
- atome_to_layout.attach(container_class)
146
- atome_to_layout.remove({ category: :atome})
147
- atome_to_layout.category(container_class)
148
- #the hash below is used to restore element state
149
- original_state={}
150
- elements_style.each do |particle, value|
151
- # we have to store all elements particle to restore it later
152
- original_state[particle]=atome_to_layout.send(particle)
153
- atome_to_layout.send(particle, value)
154
- end
155
- atome_to_layout.display[:default]=original_state
156
- # puts "display is : #{atome_to_layout.display}"
157
- # atome_to_layout.html.add_class(container_class)
158
- # puts container_class
159
- end
160
- end
161
- params
162
- end
163
-
164
- # new({ renderer: :html, method: :layout, type: :hash }) do |params, _user_proc|
165
- # html.layout(params)
166
- # end
167
-
168
- new({ particle: :display })
169
-
170
- # system
171
- Atome.new({ renderers: [:html], id: :selector, collect: [], type: :group, tag: { system: true } })
172
-
173
- ############### tests
174
-
175
3
  b = box({ color: :red, id: :the_box, left: 3 })
176
- 16.times do |index|
4
+ 5.times do |index|
177
5
  width_found = b.width
178
6
  b.duplicate({ left: b.left + index * (width_found + 45), top: 0, category: :custom_category })
179
7
  end
@@ -182,7 +10,7 @@ grab(:view).attached.each do |atome_found|
182
10
  grab(atome_found).selected(true)
183
11
  end
184
12
  grab(:the_box_copy_1).text(:hello)
185
- #################
13
+
186
14
  selected_items = grab(Universe.current_user).selection # we create a group
187
15
  # we collect all atomes in the view
188
16
  atomes_found = []
@@ -190,38 +18,34 @@ selected_items.each do |atome_found|
190
18
  atomes_found << atome_found
191
19
  end
192
20
 
193
- random_found = atomes_found.sample(17)
194
-
21
+ # random_found = atomes_found.sample(17)
22
+ #
195
23
  # random_found.each do |atome_id|
196
24
  # atome_found = grab(atome_id)
197
25
  # if atome_found.type == :shape
198
26
  # atome_found.left(rand(700))
199
- # atome_found.width(rand(120))
200
- # atome_found.height(rand(120))
27
+ # atome_found.width(rand(200))
28
+ # atome_found.height(rand(200))
29
+ # # atome_found.rotate(rand(90))
201
30
  # atome_found.smooth(rand(120))
202
31
  # atome_found.color({ red: rand, green: rand, blue: rand })
203
32
  # end
204
33
  # end
34
+
35
+ selected_items.layout({ mode: :default, width: 500, height: 22 })
36
+
205
37
  wait 1 do
206
- selected_items.layout({ mode: :grid, width: 900, height: 500, color: :green,element: {height: 22, rotate: 22} })
207
- # alert grab('the_box_copy_4').display
38
+ selected_items.layout({ mode: :grid, width: 900, height: 500, color: :green, element: { rotate: 22, height: 100, width: 150 } })
208
39
  wait 1 do
209
- # selected_items.layout({ mode: :grid, width: 800, height: 500 })
40
+ selected_items.layout({ mode: :grid, width: 1200, height: 500, overflow: :scroll })
210
41
  wait 1 do
211
- selected_items.layout({ mode: :default, width: 500, height: 500 })
212
- # alert grab('the_box_copy_4').display
42
+ selected_items.layout({ mode: :default, width: 500, height: 22 })
213
43
  wait 1 do
214
- selected_items.layout({ id: :my_layout, mode: :list, width: 151, height: 800, overflow: :scroll })
44
+ selected_items.layout({ id: :my_layout, mode: :list, width: 800, height: 800, overflow: :scroll, element: { height: 22, width: 800 } })
215
45
  wait 1 do
216
- selected_items.layout({ mode: :default, width: 500, height: 500 })
46
+ selected_items.layout({ mode: :default })
217
47
  end
218
48
  end
219
49
  end
220
50
  end
221
51
  end
222
-
223
- # JS.global[:console].clear()
224
-
225
-
226
- # b=box
227
- # alert ">> #{b.display}"
@@ -21,7 +21,6 @@ t.touch(true) do
21
21
  atome_selected.height=rand(333)
22
22
 
23
23
  end
24
-
25
24
  b.selected(false)
26
25
  puts "3 current_user- #{grab(Universe.current_user).selection}"
27
26
  puts "3 - b selected : #{b.selected}"
@@ -23,7 +23,7 @@ html, body {
23
23
  display: grid;
24
24
  grid-template-columns: repeat(4, 1fr);
25
25
  flex-direction: column;
26
- gap: 20px;
26
+ gap: 12px;
27
27
  padding: 3px;
28
28
  }
29
29
  /*.matrix_element{*/
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.5.6.4
4
+ version: 0.5.5.6.5
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: 2023-12-14 00:00:00.000000000 Z
11
+ date: 2023-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arduino_firmata