atome 0.5.3.8.1 → 0.5.4.0.9
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 +4 -4
- data/Rakefile +52 -17
- data/app_builder_helpers/Rakefile +20 -3
- data/exe/atome +33 -1
- data/lib/atome/atome.rb +64 -75
- data/lib/atome/extensions/atome.rb +82 -52
- data/lib/atome/extensions/mathematic.rb +8 -12
- data/lib/atome/extensions/matrix.rb +141 -202
- data/lib/atome/genesis/generators/atome.rb +13 -96
- data/lib/atome/genesis/generators/communication.rb +0 -1
- data/lib/atome/genesis/generators/effect.rb +0 -6
- data/lib/atome/genesis/generators/event.rb +64 -77
- data/lib/atome/genesis/generators/geometry.rb +0 -18
- data/lib/atome/genesis/generators/identity.rb +56 -52
- data/lib/atome/genesis/generators/material.rb +3 -54
- data/lib/atome/genesis/generators/spatial.rb +8 -8
- data/lib/atome/genesis/generators/utility.rb +82 -68
- data/lib/atome/genesis/genesis.rb +15 -4
- data/lib/atome/genesis/sparkle.rb +38 -19
- data/lib/atome/helpers/callbacks.rb +47 -1
- data/lib/atome/helpers/essentials.rb +21 -18
- data/lib/atome/helpers/sanitizer.rb +0 -10
- data/lib/atome/helpers/utilities.rb +143 -45
- data/lib/atome/kernel/batch.rb +13 -36
- data/lib/atome/kernel/universe.rb +3 -1
- data/lib/atome/presets/atome.rb +14 -23
- data/lib/atome/renderers/browser/atome.rb +2 -1
- data/lib/atome/renderers/browser/browser.rb +2 -0
- data/lib/atome/renderers/browser/event.rb +18 -0
- data/lib/atome/renderers/browser/helpers/browser_helper.rb +17 -0
- data/lib/atome/renderers/browser/helpers/drag_helper.rb +13 -0
- data/lib/atome/renderers/browser/helpers/drop_helper.rb +13 -0
- data/lib/atome/renderers/browser/helpers/event_helper.rb +16 -11
- data/lib/atome/renderers/browser/helpers/over_helper.rb +13 -0
- data/lib/atome/renderers/browser/helpers/text_helper.rb +14 -2
- data/lib/atome/renderers/browser/identity.rb +23 -5
- data/lib/atome/renderers/browser/spatial.rb +3 -2
- data/lib/atome/renderers/browser/utility.rb +7 -6
- data/lib/atome/renderers/renderer.rb +1 -0
- data/lib/atome/version.rb +2 -2
- data/lib/atome.rb +1 -0
- data/sig/atome.rbs +36 -0
- data/sig/batch.rbs +7 -0
- data/sig/browser_helper.rbs +14 -0
- data/sig/essentials.rbs +11 -0
- data/sig/matrix.rbs +5 -0
- data/sig/object.rbs +3 -0
- data/vendor/assets/aui.rb +5 -0
- data/vendor/assets/src/index.html +15 -3
- data/vendor/assets/src/js/atome/atome.js +1 -1
- data/vendor/assets/src/js/atome/atome_helpers/atome_animate.js +1 -1
- data/vendor/assets/src/js/atome/atome_helpers/atome_communication.js +40 -0
- data/vendor/assets/src/js/atome/atome_helpers/atome_drag.js +40 -3
- data/vendor/assets/src/js/atome/atome_helpers/atome_drop.js +12 -0
- data/vendor/assets/src/js/atome/atome_helpers/atome_events.js +166 -0
- data/vendor/assets/src/js/atome/atome_helpers/atome_file.js +6 -1
- data/vendor/assets/src/js/atome/atome_helpers/atome_over.js +43 -0
- data/vendor/assets/src/medias/images/icons/email.svg +12 -12
- data/vendor/assets/src/medias/rubies/demos.rb +63 -0
- data/vendor/assets/src/medias/rubies/examples/add.rb +3 -4
- data/vendor/assets/src/medias/rubies/examples/animation.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/atome_new.rb +18 -6
- data/vendor/assets/src/medias/rubies/examples/attach.rb +15 -0
- data/vendor/assets/src/medias/rubies/examples/attached.rb +5 -6
- data/vendor/assets/src/medias/rubies/examples/batch.rb +17 -0
- data/vendor/assets/src/medias/rubies/examples/blur.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/box.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/code.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/color.rb +20 -4
- data/vendor/assets/src/medias/rubies/examples/delete.rb +18 -2
- data/vendor/assets/src/medias/rubies/examples/detached.rb +3 -3
- data/vendor/assets/src/medias/rubies/examples/drag.rb +53 -2
- data/vendor/assets/src/medias/rubies/examples/drop.rb +26 -0
- data/vendor/assets/src/medias/rubies/examples/fullscreen.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/image.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/link.rb +7 -5
- data/vendor/assets/src/medias/rubies/examples/markers.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/materials.rb +15 -0
- data/vendor/assets/src/medias/rubies/examples/matrix.rb +85 -41
- data/vendor/assets/src/medias/rubies/examples/matrix_changes.rb +483 -0
- data/vendor/assets/src/medias/rubies/examples/matrix_simple.rb +32 -0
- data/vendor/assets/src/medias/rubies/examples/monitoring.rb +44 -18
- data/vendor/assets/src/medias/rubies/examples/mute.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/on.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/over.rb +6 -4
- data/vendor/assets/src/medias/rubies/examples/pause.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/physical.rb +19 -0
- data/vendor/assets/src/medias/rubies/examples/play.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/read.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/repeat.rb +3 -2
- data/vendor/assets/src/medias/rubies/examples/shadow.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/sort.rb +3 -4
- data/vendor/assets/src/medias/rubies/examples/tags.rb +10 -0
- data/vendor/assets/src/medias/rubies/examples/text.rb +4 -4
- data/vendor/assets/src/medias/rubies/examples/time.rb +3 -3
- data/vendor/assets/src/medias/rubies/examples/video.rb +2 -2
- data/vendor/assets/src/medias/rubies/examples/web.rb +2 -2
- data/vendor/assets/src/medias/rubies/{examples → unstable}/_2_solve.rb +1 -1
- data/vendor/assets/src/medias/rubies/{examples → unstable}/_audio.rb +1 -1
- data/vendor/assets/src/medias/rubies/{examples → unstable}/_dataset.rb +4 -4
- data/vendor/assets/src/medias/rubies/unstable/_matrix.rb +58 -0
- data/vendor/assets/src/medias/rubies/{examples → unstable}/_table2.rb +2 -2
- data/vendor/assets/src/medias/rubies/{examples → unstable}/_vie.rb +2 -2
- data/vendor/assets/src/utilities/mode.rb +0 -0
- data/vendor/assets/src-tauri/tauri.conf.json +2 -2
- metadata +34 -14
- data/vendor/assets/src/medias/rubies/examples/parents.rb +0 -15
- data/vendor/assets/src/medias/rubies/examples/table.rb +0 -479
- /data/vendor/assets/src/medias/rubies/{examples → unstable}/!run.rb +0 -0
- /data/vendor/assets/src/medias/rubies/{examples → unstable}/_attach.rb +0 -0
- /data/vendor/assets/src/medias/rubies/{examples → unstable}/_os.rb +0 -0
- /data/vendor/assets/src/medias/rubies/{examples → unstable}/_test.rb +0 -0
@@ -1,40 +1,138 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
#
|
3
2
|
|
4
3
|
module Matrix
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
4
|
+
|
5
|
+
def matrix(params = {}, &bloc)
|
6
|
+
|
7
|
+
params = matrix_sanitizer(params)
|
8
|
+
|
9
|
+
columns_data = if params[:columns]
|
10
|
+
params.delete(:columns)
|
11
|
+
else
|
12
|
+
{ count: 4 }
|
13
|
+
end
|
14
|
+
|
15
|
+
rows_data = if params[:rows]
|
16
|
+
params.delete(:rows)
|
17
|
+
else
|
18
|
+
{ count: 4 }
|
19
|
+
end
|
20
|
+
|
21
|
+
cells_data = if params[:cells]
|
22
|
+
params.delete(:cells)
|
23
|
+
else
|
24
|
+
{ particles: { margin: 9, color: :lightgray } }
|
25
|
+
end
|
26
|
+
cells_color = cells_data[:particles].delete(:color)
|
27
|
+
# we grab Black matter to avoid coloring the view
|
28
|
+
cells_color_id = grab(:black_matter).color(cells_color).id
|
29
|
+
cells_shadow = cells_data[:particles].delete(:shadow)
|
30
|
+
cells_shadow_id = grab(:black_matter).shadow(cells_shadow).id
|
31
|
+
exceptions_data = params.delete(:exceptions)
|
32
|
+
default_renderer = Essentials.default_params[:render_engines]
|
33
|
+
atome_type = :matrix
|
34
|
+
# generated_render = params[:renderers] || default_renderer
|
35
|
+
# TODO: maybe change the code below and don't use identity_generator directly!!!
|
36
|
+
generated_id = params[:id] || identity_generator(:matrix)
|
37
|
+
params = atome_common(:matrix, params)
|
38
|
+
the_matrix = Atome.new(atome_type => params, &bloc)
|
39
|
+
|
40
|
+
# the_matrix = Atome.new(matrix: { type: :shape, id: :my_table, renderers: [:browser], parents: [] }, &bloc)
|
41
|
+
# example = Atome.new(code: { type: :code, renderers: [:headless], parents: [], children: [] })
|
42
|
+
# TODO: use the standard atome creation method (generator.build_atome(:collector)),
|
43
|
+
# TODO suite => For now its impossible to make it draggable because it return the created box not the matrix
|
44
|
+
# get necessary params
|
45
|
+
matrix_id = params[:id]
|
46
|
+
matrix_width = params[:width]
|
47
|
+
matrix_height = params[:height]
|
48
|
+
columns = columns_data[:count]
|
49
|
+
rows = rows_data[:count]
|
50
|
+
margin = cells_data[:particles].delete(:margin)
|
51
|
+
the_matrix.instance_variable_set('@columns', columns)
|
52
|
+
the_matrix.instance_variable_set('@rows', rows)
|
53
|
+
the_matrix.instance_variable_set('@margin', margin)
|
54
|
+
the_matrix.instance_variable_set('@cell_style', cells_data[:particles])
|
55
|
+
the_matrix.instance_variable_set('@matrix_width', matrix_width)
|
56
|
+
the_matrix.instance_variable_set('@matrix_height', matrix_height)
|
57
|
+
the_matrix.instance_variable_set('@cells', [])
|
58
|
+
rows = rows_data[:count]
|
59
|
+
columns = columns_data[:count]
|
60
|
+
|
61
|
+
# exceptions reorganisation
|
62
|
+
if exceptions_data
|
63
|
+
columns_exceptions = exceptions_data[:columns] ||= {}
|
64
|
+
columns_fusion_exceptions = columns_exceptions[:fusion] ||= {}
|
65
|
+
columns_divided_exceptions = columns_exceptions[:divided] ||= {}
|
66
|
+
rows_exceptions = exceptions_data[:rows] ||= {}
|
67
|
+
rows_fusion_exceptions = rows_exceptions[:fusion] ||= {}
|
68
|
+
rows_divided_exceptions = rows_exceptions[:divided] ||= {}
|
69
|
+
exceptions = { columns_fusion: columns_fusion_exceptions,
|
70
|
+
columns_divided: columns_divided_exceptions,
|
71
|
+
rows_fusion: rows_fusion_exceptions,
|
72
|
+
rows_divided: rows_divided_exceptions }
|
73
|
+
|
24
74
|
else
|
25
|
-
|
75
|
+
exceptions = {
|
76
|
+
columns_fusion: {},
|
77
|
+
columns_divided: {},
|
78
|
+
rows_fusion: {},
|
79
|
+
rows_divided: {}
|
80
|
+
}
|
81
|
+
|
82
|
+
end
|
83
|
+
the_matrix.instance_variable_set('@exceptions', exceptions)
|
84
|
+
|
85
|
+
# let's create the matrix background
|
86
|
+
# cells creation below
|
87
|
+
number_of_cells = rows * columns
|
88
|
+
number_of_cells.times do |index|
|
89
|
+
current_matrix = grab(matrix_id)
|
90
|
+
current_cell_id = "#{matrix_id}_#{index}"
|
91
|
+
current_cell = current_matrix.box({ id: current_cell_id })
|
92
|
+
the_matrix.instance_variable_set('@cell_style', cells_data[:particles])
|
93
|
+
current_matrix.instance_variable_get('@cells') << current_cell_id
|
94
|
+
|
95
|
+
current_cell.attached([cells_shadow_id])
|
96
|
+
current_cell.attached([cells_color_id])
|
97
|
+
apply_style(current_cell, cells_data[:particles])
|
98
|
+
|
26
99
|
end
|
100
|
+
# lets create the columns and rows
|
101
|
+
the_matrix.format_matrix(matrix_id, matrix_width, matrix_height, rows, columns, margin, exceptions)
|
102
|
+
|
103
|
+
the_matrix
|
104
|
+
end
|
105
|
+
|
106
|
+
def matrix_sanitizer(params)
|
107
|
+
|
108
|
+
default_params = {
|
109
|
+
|
110
|
+
left: 33, top: 33, width: 369, height: 369, smooth: 8, color: :gray,
|
111
|
+
columns: { count: 4 },
|
112
|
+
rows: { count: 4 },
|
113
|
+
cells: { particles: { margin: 9, color: :lightgray, smooth: 9, shadow: { blur: 9, left: 3, top: 3 } }
|
114
|
+
}
|
115
|
+
}
|
116
|
+
default_params.merge(params)
|
27
117
|
end
|
28
118
|
|
29
|
-
def cells(cell_nb)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
119
|
+
def cells(cell_nb, &proc)
|
120
|
+
if cell_nb
|
121
|
+
collected_atomes = []
|
122
|
+
cell_nb.each do |cell_found|
|
123
|
+
if cell_found.instance_of?(Integer)
|
124
|
+
cell_found = cells[cell_found]
|
125
|
+
collected_atomes << cell_found
|
126
|
+
else
|
127
|
+
collected_atomes << cell_found
|
128
|
+
end
|
129
|
+
end
|
130
|
+
instance_exec(collected_atomes, &proc) if proc.is_a?(Proc)
|
131
|
+
else
|
132
|
+
instance_exec(@cells, &proc) if proc.is_a?(Proc)
|
133
|
+
@cells
|
35
134
|
end
|
36
|
-
|
37
|
-
collector_object
|
135
|
+
|
38
136
|
end
|
39
137
|
|
40
138
|
def cell(cell_nb)
|
@@ -65,11 +163,6 @@ module Matrix
|
|
65
163
|
element({ data: cells_found })
|
66
164
|
end
|
67
165
|
|
68
|
-
# def ratio(val)
|
69
|
-
# puts "ratio must be : #{val}"
|
70
|
-
#
|
71
|
-
# end
|
72
|
-
|
73
166
|
def fusion(params)
|
74
167
|
number_of_cells = @columns * @rows
|
75
168
|
if params[:columns]
|
@@ -79,7 +172,7 @@ module Matrix
|
|
79
172
|
cells_in_column = get_column_or_row(number_of_cells, @columns, column_to_alter, true)
|
80
173
|
cells_to_alter = cells_in_column[value[0]..value[1]]
|
81
174
|
cells_to_alter.each_with_index do |cell_nb, index|
|
82
|
-
current_cell = grab("#{id
|
175
|
+
current_cell = grab("#{id}_#{cell_nb}")
|
83
176
|
if index.zero?
|
84
177
|
current_cell.height(cell_height * cells_to_alter.length + @margin * (cells_to_alter.length - 1))
|
85
178
|
else
|
@@ -95,7 +188,7 @@ module Matrix
|
|
95
188
|
cells_to_alter = cells_in_column[value[0]..value[1]]
|
96
189
|
|
97
190
|
cells_to_alter.each_with_index do |cell_nb, index|
|
98
|
-
current_cell = grab("#{id
|
191
|
+
current_cell = grab("#{id}_#{cell_nb}")
|
99
192
|
if index.zero?
|
100
193
|
current_cell.width(cell_width * cells_to_alter.length + @margin * (cells_to_alter.length - 1))
|
101
194
|
else
|
@@ -114,10 +207,10 @@ module Matrix
|
|
114
207
|
# we get the nth first element
|
115
208
|
cells_to_alter = cells_in_column.take(value)
|
116
209
|
cells_in_column.each_with_index do |cell_nb, index|
|
117
|
-
current_cell = grab("#{id
|
210
|
+
current_cell = grab("#{id}_#{cell_nb}")
|
118
211
|
if cells_to_alter.include?(cell_nb)
|
119
212
|
current_cell.height(@matrix_height / value - (@margin + value))
|
120
|
-
current_cell.top(current_cell.height
|
213
|
+
current_cell.top(current_cell.height * index + @margin * (index + 1))
|
121
214
|
else
|
122
215
|
current_cell.hide(true)
|
123
216
|
end
|
@@ -129,10 +222,10 @@ module Matrix
|
|
129
222
|
# we get the nth first element
|
130
223
|
cells_to_alter = cells_in_row.take(value)
|
131
224
|
cells_in_row.each_with_index do |cell_nb, index|
|
132
|
-
current_cell = grab("#{id
|
225
|
+
current_cell = grab("#{id}_#{cell_nb}")
|
133
226
|
if cells_to_alter.include?(cell_nb)
|
134
227
|
current_cell.width(@matrix_width / value - @margin - (@margin / value))
|
135
|
-
current_cell.left(current_cell.width
|
228
|
+
current_cell.left(current_cell.width * index + @margin * (index + 1))
|
136
229
|
else
|
137
230
|
current_cell.hide(true)
|
138
231
|
end
|
@@ -141,11 +234,6 @@ module Matrix
|
|
141
234
|
end
|
142
235
|
end
|
143
236
|
|
144
|
-
# def override(params)
|
145
|
-
# # TODO : allow fixed height ond fixed width when resizing
|
146
|
-
# puts "should override to allow fixed height or fixed width when resizing #{params}"
|
147
|
-
# end
|
148
|
-
|
149
237
|
def first(item, &proc)
|
150
238
|
if item[:columns]
|
151
239
|
columns(0, &proc)
|
@@ -173,9 +261,7 @@ module Matrix
|
|
173
261
|
x = (col_index + 1) * margin + col_index * cell_width
|
174
262
|
y = (row_index + 1) * margin + row_index * cell_height
|
175
263
|
current_cell = grab("#{matrix_id}_#{i}")
|
176
|
-
|
177
|
-
current_cell.children.each do |child|
|
178
|
-
# puts "=>#{cell_width}"
|
264
|
+
current_cell.materials.each do |child|
|
179
265
|
grab(child).width(cell_width) if grab(child)
|
180
266
|
grab(child).height(cell_width) if grab(child)
|
181
267
|
end
|
@@ -188,143 +274,15 @@ module Matrix
|
|
188
274
|
end
|
189
275
|
|
190
276
|
# exceptions management
|
191
|
-
|
192
|
-
number_of_cells = nb_of_rows * nb_of_cols
|
193
|
-
# columns exceptions
|
194
277
|
return unless exceptions
|
195
278
|
|
196
279
|
fusion({ columns: exceptions[:columns_fusion] }) if exceptions[:columns_fusion]
|
197
|
-
|
198
|
-
divide({ columns: exceptions[:columns_divided] }) if exceptions[:columns_divided]
|
199
|
-
divide({ rows: exceptions[:rows_divided] }) if exceptions[:rows_divided]
|
280
|
+
|
200
281
|
end
|
201
282
|
|
202
283
|
def apply_style(current_cell, style)
|
203
284
|
current_cell.set(style)
|
204
285
|
end
|
205
|
-
def matrix_sanitizer(params)
|
206
|
-
default_params = {
|
207
|
-
|
208
|
-
id: :my_table, left: 33, top: 33, width: 369, height: 369, smooth: 8, color: :gray,
|
209
|
-
columns: { count: 4 },
|
210
|
-
rows: { count: 4 },
|
211
|
-
cells: { particles: { margin: 9, color: :lightgray, smooth: 9, shadow: { blur: 9, left: 3, top: 3 } }
|
212
|
-
}
|
213
|
-
}
|
214
|
-
default_params.merge(params)
|
215
|
-
end
|
216
|
-
def matrix(params = {}, &bloc)
|
217
|
-
params= matrix_sanitizer(params)
|
218
|
-
columns_data = if params[:columns]
|
219
|
-
params.delete(:columns)
|
220
|
-
else
|
221
|
-
{ count: 4 }
|
222
|
-
end
|
223
|
-
|
224
|
-
rows_data = if params[:rows]
|
225
|
-
params.delete(:rows)
|
226
|
-
else
|
227
|
-
{ count: 4 }
|
228
|
-
end
|
229
|
-
|
230
|
-
cells_data = if params[:cells]
|
231
|
-
params.delete(:cells)
|
232
|
-
else
|
233
|
-
{ particles: { margin: 9, color: :lightgray } }
|
234
|
-
end
|
235
|
-
cells_color = cells_data[:particles].delete(:color)
|
236
|
-
cells_color_id = color(cells_color).id.value
|
237
|
-
|
238
|
-
cells_shadow = cells_data[:particles].delete(:shadow)
|
239
|
-
cells_shadow_id = shadow(cells_shadow).id.value
|
240
|
-
|
241
|
-
exceptions_data = params.delete(:exceptions)
|
242
|
-
default_renderer = Essentials.default_params[:render_engines]
|
243
|
-
atome_type = :matrix
|
244
|
-
generated_render = params[:renderers] || default_renderer
|
245
|
-
generated_id = params[:id] || identity_generator(:matrix)
|
246
|
-
|
247
|
-
generated_parents = params[:parents] || [id.value]
|
248
|
-
generated_children = params[:children] || []
|
249
|
-
params = atome_common(atome_type, generated_id, generated_render, generated_parents, generated_children, params)
|
250
|
-
the_matrix = Atome.new({ atome_type => params }, &bloc)
|
251
|
-
|
252
|
-
# TODO: use the standard atome creation method (generator.build_atome(:collector)),
|
253
|
-
# TODO suite => For now its impossible to make it draggable because it return the created box not the matrix
|
254
|
-
# get necessary params
|
255
|
-
matrix_id = params[:id]
|
256
|
-
matrix_width = params[:width]
|
257
|
-
matrix_height = params[:height]
|
258
|
-
columns = columns_data[:count]
|
259
|
-
rows = rows_data[:count]
|
260
|
-
margin = cells_data[:particles].delete(:margin)
|
261
|
-
the_matrix.instance_variable_set('@columns', columns)
|
262
|
-
the_matrix.instance_variable_set('@rows', rows)
|
263
|
-
the_matrix.instance_variable_set('@margin', margin)
|
264
|
-
the_matrix.instance_variable_set('@cell_style', cells_data[:particles])
|
265
|
-
the_matrix.instance_variable_set('@matrix_width', matrix_width)
|
266
|
-
the_matrix.instance_variable_set('@matrix_height', matrix_height)
|
267
|
-
|
268
|
-
rows = rows_data[:count]
|
269
|
-
columns = columns_data[:count]
|
270
|
-
# @rows = rows_data[:count]
|
271
|
-
# @columns = columns_data[:count]
|
272
|
-
# @margin = cells_data[:particles].delete(:margin)
|
273
|
-
# @cell_style = cells_data[:particles]
|
274
|
-
# @matrix_width = params[:width]
|
275
|
-
# @matrix_height = params[:height]
|
276
|
-
|
277
|
-
# exceptions reorganisation
|
278
|
-
if exceptions_data
|
279
|
-
columns_exceptions = exceptions_data[:columns] ||= {}
|
280
|
-
columns_fusion_exceptions = columns_exceptions[:fusion] ||= {}
|
281
|
-
columns_divided_exceptions = columns_exceptions[:divided] ||= {}
|
282
|
-
rows_exceptions = exceptions_data[:rows] ||= {}
|
283
|
-
rows_fusion_exceptions = rows_exceptions[:fusion] ||= {}
|
284
|
-
rows_divided_exceptions = rows_exceptions[:divided] ||= {}
|
285
|
-
exceptions = { columns_fusion: columns_fusion_exceptions,
|
286
|
-
columns_divided: columns_divided_exceptions,
|
287
|
-
rows_fusion: rows_fusion_exceptions,
|
288
|
-
rows_divided: rows_divided_exceptions }
|
289
|
-
# @exceptions = {
|
290
|
-
# columns_fusion: columns_fusion_exceptions,
|
291
|
-
# columns_divided: columns_divided_exceptions,
|
292
|
-
# rows_fusion: rows_fusion_exceptions,
|
293
|
-
# rows_divided: rows_divided_exceptions,
|
294
|
-
# }
|
295
|
-
else
|
296
|
-
exceptions = {
|
297
|
-
columns_fusion: {},
|
298
|
-
columns_divided: {},
|
299
|
-
rows_fusion: {},
|
300
|
-
rows_divided: {}
|
301
|
-
}
|
302
|
-
# @exceptions = {
|
303
|
-
# columns_fusion: {},
|
304
|
-
# columns_divided: {},
|
305
|
-
# rows_fusion: {},
|
306
|
-
# rows_divided: {},
|
307
|
-
# }
|
308
|
-
end
|
309
|
-
the_matrix.instance_variable_set('@exceptions', exceptions)
|
310
|
-
|
311
|
-
# let's create the matrix background
|
312
|
-
# current_matrix = grab(:view).box({ id: matrix_id })
|
313
|
-
# current_matrix.set(params[:matrix][:particles])
|
314
|
-
|
315
|
-
# cells creation below
|
316
|
-
number_of_cells = rows * columns
|
317
|
-
number_of_cells.times do |index|
|
318
|
-
current_cell = grab(matrix_id).box({ id: "#{matrix_id}_#{index}" })
|
319
|
-
the_matrix.instance_variable_set('@cell_style', cells_data[:particles])
|
320
|
-
current_cell.attached([cells_shadow_id])
|
321
|
-
current_cell.attached([cells_color_id])
|
322
|
-
apply_style(current_cell, cells_data[:particles])
|
323
|
-
end
|
324
|
-
# lets create the columns and rows
|
325
|
-
the_matrix.format_matrix(matrix_id, matrix_width, matrix_height, rows, columns, margin, exceptions)
|
326
|
-
the_matrix
|
327
|
-
end
|
328
286
|
|
329
287
|
def add_columns(nb)
|
330
288
|
prev_nb_of_cells = @columns * @rows
|
@@ -332,22 +290,12 @@ module Matrix
|
|
332
290
|
new_nb_of_cells = prev_nb_of_cells + nb_of_cells_to_adds
|
333
291
|
new_nb_of_cells.times do |index|
|
334
292
|
if index < prev_nb_of_cells
|
335
|
-
grab("#{id
|
336
|
-
# puts index
|
337
|
-
#
|
293
|
+
grab("#{id}_#{index}").delete(true)
|
338
294
|
end
|
339
295
|
current_cell = box({ id: "#{id}_#{index}" })
|
340
296
|
apply_style(current_cell, @cell_style)
|
341
297
|
end
|
342
298
|
@columns += nb
|
343
|
-
########## old algo
|
344
|
-
# nb_of_cells_to_adds = nb * @rows
|
345
|
-
# prev_nb_of_cells = @columns * @rows
|
346
|
-
# nb_of_cells_to_adds.times do |index|
|
347
|
-
# current_cell = self.box({ id: "#{id}_#{prev_nb_of_cells + index}" })
|
348
|
-
# apply_style(current_cell, @cell_style)
|
349
|
-
# end
|
350
|
-
# @columns = @columns + nb
|
351
299
|
format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
|
352
300
|
end
|
353
301
|
|
@@ -357,35 +305,24 @@ module Matrix
|
|
357
305
|
new_nb_of_cells = prev_nb_of_cells + nb_of_cells_to_adds
|
358
306
|
new_nb_of_cells.times do |index|
|
359
307
|
if index < prev_nb_of_cells
|
360
|
-
grab("#{id
|
361
|
-
# puts index
|
362
|
-
#
|
308
|
+
grab("#{id}_#{index}").delete(true)
|
363
309
|
end
|
364
310
|
current_cell = box({ id: "#{id}_#{index}" })
|
365
311
|
apply_style(current_cell, @cell_style)
|
366
312
|
end
|
367
313
|
@rows += nb
|
368
|
-
########## old algo
|
369
|
-
# nb_of_cells_to_adds = nb * @columns
|
370
|
-
# prev_nb_of_cells = @columns * @rows
|
371
|
-
# nb_of_cells_to_adds.times do |index|
|
372
|
-
# current_cell = self.box({ id: "#{id}_#{prev_nb_of_cells + index}" })
|
373
|
-
# apply_style(current_cell, @cell_style)
|
374
|
-
# end
|
375
|
-
# @rows = @rows + nb
|
376
314
|
format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
|
377
315
|
end
|
378
316
|
|
379
317
|
def resize(width, height)
|
380
318
|
@matrix_width = width
|
381
319
|
@matrix_height = height
|
382
|
-
grab(id
|
383
|
-
grab(id
|
320
|
+
grab(id).width(width)
|
321
|
+
grab(id).height(height)
|
384
322
|
format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
|
385
323
|
end
|
386
324
|
|
387
325
|
def get_column_or_row(length, num_columns, index, is_column)
|
388
|
-
# puts "length: #{length}, #{num_columns} : #{num_columns}, index : #{index}, is_column : #{is_column}"
|
389
326
|
# Compute the number of line
|
390
327
|
num_rows = length / num_columns
|
391
328
|
if is_column
|
@@ -405,3 +342,5 @@ end
|
|
405
342
|
class Atome
|
406
343
|
include Matrix
|
407
344
|
end
|
345
|
+
|
346
|
+
|
@@ -1,138 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
new({ atome: :color, type: :hash })
|
4
3
|
|
5
4
|
new({ sanitizer: :color }) do |params|
|
6
|
-
|
7
|
-
if parent_found == [:black_matter]
|
8
|
-
|
9
|
-
elsif color.value
|
10
|
-
# we delete any previous color if there's one
|
11
|
-
detached(color.value)
|
12
|
-
grab(color.value)&.delete(true) # we had the condition because the color may exist but
|
13
|
-
# so it is not sanitized so it has no id
|
14
|
-
end
|
15
|
-
|
16
|
-
render_found = found_parents_and_renderers[:renderers]
|
17
|
-
generated_id = params[:id] || identity_generator(:color)
|
18
|
-
|
19
|
-
default_params = { renderers: render_found, id: generated_id, type: :color,
|
20
|
-
attach: parent_found,
|
21
|
-
red: 0, green: 0, blue: 0, alpha: 1 }
|
5
|
+
# TODO : when attaching color to a shadow it should colorized it , cf : c.shadow({color: :blue}) should work
|
22
6
|
params = create_color_hash(params) unless params.instance_of? Hash
|
23
|
-
|
24
|
-
atome[:color] = new_params[:id]
|
25
|
-
new_params
|
7
|
+
params
|
26
8
|
end
|
27
9
|
|
28
10
|
new({ atome: :image })
|
29
11
|
new({ sanitizer: :image }) do |params|
|
30
12
|
unless params.instance_of? Hash
|
31
13
|
# TODO : we have to convert all image to png or maintain a database with extension
|
14
|
+
# FIXME : temporary patch that add .png to the string if no extension is found
|
15
|
+
if params.split('.').length == 1
|
16
|
+
params = "#{params}.png"
|
17
|
+
end
|
18
|
+
|
32
19
|
params = { path: "./medias/images/#{params}" }
|
33
20
|
end
|
34
|
-
default_renderer = Essentials.default_params[:render_engines]
|
35
|
-
generated_id = params[:id] || identity_generator(:image)
|
36
|
-
|
37
|
-
generated_render = params[:renderers] || default_renderer
|
38
|
-
generated_parents = params[:parents] || id.value
|
39
21
|
# TODO : the line below should get the value from default params Essentials
|
40
|
-
temp_default = { renderers: generated_render, id: generated_id, type: :image, parents: [generated_parents],
|
41
|
-
children: [], width: 99, height: 99, path: './medias/images/atome.svg' }
|
42
|
-
params = temp_default.merge(params)
|
43
22
|
params
|
44
23
|
end
|
45
24
|
new({ atome: :video })
|
46
|
-
new({ sanitizer: :video }) do |params|
|
47
|
-
parent_found = found_parents_and_renderers[:parent]
|
48
|
-
render_found = found_parents_and_renderers[:renderers]
|
49
|
-
generated_id = params[:id] || identity_generator(:video)
|
50
25
|
|
51
|
-
|
52
|
-
parents: parent_found }
|
53
|
-
default_params.merge!(params)
|
54
|
-
end
|
55
|
-
new({ atome: :shadow })
|
26
|
+
new({ atome: :shadow, type: :hash })
|
56
27
|
new({ sanitizer: :shadow }) do |params|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
parent_found = [:black_matter] if parent_found == [:view]
|
61
|
-
elsif shadow.value
|
62
|
-
# we delete any previous color if there's one
|
63
|
-
detached(shadow.value)
|
64
|
-
grab(shadow.value)&.delete(true) # we had the condition because the shadow may exist but
|
65
|
-
# so it is not sanitized so it has no id
|
66
|
-
end
|
67
|
-
## we delete any previous shadow if there's one
|
68
|
-
# if shadow.value
|
69
|
-
# attached.value.delete(shadow.value)
|
70
|
-
# grab(shadow.value)&.delete(true) # we had the condition because the color may exist but
|
71
|
-
# # so it is not sanitized so it has no id
|
72
|
-
# end
|
73
|
-
# parent_found = found_parents_and_renderers[:parent]
|
74
|
-
# parent_found = [:user_view] if parent_found == [:view]
|
75
|
-
render_found = found_parents_and_renderers[:renderers]
|
76
|
-
generated_id = params[:id] || identity_generator(:shadow)
|
77
|
-
|
78
|
-
default_params = { renderers: render_found, id: generated_id, type: :shadow,
|
79
|
-
attach: parent_found,
|
80
|
-
red: 0, green: 0, blue: 0, alpha: 1, blur: 3, left: 3, top: 3 }
|
81
|
-
# default_params.merge!(params)
|
82
|
-
params = create_shadow_hash(params) unless params.instance_of? Hash
|
28
|
+
# TODO : when attaching color to a shadow it should colorised it , cf : c.shadow({color: :blue}) should work
|
29
|
+
params = {} unless params.instance_of? Hash
|
30
|
+
default_params = { red: 0, green: 0, blue: 0, alpha: 1, blur: 3, left: 3, top: 3 }
|
83
31
|
new_params = default_params.merge!(params)
|
84
|
-
atome[:shadow] = new_params
|
85
32
|
new_params
|
86
|
-
|
87
33
|
end
|
88
34
|
new({ atome: :shape })
|
89
35
|
new({ atome: :code })
|
90
36
|
new({ atome: :audio })
|
91
37
|
new({ atome: :element })
|
92
38
|
new({ sanitizer: :element }) do |params|
|
93
|
-
|
94
|
-
render_found = []
|
95
|
-
generated_id = params[:id] || identity_generator(:element)
|
96
|
-
|
97
|
-
default_params = { renderers: render_found, id: generated_id, type: :element,
|
98
|
-
parents: parent_found, data: '' }
|
39
|
+
default_params = { data: '' }
|
99
40
|
default_params.merge!(params)
|
100
41
|
end
|
101
42
|
new({ atome: :web })
|
102
43
|
new({ sanitizer: :web }) do |params|
|
103
|
-
default_renderer = Essentials.default_params[:render_engines]
|
104
|
-
generated_id = params[:id] || identity_generator(:web)
|
105
|
-
|
106
|
-
generated_render = params[:renderers] || default_renderer
|
107
|
-
generated_parents = params[:parents] || id.value
|
108
44
|
# TODO : the line below should get the value from default params Essentials
|
109
|
-
temp_default = {
|
110
|
-
children: [], width: 120, height: 120, path: 'https://www.youtube.com/embed/usQDazZKWAk' }
|
45
|
+
temp_default = { path: 'https://www.youtube.com/embed/usQDazZKWAk' }
|
111
46
|
params = temp_default.merge(params)
|
112
47
|
params
|
113
48
|
end
|
114
49
|
new({ atome: :collector })
|
115
50
|
new({ atome: :animation })
|
116
|
-
new({ sanitizer: :animation }) do |params|
|
117
|
-
default_renderer = Essentials.default_params[:render_engines]
|
118
|
-
atome_type = :animation
|
119
|
-
generated_render = params[:renderers] || default_renderer
|
120
|
-
generated_id = params[:id] || identity_generator(atome_type)
|
121
|
-
generated_parents = params[:parents] || []
|
122
|
-
generated_children = params[:children] || []
|
123
|
-
params = atome_common(atome_type, generated_id, generated_render, generated_parents, generated_children, params)
|
124
|
-
params
|
125
|
-
end
|
126
51
|
new({ atome: :text, type: :hash })
|
127
52
|
new({ sanitizer: :text }) do |params|
|
128
53
|
params = { data: params } unless params.instance_of? Hash
|
129
|
-
default_renderer = Essentials.default_params[:render_engines]
|
130
|
-
atome_type = :text
|
131
|
-
generated_render = params[:renderers] || default_renderer
|
132
|
-
generated_id = params[:id] || identity_generator(atome_type)
|
133
|
-
generated_parents = params[:parents] || [id.value]
|
134
|
-
generated_children = params[:children] || []
|
135
|
-
params = atome_common(atome_type, generated_id, generated_render, generated_parents, generated_children, params)
|
136
54
|
params
|
137
55
|
end
|
138
|
-
|