glimmer-dsl-swt 4.18.2.1 → 4.18.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/README.md +175 -32
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +18 -6
- data/lib/glimmer/dsl/swt/color_expression.rb +4 -4
- data/lib/glimmer/dsl/swt/data_binding_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/display_expression.rb +3 -3
- data/lib/glimmer/dsl/swt/dsl.rb +1 -0
- data/lib/glimmer/dsl/swt/multiply_expression.rb +53 -0
- data/lib/glimmer/dsl/swt/property_expression.rb +4 -2
- data/lib/glimmer/dsl/swt/shape_expression.rb +2 -4
- data/lib/glimmer/dsl/swt/transform_expression.rb +55 -0
- data/lib/glimmer/dsl/swt/widget_expression.rb +2 -1
- data/lib/glimmer/rake_task/scaffold.rb +4 -3
- data/lib/glimmer/swt/color_proxy.rb +28 -6
- data/lib/glimmer/swt/custom/drawable.rb +8 -0
- data/lib/glimmer/swt/custom/shape.rb +66 -26
- data/lib/glimmer/swt/display_proxy.rb +1 -1
- data/lib/glimmer/swt/layout_data_proxy.rb +3 -3
- data/lib/glimmer/swt/shell_proxy.rb +4 -3
- data/lib/glimmer/swt/transform_proxy.rb +109 -0
- data/lib/glimmer/swt/widget_proxy.rb +34 -25
- data/lib/glimmer/ui/custom_shell.rb +15 -2
- data/lib/glimmer/ui/custom_widget.rb +44 -31
- data/samples/elaborate/meta_sample.rb +21 -0
- data/samples/elaborate/tetris.rb +106 -0
- data/samples/elaborate/tetris/model/block.rb +48 -0
- data/samples/elaborate/tetris/model/game.rb +185 -0
- data/samples/elaborate/tetris/model/tetromino.rb +313 -0
- data/samples/elaborate/tetris/view/block.rb +70 -0
- data/samples/elaborate/tetris/view/game_over_dialog.rb +72 -0
- data/samples/elaborate/tetris/view/playfield.rb +56 -0
- data/samples/elaborate/tetris/view/score_lane.rb +87 -0
- data/samples/hello/hello_canvas_transform.rb +40 -0
- metadata +16 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.
|
1
|
+
4.18.3.0
|
data/glimmer-dsl-swt.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: glimmer-dsl-swt 4.18.
|
5
|
+
# stub: glimmer-dsl-swt 4.18.3.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-swt".freeze
|
9
|
-
s.version = "4.18.
|
9
|
+
s.version = "4.18.3.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["AndyMaleh".freeze]
|
14
|
-
s.date = "2021-01-
|
14
|
+
s.date = "2021-01-26"
|
15
15
|
s.description = "Glimmer DSL for SWT (JRuby Desktop Development GUI Framework) is a native-GUI cross-platform desktop development library written in JRuby, an OS-threaded faster JVM version of Ruby. Glimmer's main innovation is a declarative Ruby DSL that enables productive and efficient authoring of desktop application user-interfaces by relying on the robust Eclipse SWT library. Glimmer additionally innovates by having built-in data-binding support, which greatly facilitates synchronizing the GUI with domain models, thus achieving true decoupling of object oriented components and enabling developers to solve business problems (test-first) without worrying about GUI concerns, or alternatively drive development GUI-first, and then write clean business models (test-first) afterwards. Not only does Glimmer provide a large set of GUI widgets, but it also supports drawing Canvas Graphics like Shapes and Animations. To get started quickly, Glimmer offers scaffolding options for Apps, Gems, and Custom Widgets. Glimmer also includes native-executable packaging support, sorely lacking in other libraries, thus enabling the delivery of desktop apps written in Ruby as truly native DMG/PKG/APP files on the Mac + App Store, MSI/EXE files on Windows, and Gem Packaged Shell Scripts on Linux.".freeze
|
16
16
|
s.email = "andy.am@gmail.com".freeze
|
17
17
|
s.executables = ["glimmer".freeze, "girb".freeze]
|
@@ -69,6 +69,7 @@ Gem::Specification.new do |s|
|
|
69
69
|
"lib/glimmer/dsl/swt/menu_bar_expression.rb",
|
70
70
|
"lib/glimmer/dsl/swt/menu_expression.rb",
|
71
71
|
"lib/glimmer/dsl/swt/message_box_expression.rb",
|
72
|
+
"lib/glimmer/dsl/swt/multiply_expression.rb",
|
72
73
|
"lib/glimmer/dsl/swt/observe_expression.rb",
|
73
74
|
"lib/glimmer/dsl/swt/property_expression.rb",
|
74
75
|
"lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb",
|
@@ -80,6 +81,7 @@ Gem::Specification.new do |s|
|
|
80
81
|
"lib/glimmer/dsl/swt/sync_exec_expression.rb",
|
81
82
|
"lib/glimmer/dsl/swt/tab_item_expression.rb",
|
82
83
|
"lib/glimmer/dsl/swt/table_items_data_binding_expression.rb",
|
84
|
+
"lib/glimmer/dsl/swt/transform_expression.rb",
|
83
85
|
"lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb",
|
84
86
|
"lib/glimmer/dsl/swt/tree_properties_expression.rb",
|
85
87
|
"lib/glimmer/dsl/swt/widget_expression.rb",
|
@@ -120,6 +122,7 @@ Gem::Specification.new do |s|
|
|
120
122
|
"lib/glimmer/swt/tab_item_proxy.rb",
|
121
123
|
"lib/glimmer/swt/table_column_proxy.rb",
|
122
124
|
"lib/glimmer/swt/table_proxy.rb",
|
125
|
+
"lib/glimmer/swt/transform_proxy.rb",
|
123
126
|
"lib/glimmer/swt/tree_proxy.rb",
|
124
127
|
"lib/glimmer/swt/widget_listener_proxy.rb",
|
125
128
|
"lib/glimmer/swt/widget_proxy.rb",
|
@@ -132,6 +135,14 @@ Gem::Specification.new do |s|
|
|
132
135
|
"samples/elaborate/contact_manager/contact_repository.rb",
|
133
136
|
"samples/elaborate/login.rb",
|
134
137
|
"samples/elaborate/meta_sample.rb",
|
138
|
+
"samples/elaborate/tetris.rb",
|
139
|
+
"samples/elaborate/tetris/model/block.rb",
|
140
|
+
"samples/elaborate/tetris/model/game.rb",
|
141
|
+
"samples/elaborate/tetris/model/tetromino.rb",
|
142
|
+
"samples/elaborate/tetris/view/block.rb",
|
143
|
+
"samples/elaborate/tetris/view/game_over_dialog.rb",
|
144
|
+
"samples/elaborate/tetris/view/playfield.rb",
|
145
|
+
"samples/elaborate/tetris/view/score_lane.rb",
|
135
146
|
"samples/elaborate/tic_tac_toe.rb",
|
136
147
|
"samples/elaborate/tic_tac_toe/board.rb",
|
137
148
|
"samples/elaborate/tic_tac_toe/cell.rb",
|
@@ -140,6 +151,7 @@ Gem::Specification.new do |s|
|
|
140
151
|
"samples/hello/hello_button.rb",
|
141
152
|
"samples/hello/hello_canvas.rb",
|
142
153
|
"samples/hello/hello_canvas_animation.rb",
|
154
|
+
"samples/hello/hello_canvas_transform.rb",
|
143
155
|
"samples/hello/hello_checkbox.rb",
|
144
156
|
"samples/hello/hello_checkbox_group.rb",
|
145
157
|
"samples/hello/hello_combo.rb",
|
@@ -182,7 +194,7 @@ Gem::Specification.new do |s|
|
|
182
194
|
s.specification_version = 4
|
183
195
|
|
184
196
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
185
|
-
s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
197
|
+
s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.9"])
|
186
198
|
s.add_runtime_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
187
199
|
s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
188
200
|
s.add_runtime_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
|
@@ -201,7 +213,7 @@ Gem::Specification.new do |s|
|
|
201
213
|
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
202
214
|
s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
203
215
|
else
|
204
|
-
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
216
|
+
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.9"])
|
205
217
|
s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
206
218
|
s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
207
219
|
s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
|
@@ -221,7 +233,7 @@ Gem::Specification.new do |s|
|
|
221
233
|
s.add_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
222
234
|
end
|
223
235
|
else
|
224
|
-
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
236
|
+
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.9"])
|
225
237
|
s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
226
238
|
s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
227
239
|
s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -32,7 +32,7 @@ module Glimmer
|
|
32
32
|
include_package 'org.eclipse.swt.widgets'
|
33
33
|
|
34
34
|
def interpret(parent, keyword, *args, &block)
|
35
|
-
Glimmer::SWT::ColorProxy.
|
35
|
+
Glimmer::SWT::ColorProxy.flyweight(*args)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
data/lib/glimmer/dsl/swt/dsl.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/expression'
|
23
|
+
require 'glimmer/dsl/parent_expression'
|
24
|
+
require 'glimmer/swt/transform_proxy'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module DSL
|
28
|
+
module SWT
|
29
|
+
# Special treatment for transform {multiply(){} } operation
|
30
|
+
class MultiplyExpression < Expression
|
31
|
+
include ParentExpression
|
32
|
+
|
33
|
+
def can_interpret?(parent, keyword, *args, &block)
|
34
|
+
keyword == 'multiply' and
|
35
|
+
parent.is_a?(Glimmer::SWT::TransformProxy)
|
36
|
+
end
|
37
|
+
|
38
|
+
def interpret(parent, keyword, *args, &block)
|
39
|
+
Glimmer::SWT::TransformProxy.new(parent, *args, multiply: true)
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_content(parent, &block)
|
43
|
+
super
|
44
|
+
parent.post_add_content
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -21,13 +21,15 @@
|
|
21
21
|
|
22
22
|
require 'glimmer/dsl/expression'
|
23
23
|
|
24
|
+
require 'glimmer/swt/transform_proxy'
|
25
|
+
|
24
26
|
module Glimmer
|
25
27
|
module DSL
|
26
28
|
module SWT
|
27
29
|
class PropertyExpression < Expression
|
28
30
|
def can_interpret?(parent, keyword, *args, &block)
|
29
31
|
block.nil? and
|
30
|
-
args.size > 0 and
|
32
|
+
(args.size > 0 || parent.is_a?(Glimmer::SWT::TransformProxy)) and
|
31
33
|
parent.respond_to?(:set_attribute) and
|
32
34
|
parent.respond_to?(:has_attribute?) and
|
33
35
|
parent.has_attribute?(keyword, *args) and
|
@@ -36,7 +38,7 @@ module Glimmer
|
|
36
38
|
|
37
39
|
def interpret(parent, keyword, *args, &block)
|
38
40
|
parent.set_attribute(keyword, *args)
|
39
|
-
|
41
|
+
parent
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
@@ -23,6 +23,7 @@ require 'glimmer/dsl/expression'
|
|
23
23
|
require 'glimmer/dsl/parent_expression'
|
24
24
|
require 'glimmer/swt/swt_proxy'
|
25
25
|
require 'glimmer/swt/custom/shape'
|
26
|
+
require 'glimmer/swt/custom/drawable'
|
26
27
|
|
27
28
|
module Glimmer
|
28
29
|
module DSL
|
@@ -31,10 +32,7 @@ module Glimmer
|
|
31
32
|
include ParentExpression
|
32
33
|
|
33
34
|
def can_interpret?(parent, keyword, *args, &block)
|
34
|
-
(
|
35
|
-
(parent.respond_to?(:swt_widget) and parent.swt_widget.is_a?(org.eclipse.swt.graphics.Drawable)) or
|
36
|
-
(parent.respond_to?(:swt_display) and parent.swt_display.is_a?(org.eclipse.swt.graphics.Drawable))
|
37
|
-
) and
|
35
|
+
parent.is_a?(Glimmer::SWT::Custom::Drawable) and
|
38
36
|
Glimmer::SWT::Custom::Shape.valid?(parent, keyword, *args, &block)
|
39
37
|
end
|
40
38
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/dsl/static_expression'
|
23
|
+
require 'glimmer/dsl/top_level_expression'
|
24
|
+
require 'glimmer/dsl/parent_expression'
|
25
|
+
require 'glimmer/swt/custom/shape'
|
26
|
+
require 'glimmer/swt/transform_proxy'
|
27
|
+
|
28
|
+
module Glimmer
|
29
|
+
module DSL
|
30
|
+
module SWT
|
31
|
+
class TransformExpression < StaticExpression
|
32
|
+
include TopLevelExpression
|
33
|
+
include ParentExpression
|
34
|
+
|
35
|
+
def can_interpret?(parent, keyword, *args, &block)
|
36
|
+
super and
|
37
|
+
(parent.nil? or parent.is_a?(Glimmer::SWT::Custom::Shape))
|
38
|
+
end
|
39
|
+
|
40
|
+
def interpret(parent, keyword, *args, &block)
|
41
|
+
Glimmer::SWT::TransformProxy.new(parent, *args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_content(parent, &block)
|
45
|
+
super
|
46
|
+
parent.post_add_content
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -22,6 +22,7 @@
|
|
22
22
|
require 'glimmer'
|
23
23
|
require 'glimmer/dsl/expression'
|
24
24
|
require 'glimmer/dsl/parent_expression'
|
25
|
+
require 'glimmer/swt/custom/shape'
|
25
26
|
|
26
27
|
module Glimmer
|
27
28
|
module DSL
|
@@ -29,7 +30,7 @@ module Glimmer
|
|
29
30
|
class WidgetExpression < Expression
|
30
31
|
include ParentExpression
|
31
32
|
|
32
|
-
EXCLUDED_KEYWORDS = %w[shell display tab_item]
|
33
|
+
EXCLUDED_KEYWORDS = %w[shell display tab_item] + Glimmer::SWT::Custom::Shape.keywords - ['text']
|
33
34
|
|
34
35
|
def can_interpret?(parent, keyword, *args, &block)
|
35
36
|
result = !EXCLUDED_KEYWORDS.include?(keyword) &&
|
@@ -42,6 +42,7 @@ module Glimmer
|
|
42
42
|
*.gem
|
43
43
|
*.rbc
|
44
44
|
/.config
|
45
|
+
/.mvn/
|
45
46
|
/coverage/
|
46
47
|
/InstalledFiles
|
47
48
|
/pkg/
|
@@ -97,9 +98,9 @@ module Glimmer
|
|
97
98
|
.gladiator
|
98
99
|
|
99
100
|
# Glimmer
|
100
|
-
dist
|
101
|
-
packages
|
102
|
-
vendor/jars
|
101
|
+
/dist/
|
102
|
+
/packages/
|
103
|
+
/vendor/jars/
|
103
104
|
MULTI_LINE_STRING
|
104
105
|
|
105
106
|
GEMFILE = <<~MULTI_LINE_STRING
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2007-2021 Andy Maleh
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# "Software"), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
@@ -28,9 +28,20 @@ module Glimmer
|
|
28
28
|
#
|
29
29
|
# Invoking `#swt_color` returns the SWT Color object wrapped by this proxy
|
30
30
|
#
|
31
|
-
# Follows the Proxy Design Pattern
|
31
|
+
# Follows the Proxy Design Pattern and Flyweight Design Pattern (caching memoization)
|
32
32
|
class ColorProxy
|
33
33
|
include_package 'org.eclipse.swt.graphics'
|
34
|
+
|
35
|
+
class << self
|
36
|
+
def flyweight(*args)
|
37
|
+
flyweight_color_proxies[args] ||= new(*args)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Flyweight Design Pattern memoization cache. Can be cleared if memory is needed.
|
41
|
+
def flyweight_color_proxies
|
42
|
+
@flyweight_color_proxies ||= {}
|
43
|
+
end
|
44
|
+
end
|
34
45
|
|
35
46
|
# Initializes a proxy for an SWT Color object
|
36
47
|
#
|
@@ -49,6 +60,7 @@ module Glimmer
|
|
49
60
|
#
|
50
61
|
def initialize(*args)
|
51
62
|
@args = args
|
63
|
+
ensure_arg_values_within_valid_bounds
|
52
64
|
end
|
53
65
|
|
54
66
|
def swt_color
|
@@ -64,7 +76,7 @@ module Glimmer
|
|
64
76
|
end
|
65
77
|
when 3..4
|
66
78
|
red, green, blue, alpha = @args
|
67
|
-
@swt_color = Color.new(
|
79
|
+
@swt_color = Color.new(*[red, green, blue, alpha].compact)
|
68
80
|
end
|
69
81
|
end
|
70
82
|
@swt_color
|
@@ -79,7 +91,17 @@ module Glimmer
|
|
79
91
|
|
80
92
|
def respond_to?(method, *args, &block)
|
81
93
|
super || swt_color.respond_to?(method, *args, &block)
|
82
|
-
end
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def ensure_arg_values_within_valid_bounds
|
99
|
+
if @args.to_a.size >= 3
|
100
|
+
@args = @args.map do |value|
|
101
|
+
[[value, 255].min, 0].max
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
83
105
|
end
|
84
106
|
end
|
85
107
|
end
|
@@ -34,6 +34,14 @@ module Glimmer
|
|
34
34
|
shapes.delete(shape)
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
38
|
+
def resetup_shape_paint_listeners
|
39
|
+
# TODO consider performance optimization relating to order of shape rendering (affecting only further shapes not previous ones)
|
40
|
+
shapes.each do |shape|
|
41
|
+
shape.paint_listener_proxy&.unregister
|
42
|
+
shape.setup_paint_listener
|
43
|
+
end
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
end
|