cura 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +25 -11
- data/Gemfile.lock +157 -62
- data/Rakefile +71 -18
- data/examples/todo_list/bin/todo_list +4 -1
- data/examples/todo_list/lib/todo_list/component/list_items.rb +27 -27
- data/examples/todo_list/lib/todo_list/component/lists.rb +27 -27
- data/lib/cura/application.rb +3 -0
- data/lib/cura/attributes/has_children.rb +25 -4
- data/lib/cura/attributes/has_colors.rb +7 -3
- data/lib/cura/attributes/has_dimensions.rb +1 -1
- data/lib/cura/attributes/has_events.rb +1 -1
- data/lib/cura/attributes/has_root.rb +8 -3
- data/lib/cura/attributes/has_visibility.rb +28 -0
- data/lib/cura/color.rb +2 -0
- data/lib/cura/component/base.rb +34 -9
- data/lib/cura/component/group.rb +19 -2
- data/lib/cura/component/listbox.rb +15 -4
- data/lib/cura/component/pack.rb +8 -4
- data/lib/cura/component.rb +23 -0
- data/lib/cura/error/invalid_component.rb +1 -1
- data/lib/cura/event/dispatcher.rb +1 -1
- data/lib/cura/event/middleware/aimer/target_option.rb +1 -3
- data/lib/cura/event/middleware/dispatch.rb +3 -2
- data/lib/cura/event/middleware/translator/mouse_click.rb +1 -1
- data/lib/cura/key.rb +12 -12
- data/lib/cura/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/{cura → unit/cura}/attributes/has_ancestry_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_application_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_attributes_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_children_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_colors_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_coordinates_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_dimensions_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_events_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_focusability_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_offsets_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_orientation_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_relative_coordinates_spec.rb +0 -0
- data/spec/{cura → unit/cura}/attributes/has_side_attributes_spec.rb +0 -0
- metadata +43 -51
- data/examples/box_model/debug.log +0 -0
- data/examples/todo_list/app.log +0 -9
- data/examples/todo_list/data.db +0 -0
- data/examples/todo_list/debug.log +0 -0
- data/examples/todo_list/profile.html +0 -11354
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 101932a48d4c3d660f5360f3a92f997504b9f1e2
|
4
|
+
data.tar.gz: b2fbda7185993831bd53cd6786bd49984cd9a224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7911a0fefeab097a3f83a7270add610a84595ea1b87f5deb24d387ab0a391e39176dd24a17ec71a3f3a10efb5f50be6390b8e98716ba9170529fcdae3b56e5d
|
7
|
+
data.tar.gz: 5063b2f4e90fc3d0b851463015fe2c513d15fb898b47c9d4ded0a2f7aea5cc6f0199583ea5e8bff20afbc206a0cf37e28393bb8bf28d98d96024fb90f839ce0d
|
data/Gemfile
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
|
+
gemspec
|
4
|
+
|
3
5
|
group :development do
|
4
|
-
gem "
|
5
|
-
gem "
|
6
|
-
gem "
|
7
|
-
gem "
|
8
|
-
gem "
|
9
|
-
gem "rubocop"
|
10
|
-
gem "ruby-prof"
|
11
|
-
gem "simplecov
|
12
|
-
gem "
|
13
|
-
gem "
|
14
|
-
gem "
|
6
|
+
gem "rake" # Project tasks
|
7
|
+
gem "rspec" # BDD Testing
|
8
|
+
gem "fuubar" # RSpec formatter
|
9
|
+
gem "mutant-rspec" # RSpec mutation testing
|
10
|
+
gem "reek" # Code smell analyzer
|
11
|
+
gem "rubocop" # Static code analyzer
|
12
|
+
gem "ruby-prof" # Code profiler # TODO: No guard or rake. For use in integration tests.
|
13
|
+
gem "simplecov" # Test coverage # TODO: No guard or rake. For use in integration tests.
|
14
|
+
gem "yard" # Code documentation
|
15
|
+
gem "yardstick" # Documentation coverage
|
16
|
+
gem "redcarpet" # Markdown parser (for markdown within documentation)
|
17
|
+
gem "github-markup" # Github Flavored Markdown (GFM) parsing
|
18
|
+
gem "guard" # Filesystem event watching
|
19
|
+
|
20
|
+
gem "guard-bundler"
|
21
|
+
gem "guard-shell"
|
22
|
+
gem "guard-rake"
|
23
|
+
gem "guard-rspec"
|
24
|
+
# gem "guard-mutant" # TODO: Broken, custom guard
|
25
|
+
gem "guard-reek"
|
26
|
+
gem "guard-rubocop"
|
27
|
+
gem "guard-yard"
|
28
|
+
gem "guard-yardstick"
|
15
29
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cura (0.0.3)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: https://rubygems.org/
|
3
8
|
specs:
|
@@ -5,102 +10,177 @@ GEM
|
|
5
10
|
adamantium (0.2.0)
|
6
11
|
ice_nine (~> 0.11.0)
|
7
12
|
memoizable (~> 0.4.0)
|
8
|
-
anima (0.
|
13
|
+
anima (0.3.0)
|
9
14
|
abstract_type (~> 0.0.7)
|
10
|
-
adamantium (~> 0.
|
11
|
-
equalizer (~> 0.0.
|
12
|
-
ast (2.
|
13
|
-
|
14
|
-
|
15
|
+
adamantium (~> 0.2)
|
16
|
+
equalizer (~> 0.0.11)
|
17
|
+
ast (2.2.0)
|
18
|
+
axiom-types (0.1.1)
|
19
|
+
descendants_tracker (~> 0.0.4)
|
20
|
+
ice_nine (~> 0.11.0)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
22
|
+
builder (3.2.2)
|
23
|
+
codeclimate-engine-rb (0.3.1)
|
24
|
+
virtus (~> 1.0)
|
25
|
+
coderay (1.1.1)
|
26
|
+
coercible (1.0.0)
|
27
|
+
descendants_tracker (~> 0.0.1)
|
15
28
|
concord (0.1.5)
|
16
29
|
adamantium (~> 0.2.0)
|
17
30
|
equalizer (~> 0.0.9)
|
31
|
+
descendants_tracker (0.0.4)
|
32
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
18
33
|
diff-lcs (1.2.5)
|
19
34
|
docile (1.1.5)
|
20
35
|
equalizer (0.0.11)
|
36
|
+
ffi (1.9.10)
|
37
|
+
formatador (0.2.5)
|
21
38
|
fuubar (2.0.0)
|
22
39
|
rspec (~> 3.0)
|
23
40
|
ruby-progressbar (~> 1.4)
|
24
|
-
|
41
|
+
github-markup (1.4.0)
|
42
|
+
guard (2.13.0)
|
43
|
+
formatador (>= 0.2.4)
|
44
|
+
listen (>= 2.7, <= 4.0)
|
45
|
+
lumberjack (~> 1.0)
|
46
|
+
nenv (~> 0.1)
|
47
|
+
notiffany (~> 0.0)
|
48
|
+
pry (>= 0.9.12)
|
49
|
+
shellany (~> 0.0)
|
50
|
+
thor (>= 0.18.1)
|
51
|
+
guard-bundler (2.1.0)
|
52
|
+
bundler (~> 1.0)
|
53
|
+
guard (~> 2.2)
|
54
|
+
guard-compat (~> 1.1)
|
55
|
+
guard-compat (1.2.1)
|
56
|
+
guard-rake (1.0.0)
|
57
|
+
guard
|
58
|
+
rake
|
59
|
+
guard-reek (0.0.4)
|
60
|
+
guard
|
61
|
+
reek
|
62
|
+
guard-rspec (4.6.5)
|
63
|
+
guard (~> 2.1)
|
64
|
+
guard-compat (~> 1.1)
|
65
|
+
rspec (>= 2.99.0, < 4.0)
|
66
|
+
guard-rubocop (1.2.0)
|
67
|
+
guard (~> 2.0)
|
68
|
+
rubocop (~> 0.20)
|
69
|
+
guard-shell (0.7.1)
|
70
|
+
guard (>= 2.0.0)
|
71
|
+
guard-compat (~> 1.0)
|
72
|
+
guard-yard (2.1.4)
|
73
|
+
guard (>= 1.1.0)
|
74
|
+
yard (>= 0.7.0)
|
75
|
+
guard-yardstick (0.1.0)
|
76
|
+
guard (>= 2.0)
|
77
|
+
guard-compat (>= 1.2)
|
78
|
+
yardstick (>= 0.9)
|
79
|
+
ice_nine (0.11.2)
|
25
80
|
json (1.8.3)
|
81
|
+
listen (3.1.4)
|
82
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
83
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
84
|
+
ruby_dep (~> 1.2)
|
85
|
+
lumberjack (1.0.10)
|
26
86
|
memoizable (0.4.2)
|
27
87
|
thread_safe (~> 0.3, >= 0.3.1)
|
28
|
-
|
88
|
+
method_source (0.8.2)
|
89
|
+
morpher (0.2.6)
|
29
90
|
abstract_type (~> 0.0.7)
|
30
91
|
adamantium (~> 0.2.0)
|
31
|
-
anima (~> 0.
|
32
|
-
ast (~> 2.
|
33
|
-
concord (~> 0.1.
|
92
|
+
anima (~> 0.3.0)
|
93
|
+
ast (~> 2.2)
|
94
|
+
concord (~> 0.1.5)
|
34
95
|
equalizer (~> 0.0.9)
|
35
96
|
ice_nine (~> 0.11.0)
|
36
97
|
procto (~> 0.0.2)
|
37
|
-
mutant (0.8.
|
98
|
+
mutant (0.8.10)
|
38
99
|
abstract_type (~> 0.0.7)
|
39
100
|
adamantium (~> 0.2.0)
|
40
|
-
anima (~> 0.
|
41
|
-
ast (~> 2.
|
101
|
+
anima (~> 0.3.0)
|
102
|
+
ast (~> 2.2)
|
42
103
|
concord (~> 0.1.5)
|
43
104
|
diff-lcs (~> 1.2)
|
44
105
|
equalizer (~> 0.0.9)
|
45
106
|
ice_nine (~> 0.11.1)
|
46
107
|
memoizable (~> 0.4.2)
|
47
|
-
morpher (~> 0.2.
|
108
|
+
morpher (~> 0.2.6)
|
48
109
|
parallel (~> 1.3)
|
49
|
-
parser (~> 2.
|
110
|
+
parser (~> 2.3.0)
|
50
111
|
procto (~> 0.0.2)
|
51
|
-
unparser (~> 0.2.
|
52
|
-
mutant-rspec (0.8.
|
53
|
-
mutant (~> 0.8.
|
54
|
-
rspec-core (>= 3.2.0, < 3.
|
55
|
-
|
56
|
-
|
57
|
-
|
112
|
+
unparser (~> 0.2.5)
|
113
|
+
mutant-rspec (0.8.8)
|
114
|
+
mutant (~> 0.8.8)
|
115
|
+
rspec-core (>= 3.2.0, < 3.5.0)
|
116
|
+
nenv (0.3.0)
|
117
|
+
notiffany (0.0.8)
|
118
|
+
nenv (~> 0.1)
|
119
|
+
shellany (~> 0.0)
|
120
|
+
parallel (1.8.0)
|
121
|
+
parser (2.3.0.7)
|
122
|
+
ast (~> 2.2)
|
58
123
|
powerpack (0.1.1)
|
59
|
-
procto (0.0.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
124
|
+
procto (0.0.3)
|
125
|
+
pry (0.10.3)
|
126
|
+
coderay (~> 1.1.0)
|
127
|
+
method_source (~> 0.8.1)
|
128
|
+
slop (~> 3.4)
|
129
|
+
rainbow (2.1.0)
|
130
|
+
rake (11.1.2)
|
131
|
+
rb-fsevent (0.9.7)
|
132
|
+
rb-inotify (0.9.7)
|
133
|
+
ffi (>= 0.5.0)
|
134
|
+
redcarpet (3.3.4)
|
135
|
+
reek (4.0.1)
|
136
|
+
codeclimate-engine-rb (~> 0.3.1)
|
137
|
+
parser (~> 2.3, >= 2.3.0.6)
|
64
138
|
rainbow (~> 2.0)
|
65
|
-
|
66
|
-
|
67
|
-
rspec-
|
68
|
-
rspec-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
rspec-expectations (3.3.0)
|
139
|
+
rspec (3.4.0)
|
140
|
+
rspec-core (~> 3.4.0)
|
141
|
+
rspec-expectations (~> 3.4.0)
|
142
|
+
rspec-mocks (~> 3.4.0)
|
143
|
+
rspec-core (3.4.4)
|
144
|
+
rspec-support (~> 3.4.0)
|
145
|
+
rspec-expectations (3.4.0)
|
73
146
|
diff-lcs (>= 1.2.0, < 2.0)
|
74
|
-
rspec-support (~> 3.
|
75
|
-
rspec-mocks (3.
|
147
|
+
rspec-support (~> 3.4.0)
|
148
|
+
rspec-mocks (3.4.1)
|
76
149
|
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
-
rspec-support (~> 3.
|
78
|
-
rspec-support (3.
|
79
|
-
rubocop (0.
|
80
|
-
|
81
|
-
parser (>= 2.2.2.5, < 3.0)
|
150
|
+
rspec-support (~> 3.4.0)
|
151
|
+
rspec-support (3.4.1)
|
152
|
+
rubocop (0.39.0)
|
153
|
+
parser (>= 2.3.0.7, < 3.0)
|
82
154
|
powerpack (~> 0.1)
|
83
155
|
rainbow (>= 1.99.1, < 3.0)
|
84
|
-
ruby-progressbar (~> 1.
|
85
|
-
|
156
|
+
ruby-progressbar (~> 1.7)
|
157
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
158
|
+
ruby-prof (0.15.9)
|
86
159
|
ruby-progressbar (1.7.5)
|
87
|
-
|
160
|
+
ruby_dep (1.3.1)
|
161
|
+
shellany (0.0.1)
|
162
|
+
simplecov (0.11.2)
|
88
163
|
docile (~> 1.1.0)
|
89
164
|
json (~> 1.8)
|
90
165
|
simplecov-html (~> 0.10.0)
|
91
166
|
simplecov-html (0.10.0)
|
92
|
-
|
93
|
-
|
94
|
-
simplecov
|
167
|
+
slop (3.6.0)
|
168
|
+
thor (0.19.1)
|
95
169
|
thread_safe (0.3.5)
|
96
|
-
|
170
|
+
unicode-display_width (1.0.3)
|
171
|
+
unparser (0.2.5)
|
97
172
|
abstract_type (~> 0.0.7)
|
98
173
|
adamantium (~> 0.2.0)
|
99
174
|
concord (~> 0.1.5)
|
100
175
|
diff-lcs (~> 1.2.5)
|
101
176
|
equalizer (~> 0.0.9)
|
102
|
-
parser (~> 2.
|
177
|
+
parser (~> 2.3.0)
|
103
178
|
procto (~> 0.0.2)
|
179
|
+
virtus (1.0.5)
|
180
|
+
axiom-types (~> 0.1)
|
181
|
+
coercible (~> 1.0)
|
182
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
183
|
+
equalizer (~> 0.0, >= 0.0.9)
|
104
184
|
yard (0.8.7.6)
|
105
185
|
yardstick (0.9.9)
|
106
186
|
yard (~> 0.8, >= 0.8.7.2)
|
@@ -109,14 +189,29 @@ PLATFORMS
|
|
109
189
|
ruby
|
110
190
|
|
111
191
|
DEPENDENCIES
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
192
|
+
builder (~> 3.2.2)
|
193
|
+
cura!
|
194
|
+
fuubar
|
195
|
+
github-markup
|
196
|
+
guard
|
197
|
+
guard-bundler
|
198
|
+
guard-rake
|
199
|
+
guard-reek
|
200
|
+
guard-rspec
|
201
|
+
guard-rubocop
|
202
|
+
guard-shell
|
203
|
+
guard-yard
|
204
|
+
guard-yardstick
|
205
|
+
mutant-rspec
|
206
|
+
rake
|
207
|
+
redcarpet
|
208
|
+
reek
|
209
|
+
rspec
|
210
|
+
rubocop
|
211
|
+
ruby-prof
|
212
|
+
simplecov
|
213
|
+
yard
|
214
|
+
yardstick
|
215
|
+
|
216
|
+
BUNDLED WITH
|
217
|
+
1.12.2
|
data/Rakefile
CHANGED
@@ -1,42 +1,95 @@
|
|
1
|
+
# Package task
|
2
|
+
|
1
3
|
require "pathname"
|
2
4
|
require "rubygems/package_task"
|
3
|
-
require "yard"
|
4
|
-
require "rspec/core/rake_task"
|
5
|
-
require "rubocop/rake_task"
|
6
|
-
require "reek/rake/task"
|
7
|
-
require "yardstick/rake/measurement"
|
8
|
-
require "yardstick/rake/verify"
|
9
5
|
|
10
|
-
|
6
|
+
PROJECT_ROOT = Pathname.new(__FILE__).join("..").expand_path
|
7
|
+
|
8
|
+
gemspec = Pathname.glob(PROJECT_ROOT.join("*.gemspec")).first
|
11
9
|
spec = Gem::Specification.load(gemspec.to_s)
|
12
10
|
|
13
11
|
Gem::PackageTask.new(spec) do |task|
|
14
12
|
task.need_zip = false
|
15
13
|
end
|
16
14
|
|
17
|
-
|
15
|
+
# RSpec
|
16
|
+
|
17
|
+
require "rspec/core/rake_task"
|
18
18
|
|
19
19
|
RSpec::Core::RakeTask.new(:spec)
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
# Mutant
|
22
|
+
|
23
|
+
desc "Mutation testing"
|
24
|
+
task :mutant do
|
25
|
+
exec("bundle exec mutant --include lib --require cura --use rspec Cura*")
|
24
26
|
end
|
25
27
|
|
28
|
+
# Reek
|
29
|
+
|
30
|
+
require "reek/rake/task"
|
31
|
+
|
26
32
|
Reek::Rake::Task.new do |t|
|
27
33
|
t.fail_on_error = false
|
28
34
|
end
|
29
35
|
|
36
|
+
# Rubocop
|
37
|
+
|
38
|
+
require "rubocop/rake_task"
|
39
|
+
|
40
|
+
RuboCop::RakeTask.new do |task|
|
41
|
+
task.patterns = ["lib/**/*.rb"]
|
42
|
+
# task.formatters = ["fuubar"]
|
43
|
+
end
|
44
|
+
|
45
|
+
# YARD
|
46
|
+
|
47
|
+
require "yard"
|
48
|
+
|
49
|
+
YARD::Rake::YardocTask.new
|
50
|
+
|
51
|
+
# Yardstick
|
52
|
+
|
53
|
+
require "yardstick/rake/measurement"
|
54
|
+
require "yardstick/rake/verify"
|
55
|
+
|
30
56
|
options = YAML.load_file(".yardstick.yml")
|
31
57
|
Yardstick::Rake::Measurement.new(:yardstick, options) do |measurement|
|
32
|
-
measurement.output = "coverage
|
58
|
+
measurement.output = PROJECT_ROOT.join("doc", "yard", "coverage.txt")
|
33
59
|
end
|
34
60
|
|
35
|
-
|
36
|
-
|
37
|
-
|
61
|
+
Yardstick::Rake::Verify.new do |verify|
|
62
|
+
verify.threshold = 100
|
63
|
+
end
|
38
64
|
|
39
|
-
|
40
|
-
|
41
|
-
|
65
|
+
# Graphs
|
66
|
+
|
67
|
+
namespace :graph do
|
68
|
+
desc "Generate YARD dot file"
|
69
|
+
task :yard do
|
70
|
+
path = PROJECT_ROOT.join("doc", "graphs", "yard.dot").relative_path_from(PROJECT_ROOT)
|
71
|
+
|
72
|
+
sh("bundle exec yard graph --full --file #{path}")
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Generate png files from dot files"
|
76
|
+
task :png do
|
77
|
+
renders_path = PROJECT_ROOT.join("doc", "graphs", "renders")
|
78
|
+
renders_path.mkpath
|
79
|
+
|
80
|
+
glob_query = PROJECT_ROOT.join("doc", "graphs", "*.dot")
|
81
|
+
|
82
|
+
Pathname.glob(glob_query).each do |input_path|
|
83
|
+
output_filename = "#{input_path.basename(".dot")}.png"
|
84
|
+
output_path = renders_path.join(output_filename)
|
85
|
+
|
86
|
+
sh("dot -T png \"#{input_path}\" -o \"#{output_path}\"")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
desc "Generate all graphs"
|
92
|
+
task :graph do
|
93
|
+
Rake::Task["graph:yard"].execute
|
94
|
+
Rake::Task["graph:png"].execute
|
42
95
|
end
|
@@ -20,7 +20,10 @@ if profile
|
|
20
20
|
result = RubyProf.stop
|
21
21
|
printer = RubyProf::CallStackPrinter.new(result)
|
22
22
|
|
23
|
-
Pathname.new(__FILE__).join("..", "..", "
|
23
|
+
path = Pathname.new(__FILE__).join("..", "..", "..", "..", "doc", "coverage", "todo_list.html").expand_path
|
24
|
+
path.dirname.mkpath
|
25
|
+
|
26
|
+
path.open("w+") { |file| printer.print(file) }
|
24
27
|
else
|
25
28
|
TodoList.run
|
26
29
|
end
|
@@ -2,34 +2,34 @@ require "todo_list/component/list_item"
|
|
2
2
|
|
3
3
|
module TodoList
|
4
4
|
module Component
|
5
|
-
|
5
|
+
|
6
6
|
class ListItems < Cura::Component::Pack
|
7
|
-
|
7
|
+
|
8
8
|
attr_reader :create_list_item_textbox
|
9
9
|
attr_reader :listbox
|
10
10
|
attr_reader :list
|
11
|
-
|
11
|
+
|
12
12
|
def initialize(attributes={})
|
13
13
|
attributes = { fill: true, padding: { top: 1, bottom: 1 } }.merge(attributes)
|
14
|
-
|
14
|
+
|
15
15
|
super(attributes)
|
16
|
-
|
16
|
+
|
17
17
|
create_form_pack = Cura::Component::Pack.new(orientation: :horizontal)
|
18
18
|
add_child(create_form_pack)
|
19
|
-
|
19
|
+
|
20
20
|
@create_list_item_textbox = Cura::Component::Textbox.new(width: width - 21, margin: { right: 1 })
|
21
21
|
@create_list_item_textbox.on_event(:key_down, self) { |event, model_list| model_list.create_list_item if event.name == :enter }
|
22
22
|
create_form_pack.add_child(@create_list_item_textbox)
|
23
|
-
|
23
|
+
|
24
24
|
@create_list_item_button = Cura::Component::Button.new(text: "Create List Item", padding: { left: 1, right: 1 })
|
25
25
|
@create_list_item_button.on_event(:click, self) { |_, model_list| model_list.create_list_item }
|
26
26
|
create_form_pack.add_child(@create_list_item_button)
|
27
|
-
|
27
|
+
|
28
28
|
@listbox_header_label = Cura::Component::Label.new(text: " " * width, bold: true, underline: true, margin: { top: 1 })
|
29
29
|
add_child(@listbox_header_label)
|
30
|
-
|
30
|
+
|
31
31
|
@listbox = Cura::Component::Listbox.new(width: @width)
|
32
|
-
|
32
|
+
|
33
33
|
@listbox.on_event(:key_down, self) do |event, model_list|
|
34
34
|
if event.target == self
|
35
35
|
if event.control? && event.name == :D && !selected_object.nil?
|
@@ -40,58 +40,58 @@ module TodoList
|
|
40
40
|
model_list.fill_listbox
|
41
41
|
self.selected_index = [previous_selected_index, count - 1].min
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
if event.control? && event.name == :E
|
45
45
|
selected_child.focusable = true
|
46
46
|
selected_child.focus
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
if event.name == :enter
|
50
50
|
selected_object.completed = !selected_object.completed
|
51
51
|
selected_object.save
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
add_child(@listbox)
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
def create_list_item
|
60
60
|
text = @create_list_item_textbox.text
|
61
|
-
|
61
|
+
|
62
62
|
@list.add_list_item(text: text)
|
63
|
-
|
63
|
+
|
64
64
|
fill_listbox
|
65
|
-
|
65
|
+
|
66
66
|
@create_list_item_textbox.clear
|
67
67
|
@create_list_item_textbox.focus
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
def fill_listbox
|
71
71
|
@listbox.delete_children
|
72
|
-
|
72
|
+
|
73
73
|
return nil if @list.nil?
|
74
|
-
|
74
|
+
|
75
75
|
@list.list_items.each do |list_item|
|
76
76
|
list_item_component = Component::ListItem.new(listbox: @listbox, model: list_item, width: @listbox.width)
|
77
|
-
|
78
|
-
@listbox.add_child(list_item_component, list_item)
|
77
|
+
|
78
|
+
@listbox.add_child(list_item_component, object: list_item)
|
79
79
|
end unless @list.nil?
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def list=(list)
|
83
83
|
@list = list
|
84
|
-
|
84
|
+
|
85
85
|
if @list.nil?
|
86
86
|
@listbox_header_label.text = " " * width
|
87
87
|
else
|
88
88
|
@listbox_header_label.text = @list.text + " " * (width - @list.text.length) unless @list.text.length >= width
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
fill_listbox
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
end
|
97
97
|
end
|