glimmer-dsl-swt 4.18.2.3 → 4.18.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +59 -0
- data/README.md +267 -39
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +14 -6
- data/lib/ext/glimmer/config.rb +24 -7
- data/lib/glimmer/data_binding/widget_binding.rb +14 -4
- 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/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/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/directory_dialog_proxy.rb +3 -3
- data/lib/glimmer/swt/display_proxy.rb +25 -4
- data/lib/glimmer/swt/file_dialog_proxy.rb +3 -3
- data/lib/glimmer/swt/layout_data_proxy.rb +3 -3
- data/lib/glimmer/swt/shell_proxy.rb +20 -5
- data/lib/glimmer/swt/table_proxy.rb +19 -4
- data/lib/glimmer/swt/transform_proxy.rb +109 -0
- data/lib/glimmer/swt/widget_listener_proxy.rb +14 -5
- data/lib/glimmer/swt/widget_proxy.rb +31 -20
- data/lib/glimmer/ui/custom_shell.rb +13 -11
- data/lib/glimmer/ui/custom_widget.rb +68 -44
- data/samples/elaborate/meta_sample.rb +81 -24
- data/samples/elaborate/tetris.rb +102 -47
- data/samples/elaborate/tetris/model/block.rb +2 -2
- data/samples/elaborate/tetris/model/game.rb +236 -74
- data/samples/elaborate/tetris/model/past_game.rb +26 -0
- data/samples/elaborate/tetris/model/tetromino.rb +123 -35
- data/samples/elaborate/tetris/view/block.rb +34 -9
- data/samples/elaborate/tetris/view/high_score_dialog.rb +114 -0
- data/samples/elaborate/tetris/view/playfield.rb +12 -5
- data/samples/elaborate/tetris/view/score_lane.rb +87 -0
- data/samples/elaborate/tetris/view/tetris_menu_bar.rb +123 -0
- data/samples/elaborate/tic_tac_toe.rb +4 -4
- data/samples/hello/hello_canvas_transform.rb +40 -0
- data/samples/hello/hello_link.rb +1 -1
- metadata +12 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.2
|
1
|
+
4.18.3.2
|
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.2
|
5
|
+
# stub: glimmer-dsl-swt 4.18.3.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "glimmer-dsl-swt".freeze
|
9
|
-
s.version = "4.18.2
|
9
|
+
s.version = "4.18.3.2"
|
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-28"
|
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",
|
@@ -135,9 +138,13 @@ Gem::Specification.new do |s|
|
|
135
138
|
"samples/elaborate/tetris.rb",
|
136
139
|
"samples/elaborate/tetris/model/block.rb",
|
137
140
|
"samples/elaborate/tetris/model/game.rb",
|
141
|
+
"samples/elaborate/tetris/model/past_game.rb",
|
138
142
|
"samples/elaborate/tetris/model/tetromino.rb",
|
139
143
|
"samples/elaborate/tetris/view/block.rb",
|
144
|
+
"samples/elaborate/tetris/view/high_score_dialog.rb",
|
140
145
|
"samples/elaborate/tetris/view/playfield.rb",
|
146
|
+
"samples/elaborate/tetris/view/score_lane.rb",
|
147
|
+
"samples/elaborate/tetris/view/tetris_menu_bar.rb",
|
141
148
|
"samples/elaborate/tic_tac_toe.rb",
|
142
149
|
"samples/elaborate/tic_tac_toe/board.rb",
|
143
150
|
"samples/elaborate/tic_tac_toe/cell.rb",
|
@@ -146,6 +153,7 @@ Gem::Specification.new do |s|
|
|
146
153
|
"samples/hello/hello_button.rb",
|
147
154
|
"samples/hello/hello_canvas.rb",
|
148
155
|
"samples/hello/hello_canvas_animation.rb",
|
156
|
+
"samples/hello/hello_canvas_transform.rb",
|
149
157
|
"samples/hello/hello_checkbox.rb",
|
150
158
|
"samples/hello/hello_checkbox_group.rb",
|
151
159
|
"samples/hello/hello_combo.rb",
|
@@ -188,7 +196,7 @@ Gem::Specification.new do |s|
|
|
188
196
|
s.specification_version = 4
|
189
197
|
|
190
198
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
191
|
-
s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
199
|
+
s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.11"])
|
192
200
|
s.add_runtime_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
193
201
|
s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
194
202
|
s.add_runtime_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
|
@@ -207,7 +215,7 @@ Gem::Specification.new do |s|
|
|
207
215
|
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
208
216
|
s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
209
217
|
else
|
210
|
-
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
218
|
+
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.11"])
|
211
219
|
s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
212
220
|
s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
213
221
|
s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
|
@@ -227,7 +235,7 @@ Gem::Specification.new do |s|
|
|
227
235
|
s.add_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
228
236
|
end
|
229
237
|
else
|
230
|
-
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
238
|
+
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.11"])
|
231
239
|
s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
232
240
|
s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
233
241
|
s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
|
data/lib/ext/glimmer/config.rb
CHANGED
@@ -32,6 +32,8 @@ module Glimmer
|
|
32
32
|
'org.eclipse.swt.custom',
|
33
33
|
'org.eclipse.swt.dnd',
|
34
34
|
]
|
35
|
+
DEFAULT_AUTO_SYNC_EXEC = false
|
36
|
+
GUI_THREAD = Thread.current
|
35
37
|
|
36
38
|
class << self
|
37
39
|
# Tells Glimmer to import SWT packages into including class (default: true)
|
@@ -45,6 +47,22 @@ module Glimmer
|
|
45
47
|
@@import_swt_packages
|
46
48
|
end
|
47
49
|
|
50
|
+
# Tells Glimmer to avoid automatic use of sync_exec when invoking GUI calls from another thread (default: true)
|
51
|
+
def auto_sync_exec=(value)
|
52
|
+
@@auto_sync_exec = value
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns whether Glimmer will import SWT packages into including class
|
56
|
+
def auto_sync_exec
|
57
|
+
@@auto_sync_exec = DEFAULT_AUTO_SYNC_EXEC if !defined?(@@auto_sync_exec)
|
58
|
+
@@auto_sync_exec
|
59
|
+
end
|
60
|
+
alias auto_sync_exec? auto_sync_exec
|
61
|
+
|
62
|
+
def require_sync_exec?
|
63
|
+
Thread.current != GUI_THREAD
|
64
|
+
end
|
65
|
+
|
48
66
|
# Returns Logging Devices. Default is [:stdout, :syslog]
|
49
67
|
def logging_devices
|
50
68
|
unless defined? @@logging_devices
|
@@ -140,11 +158,10 @@ end
|
|
140
158
|
|
141
159
|
Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
|
142
160
|
method = method_symbol.to_s
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
result ||= ['finish_edit!', 'search', 'all_tree_items', 'depth_first_search'].include?(method) && is_a?(Glimmer::UI::CustomWidget) && body_root.respond_to?(method)
|
161
|
+
return true if method == 'post_initialize_child'
|
162
|
+
return true if method == 'handle'
|
163
|
+
return true if method.end_with?('=')
|
164
|
+
return true if ['drag_source_proxy', 'drop_target_proxy'].include?(method) && is_a?(Glimmer::UI::CustomWidget)
|
165
|
+
return true if method == 'dispose' && is_a?(Glimmer::UI::CustomWidget) && respond_to?(method)
|
166
|
+
return true if ['finish_edit!', 'search', 'all_tree_items', 'depth_first_search'].include?(method) && is_a?(Glimmer::UI::CustomWidget) && body_root.respond_to?(method)
|
150
167
|
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
|
@@ -22,6 +22,8 @@
|
|
22
22
|
require 'glimmer/data_binding/observable'
|
23
23
|
require 'glimmer/data_binding/observer'
|
24
24
|
|
25
|
+
require 'glimmer/swt/display_proxy'
|
26
|
+
|
25
27
|
module Glimmer
|
26
28
|
module DataBinding
|
27
29
|
class WidgetBinding
|
@@ -44,7 +46,15 @@ module Glimmer
|
|
44
46
|
|
45
47
|
def call(value)
|
46
48
|
converted_value = translated_value = @translator.call(value)
|
47
|
-
|
49
|
+
|
50
|
+
update_operation = lambda do
|
51
|
+
@widget.set_attribute(@property, converted_value) unless evaluate_property == converted_value
|
52
|
+
end
|
53
|
+
if Config.auto_sync_exec? && Config.require_sync_exec?
|
54
|
+
SWT::DisplayProxy.instance.sync_exec(&update_operation)
|
55
|
+
else
|
56
|
+
update_operation.call
|
57
|
+
end
|
48
58
|
end
|
49
59
|
|
50
60
|
def evaluate_property
|
@@ -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
|
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) &&
|
@@ -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
|