atome 0.5.7.1.4 → 0.5.7.1.7
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/atome.gemspec +2 -2
- data/lib/atome/extensions/atome.rb +48 -0
- data/lib/atome/genesis/particles/event.rb +24 -2
- data/lib/atome/genesis/sparkle.rb +7 -12
- data/lib/atome/utilities/utilities.rb +0 -10
- data/lib/atome/version.rb +1 -1
- data/lib/atome.rb +2 -1
- data/lib/atome_relative.rb +2 -1
- data/lib/molecules/intuition/tools.rb +359 -0
- data/lib/molecules/intuition/{utillities.rb → utilities.rb} +17 -10
- data/lib/renderers/html/html.rb +25 -32
- data/vendor/assets/application/examples/above_below_before_after.rb +22 -0
- data/vendor/assets/application/examples/animation.rb +29 -1
- data/vendor/assets/application/examples/audio.rb +10 -26
- data/vendor/assets/application/examples/test.rb +196 -150
- data/vendor/assets/application/examples/tools.rb +7 -384
- data/vendor/assets/server/database.rb +6 -14
- data/vendor/assets/server/eDen.rb +1 -1
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49d9ecf130f643cc65b60e7a935dd513871f3ecf0afca6b97476b57650ac0fee
|
4
|
+
data.tar.gz: 60843a34a863fc4ed3b324d0ae29913c58355eb69c7a8a732eb9445c933d256e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e599f47ecf7ab87cf472fe12d95ac2991ad3e192b85e74252304b738537ec0c513bbda6371331912ffaee9fa33be66795a2ba31ca3607296d4e910bd4b06d0b9
|
7
|
+
data.tar.gz: 5041dfd0b3600ec8b406f7a3d9bfbdc6e9e66c3e8b002ba576292d01e6277f379040d1f0f945922a21e33bcc09e8037f8889fb62caf4cb06472bad0109bba827
|
data/atome.gemspec
CHANGED
@@ -52,7 +52,7 @@ Gem::Specification.new do |spec|
|
|
52
52
|
spec.require_paths = ['lib']
|
53
53
|
|
54
54
|
|
55
|
-
spec.add_runtime_dependency 'artoo', '~> 1.8.2'
|
55
|
+
# spec.add_runtime_dependency 'artoo', '~> 1.8.2'
|
56
56
|
# spec.add_runtime_dependency 'arduino_firmata', '~> 0.3'
|
57
57
|
# spec.add_runtime_dependency 'eVe', '~> 0.1.0'
|
58
58
|
spec.add_runtime_dependency 'eventmachine', '~> 1.2.7'
|
@@ -90,7 +90,7 @@ Gem::Specification.new do |spec|
|
|
90
90
|
spec.add_runtime_dependency 'wdm', '>= 0.1.0' if Gem.win_platform?
|
91
91
|
|
92
92
|
# patch because guard have bad dependency
|
93
|
-
|
93
|
+
spec.add_runtime_dependency 'pry', '>= 0.14.2'
|
94
94
|
|
95
95
|
# Uncomment to register a new dependency of your gem
|
96
96
|
# spec.add_dependency "example-gem", "~> 1.0"
|
@@ -642,7 +642,53 @@ class Object
|
|
642
642
|
end
|
643
643
|
end
|
644
644
|
|
645
|
+
def above(item, margin=6)
|
646
|
+
pos = item.to_px(:bottom) + item.height + margin
|
647
|
+
if item.display == :none
|
648
|
+
33
|
649
|
+
else
|
650
|
+
pos
|
651
|
+
end
|
652
|
+
end
|
653
|
+
|
654
|
+
def below(item, margin=6)
|
655
|
+
pos = item.to_px(:top) + item.to_px(:height) + margin
|
656
|
+
if item.display == :none
|
657
|
+
0
|
658
|
+
else
|
659
|
+
pos
|
660
|
+
end
|
661
|
+
|
662
|
+
end
|
663
|
+
|
664
|
+
def after(item, margin=6)
|
665
|
+
left_f = if item.left.instance_of?(Integer)
|
666
|
+
item.left
|
667
|
+
else
|
668
|
+
item.to_px(:left)
|
669
|
+
end
|
645
670
|
|
671
|
+
width_f = if item.width.instance_of?(Integer)
|
672
|
+
item.width
|
673
|
+
else
|
674
|
+
item.to_px(:width)
|
675
|
+
end
|
676
|
+
pos = left_f + width_f + margin
|
677
|
+
if item.display == :none
|
678
|
+
0
|
679
|
+
else
|
680
|
+
pos
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
684
|
+
def before(item, margin=6)
|
685
|
+
pos = item.to_px(:right) + item.width + margin
|
686
|
+
if item.display == :none
|
687
|
+
0
|
688
|
+
else
|
689
|
+
pos
|
690
|
+
end
|
691
|
+
end
|
646
692
|
|
647
693
|
|
648
694
|
end
|
@@ -687,6 +733,8 @@ class CssProxy
|
|
687
733
|
bloc.call(parsed)
|
688
734
|
end
|
689
735
|
|
736
|
+
|
737
|
+
|
690
738
|
end
|
691
739
|
|
692
740
|
|
@@ -334,11 +334,33 @@ new({ particle: :overflow, category: :event, type: :boolean }) do |params, bloc|
|
|
334
334
|
params
|
335
335
|
|
336
336
|
end
|
337
|
-
|
337
|
+
|
338
|
+
class Atome
|
339
|
+
def animation_callback(proc_sub_category, value=nil)
|
340
|
+
# puts "#{p◊roc_sub_category}"
|
341
|
+
proc_found = @animate_code[proc_sub_category]
|
342
|
+
# puts proc_found
|
343
|
+
instance_exec(value,&proc_found) if proc_found.is_a?(Proc)
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
new({ particle: :animate, category: :event, type: :hash }) do |params, proc|
|
338
348
|
if params.instance_of? Hash
|
339
349
|
params = { from: 0, to: 300, duration: 1000 }.merge(params)
|
340
350
|
else
|
341
351
|
params = { from: 0, to: 300, duration: 1000 }
|
342
352
|
end
|
343
|
-
|
353
|
+
# @animate_code["#{params[:particle]}"] = proc
|
354
|
+
if params[:end]
|
355
|
+
@animate_code["#{params[:end]}_end"] = proc
|
356
|
+
else
|
357
|
+
@animate_code||= {}
|
358
|
+
@animate_code["#{params[:particle]}"] = proc
|
359
|
+
end
|
360
|
+
|
361
|
+
params
|
362
|
+
end
|
363
|
+
|
364
|
+
new ({ after: :animate }) do |params|
|
365
|
+
html.animate(params) unless params[:end] || params[:start]
|
344
366
|
end
|
@@ -64,6 +64,7 @@ Atome.new(
|
|
64
64
|
Atome.new(
|
65
65
|
{ renderers: default_render, aid: :view,type: :shape, attach: :user_view, apply: [:view_color],
|
66
66
|
tag: { system: true }, left: 0, right: 0, top: 0, bottom: 0, width: :auto, height: :auto, overflow: :auto,
|
67
|
+
language: :english
|
67
68
|
}
|
68
69
|
|
69
70
|
)
|
@@ -166,17 +167,18 @@ def init_database
|
|
166
167
|
|
167
168
|
particles = Universe.particle_list
|
168
169
|
# now we populate the DB
|
169
|
-
A.sync({ action: :
|
170
|
+
A.sync({ action: :create_db_table, data: { table: :user, type: :string } }) do |_db_state|
|
170
171
|
# puts "===> #{_db_state}"
|
171
172
|
end
|
172
|
-
|
173
|
-
A.sync({ action: :create_db_column, data: { table: :user, column: :email, type: :string, unique: true } }) do |_db_state|
|
173
|
+
A.sync({ action: :create_db_table, data: { table: :atome } }) do |_db_state|
|
174
174
|
end
|
175
175
|
|
176
|
-
A.sync({ action: :
|
176
|
+
A.sync({ action: :create_db_table, data: { table: :history } }) do |_db_state|
|
177
177
|
end
|
178
178
|
|
179
|
-
A.sync({ action: :
|
179
|
+
A.sync({ action: :create_db_column, data: { table: :user, column: :email, type: :string, unique: true } }) do |_db_state|
|
180
|
+
end
|
181
|
+
A.sync({ action: :create_db_column, data: { table: :user, column: :password, type: :string } }) do |_db_state|
|
180
182
|
end
|
181
183
|
A.sync({ action: :create_db_column, data: { table: :history, column: :aid, type: :string } }) do |_db_state|
|
182
184
|
end
|
@@ -187,13 +189,6 @@ def init_database
|
|
187
189
|
A.sync({ action: :create_db_column, data: { table: :history, column: :date, type: :datetime } }) do |_db_state|
|
188
190
|
end
|
189
191
|
|
190
|
-
A.sync({ action: :crate_db_table, data: { table: :atome } }) do |_db_state|
|
191
|
-
end
|
192
|
-
particles.each do |particle, infos|
|
193
|
-
type = infos[:type]
|
194
|
-
A.sync({ action: :create_db_column, data: { table: :atome, column: particle, type: type } }) do |_db_state|
|
195
|
-
end
|
196
|
-
end
|
197
192
|
|
198
193
|
# now we send localstorage content to the server
|
199
194
|
puts "sending localstorage"
|
@@ -350,18 +350,8 @@ class Atome
|
|
350
350
|
|
351
351
|
def js_callback(id, particle, value, sub = nil)
|
352
352
|
current_atome = grab(id)
|
353
|
-
# # alert current_atome.instance_variable_get('@record_code')
|
354
353
|
proc_found = current_atome.instance_variable_get("@#{particle}_code")[particle.to_sym]
|
355
|
-
# proc_found= current_atome.instance_variable_get("@record_code")[:record]
|
356
|
-
# # alert particle.class
|
357
|
-
# # alert proc_found.class
|
358
|
-
# proc_found.call
|
359
354
|
instance_exec(value, &proc_found) if proc_found.is_a?(Proc)
|
360
|
-
# # # puts "params to be exec #{id}, #{particle}, #{value}, #{sub}"
|
361
|
-
# alpha= grab(:the_big_box)
|
362
|
-
# proc_found= alpha.instance_variable_get("@record_code")[:record]
|
363
|
-
# proc_found.call
|
364
|
-
|
365
355
|
end
|
366
356
|
|
367
357
|
# def callback(data)
|
data/lib/atome/version.rb
CHANGED
data/lib/atome.rb
CHANGED
data/lib/atome_relative.rb
CHANGED
@@ -36,4 +36,5 @@ require_relative './atome/utilities/sanitizer'
|
|
36
36
|
require_relative './atome/genesis/presets'
|
37
37
|
require_relative './atome/genesis/sparkle'
|
38
38
|
require_relative './molecules/init'
|
39
|
-
require_relative './molecules/intuition/
|
39
|
+
require_relative './molecules/intuition/utilities'
|
40
|
+
require_relative './molecules/intuition/tools'
|
@@ -0,0 +1,359 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
size = 33
|
4
|
+
smooth = 3
|
5
|
+
shadow({
|
6
|
+
id: :tool_shade,
|
7
|
+
left: 3, top: 3, blur: 3,
|
8
|
+
invert: false,
|
9
|
+
red: 0, green: 0, blue: 0, alpha: 0.6
|
10
|
+
})
|
11
|
+
|
12
|
+
color({ id: :tool_inactive_color, red: 1, green: 1, blue: 1, alpha: 0.12 })
|
13
|
+
color({ id: :tool_active_color, red: 1, green: 1, blue: 1, alpha: 0.3 })
|
14
|
+
border({ id: :tool_box_border, thickness: 1, red: 1, green: 1, blue: 1, alpha: 0.06, pattern: :solid, inside: true })
|
15
|
+
# Tool's style object container below
|
16
|
+
element({ aid: :toolbox_style, id: :toolbox_style, data: {
|
17
|
+
color: :gray,
|
18
|
+
size: size,
|
19
|
+
smooth: smooth
|
20
|
+
} })
|
21
|
+
|
22
|
+
class Atome
|
23
|
+
class << self
|
24
|
+
def init_intuition
|
25
|
+
Atome.start_click_analysis
|
26
|
+
toolbox_root = Universe.tools_root
|
27
|
+
toolbox_root[:tools].each_with_index do |root_tool, index|
|
28
|
+
tools_scheme = Universe.tools[root_tool]
|
29
|
+
A.build_tool({ name: root_tool, scheme: tools_scheme, index: index ,toolbox: toolbox_root[:toolbox] })
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def selection
|
34
|
+
grab(Universe.current_user).selection.collect
|
35
|
+
end
|
36
|
+
|
37
|
+
def activate_click_analysis
|
38
|
+
|
39
|
+
# the condition below avoid touchdown analysis accumulation
|
40
|
+
unless @click_analysis_active
|
41
|
+
# this method analyse all object under the touchdown to find the first user objet and return it's id
|
42
|
+
@click_analysis = lambda { |native_event|
|
43
|
+
# the instance variable below check if we can apply tool (cf: if the atome we don't want to apply tool)
|
44
|
+
if Universe.allow_tool_operations
|
45
|
+
event = Native(native_event)
|
46
|
+
x = event[:clientX]
|
47
|
+
y = event[:clientY]
|
48
|
+
elements = JS.global[:document].elementsFromPoint(x, y)
|
49
|
+
elements.to_a.each do |atome_touched|
|
50
|
+
id_found = atome_touched[:id].to_s
|
51
|
+
atome_found = grab(id_found)
|
52
|
+
unless atome_found && atome_found.tag[:system]
|
53
|
+
|
54
|
+
# if atome_found
|
55
|
+
Universe.active_tools.each do |tool|
|
56
|
+
apply_tool(tool, atome_found, event)
|
57
|
+
end
|
58
|
+
break
|
59
|
+
end
|
60
|
+
end
|
61
|
+
else
|
62
|
+
Universe.allow_tool_operations = true
|
63
|
+
end
|
64
|
+
}
|
65
|
+
@click_analysis_active = true
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
def de_activate_click_analysis
|
71
|
+
@click_analysis = nil
|
72
|
+
@click_analysis_active = false
|
73
|
+
end
|
74
|
+
|
75
|
+
def start_click_analysis
|
76
|
+
@click_analysis_active = false
|
77
|
+
JS.global[:document].addEventListener('mouseup') do |native_event|
|
78
|
+
Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def alteration(current_tool, tool_actions, atome_touched, a_event)
|
83
|
+
if atome_touched
|
84
|
+
storage_allowed = Universe.allow_localstorage
|
85
|
+
action_found = tool_actions[:action]
|
86
|
+
pre = tool_actions[:pre]
|
87
|
+
post = tool_actions[:post]
|
88
|
+
params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
|
89
|
+
action_found.each do |part, val|
|
90
|
+
Universe.allow_localstorage = false
|
91
|
+
#################################
|
92
|
+
touch_found = atome_touched.touch
|
93
|
+
touch_procs = atome_touched.instance_variable_get("@touch_code")
|
94
|
+
resize_found = atome_touched.resize
|
95
|
+
resize_procs = atome_touched.instance_variable_get("@resize_code")
|
96
|
+
current_tool.data[:prev_states][atome_touched] = { events: { touch: touch_found, resize: resize_found },
|
97
|
+
procs: { touch_code: touch_procs, resize_code: resize_procs } }
|
98
|
+
#################################
|
99
|
+
current_tool.instance_exec(params, &pre) if pre.is_a? Proc
|
100
|
+
Universe.allow_localstorage = storage_allowed
|
101
|
+
if current_tool.data[:allow_alteration]
|
102
|
+
atome_touched.send(part, val)
|
103
|
+
current_tool.data[:treated] << atome_touched
|
104
|
+
end
|
105
|
+
current_tool.instance_exec(params, &post) if post.is_a? Proc
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def creation(current_tool, tool_actions, atome_touched, a_event)
|
112
|
+
# we store prev_local_storage prior to lock it to prevent unwanted logs
|
113
|
+
# prev_local_storage=Universe.allow_localstorage()
|
114
|
+
storage_allowed = Universe.allow_localstorage
|
115
|
+
Universe.allow_localstorage = false
|
116
|
+
|
117
|
+
action_found = tool_actions[:action]
|
118
|
+
pre = tool_actions[:pre]
|
119
|
+
post = tool_actions[:post]
|
120
|
+
params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
|
121
|
+
|
122
|
+
action_found.each do |atome, particle|
|
123
|
+
current_tool.instance_exec(params, &pre) if pre.is_a? Proc
|
124
|
+
temp_val = particle.merge({ resize: true, drag: true, top: a_event[:pageY].to_i, left: a_event[:pageX].to_i })
|
125
|
+
if current_tool.data[:allow_creation]
|
126
|
+
# uncomment the line below if you want to attach to current atome
|
127
|
+
if atome_touched
|
128
|
+
new_atome = atome_touched.send(atome, temp_val)
|
129
|
+
else
|
130
|
+
new_atome = grab(:view).send(atome, temp_val)
|
131
|
+
end
|
132
|
+
# current_tool.data[:treated] << new_atome
|
133
|
+
current_tool.data[:created] << new_atome
|
134
|
+
params.delete(:atome_touched)
|
135
|
+
params[new_atome: new_atome]
|
136
|
+
Universe.allow_localstorage = [atome]
|
137
|
+
Universe.historicize(new_atome.aid, :write, atome, particle)
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
current_tool.instance_exec(params, &post) if post.is_a? Proc
|
142
|
+
# we restore prev_local_storage to allow logs of drag and resize ...
|
143
|
+
Universe.allow_localstorage = storage_allowed
|
144
|
+
end
|
145
|
+
|
146
|
+
def apply_tool(tool, atome_touched, a_event)
|
147
|
+
current_tool = grab(tool)
|
148
|
+
tool_actions = current_tool.data
|
149
|
+
method_found = tool_actions[:method]
|
150
|
+
unless method_found
|
151
|
+
method_found = :alteration
|
152
|
+
tool_actions[:action] = { noop: true }
|
153
|
+
current_tool.data = tool_actions
|
154
|
+
end
|
155
|
+
|
156
|
+
send(method_found, current_tool, tool_actions, atome_touched, a_event)
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
def noop(_p)
|
162
|
+
# this method is used by tools when no treatment is needed
|
163
|
+
end
|
164
|
+
|
165
|
+
def set_action_on_touch(&action)
|
166
|
+
@touch_action = action
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
def remove_get_atome_on_touch
|
171
|
+
@touch_action = nil
|
172
|
+
end
|
173
|
+
|
174
|
+
def build_tool(params)
|
175
|
+
# here is the main entry for tool creation
|
176
|
+
language ||= grab(:view).language
|
177
|
+
|
178
|
+
label = params.dig(:scheme, :int8, language) || params[:name]
|
179
|
+
tool_name = "#{params[:name]}_tool"
|
180
|
+
index = params[:index]
|
181
|
+
tool_scheme = params[:scheme]
|
182
|
+
toolbox=params[:toolbox] || {}
|
183
|
+
orientation_wanted = tool_scheme[:orientation] || :sn
|
184
|
+
color({ id: :active_tool_col, alpha: 1, red: 1, green: 1, blue: 1 })
|
185
|
+
color({ id: :inactive_tool_col, alpha: 0.6 })
|
186
|
+
grab(:intuition).storage[:tool_open] ||= []
|
187
|
+
grab(:intuition).storage[:tool_open] << tool_name
|
188
|
+
size = grab(:toolbox_style).data[:size]
|
189
|
+
smooth = grab(:toolbox_style).data[:smooth]
|
190
|
+
case orientation_wanted
|
191
|
+
when :sn
|
192
|
+
top = :auto
|
193
|
+
bottom_offset=toolbox[:bottom] || 3
|
194
|
+
spacing = toolbox[:spacing] || 3
|
195
|
+
bottom = index * (size + spacing)+bottom_offset
|
196
|
+
left = toolbox[:left] || 3
|
197
|
+
right = :auto
|
198
|
+
when :ns
|
199
|
+
when :ew
|
200
|
+
when :we
|
201
|
+
else
|
202
|
+
#
|
203
|
+
end
|
204
|
+
|
205
|
+
# tool creation
|
206
|
+
if tool_scheme[:creation]
|
207
|
+
action = tool_scheme[:creation]
|
208
|
+
method = :creation
|
209
|
+
end
|
210
|
+
if tool_scheme[:alteration]
|
211
|
+
action = tool_scheme[:alteration]
|
212
|
+
method = :alteration
|
213
|
+
end
|
214
|
+
|
215
|
+
tool = grab(:intuition).box({ id: tool_name,
|
216
|
+
tag: { system: true },
|
217
|
+
# orientation: orientation_wanted,
|
218
|
+
top: top,
|
219
|
+
bottom: bottom,
|
220
|
+
left: left,
|
221
|
+
right: right,
|
222
|
+
width: size,
|
223
|
+
height: size,
|
224
|
+
smooth: smooth,
|
225
|
+
apply: [:tool_inactive_color, :tool_box_border, :tool_shade],
|
226
|
+
state: :closed,
|
227
|
+
data: { method: method,
|
228
|
+
action: action,
|
229
|
+
allow_alteration: true,
|
230
|
+
allow_creation: true,
|
231
|
+
# activation: tool_scheme[:activation],
|
232
|
+
# inactivation: tool_scheme[:inactivation], zone: tool_scheme[:zone],
|
233
|
+
post: tool_scheme[:post],
|
234
|
+
pre: tool_scheme[:pre],
|
235
|
+
}
|
236
|
+
|
237
|
+
})
|
238
|
+
edition = "M257.7 752c2 0 4-0.2 6-0.5L431.9 722c2-0.4 3.9-1.3 5.3-2.8l423.9-423.9c3.9-3.9 3.9-10.2 0-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2c-1.9 11.1 1.5 21.9 9.4 29.8 6.6 6.4 14.9 9.9 23.8 9.9z m67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"
|
239
|
+
|
240
|
+
icon= tool.vector({ tag: { system: true }, left: 9, top: :auto, bottom: 9, width: 18, height: 18, id: "#{tool_name}_icon",
|
241
|
+
data: { path: { d: edition, id: :p1, stroke: :black, 'stroke-width' => 37, fill: :white } }})
|
242
|
+
# wait 2 do
|
243
|
+
# alert "#{tool_name}_icon"
|
244
|
+
# alert "current vector : #{grab("#{tool_name}_icon").id}"
|
245
|
+
grab("#{tool_name}_icon").color(:blue)
|
246
|
+
# icon.color(:red)
|
247
|
+
# end
|
248
|
+
# icon= tool_scheme[:icon] || params[:name]
|
249
|
+
# tool.image({path: "medias/images/icons/#{icon}.svg"})
|
250
|
+
tool.text({ tag: { system: true }, data: label, component: { size: 9 }, color: :grey, id: "#{tool_name}_label" })
|
251
|
+
code_for_zone = tool_scheme[:zone]
|
252
|
+
tool.instance_exec(tool, &code_for_zone) if code_for_zone.is_a? Proc
|
253
|
+
tool.touch(true) do
|
254
|
+
# we add all specific tool actions to @tools_actions_to_exec hash
|
255
|
+
# we set allow_tool_operations to false to ignore tool operation when clicking on a tool
|
256
|
+
Universe.allow_tool_operations = false
|
257
|
+
# we create the creation_layer if not already exist
|
258
|
+
tick(tool_name)
|
259
|
+
# active code exec
|
260
|
+
if tick[tool_name] == 1 # first click
|
261
|
+
events_allow = [:top, :left, :right, :bottom, :width, :height]
|
262
|
+
alterations = tool_scheme[:alteration] ? tool_scheme[:alteration].keys : []
|
263
|
+
creations = tool_scheme[:creation] ? tool_scheme[:creation].keys : []
|
264
|
+
prev_auth = Universe.allow_localstorage ||= []
|
265
|
+
storage_allowed = events_allow.concat(alterations).concat(creations).concat(prev_auth).uniq
|
266
|
+
Universe.allow_localstorage = storage_allowed
|
267
|
+
# we set edit mode to true (this allow to prevent user atome to respond from click)
|
268
|
+
Universe.edit_mode = true
|
269
|
+
Universe.active_tools << tool_name
|
270
|
+
# init the tool
|
271
|
+
tool.data[:treated] = []
|
272
|
+
tool.data[:created] = []
|
273
|
+
tool.data[:prev_states] = {}
|
274
|
+
# generic behavior
|
275
|
+
tool.apply(:active_tool_col)
|
276
|
+
# activation code
|
277
|
+
activation_code = tool_scheme[:activation]
|
278
|
+
tool.instance_exec(&activation_code) if activation_code.is_a? Proc
|
279
|
+
# below we the particles of selected atomes to feed tools values
|
280
|
+
# possibility 1 (pipette like):
|
281
|
+
# now we get the values from selected atomes
|
282
|
+
Atome.selection.each do |atome_id_to_treat|
|
283
|
+
tool.data[:action].each do |particle_req, value_f|
|
284
|
+
unless Universe.atome_preset
|
285
|
+
value_found = grab(atome_id_to_treat).send(particle_req)
|
286
|
+
if value_found
|
287
|
+
tool.data[:action][particle_req] = value_found
|
288
|
+
else
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
# possibility 2 (immediate apply):
|
294
|
+
allow_creation = tool.data[:allow_creation]
|
295
|
+
allow_alteration = tool.data[:allow_alteration]
|
296
|
+
Atome.selection.each do |atome_id_to_treat|
|
297
|
+
atome_found = grab(atome_id_to_treat)
|
298
|
+
event = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }
|
299
|
+
Atome.apply_tool(tool_name, atome_found, event)
|
300
|
+
end unless tool_name.to_sym == :select_tool || !allow_creation || !allow_alteration
|
301
|
+
|
302
|
+
# activate tool analysis test
|
303
|
+
Atome.activate_click_analysis
|
304
|
+
else
|
305
|
+
Universe.allow_localstorage = false
|
306
|
+
# when closing delete tools action from tool_actions_to_exec
|
307
|
+
Universe.active_tools.delete(tool_name)
|
308
|
+
# we check if all tools are inactive if so we set edit_mode to false
|
309
|
+
if Universe.active_tools.length == 0
|
310
|
+
Atome.de_activate_click_analysis
|
311
|
+
Universe.edit_mode = false
|
312
|
+
end
|
313
|
+
|
314
|
+
inactivation_code = tool_scheme[:inactivation]
|
315
|
+
tool.instance_exec(tool.data, &inactivation_code) if inactivation_code.is_a? Proc
|
316
|
+
# end if tool_content && tool_content[:inactive]
|
317
|
+
|
318
|
+
# generic behavior
|
319
|
+
# we remove touch and resize binding on newly created atomes
|
320
|
+
tool.apply(:inactive_tool_col)
|
321
|
+
tool.data[:created].each do |new_atome|
|
322
|
+
new_atome.drag(false)
|
323
|
+
new_atome.resize(:remove)
|
324
|
+
end
|
325
|
+
################################
|
326
|
+
# we restore prev touch and resize
|
327
|
+
tool.data[:prev_states].each do |atome_f, prev_par|
|
328
|
+
puts prev_par
|
329
|
+
# params[:events].each do |part_f, val_f|
|
330
|
+
# # alert "@#{part_f}, #{part_f}"
|
331
|
+
# atome_f.send(part_f, val_f)
|
332
|
+
# end
|
333
|
+
# alert "--> params : #{params[:events]}"
|
334
|
+
# alert "--> procs : #{params[:procs][params[:events]]}"
|
335
|
+
# atome_f.touch(false)
|
336
|
+
# atome_f.touch(true) do
|
337
|
+
# alert :kool
|
338
|
+
# end
|
339
|
+
# alert params[:procs]
|
340
|
+
# params[:procs].each do |var_n, procs_f|
|
341
|
+
# # procs_f.each do |action_f, proc|
|
342
|
+
# # # puts "#{var_n}==> #{action_f}, #{proc}"
|
343
|
+
# # end
|
344
|
+
# puts "==> #{var_n}, #{proc_f}"
|
345
|
+
# # atome_f.instance_variable_set("@#{var_n}", proc_f)
|
346
|
+
# end
|
347
|
+
# atome_f.touch(false)
|
348
|
+
# alert "#{atome_f.touch} : #{atome_f.instance_variable_get("@touch_code")}"
|
349
|
+
end
|
350
|
+
|
351
|
+
# atome_f.touch(touch_found)
|
352
|
+
# atome_f.resize(resize_found)
|
353
|
+
# inactivation code
|
354
|
+
#################################
|
355
|
+
tick[tool_name] = 0
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
@@ -129,7 +129,6 @@ new(molecule: :list) do |params, _bloc|
|
|
129
129
|
# let's create the container
|
130
130
|
new_atome = { renderers: renderer_found, attach: list.id }.merge(styles_found).merge({ type: :shape })
|
131
131
|
|
132
|
-
|
133
132
|
el = Atome.new(new_atome)
|
134
133
|
if action
|
135
134
|
el.touch(action[:touch]) do
|
@@ -329,11 +328,11 @@ class Atome
|
|
329
328
|
|
330
329
|
width(params[:width])
|
331
330
|
height(params[:height])
|
332
|
-
current_matrix=self
|
331
|
+
current_matrix = self
|
333
332
|
real_width = current_matrix.to_px(:width)
|
334
333
|
real_height = current_matrix.to_px(:height)
|
335
334
|
spacing = current_matrix.data[:spacing]
|
336
|
-
matrix_cells= current_matrix.data[:matrix]
|
335
|
+
matrix_cells = current_matrix.data[:matrix]
|
337
336
|
|
338
337
|
total_spacing_x = spacing * (matrix_cells.collect.length ** (0.5) + 1)
|
339
338
|
total_spacing_y = spacing * (matrix_cells.collect.length ** (0.5) + 1)
|
@@ -363,13 +362,21 @@ class Atome
|
|
363
362
|
end
|
364
363
|
|
365
364
|
new(molecule: :matrix) do |params, &bloc|
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
365
|
+
params ||= {}
|
366
|
+
# We test if self is main if so we attach the matrix to the view
|
367
|
+
parent_found = if self == self
|
368
|
+
grab(:view)
|
369
|
+
else
|
370
|
+
self
|
371
|
+
end
|
372
|
+
|
373
|
+
id = params[:id] || identity_generator
|
374
|
+
rows = params[:rows] || 8
|
375
|
+
columns = params[:columns] || 8
|
376
|
+
spacing = params[:spacing] || 6
|
377
|
+
size = params[:size] || '100%'
|
371
378
|
|
372
|
-
parent_found = self
|
379
|
+
# parent_found = self
|
373
380
|
current_matrix = group({ id: id })
|
374
381
|
|
375
382
|
current_matrix.data({ spacing: spacing, size: size })
|
@@ -414,7 +421,7 @@ new(molecule: :matrix) do |params, &bloc|
|
|
414
421
|
end
|
415
422
|
current_matrix.collect(matrix_cells)
|
416
423
|
matrix_back.cells(current_matrix)
|
417
|
-
params= params.merge({matrix: current_matrix})
|
424
|
+
params = params.merge({ matrix: current_matrix })
|
418
425
|
matrix_back.data(params)
|
419
426
|
matrix_back
|
420
427
|
end
|