atome 0.5.7.1.2 → 0.5.7.1.6
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/Gemfile +1 -0
- data/atome.gemspec +2 -2
- data/documentation/deep learning/basic_infos.txt +1 -1
- data/lib/atome/extensions/atome.rb +57 -19
- data/lib/atome/genesis/atomes.rb +11 -0
- data/lib/atome/genesis/particles/event.rb +24 -2
- data/lib/atome/genesis/sparkle.rb +2 -1
- data/lib/atome/presets/atome.rb +5 -14
- 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 +344 -0
- data/lib/renderers/html/hierarchy.rb +2 -2
- data/lib/renderers/html/html.rb +52 -48
- data/lib/renderers/html/identity.rb +4 -1
- data/lib/renderers/html/utility.rb +1 -1
- 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 +54 -0
- data/vendor/assets/application/examples/hypertext.rb +24 -3
- data/vendor/assets/application/examples/test.rb +1 -56
- data/vendor/assets/application/examples/tools.rb +7 -384
- data/vendor/assets/src/index.html +13 -6
- data/vendor/assets/src/index_opal.html +15 -7
- data/vendor/assets/src/index_server.html +19 -0
- data/vendor/assets/src/index_server_wasm.html +13 -6
- data/vendor/assets/src/index_wasm.html +19 -12
- data/vendor/assets/src/js/third_parties/webaudio-pianoroll.min.js +66 -0
- data/vendor/assets/src/medias/images/utils/full_keyboard.svg +50 -0
- data/vendor/assets/src/medias/images/utils/keyboard.svg +29 -0
- data/vendor/assets/src/medias/images/utils/notes.svg +28 -0
- metadata +25 -18
- /data/lib/molecules/intuition/{utillities.rb → utilities.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c05197d3eeae9cee5e96894387b264fa64b3f0436c513d03c9bee7edd7edc7aa
|
4
|
+
data.tar.gz: d21606ce307a9c85eca0207d95b502572bf287668c360228230d917672306f53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69e1cc8e30ca124fa5402bd30ea6cb302bbef0b7aa90cad60cbcf9c80cef49bfefc2dc1ba35551f5ecc8d604154fd62f7c21dc3ca6340902d1a6a2c390d18aae
|
7
|
+
data.tar.gz: 4a3b520343611c272ea18853bf5449af84e35adbc8153538b1c3a969dcbaaccbe60375ba08ac97eb70e27b8cdf57ba38d0eb1f1d8d5a9ac998d80832f4a44476
|
data/Gemfile
CHANGED
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"
|
@@ -13,7 +13,7 @@ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
|
|
13
13
|
brew install openssl
|
14
14
|
cargo install tauri-cli --force
|
15
15
|
|
16
|
-
Install
|
16
|
+
Install Homebrew
|
17
17
|
|
18
18
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
19
19
|
|
@@ -614,11 +614,6 @@ class Object
|
|
614
614
|
end
|
615
615
|
|
616
616
|
|
617
|
-
JS.eval(<<~JS)
|
618
|
-
window.preventDefaultAction = function(e) {
|
619
|
-
e.preventDefault();
|
620
|
-
}
|
621
|
-
JS
|
622
617
|
|
623
618
|
def touch_allow(allow)
|
624
619
|
if allow
|
@@ -633,26 +628,67 @@ JS
|
|
633
628
|
|
634
629
|
def allow_copy(allow)
|
635
630
|
if allow
|
636
|
-
#
|
631
|
+
# allow selection and text copy
|
637
632
|
JS.eval(<<~JS)
|
638
|
-
|
639
|
-
|
640
|
-
|
633
|
+
document.body.style.userSelect = 'auto'; // allow text slectiion
|
634
|
+
document.removeEventListener('copy', preventDefaultAction); // allow copy
|
635
|
+
JS
|
641
636
|
else
|
642
|
-
#
|
637
|
+
# lock selection and text copy
|
643
638
|
JS.eval(<<~JS)
|
644
|
-
|
645
|
-
|
646
|
-
|
639
|
+
document.body.style.userSelect = 'none'; // prevent text selection
|
640
|
+
document.addEventListener('copy', preventDefaultAction); // prevent copy
|
641
|
+
JS
|
642
|
+
end
|
643
|
+
end
|
644
|
+
|
645
|
+
def above(item, margin)
|
646
|
+
pos = item.to_px(:bottom) + item.height + margin
|
647
|
+
if item.display == :none
|
648
|
+
33
|
649
|
+
else
|
650
|
+
pos
|
647
651
|
end
|
648
652
|
end
|
649
653
|
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
654
|
+
def below(item, margin)
|
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)
|
665
|
+
left_f = if item.left.instance_of?(Integer)
|
666
|
+
item.left
|
667
|
+
else
|
668
|
+
item.to_px(:left)
|
669
|
+
end
|
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)
|
685
|
+
pos = item.to_px(:right) + item.width + margin
|
686
|
+
if item.display == :none
|
687
|
+
0
|
688
|
+
else
|
689
|
+
pos
|
690
|
+
end
|
691
|
+
end
|
656
692
|
|
657
693
|
|
658
694
|
end
|
@@ -697,6 +733,8 @@ class CssProxy
|
|
697
733
|
bloc.call(parsed)
|
698
734
|
end
|
699
735
|
|
736
|
+
|
737
|
+
|
700
738
|
end
|
701
739
|
|
702
740
|
|
data/lib/atome/genesis/atomes.rb
CHANGED
@@ -63,6 +63,17 @@ new({ atome: :raw })
|
|
63
63
|
new({ atome: :shape })
|
64
64
|
new({ atome: :code })
|
65
65
|
new({ atome: :audio })
|
66
|
+
new({ sanitizer: :audio }) do |params|
|
67
|
+
unless params.instance_of? Hash
|
68
|
+
# TODO : we have to convert all image to png or maintain a database with extension
|
69
|
+
# FIXME : temporary patch that add .mp4 to the string if no extension is found
|
70
|
+
params = "#{params}.mp4" if params.to_s.split('.').length == 1
|
71
|
+
|
72
|
+
params = { path: "./medias/audios/#{params}" }
|
73
|
+
end
|
74
|
+
# TODO : the line below should get the value from default params Essentials
|
75
|
+
params
|
76
|
+
end
|
66
77
|
new({ atome: :element })
|
67
78
|
new({ sanitizer: :element }) do |params|
|
68
79
|
default_params = { data: '' }
|
@@ -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
|
@@ -154,7 +154,8 @@ def atome_genesis
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
|
157
|
+
# this method is call from JS (atome/communication) at WS connection
|
158
|
+
def init_database
|
158
159
|
# we init the db file eDen
|
159
160
|
A.sync({ action: :init_db, data: { database: :eDen } }) do |data|
|
160
161
|
Universe.database_ready = data[:data][:message] == 'database_ready'
|
data/lib/atome/presets/atome.rb
CHANGED
@@ -16,13 +16,15 @@ class Atome
|
|
16
16
|
# preset_params = {preset: atome_preset}
|
17
17
|
basic_params[:type] = preset_params[:type] || :element
|
18
18
|
# basic_params[:aid] = identity_generator(:a)
|
19
|
-
|
19
|
+
# alert "common => #{params[:id]}"
|
20
|
+
# alert "basic_params #{basic_params[:id].class}"
|
21
|
+
basic_params[:id] = params[:id] || identity_generator
|
20
22
|
basic_params[:renderers] = @renderers || preset_params[:renderers]
|
21
23
|
essential_params = basic_params.merge(preset_params)
|
22
24
|
#
|
23
25
|
reordered_params = essential_params.reject { |key, _| params.has_key?(key) }
|
24
26
|
params = reordered_params.merge(params)
|
25
|
-
params[:id]=params[:id].to_sym
|
27
|
+
params[:id] = params[:id].to_sym
|
26
28
|
# condition to handle color/shadow/paint atomes that shouldn't be attach to view
|
27
29
|
if Universe.applicable_atomes.include?(atome_preset)
|
28
30
|
unless params[:affect]
|
@@ -36,24 +38,13 @@ class Atome
|
|
36
38
|
params[:attach] = params[:attach] || @id || :view
|
37
39
|
end
|
38
40
|
# we reorder the hash
|
39
|
-
|
41
|
+
reorder_particles(params)
|
40
42
|
end
|
41
43
|
|
42
44
|
def preset_common(params, &bloc)
|
43
|
-
|
44
|
-
## if an atome with current id exist we update the ID in the params
|
45
|
-
# params[:id] = "#{params[:id]}_#{Universe.atomes.length}" if grab(params[:id])
|
46
|
-
# if Universe.atomes[params[:id]]
|
47
|
-
# alert "atome found : #{ grab(params[:id])}"
|
48
|
-
# grab(params[:id])
|
49
|
-
# else
|
50
|
-
|
51
45
|
Atome.new(params, &bloc)
|
52
|
-
# end
|
53
46
|
end
|
54
47
|
|
55
|
-
|
56
|
-
|
57
48
|
# def box(params = {}, &bloc)
|
58
49
|
# atome_preset = :box
|
59
50
|
# params = atome_common(atome_preset, params)
|
@@ -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,344 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
size = 33
|
6
|
+
smooth = 3
|
7
|
+
shadow({
|
8
|
+
id: :tool_shade,
|
9
|
+
left: 3, top: 3, blur: 3,
|
10
|
+
invert: false,
|
11
|
+
red: 0, green: 0, blue: 0, alpha: 0.6
|
12
|
+
})
|
13
|
+
|
14
|
+
color({ id: :tool_inactive_color, red: 1, green: 1, blue: 1, alpha: 0.12 })
|
15
|
+
color({ id: :tool_active_color, red: 1, green: 1, blue: 1, alpha: 0.3 })
|
16
|
+
border({ id: :tool_box_border, thickness: 1, red: 1, green: 1, blue: 1, alpha: 0.06, pattern: :solid, inside: true })
|
17
|
+
# Tool's style object container below
|
18
|
+
element({ aid: :toolbox_style, id: :toolbox_style, data: {
|
19
|
+
color: :gray,
|
20
|
+
size: size,
|
21
|
+
smooth: smooth
|
22
|
+
} })
|
23
|
+
|
24
|
+
class Atome
|
25
|
+
class << self
|
26
|
+
def init_intuition
|
27
|
+
Atome.start_click_analysis
|
28
|
+
root = Universe.tools_root
|
29
|
+
root.each_with_index do |root_tool, index|
|
30
|
+
tools_scheme = Universe.tools[root_tool]
|
31
|
+
A.build_tool({ name: root_tool, scheme: tools_scheme, index: index })
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def selection
|
36
|
+
grab(Universe.current_user).selection.collect
|
37
|
+
end
|
38
|
+
|
39
|
+
def activate_click_analysis
|
40
|
+
|
41
|
+
# the condition below avoid touchdown analysis accumulation
|
42
|
+
unless @click_analysis_active
|
43
|
+
# this method analyse all object under the touchdown to find the first user objet and return it's id
|
44
|
+
@click_analysis = lambda { |native_event|
|
45
|
+
# the instance variable below check if we can apply tool (cf: if the atome we don't want to apply tool)
|
46
|
+
if Universe.allow_tool_operations
|
47
|
+
event = Native(native_event)
|
48
|
+
x = event[:clientX]
|
49
|
+
y = event[:clientY]
|
50
|
+
elements = JS.global[:document].elementsFromPoint(x, y)
|
51
|
+
elements.to_a.each do |atome_touched|
|
52
|
+
id_found = atome_touched[:id].to_s
|
53
|
+
atome_found = grab(id_found)
|
54
|
+
unless atome_found && atome_found.tag[:system]
|
55
|
+
|
56
|
+
# if atome_found
|
57
|
+
Universe.active_tools.each do |tool|
|
58
|
+
apply_tool(tool, atome_found, event)
|
59
|
+
end
|
60
|
+
break
|
61
|
+
end
|
62
|
+
end
|
63
|
+
else
|
64
|
+
Universe.allow_tool_operations = true
|
65
|
+
end
|
66
|
+
}
|
67
|
+
@click_analysis_active = true
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def de_activate_click_analysis
|
73
|
+
@click_analysis = nil
|
74
|
+
@click_analysis_active = false
|
75
|
+
end
|
76
|
+
|
77
|
+
def start_click_analysis
|
78
|
+
@click_analysis_active = false
|
79
|
+
JS.global[:document].addEventListener('mouseup') do |native_event|
|
80
|
+
Atome.instance_exec(native_event, &@click_analysis) if @click_analysis.is_a?(Proc)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def alteration(current_tool, tool_actions, atome_touched, a_event)
|
85
|
+
if atome_touched
|
86
|
+
storage_allowed = Universe.allow_localstorage
|
87
|
+
action_found = tool_actions[:action]
|
88
|
+
pre = tool_actions[:pre]
|
89
|
+
post = tool_actions[:post]
|
90
|
+
params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
|
91
|
+
action_found.each do |part, val|
|
92
|
+
Universe.allow_localstorage = false
|
93
|
+
#################################
|
94
|
+
touch_found = atome_touched.touch
|
95
|
+
touch_procs=atome_touched.instance_variable_get("@touch_code")
|
96
|
+
resize_found = atome_touched.resize
|
97
|
+
resize_procs=atome_touched.instance_variable_get("@resize_code")
|
98
|
+
current_tool.data[:prev_states][atome_touched] = {events: { touch: touch_found, resize: resize_found },
|
99
|
+
procs: {touch_code: touch_procs, resize_code: resize_procs } }
|
100
|
+
#################################
|
101
|
+
current_tool.instance_exec(params, &pre) if pre.is_a? Proc
|
102
|
+
Universe.allow_localstorage = storage_allowed
|
103
|
+
if current_tool.data[:allow_alteration]
|
104
|
+
atome_touched.send(part, val)
|
105
|
+
current_tool.data[:treated] << atome_touched
|
106
|
+
end
|
107
|
+
current_tool.instance_exec(params, &post) if post.is_a? Proc
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def creation(current_tool, tool_actions, atome_touched, a_event)
|
114
|
+
# we store prev_local_storage prior to lock it to prevent unwanted logs
|
115
|
+
# prev_local_storage=Universe.allow_localstorage()
|
116
|
+
storage_allowed = Universe.allow_localstorage
|
117
|
+
Universe.allow_localstorage = false
|
118
|
+
|
119
|
+
action_found = tool_actions[:action]
|
120
|
+
pre = tool_actions[:pre]
|
121
|
+
post = tool_actions[:post]
|
122
|
+
params = { current_tool: current_tool, atome_touched: atome_touched, event: a_event }
|
123
|
+
|
124
|
+
action_found.each do |atome, particle|
|
125
|
+
current_tool.instance_exec(params, &pre) if pre.is_a? Proc
|
126
|
+
temp_val = particle.merge({ resize: true, drag: true, top: a_event[:pageY].to_i, left: a_event[:pageX].to_i })
|
127
|
+
if current_tool.data[:allow_creation]
|
128
|
+
# uncomment the line below if you want to attach to current atome
|
129
|
+
if atome_touched
|
130
|
+
new_atome = atome_touched.send(atome, temp_val)
|
131
|
+
else
|
132
|
+
new_atome = grab(:view).send(atome, temp_val)
|
133
|
+
end
|
134
|
+
# current_tool.data[:treated] << new_atome
|
135
|
+
current_tool.data[:created] << new_atome
|
136
|
+
params.delete(:atome_touched)
|
137
|
+
params[new_atome: new_atome]
|
138
|
+
Universe.allow_localstorage = [atome]
|
139
|
+
Universe.historicize(new_atome.aid, :write, atome, particle)
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
current_tool.instance_exec(params, &post) if post.is_a? Proc
|
144
|
+
# we restore prev_local_storage to allow logs of drag and resize ...
|
145
|
+
Universe.allow_localstorage = storage_allowed
|
146
|
+
end
|
147
|
+
|
148
|
+
def apply_tool(tool, atome_touched, a_event)
|
149
|
+
current_tool = grab(tool)
|
150
|
+
tool_actions = current_tool.data
|
151
|
+
method_found = tool_actions[:method]
|
152
|
+
unless method_found
|
153
|
+
method_found = :alteration
|
154
|
+
tool_actions[:action] = { noop: true }
|
155
|
+
current_tool.data = tool_actions
|
156
|
+
end
|
157
|
+
|
158
|
+
send(method_found, current_tool, tool_actions, atome_touched, a_event)
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
def noop(_p)
|
164
|
+
# this method is used by tools when no treatment is needed
|
165
|
+
end
|
166
|
+
|
167
|
+
def set_action_on_touch(&action)
|
168
|
+
@touch_action = action
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
def remove_get_atome_on_touch
|
173
|
+
@touch_action = nil
|
174
|
+
end
|
175
|
+
|
176
|
+
def build_tool(params)
|
177
|
+
label = params[:name]
|
178
|
+
tool_name = "#{params[:name]}_tool"
|
179
|
+
index = params[:index]
|
180
|
+
orientation_wanted = :sn
|
181
|
+
tool_scheme = params[:scheme]
|
182
|
+
color({ id: :active_tool_col, alpha: 1, red: 1, green: 1, blue: 1 })
|
183
|
+
color({ id: :inactive_tool_col, alpha: 0.6 })
|
184
|
+
grab(:intuition).storage[:tool_open] ||= []
|
185
|
+
grab(:intuition).storage[:tool_open] << tool_name
|
186
|
+
size = grab(:toolbox_style).data[:size]
|
187
|
+
smooth = grab(:toolbox_style).data[:smooth]
|
188
|
+
case orientation_wanted
|
189
|
+
when :sn
|
190
|
+
top = :auto
|
191
|
+
bottom = index * (size + 3)
|
192
|
+
left = 0
|
193
|
+
right = :auto
|
194
|
+
when :ns
|
195
|
+
when :ew
|
196
|
+
when :we
|
197
|
+
else
|
198
|
+
#
|
199
|
+
end
|
200
|
+
|
201
|
+
# tool creation
|
202
|
+
if tool_scheme[:creation]
|
203
|
+
action = tool_scheme[:creation]
|
204
|
+
method = :creation
|
205
|
+
end
|
206
|
+
if tool_scheme[:alteration]
|
207
|
+
action = tool_scheme[:alteration]
|
208
|
+
method = :alteration
|
209
|
+
end
|
210
|
+
|
211
|
+
tool = grab(:intuition).box({ id: tool_name,
|
212
|
+
tag: { system: true },
|
213
|
+
# orientation: orientation_wanted,
|
214
|
+
top: top,
|
215
|
+
bottom: bottom,
|
216
|
+
left: left,
|
217
|
+
right: right,
|
218
|
+
width: size,
|
219
|
+
height: size,
|
220
|
+
smooth: smooth,
|
221
|
+
apply: [:tool_inactive_color, :tool_box_border, :tool_shade],
|
222
|
+
state: :closed,
|
223
|
+
data: { method: method,
|
224
|
+
action: action,
|
225
|
+
allow_alteration: true,
|
226
|
+
allow_creation: true,
|
227
|
+
# activation: tool_scheme[:activation],
|
228
|
+
# inactivation: tool_scheme[:inactivation], zone: tool_scheme[:zone],
|
229
|
+
post: tool_scheme[:post],
|
230
|
+
pre: tool_scheme[:pre],
|
231
|
+
}
|
232
|
+
|
233
|
+
})
|
234
|
+
tool.vector({ tag: { system: true }, left: 9, top: :auto, bottom: 9, width: 18, height: 18, id: "#{tool_name}_icon" })
|
235
|
+
tool.text({ tag: { system: true }, data: label, component: { size: 9 }, color: :grey, id: "#{tool_name}_label" })
|
236
|
+
code_for_zone = tool_scheme[:zone]
|
237
|
+
tool.instance_exec(tool, &code_for_zone) if code_for_zone.is_a? Proc
|
238
|
+
tool.touch(true) do
|
239
|
+
# we add all specific tool actions to @tools_actions_to_exec hash
|
240
|
+
# we set allow_tool_operations to false to ignore tool operation when clicking on a tool
|
241
|
+
Universe.allow_tool_operations = false
|
242
|
+
# we create the creation_layer if not already exist
|
243
|
+
tick(tool_name)
|
244
|
+
# active code exec
|
245
|
+
if tick[tool_name] == 1 # first click
|
246
|
+
events_allow = [:top, :left, :right, :bottom, :width, :height]
|
247
|
+
alterations = tool_scheme[:alteration] ? tool_scheme[:alteration].keys : []
|
248
|
+
creations = tool_scheme[:creation] ? tool_scheme[:creation].keys : []
|
249
|
+
prev_auth = Universe.allow_localstorage ||= []
|
250
|
+
storage_allowed = events_allow.concat(alterations).concat(creations).concat(prev_auth).uniq
|
251
|
+
Universe.allow_localstorage = storage_allowed
|
252
|
+
# we set edit mode to true (this allow to prevent user atome to respond from click)
|
253
|
+
Universe.edit_mode = true
|
254
|
+
Universe.active_tools << tool_name
|
255
|
+
# init the tool
|
256
|
+
tool.data[:treated] = []
|
257
|
+
tool.data[:created] = []
|
258
|
+
tool.data[:prev_states] = {}
|
259
|
+
# generic behavior
|
260
|
+
tool.apply(:active_tool_col)
|
261
|
+
# activation code
|
262
|
+
activation_code = tool_scheme[:activation]
|
263
|
+
tool.instance_exec(&activation_code) if activation_code.is_a? Proc
|
264
|
+
# below we the particles of selected atomes to feed tools values
|
265
|
+
# possibility 1 (pipette like):
|
266
|
+
# now we get the values from selected atomes
|
267
|
+
Atome.selection.each do |atome_id_to_treat|
|
268
|
+
tool.data[:action].each do |particle_req, value_f|
|
269
|
+
unless Universe.atome_preset
|
270
|
+
value_found = grab(atome_id_to_treat).send(particle_req)
|
271
|
+
if value_found
|
272
|
+
tool.data[:action][particle_req] = value_found
|
273
|
+
else
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
# possibility 2 (immediate apply):
|
279
|
+
allow_creation = tool.data[:allow_creation]
|
280
|
+
allow_alteration = tool.data[:allow_alteration]
|
281
|
+
Atome.selection.each do |atome_id_to_treat|
|
282
|
+
atome_found = grab(atome_id_to_treat)
|
283
|
+
event = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }
|
284
|
+
Atome.apply_tool(tool_name, atome_found, event)
|
285
|
+
end unless tool_name.to_sym == :select_tool || !allow_creation || !allow_alteration
|
286
|
+
|
287
|
+
# activate tool analysis test
|
288
|
+
Atome.activate_click_analysis
|
289
|
+
else
|
290
|
+
Universe.allow_localstorage = false
|
291
|
+
# when closing delete tools action from tool_actions_to_exec
|
292
|
+
Universe.active_tools.delete(tool_name)
|
293
|
+
# we check if all tools are inactive if so we set edit_mode to false
|
294
|
+
if Universe.active_tools.length == 0
|
295
|
+
Atome.de_activate_click_analysis
|
296
|
+
Universe.edit_mode = false
|
297
|
+
end
|
298
|
+
|
299
|
+
inactivation_code = tool_scheme[:inactivation]
|
300
|
+
tool.instance_exec(tool.data, &inactivation_code) if inactivation_code.is_a? Proc
|
301
|
+
# end if tool_content && tool_content[:inactive]
|
302
|
+
|
303
|
+
# generic behavior
|
304
|
+
# we remove touch and resize binding on newly created atomes
|
305
|
+
tool.apply(:inactive_tool_col)
|
306
|
+
tool.data[:created].each do |new_atome|
|
307
|
+
new_atome.drag(false)
|
308
|
+
new_atome.resize(:remove)
|
309
|
+
end
|
310
|
+
################################
|
311
|
+
# we restore prev touch and resize
|
312
|
+
tool.data[:prev_states].each do |atome_f, prev_par|
|
313
|
+
puts prev_par
|
314
|
+
# params[:events].each do |part_f, val_f|
|
315
|
+
# # alert "@#{part_f}, #{part_f}"
|
316
|
+
# atome_f.send(part_f, val_f)
|
317
|
+
# end
|
318
|
+
# alert "--> params : #{params[:events]}"
|
319
|
+
# alert "--> procs : #{params[:procs][params[:events]]}"
|
320
|
+
# atome_f.touch(false)
|
321
|
+
# atome_f.touch(true) do
|
322
|
+
# alert :kool
|
323
|
+
# end
|
324
|
+
# alert params[:procs]
|
325
|
+
# params[:procs].each do |var_n, procs_f|
|
326
|
+
# # procs_f.each do |action_f, proc|
|
327
|
+
# # # puts "#{var_n}==> #{action_f}, #{proc}"
|
328
|
+
# # end
|
329
|
+
# puts "==> #{var_n}, #{proc_f}"
|
330
|
+
# # atome_f.instance_variable_set("@#{var_n}", proc_f)
|
331
|
+
# end
|
332
|
+
# atome_f.touch(false)
|
333
|
+
# alert "#{atome_f.touch} : #{atome_f.instance_variable_get("@touch_code")}"
|
334
|
+
end
|
335
|
+
|
336
|
+
# atome_f.touch(touch_found)
|
337
|
+
# atome_f.resize(resize_found)
|
338
|
+
# inactivation code
|
339
|
+
#################################
|
340
|
+
tick[tool_name] = 0
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
@@ -4,9 +4,10 @@ new({ renderer: :html, method: :attach, type: :string }) do |parent_found, _user
|
|
4
4
|
html.append_to(parent_found)
|
5
5
|
end
|
6
6
|
|
7
|
+
|
7
8
|
new({ renderer: :html, method: :apply, type: :string }) do |parent_found, _user_proc|
|
8
9
|
|
9
|
-
# TODO : factorise code below between text and shape, especially shadow as code is written twice and
|
10
|
+
# TODO : factorise code below between text and shape, especially shadow as code is written twice and identical
|
10
11
|
case parent_found.type
|
11
12
|
when :shadow
|
12
13
|
shadows_to_apply = { filter: [], boxShadow: [] }
|
@@ -32,7 +33,6 @@ new({ renderer: :html, method: :apply, type: :string }) do |parent_found, _user_
|
|
32
33
|
html.style("boxShadow", box_shadow)
|
33
34
|
html.style("filter", drop_shadow)
|
34
35
|
when :color
|
35
|
-
|
36
36
|
red = parent_found.red * 255
|
37
37
|
green = parent_found.green * 255
|
38
38
|
blue = parent_found.blue * 255
|