glimmer-dsl-swt 4.18.2.1 → 4.18.3.0
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/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
@@ -0,0 +1,70 @@
|
|
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
|
+
class Tetris
|
23
|
+
module View
|
24
|
+
class Block
|
25
|
+
include Glimmer::UI::CustomWidget
|
26
|
+
|
27
|
+
options :game_playfield, :block_size, :row, :column
|
28
|
+
|
29
|
+
before_body {
|
30
|
+
@bevel_constant = 20
|
31
|
+
}
|
32
|
+
|
33
|
+
body {
|
34
|
+
canvas {
|
35
|
+
layout nil
|
36
|
+
background bind(game_playfield[row][column], :color)
|
37
|
+
polygon(0, 0, block_size, 0, block_size - 4, 4, 4, 4, fill: true) {
|
38
|
+
background bind(game_playfield[row][column], :color) { |color_value|
|
39
|
+
color = color(color_value)
|
40
|
+
rgb(color.red + 4*@bevel_constant, color.green + 4*@bevel_constant, color.blue + 4*@bevel_constant)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
polygon(block_size, 0, block_size - 4, 4, block_size - 4, block_size - 4, block_size, block_size, fill: true) {
|
44
|
+
background bind(game_playfield[row][column], :color) { |color_value|
|
45
|
+
color = color(color_value)
|
46
|
+
rgb(color.red - @bevel_constant, color.green - @bevel_constant, color.blue - @bevel_constant)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
polygon(block_size, block_size, 0, block_size, 4, block_size - 4, block_size - 4, block_size - 4, fill: true) {
|
50
|
+
background bind(game_playfield[row][column], :color) { |color_value|
|
51
|
+
color = color(color_value)
|
52
|
+
rgb(color.red - 2*@bevel_constant, color.green - 2*@bevel_constant, color.blue - 2*@bevel_constant)
|
53
|
+
}
|
54
|
+
}
|
55
|
+
polygon(0, 0, 0, block_size, 4, block_size - 4, 4, 4, fill: true) {
|
56
|
+
background bind(game_playfield[row][column], :color) { |color_value|
|
57
|
+
color = color(color_value)
|
58
|
+
rgb(color.red - @bevel_constant, color.green - @bevel_constant, color.blue - @bevel_constant)
|
59
|
+
}
|
60
|
+
}
|
61
|
+
rectangle(0, 0, block_size, block_size) {
|
62
|
+
foreground bind(game_playfield[row][column], :color) { |color_value|
|
63
|
+
color_value == Model::Block::COLOR_CLEAR ? :gray : color_value
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,72 @@
|
|
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
|
+
class Tetris
|
23
|
+
module View
|
24
|
+
class GameOverDialog
|
25
|
+
include Glimmer::UI::CustomShell
|
26
|
+
|
27
|
+
options :parent_shell
|
28
|
+
|
29
|
+
body {
|
30
|
+
dialog(parent_shell) {
|
31
|
+
row_layout {
|
32
|
+
type :vertical
|
33
|
+
center true
|
34
|
+
}
|
35
|
+
text 'Tetris'
|
36
|
+
|
37
|
+
label(:center) {
|
38
|
+
text 'Game Over!'
|
39
|
+
font name: 'Menlo', height: 30, style: :bold
|
40
|
+
}
|
41
|
+
label # filler
|
42
|
+
button {
|
43
|
+
text 'Play Again?'
|
44
|
+
|
45
|
+
on_widget_selected {
|
46
|
+
Model::Game.restart
|
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
|
+
}
|
66
|
+
|
67
|
+
def exit_game
|
68
|
+
display.dispose if Model::Game.game_over?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,56 @@
|
|
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_relative 'block'
|
23
|
+
|
24
|
+
class Tetris
|
25
|
+
module View
|
26
|
+
class Playfield
|
27
|
+
include Glimmer::UI::CustomWidget
|
28
|
+
|
29
|
+
options :game_playfield, :playfield_width, :playfield_height, :block_size
|
30
|
+
|
31
|
+
body {
|
32
|
+
canvas {
|
33
|
+
grid_layout {
|
34
|
+
num_columns playfield_width
|
35
|
+
make_columns_equal_width true
|
36
|
+
margin_width block_size
|
37
|
+
margin_height block_size
|
38
|
+
horizontal_spacing 0
|
39
|
+
vertical_spacing 0
|
40
|
+
}
|
41
|
+
|
42
|
+
playfield_height.times { |row|
|
43
|
+
playfield_width.times { |column|
|
44
|
+
block(game_playfield: game_playfield, block_size: block_size, row: row, column: column) {
|
45
|
+
layout_data {
|
46
|
+
width_hint block_size
|
47
|
+
height_hint block_size
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,87 @@
|
|
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_relative 'block'
|
23
|
+
require_relative 'playfield'
|
24
|
+
|
25
|
+
class Tetris
|
26
|
+
module View
|
27
|
+
class ScoreLane
|
28
|
+
include Glimmer::UI::CustomWidget
|
29
|
+
|
30
|
+
options :block_size
|
31
|
+
|
32
|
+
before_body {
|
33
|
+
@font_name = 'Menlo'
|
34
|
+
@font_height = 32
|
35
|
+
}
|
36
|
+
|
37
|
+
body {
|
38
|
+
composite {
|
39
|
+
row_layout {
|
40
|
+
type :vertical
|
41
|
+
center true
|
42
|
+
fill true
|
43
|
+
margin_width 0
|
44
|
+
margin_right block_size
|
45
|
+
margin_height block_size
|
46
|
+
}
|
47
|
+
label(:center) {
|
48
|
+
text 'Next'
|
49
|
+
font name: @font_name, height: @font_height, style: :bold
|
50
|
+
}
|
51
|
+
playfield(game_playfield: Model::Game.preview_playfield, playfield_width: PREVIEW_PLAYFIELD_WIDTH, playfield_height: PREVIEW_PLAYFIELD_HEIGHT, block_size: BLOCK_SIZE)
|
52
|
+
|
53
|
+
label(:center) {
|
54
|
+
text 'Score'
|
55
|
+
font name: @font_name, height: @font_height, style: :bold
|
56
|
+
}
|
57
|
+
label(:center) {
|
58
|
+
text bind(Model::Game, :score)
|
59
|
+
font height: @font_height
|
60
|
+
}
|
61
|
+
|
62
|
+
label # spacer
|
63
|
+
|
64
|
+
label(:center) {
|
65
|
+
text 'Lines'
|
66
|
+
font name: @font_name, height: @font_height, style: :bold
|
67
|
+
}
|
68
|
+
label(:center) {
|
69
|
+
text bind(Model::Game, :lines)
|
70
|
+
font height: @font_height
|
71
|
+
}
|
72
|
+
|
73
|
+
label # spacer
|
74
|
+
|
75
|
+
label(:center) {
|
76
|
+
text 'Level'
|
77
|
+
font name: @font_name, height: @font_height, style: :bold
|
78
|
+
}
|
79
|
+
label(:center) {
|
80
|
+
text bind(Model::Game, :level)
|
81
|
+
font height: @font_height
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
include Glimmer
|
2
|
+
|
3
|
+
glimmer_logo = File.expand_path('../../images/glimmer-logo-hi-res.png', __dir__)
|
4
|
+
|
5
|
+
shell {
|
6
|
+
text 'Hello, Canvas Transform!'
|
7
|
+
minimum_size 330, 352
|
8
|
+
|
9
|
+
canvas { |canvas_proxy|
|
10
|
+
background :white
|
11
|
+
|
12
|
+
image(glimmer_logo, 0, 0) {
|
13
|
+
transform {
|
14
|
+
translate 110, 110
|
15
|
+
rotate 90
|
16
|
+
scale 0.21, 0.21
|
17
|
+
}
|
18
|
+
}
|
19
|
+
image(glimmer_logo, 0, 0) {
|
20
|
+
transform {
|
21
|
+
translate 110, 220
|
22
|
+
scale 0.21, 0.21
|
23
|
+
}
|
24
|
+
}
|
25
|
+
image(glimmer_logo, 0, 0) {
|
26
|
+
transform {
|
27
|
+
translate 220, 220
|
28
|
+
rotate 270
|
29
|
+
scale 0.21, 0.21
|
30
|
+
}
|
31
|
+
}
|
32
|
+
image(glimmer_logo, 0, 0) {
|
33
|
+
transform {
|
34
|
+
translate 220, 110
|
35
|
+
rotate 180
|
36
|
+
scale 0.21, 0.21
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}.open
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.18.
|
4
|
+
version: 4.18.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 1.0.
|
18
|
+
version: 1.0.9
|
19
19
|
name: glimmer
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.
|
26
|
+
version: 1.0.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -402,6 +402,7 @@ files:
|
|
402
402
|
- lib/glimmer/dsl/swt/menu_bar_expression.rb
|
403
403
|
- lib/glimmer/dsl/swt/menu_expression.rb
|
404
404
|
- lib/glimmer/dsl/swt/message_box_expression.rb
|
405
|
+
- lib/glimmer/dsl/swt/multiply_expression.rb
|
405
406
|
- lib/glimmer/dsl/swt/observe_expression.rb
|
406
407
|
- lib/glimmer/dsl/swt/property_expression.rb
|
407
408
|
- lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb
|
@@ -413,6 +414,7 @@ files:
|
|
413
414
|
- lib/glimmer/dsl/swt/sync_exec_expression.rb
|
414
415
|
- lib/glimmer/dsl/swt/tab_item_expression.rb
|
415
416
|
- lib/glimmer/dsl/swt/table_items_data_binding_expression.rb
|
417
|
+
- lib/glimmer/dsl/swt/transform_expression.rb
|
416
418
|
- lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb
|
417
419
|
- lib/glimmer/dsl/swt/tree_properties_expression.rb
|
418
420
|
- lib/glimmer/dsl/swt/widget_expression.rb
|
@@ -453,6 +455,7 @@ files:
|
|
453
455
|
- lib/glimmer/swt/tab_item_proxy.rb
|
454
456
|
- lib/glimmer/swt/table_column_proxy.rb
|
455
457
|
- lib/glimmer/swt/table_proxy.rb
|
458
|
+
- lib/glimmer/swt/transform_proxy.rb
|
456
459
|
- lib/glimmer/swt/tree_proxy.rb
|
457
460
|
- lib/glimmer/swt/widget_listener_proxy.rb
|
458
461
|
- lib/glimmer/swt/widget_proxy.rb
|
@@ -465,6 +468,14 @@ files:
|
|
465
468
|
- samples/elaborate/contact_manager/contact_repository.rb
|
466
469
|
- samples/elaborate/login.rb
|
467
470
|
- samples/elaborate/meta_sample.rb
|
471
|
+
- samples/elaborate/tetris.rb
|
472
|
+
- samples/elaborate/tetris/model/block.rb
|
473
|
+
- samples/elaborate/tetris/model/game.rb
|
474
|
+
- samples/elaborate/tetris/model/tetromino.rb
|
475
|
+
- samples/elaborate/tetris/view/block.rb
|
476
|
+
- samples/elaborate/tetris/view/game_over_dialog.rb
|
477
|
+
- samples/elaborate/tetris/view/playfield.rb
|
478
|
+
- samples/elaborate/tetris/view/score_lane.rb
|
468
479
|
- samples/elaborate/tic_tac_toe.rb
|
469
480
|
- samples/elaborate/tic_tac_toe/board.rb
|
470
481
|
- samples/elaborate/tic_tac_toe/cell.rb
|
@@ -473,6 +484,7 @@ files:
|
|
473
484
|
- samples/hello/hello_button.rb
|
474
485
|
- samples/hello/hello_canvas.rb
|
475
486
|
- samples/hello/hello_canvas_animation.rb
|
487
|
+
- samples/hello/hello_canvas_transform.rb
|
476
488
|
- samples/hello/hello_checkbox.rb
|
477
489
|
- samples/hello/hello_checkbox_group.rb
|
478
490
|
- samples/hello/hello_combo.rb
|