atome 0.5.3.8.8 → 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 +43 -57
- data/lib/atome/extensions/atome.rb +82 -52
- data/lib/atome/extensions/mathematic.rb +8 -12
- data/lib/atome/extensions/matrix.rb +138 -210
- data/lib/atome/genesis/generators/atome.rb +8 -134
- 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 +6 -33
- data/lib/atome/genesis/generators/material.rb +3 -54
- data/lib/atome/genesis/generators/utility.rb +63 -58
- data/lib/atome/genesis/genesis.rb +8 -0
- data/lib/atome/genesis/sparkle.rb +35 -16
- data/lib/atome/helpers/callbacks.rb +47 -1
- data/lib/atome/helpers/essentials.rb +1 -1
- data/lib/atome/helpers/sanitizer.rb +0 -10
- data/lib/atome/helpers/utilities.rb +74 -28
- data/lib/atome/kernel/batch.rb +13 -35
- data/lib/atome/kernel/universe.rb +2 -0
- data/lib/atome/presets/atome.rb +4 -12
- data/lib/atome/renderers/browser/atome.rb +1 -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/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 +5 -1
- data/lib/atome/renderers/browser/spatial.rb +3 -2
- data/lib/atome/renderers/browser/utility.rb +7 -7
- data/lib/atome/version.rb +2 -2
- data/lib/atome.rb +1 -0
- data/sig/atome.rbs +16 -0
- data/sig/batch.rbs +7 -0
- data/sig/browser_helper.rbs +14 -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/rubies/demos.rb +63 -0
- data/vendor/assets/src/medias/rubies/examples/add.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/animation.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/atome_new.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/attach.rb +10 -10
- data/vendor/assets/src/medias/rubies/examples/attached.rb +2 -3
- 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 +3 -3
- data/vendor/assets/src/medias/rubies/examples/delete.rb +17 -1
- data/vendor/assets/src/medias/rubies/examples/detached.rb +3 -3
- data/vendor/assets/src/medias/rubies/examples/drag.rb +52 -1
- data/vendor/assets/src/medias/rubies/examples/drop.rb +26 -0
- data/vendor/assets/src/medias/rubies/examples/fullscreen.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/markers.rb +1 -1
- data/vendor/assets/src/medias/rubies/examples/matrix.rb +102 -0
- 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 +1 -1
- 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/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 +2 -2
- data/vendor/assets/src/medias/rubies/examples/video.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/{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 +32 -14
- 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}/_matrix.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,39 +1,138 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Matrix
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
+
|
23
74
|
else
|
24
|
-
|
75
|
+
exceptions = {
|
76
|
+
columns_fusion: {},
|
77
|
+
columns_divided: {},
|
78
|
+
rows_fusion: {},
|
79
|
+
rows_divided: {}
|
80
|
+
}
|
81
|
+
|
25
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
|
+
|
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
|
26
104
|
end
|
27
105
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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)
|
117
|
+
end
|
118
|
+
|
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
|
34
134
|
end
|
35
|
-
|
36
|
-
collector_object
|
135
|
+
|
37
136
|
end
|
38
137
|
|
39
138
|
def cell(cell_nb)
|
@@ -64,11 +163,6 @@ module Matrix
|
|
64
163
|
element({ data: cells_found })
|
65
164
|
end
|
66
165
|
|
67
|
-
# def ratio(val)
|
68
|
-
# puts "ratio must be : #{val}"
|
69
|
-
#
|
70
|
-
# end
|
71
|
-
|
72
166
|
def fusion(params)
|
73
167
|
number_of_cells = @columns * @rows
|
74
168
|
if params[:columns]
|
@@ -78,8 +172,7 @@ module Matrix
|
|
78
172
|
cells_in_column = get_column_or_row(number_of_cells, @columns, column_to_alter, true)
|
79
173
|
cells_to_alter = cells_in_column[value[0]..value[1]]
|
80
174
|
cells_to_alter.each_with_index do |cell_nb, index|
|
81
|
-
current_cell = grab("#{id
|
82
|
-
# puts "==> current cell is #{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,7 +261,6 @@ 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
|
-
# puts current_cell
|
177
264
|
current_cell.materials.each do |child|
|
178
265
|
grab(child).width(cell_width) if grab(child)
|
179
266
|
grab(child).height(cell_width) if grab(child)
|
@@ -187,176 +274,28 @@ module Matrix
|
|
187
274
|
end
|
188
275
|
|
189
276
|
# exceptions management
|
190
|
-
|
191
|
-
# number_of_cells = nb_of_rows * nb_of_cols
|
192
|
-
# columns exceptions
|
193
|
-
# return
|
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
286
|
|
206
|
-
def matrix_sanitizer(params)
|
207
|
-
default_params = {
|
208
|
-
|
209
|
-
id: :my_table, left: 33, top: 33, width: 369, height: 369, smooth: 8, color: :gray,
|
210
|
-
columns: { count: 4 },
|
211
|
-
rows: { count: 4 },
|
212
|
-
cells: { particles: { margin: 9, color: :lightgray, smooth: 9, shadow: { blur: 9, left: 3, top: 3 } }
|
213
|
-
}
|
214
|
-
}
|
215
|
-
default_params.merge(params)
|
216
|
-
end
|
217
|
-
|
218
|
-
def matrix(params = {}, &bloc)
|
219
|
-
params = matrix_sanitizer(params)
|
220
|
-
|
221
|
-
columns_data = if params[:columns]
|
222
|
-
params.delete(:columns)
|
223
|
-
else
|
224
|
-
{ count: 4 }
|
225
|
-
end
|
226
|
-
|
227
|
-
rows_data = if params[:rows]
|
228
|
-
params.delete(:rows)
|
229
|
-
else
|
230
|
-
{ count: 4 }
|
231
|
-
end
|
232
|
-
|
233
|
-
cells_data = if params[:cells]
|
234
|
-
params.delete(:cells)
|
235
|
-
else
|
236
|
-
{ particles: { margin: 9, color: :lightgray } }
|
237
|
-
end
|
238
|
-
cells_color = cells_data[:particles].delete(:color)
|
239
|
-
cells_color_id = color(cells_color).id.value
|
240
|
-
|
241
|
-
cells_shadow = cells_data[:particles].delete(:shadow)
|
242
|
-
cells_shadow_id = shadow(cells_shadow).id.value
|
243
|
-
|
244
|
-
exceptions_data = params.delete(:exceptions)
|
245
|
-
default_renderer = Essentials.default_params[:render_engines]
|
246
|
-
atome_type = :matrix
|
247
|
-
# generated_render = params[:renderers] || default_renderer
|
248
|
-
generated_id = params[:id] || identity_generator(:matrix)
|
249
|
-
#
|
250
|
-
# generated_parents = params[:parents] || [id.value]
|
251
|
-
# generated_children = params[:shape] || []
|
252
|
-
# params = atome_common(atome_type, params)
|
253
|
-
params = atome_common(:matrix, params)
|
254
|
-
# puts "====>#{params} #{params.class}"
|
255
|
-
the_matrix = Atome.new( atome_type => params , &bloc)
|
256
|
-
# the_matrix = Atome.new(matrix: { type: :shape, id: :my_table, renderers: [:browser], parents: [] }, &bloc)
|
257
|
-
# example = Atome.new(code: { type: :code, renderers: [:headless], parents: [], children: [] })
|
258
|
-
# TODO: use the standard atome creation method (generator.build_atome(:collector)),
|
259
|
-
# TODO suite => For now its impossible to make it draggable because it return the created box not the matrix
|
260
|
-
# get necessary params
|
261
|
-
matrix_id = params[:id]
|
262
|
-
matrix_width = params[:width]
|
263
|
-
matrix_height = params[:height]
|
264
|
-
columns = columns_data[:count]
|
265
|
-
rows = rows_data[:count]
|
266
|
-
margin = cells_data[:particles].delete(:margin)
|
267
|
-
the_matrix.instance_variable_set('@columns', columns)
|
268
|
-
the_matrix.instance_variable_set('@rows', rows)
|
269
|
-
the_matrix.instance_variable_set('@margin', margin)
|
270
|
-
the_matrix.instance_variable_set('@cell_style', cells_data[:particles])
|
271
|
-
the_matrix.instance_variable_set('@matrix_width', matrix_width)
|
272
|
-
the_matrix.instance_variable_set('@matrix_height', matrix_height)
|
273
|
-
|
274
|
-
rows = rows_data[:count]
|
275
|
-
columns = columns_data[:count]
|
276
|
-
# @rows = rows_data[:count]
|
277
|
-
# @columns = columns_data[:count]
|
278
|
-
# @margin = cells_data[:particles].delete(:margin)
|
279
|
-
# @cell_style = cells_data[:particles]
|
280
|
-
# @matrix_width = params[:width]
|
281
|
-
# @matrix_height = params[:height]
|
282
|
-
|
283
|
-
# exceptions reorganisation
|
284
|
-
if exceptions_data
|
285
|
-
columns_exceptions = exceptions_data[:columns] ||= {}
|
286
|
-
columns_fusion_exceptions = columns_exceptions[:fusion] ||= {}
|
287
|
-
columns_divided_exceptions = columns_exceptions[:divided] ||= {}
|
288
|
-
rows_exceptions = exceptions_data[:rows] ||= {}
|
289
|
-
rows_fusion_exceptions = rows_exceptions[:fusion] ||= {}
|
290
|
-
rows_divided_exceptions = rows_exceptions[:divided] ||= {}
|
291
|
-
exceptions = { columns_fusion: columns_fusion_exceptions,
|
292
|
-
columns_divided: columns_divided_exceptions,
|
293
|
-
rows_fusion: rows_fusion_exceptions,
|
294
|
-
rows_divided: rows_divided_exceptions }
|
295
|
-
# @exceptions = {
|
296
|
-
# columns_fusion: columns_fusion_exceptions,
|
297
|
-
# columns_divided: columns_divided_exceptions,
|
298
|
-
# rows_fusion: rows_fusion_exceptions,
|
299
|
-
# rows_divided: rows_divided_exceptions,
|
300
|
-
# }
|
301
|
-
else
|
302
|
-
exceptions = {
|
303
|
-
columns_fusion: {},
|
304
|
-
columns_divided: {},
|
305
|
-
rows_fusion: {},
|
306
|
-
rows_divided: {}
|
307
|
-
}
|
308
|
-
# @exceptions = {
|
309
|
-
# columns_fusion: {},
|
310
|
-
# columns_divided: {},
|
311
|
-
# rows_fusion: {},
|
312
|
-
# rows_divided: {},
|
313
|
-
# }
|
314
|
-
end
|
315
|
-
the_matrix.instance_variable_set('@exceptions', exceptions)
|
316
|
-
|
317
|
-
# let's create the matrix background
|
318
|
-
# current_matrix = grab(:view).box({ id: matrix_id })
|
319
|
-
# current_matrix.set(params[:matrix][:particles])
|
320
|
-
|
321
|
-
# cells creation below
|
322
|
-
number_of_cells = rows * columns
|
323
|
-
number_of_cells.times do |index|
|
324
|
-
current_cell = grab(matrix_id).box({ id: "#{matrix_id}_#{index}" })
|
325
|
-
the_matrix.instance_variable_set('@cell_style', cells_data[:particles])
|
326
|
-
current_cell.attached([cells_shadow_id])
|
327
|
-
current_cell.attached([cells_color_id])
|
328
|
-
apply_style(current_cell, cells_data[:particles])
|
329
|
-
end
|
330
|
-
# lets create the columns and rows
|
331
|
-
|
332
|
-
# puts "(#{matrix_id}, #{matrix_width}, #{matrix_height}, #{rows}, #{columns}, #{margin}, #{exceptions})"
|
333
|
-
the_matrix.format_matrix(matrix_id, matrix_width, matrix_height, rows, columns, margin, exceptions)
|
334
|
-
|
335
|
-
the_matrix
|
336
|
-
end
|
337
|
-
|
338
287
|
def add_columns(nb)
|
339
288
|
prev_nb_of_cells = @columns * @rows
|
340
289
|
nb_of_cells_to_adds = nb * @rows
|
341
290
|
new_nb_of_cells = prev_nb_of_cells + nb_of_cells_to_adds
|
342
291
|
new_nb_of_cells.times do |index|
|
343
292
|
if index < prev_nb_of_cells
|
344
|
-
grab("#{id
|
345
|
-
# puts index
|
346
|
-
#
|
293
|
+
grab("#{id}_#{index}").delete(true)
|
347
294
|
end
|
348
295
|
current_cell = box({ id: "#{id}_#{index}" })
|
349
296
|
apply_style(current_cell, @cell_style)
|
350
297
|
end
|
351
298
|
@columns += nb
|
352
|
-
########## old algo
|
353
|
-
# nb_of_cells_to_adds = nb * @rows
|
354
|
-
# prev_nb_of_cells = @columns * @rows
|
355
|
-
# nb_of_cells_to_adds.times do |index|
|
356
|
-
# current_cell = self.box({ id: "#{id}_#{prev_nb_of_cells + index}" })
|
357
|
-
# apply_style(current_cell, @cell_style)
|
358
|
-
# end
|
359
|
-
# @columns = @columns + nb
|
360
299
|
format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
|
361
300
|
end
|
362
301
|
|
@@ -366,35 +305,24 @@ module Matrix
|
|
366
305
|
new_nb_of_cells = prev_nb_of_cells + nb_of_cells_to_adds
|
367
306
|
new_nb_of_cells.times do |index|
|
368
307
|
if index < prev_nb_of_cells
|
369
|
-
grab("#{id
|
370
|
-
# puts index
|
371
|
-
#
|
308
|
+
grab("#{id}_#{index}").delete(true)
|
372
309
|
end
|
373
310
|
current_cell = box({ id: "#{id}_#{index}" })
|
374
311
|
apply_style(current_cell, @cell_style)
|
375
312
|
end
|
376
313
|
@rows += nb
|
377
|
-
########## old algo
|
378
|
-
# nb_of_cells_to_adds = nb * @columns
|
379
|
-
# prev_nb_of_cells = @columns * @rows
|
380
|
-
# nb_of_cells_to_adds.times do |index|
|
381
|
-
# current_cell = self.box({ id: "#{id}_#{prev_nb_of_cells + index}" })
|
382
|
-
# apply_style(current_cell, @cell_style)
|
383
|
-
# end
|
384
|
-
# @rows = @rows + nb
|
385
314
|
format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
|
386
315
|
end
|
387
316
|
|
388
317
|
def resize(width, height)
|
389
318
|
@matrix_width = width
|
390
319
|
@matrix_height = height
|
391
|
-
grab(id
|
392
|
-
grab(id
|
320
|
+
grab(id).width(width)
|
321
|
+
grab(id).height(height)
|
393
322
|
format_matrix(id, @matrix_width, @matrix_height, @rows, @columns, @margin, @exceptions)
|
394
323
|
end
|
395
324
|
|
396
325
|
def get_column_or_row(length, num_columns, index, is_column)
|
397
|
-
# puts "length: #{length}, #{num_columns} : #{num_columns}, index : #{index}, is_column : #{is_column}"
|
398
326
|
# Compute the number of line
|
399
327
|
num_rows = length / num_columns
|
400
328
|
if is_column
|
@@ -1,136 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
2
|
new({ atome: :color, type: :hash })
|
4
3
|
|
5
4
|
new({ sanitizer: :color }) do |params|
|
6
5
|
# TODO : when attaching color to a shadow it should colorized it , cf : c.shadow({color: :blue}) should work
|
7
|
-
# parent_found = found_parents_and_renderers[:parent]
|
8
|
-
# if parent_found == [:view]
|
9
|
-
# parent_found = [:black_matter] if parent_found == [:view]
|
10
|
-
# elsif color.value
|
11
|
-
# # we delete any previous color if there's one
|
12
|
-
# # puts "========= #{@atome[:color]}>We should delete the color now except : #{@atome[:add]} "
|
13
|
-
# unless @atome[:add] && @atome[:add][:color]
|
14
|
-
# detached(color.value)
|
15
|
-
# @atome[:color] = [] # we had the condition because the shadow may exist but
|
16
|
-
# end
|
17
|
-
# end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# puts "---> :: #{@atome[:add]}"
|
23
|
-
## we delete any previous shadow if there's one
|
24
|
-
# if color.value
|
25
|
-
# puts 'We should delete now'
|
26
|
-
# attached.value.delete(color.value)
|
27
|
-
# grab(color.value)&.delete(true) # we had the condition because the color may exist but
|
28
|
-
# # so it is not sanitized so it has no id
|
29
|
-
# end
|
30
|
-
# parent_found = found_parents_and_renderers[:parent]
|
31
|
-
# parent_found = [:user_view] if parent_found == [:view]
|
32
|
-
# render_found = found_parents_and_renderers[:renderers]
|
33
|
-
# generated_id = params[:id] || identity_generator(:color)
|
34
|
-
|
35
|
-
# default_params = { red: 0, green: 0, blue: 0, alpha: 1 }
|
36
6
|
params = create_color_hash(params) unless params.instance_of? Hash
|
37
|
-
# new_params = default_params.merge!(params)
|
38
|
-
# atome[:color] = [new_params[:id]]
|
39
|
-
# test below
|
40
|
-
# atome[:color] = [:poil]
|
41
|
-
# puts "==> #{color.value}"
|
42
|
-
# test above
|
43
|
-
# new_params
|
44
|
-
# atome[:color] << :poil
|
45
|
-
# params={}
|
46
|
-
#
|
47
7
|
params
|
48
8
|
end
|
49
9
|
|
50
|
-
# new({ sanitizer: :color }) do |params|
|
51
|
-
# parent_found = found_parents_and_renderers[:parent]
|
52
|
-
# # puts "'''''code_below_is_not_executed'''''"
|
53
|
-
# if parent_found == [:black_matter]
|
54
|
-
# alert :stop_get_out_we_are_the_strong_arm_of_the_law
|
55
|
-
# elsif color.value
|
56
|
-
# puts ">>> Code_below_is_not_executed : #{self}"
|
57
|
-
# # we delete any previous color if there's one
|
58
|
-
# # detached(color.value)
|
59
|
-
# grab(color.value)&.delete(true) # we had the condition because the color may exist but
|
60
|
-
# # so it is not sanitized so it has no id
|
61
|
-
# end
|
62
|
-
#
|
63
|
-
# render_found = found_parents_and_renderers[:renderers]
|
64
|
-
# generated_id = params[:id] || identity_generator(:color)
|
65
|
-
#
|
66
|
-
# default_params = { renderers: render_found, id: generated_id, type: :color,
|
67
|
-
# attach: parent_found,
|
68
|
-
# red: 0, green: 0, blue: 0, alpha: 1 }
|
69
|
-
# params = create_color_hash(params) unless params.instance_of? Hash
|
70
|
-
# new_params = default_params.merge!(params)
|
71
|
-
# new_params
|
72
|
-
# end
|
73
|
-
|
74
10
|
new({ atome: :image })
|
75
11
|
new({ sanitizer: :image }) do |params|
|
76
12
|
unless params.instance_of? Hash
|
77
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
|
+
|
78
19
|
params = { path: "./medias/images/#{params}" }
|
79
20
|
end
|
80
|
-
#
|
81
|
-
# generated_id = params[:id] || identity_generator(:image)
|
82
|
-
#
|
83
|
-
# generated_render = params[:renderers] || default_renderer
|
84
|
-
# generated_parents = params[:attach] || id.value
|
85
|
-
# # TODO : the line below should get the value from default params Essentials
|
86
|
-
# temp_default = { renderers: generated_render, id: generated_id, type: :image, attach: [generated_parents],
|
87
|
-
# width: 99, height: 99, path: './medias/images/atome.svg' }
|
88
|
-
# params = temp_default.merge(params)
|
21
|
+
# TODO : the line below should get the value from default params Essentials
|
89
22
|
params
|
90
23
|
end
|
91
24
|
new({ atome: :video })
|
92
|
-
|
93
|
-
# parent_found = found_parents_and_renderers[:parent]
|
94
|
-
# render_found = found_parents_and_renderers[:renderers]
|
95
|
-
# generated_id = params[:id] || identity_generator(:video)
|
96
|
-
#
|
97
|
-
# default_params = { renderers: render_found, id: generated_id, type: :video,
|
98
|
-
# attach: parent_found }
|
99
|
-
# default_params.merge!(params)
|
100
|
-
# end
|
25
|
+
|
101
26
|
new({ atome: :shadow, type: :hash })
|
102
27
|
new({ sanitizer: :shadow }) do |params|
|
103
28
|
# TODO : when attaching color to a shadow it should colorised it , cf : c.shadow({color: :blue}) should work
|
104
|
-
# puts "############################{params}###{test}###{test2}##################################"
|
105
29
|
params = {} unless params.instance_of? Hash
|
106
|
-
|
107
|
-
# if parent_found == [:view]
|
108
|
-
# parent_found = [:black_matter] if parent_found == [:view]
|
109
|
-
# elsif shadow.value
|
110
|
-
# # we delete any previous color if there's one
|
111
|
-
# detached(shadow.value)
|
112
|
-
# grab(shadow.value)&.delete(true) # we had the condition because the shadow may exist but
|
113
|
-
# end
|
114
|
-
## we delete any previous shadow if there's one
|
115
|
-
# if shadow.value
|
116
|
-
# attached.value.delete(shadow.value)
|
117
|
-
# grab(shadow.value)&.delete(true) # we had the condition because the color may exist but
|
118
|
-
# # so it is not sanitized so it has no id
|
119
|
-
# end
|
120
|
-
# parent_found = found_parents_and_renderers[:parent]
|
121
|
-
# parent_found = [:user_view] if parent_found == [:view]
|
122
|
-
# render_found = found_parents_and_renderers[:renderers]
|
123
|
-
# generated_id = params[:id] || identity_generator(:shadow)
|
124
|
-
|
125
|
-
# default_params = { renderers: render_found, id: generated_id, type: :shadow,
|
126
|
-
# attach: parent_found,
|
127
|
-
# red: 0, green: 0, blue: 0, alpha: 1, blur: 3, left: 3, top: 3 }
|
128
|
-
|
129
|
-
|
130
|
-
default_params = {red: 0, green: 0, blue: 0, alpha: 1, blur: 3, left: 3, top: 3 }
|
131
|
-
|
30
|
+
default_params = { red: 0, green: 0, blue: 0, alpha: 1, blur: 3, left: 3, top: 3 }
|
132
31
|
new_params = default_params.merge!(params)
|
133
|
-
# atome[:shadow] = [new_params[:id]]
|
134
32
|
new_params
|
135
33
|
end
|
136
34
|
new({ atome: :shape })
|
@@ -138,20 +36,11 @@ new({ atome: :code })
|
|
138
36
|
new({ atome: :audio })
|
139
37
|
new({ atome: :element })
|
140
38
|
new({ sanitizer: :element }) do |params|
|
141
|
-
# parent_found = found_parents_and_renderers[:parent]
|
142
|
-
# render_found = []
|
143
|
-
# generated_id = params[:id] || identity_generator(:element)
|
144
|
-
|
145
39
|
default_params = { data: '' }
|
146
40
|
default_params.merge!(params)
|
147
41
|
end
|
148
42
|
new({ atome: :web })
|
149
43
|
new({ sanitizer: :web }) do |params|
|
150
|
-
# default_renderer = Essentials.default_params[:render_engines]
|
151
|
-
# generated_id = params[:id] || identity_generator(:web)
|
152
|
-
#
|
153
|
-
# generated_render = params[:renderers] || default_renderer
|
154
|
-
# generated_parents = params[:attach] || id.value
|
155
44
|
# TODO : the line below should get the value from default params Essentials
|
156
45
|
temp_default = { path: 'https://www.youtube.com/embed/usQDazZKWAk' }
|
157
46
|
params = temp_default.merge(params)
|
@@ -159,23 +48,8 @@ new({ sanitizer: :web }) do |params|
|
|
159
48
|
end
|
160
49
|
new({ atome: :collector })
|
161
50
|
new({ atome: :animation })
|
162
|
-
# new({ sanitizer: :animation }) do |params|
|
163
|
-
# default_renderer = Essentials.default_params[:render_engines]
|
164
|
-
# atome_type = :animation
|
165
|
-
# generated_render = params[:renderers] || default_renderer
|
166
|
-
# generated_id = params[:id] || identity_generator(atome_type)
|
167
|
-
# generated_parents = params[:attach] || []
|
168
|
-
# params = atome_common(atome_type, generated_id, generated_render, generated_parents, params)
|
169
|
-
# params
|
170
|
-
# end
|
171
51
|
new({ atome: :text, type: :hash })
|
172
52
|
new({ sanitizer: :text }) do |params|
|
173
53
|
params = { data: params } unless params.instance_of? Hash
|
174
|
-
# default_renderer = Essentials.default_params[:render_engines]
|
175
|
-
# atome_type = :text
|
176
|
-
# generated_render = params[:renderers] || default_renderer
|
177
|
-
# generated_id = params[:id] || identity_generator(atome_type)
|
178
|
-
# generated_parents = params[:attach] || [id.value]
|
179
|
-
# params = atome_common(atome_type, generated_id, generated_render, generated_parents, params)
|
180
54
|
params
|
181
55
|
end
|