glimmer-dsl-swt 4.18.2.4 → 4.18.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -0
- data/README.md +240 -30
- data/VERSION +1 -1
- data/glimmer-dsl-swt.gemspec +13 -7
- data/lib/ext/glimmer/config.rb +24 -7
- data/lib/glimmer/data_binding/table_items_binding.rb +8 -5
- data/lib/glimmer/data_binding/widget_binding.rb +22 -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/{samples/elaborate/tetris/view/game_over_dialog.rb → lib/glimmer/dsl/swt/transform_expression.rb} +29 -46
- 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 +26 -5
- data/lib/glimmer/swt/file_dialog_proxy.rb +3 -3
- data/lib/glimmer/swt/shell_proxy.rb +24 -4
- data/lib/glimmer/swt/table_proxy.rb +31 -7
- 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 +35 -20
- data/lib/glimmer/ui/custom_shell.rb +11 -9
- data/lib/glimmer/ui/custom_widget.rb +65 -39
- data/samples/elaborate/meta_sample.rb +81 -24
- data/samples/elaborate/tetris.rb +105 -44
- data/samples/elaborate/tetris/model/block.rb +1 -1
- data/samples/elaborate/tetris/model/game.rb +233 -137
- data/samples/elaborate/tetris/model/past_game.rb +26 -0
- data/samples/elaborate/tetris/model/tetromino.rb +46 -30
- data/samples/elaborate/tetris/view/block.rb +33 -5
- data/samples/elaborate/tetris/view/high_score_dialog.rb +133 -0
- data/samples/elaborate/tetris/view/playfield.rb +1 -1
- data/samples/elaborate/tetris/view/score_lane.rb +11 -11
- data/samples/elaborate/tetris/view/tetris_menu_bar.rb +121 -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 +11 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.18.
|
1
|
+
4.18.3.3
|
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.3 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.3"
|
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-29"
|
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,11 +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",
|
140
|
-
"samples/elaborate/tetris/view/
|
144
|
+
"samples/elaborate/tetris/view/high_score_dialog.rb",
|
141
145
|
"samples/elaborate/tetris/view/playfield.rb",
|
142
146
|
"samples/elaborate/tetris/view/score_lane.rb",
|
147
|
+
"samples/elaborate/tetris/view/tetris_menu_bar.rb",
|
143
148
|
"samples/elaborate/tic_tac_toe.rb",
|
144
149
|
"samples/elaborate/tic_tac_toe/board.rb",
|
145
150
|
"samples/elaborate/tic_tac_toe/cell.rb",
|
@@ -148,6 +153,7 @@ Gem::Specification.new do |s|
|
|
148
153
|
"samples/hello/hello_button.rb",
|
149
154
|
"samples/hello/hello_canvas.rb",
|
150
155
|
"samples/hello/hello_canvas_animation.rb",
|
156
|
+
"samples/hello/hello_canvas_transform.rb",
|
151
157
|
"samples/hello/hello_checkbox.rb",
|
152
158
|
"samples/hello/hello_checkbox_group.rb",
|
153
159
|
"samples/hello/hello_combo.rb",
|
@@ -190,7 +196,7 @@ Gem::Specification.new do |s|
|
|
190
196
|
s.specification_version = 4
|
191
197
|
|
192
198
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
193
|
-
s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
199
|
+
s.add_runtime_dependency(%q<glimmer>.freeze, ["~> 1.0.11"])
|
194
200
|
s.add_runtime_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
195
201
|
s.add_runtime_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
196
202
|
s.add_runtime_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
|
@@ -209,7 +215,7 @@ Gem::Specification.new do |s|
|
|
209
215
|
s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.16.1"])
|
210
216
|
s.add_development_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
211
217
|
else
|
212
|
-
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
218
|
+
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.11"])
|
213
219
|
s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
214
220
|
s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
215
221
|
s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0.11.0", "< 2.0.0"])
|
@@ -229,7 +235,7 @@ Gem::Specification.new do |s|
|
|
229
235
|
s.add_dependency(%q<simplecov-lcov>.freeze, ["~> 0.7.0"])
|
230
236
|
end
|
231
237
|
else
|
232
|
-
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.
|
238
|
+
s.add_dependency(%q<glimmer>.freeze, ["~> 1.0.11"])
|
233
239
|
s.add_dependency(%q<super_module>.freeze, [">= 1.4.1", "< 2.0.0"])
|
234
240
|
s.add_dependency(%q<nested_inherited_jruby_include_package>.freeze, [">= 0.3.0", "< 2.0.0"])
|
235
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
|
@@ -36,7 +36,9 @@ module Glimmer
|
|
36
36
|
def initialize(parent, model_binding, column_properties)
|
37
37
|
@table = parent
|
38
38
|
@model_binding = model_binding
|
39
|
+
@read_only_sort = @model_binding.binding_options[:read_only_sort]
|
39
40
|
@table.swt_widget.data = @model_binding
|
41
|
+
@table.swt_widget.set_data('table_items_binding', self)
|
40
42
|
@column_properties = column_properties
|
41
43
|
@table.on_widget_disposed do |dispose_event|
|
42
44
|
unregister_all_observables
|
@@ -50,8 +52,8 @@ module Glimmer
|
|
50
52
|
call
|
51
53
|
end
|
52
54
|
|
53
|
-
def call(new_model_collection=nil)
|
54
|
-
new_model_collection = @model_binding.evaluate_property # this ensures applying converters (e.g. :on_read)
|
55
|
+
def call(new_model_collection=nil, internal_sort: false)
|
56
|
+
new_model_collection = model_binding_evaluated_property = @model_binding.evaluate_property unless internal_sort # this ensures applying converters (e.g. :on_read)
|
55
57
|
table_cells = @table.swt_widget.items.map {|item| @table.column_properties.size.times.map {|i| item.get_text(i)} }
|
56
58
|
model_cells = new_model_collection.to_a.map {|m| @table.cells_for(m)}
|
57
59
|
return if table_cells == model_cells
|
@@ -61,10 +63,10 @@ module Glimmer
|
|
61
63
|
add_dependent(@table_observer_registration => @table_items_observer_registration)
|
62
64
|
@model_collection = new_model_collection
|
63
65
|
end
|
64
|
-
populate_table(@model_collection, @table, @column_properties)
|
66
|
+
populate_table(@model_collection, @table, @column_properties, internal_sort: internal_sort)
|
65
67
|
end
|
66
68
|
|
67
|
-
def populate_table(model_collection, parent, column_properties)
|
69
|
+
def populate_table(model_collection, parent, column_properties, internal_sort: false)
|
68
70
|
selected_table_item_models = parent.swt_widget.getSelection.map(&:get_data)
|
69
71
|
parent.finish_edit!
|
70
72
|
parent.swt_widget.items.each(&:dispose)
|
@@ -78,7 +80,8 @@ module Glimmer
|
|
78
80
|
end
|
79
81
|
selected_table_items = parent.search {|item| selected_table_item_models.include?(item.get_data) }
|
80
82
|
parent.swt_widget.setSelection(selected_table_items)
|
81
|
-
parent.sort!
|
83
|
+
sorted_model_collection = parent.sort!(internal_sort: internal_sort)
|
84
|
+
call(sorted_model_collection, internal_sort: true) if @read_only_sort && !internal_sort && !sorted_model_collection.nil?
|
82
85
|
parent.swt_widget.redraw if parent&.swt_widget&.respond_to?(:redraw)
|
83
86
|
end
|
84
87
|
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,10 +46,26 @@ 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
|
+
if @widget.respond_to?(:disposed?) && @widget.disposed?
|
52
|
+
unregister_all_observables
|
53
|
+
return
|
54
|
+
end
|
55
|
+
@widget.set_attribute(@property, converted_value) unless evaluate_property == converted_value
|
56
|
+
end
|
57
|
+
if Config.auto_sync_exec? && Config.require_sync_exec?
|
58
|
+
SWT::DisplayProxy.instance.sync_exec(&update_operation)
|
59
|
+
else
|
60
|
+
update_operation.call
|
61
|
+
end
|
48
62
|
end
|
49
63
|
|
50
64
|
def evaluate_property
|
65
|
+
if @widget.respond_to?(:disposed?) && @widget.disposed?
|
66
|
+
unregister_all_observables
|
67
|
+
return
|
68
|
+
end
|
51
69
|
@widget.get_attribute(@property)
|
52
70
|
end
|
53
71
|
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
|
@@ -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
|
|
@@ -19,54 +19,37 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
body_root.close
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
on_shell_activated {
|
53
|
-
Model::Game.game_over = true
|
54
|
-
display.beep
|
55
|
-
}
|
56
|
-
|
57
|
-
on_shell_closed {
|
58
|
-
exit_game
|
59
|
-
}
|
60
|
-
|
61
|
-
on_key_pressed { |event|
|
62
|
-
exit_game if event.keyCode == swt(:cr)
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
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
|
66
48
|
|
67
|
-
def exit_game
|
68
|
-
display.dispose if Model::Game.game_over?
|
69
49
|
end
|
50
|
+
|
70
51
|
end
|
52
|
+
|
71
53
|
end
|
54
|
+
|
72
55
|
end
|