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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -0
  3. data/README.md +267 -39
  4. data/VERSION +1 -1
  5. data/glimmer-dsl-swt.gemspec +14 -6
  6. data/lib/ext/glimmer/config.rb +24 -7
  7. data/lib/glimmer/data_binding/widget_binding.rb +14 -4
  8. data/lib/glimmer/dsl/swt/color_expression.rb +4 -4
  9. data/lib/glimmer/dsl/swt/data_binding_expression.rb +3 -3
  10. data/lib/glimmer/dsl/swt/dsl.rb +1 -0
  11. data/lib/glimmer/dsl/swt/multiply_expression.rb +53 -0
  12. data/lib/glimmer/dsl/swt/property_expression.rb +4 -2
  13. data/lib/glimmer/dsl/swt/shape_expression.rb +2 -4
  14. data/lib/glimmer/dsl/swt/transform_expression.rb +55 -0
  15. data/lib/glimmer/dsl/swt/widget_expression.rb +2 -1
  16. data/lib/glimmer/swt/color_proxy.rb +28 -6
  17. data/lib/glimmer/swt/custom/drawable.rb +8 -0
  18. data/lib/glimmer/swt/custom/shape.rb +66 -26
  19. data/lib/glimmer/swt/directory_dialog_proxy.rb +3 -3
  20. data/lib/glimmer/swt/display_proxy.rb +25 -4
  21. data/lib/glimmer/swt/file_dialog_proxy.rb +3 -3
  22. data/lib/glimmer/swt/layout_data_proxy.rb +3 -3
  23. data/lib/glimmer/swt/shell_proxy.rb +20 -5
  24. data/lib/glimmer/swt/table_proxy.rb +19 -4
  25. data/lib/glimmer/swt/transform_proxy.rb +109 -0
  26. data/lib/glimmer/swt/widget_listener_proxy.rb +14 -5
  27. data/lib/glimmer/swt/widget_proxy.rb +31 -20
  28. data/lib/glimmer/ui/custom_shell.rb +13 -11
  29. data/lib/glimmer/ui/custom_widget.rb +68 -44
  30. data/samples/elaborate/meta_sample.rb +81 -24
  31. data/samples/elaborate/tetris.rb +102 -47
  32. data/samples/elaborate/tetris/model/block.rb +2 -2
  33. data/samples/elaborate/tetris/model/game.rb +236 -74
  34. data/samples/elaborate/tetris/model/past_game.rb +26 -0
  35. data/samples/elaborate/tetris/model/tetromino.rb +123 -35
  36. data/samples/elaborate/tetris/view/block.rb +34 -9
  37. data/samples/elaborate/tetris/view/high_score_dialog.rb +114 -0
  38. data/samples/elaborate/tetris/view/playfield.rb +12 -5
  39. data/samples/elaborate/tetris/view/score_lane.rb +87 -0
  40. data/samples/elaborate/tetris/view/tetris_menu_bar.rb +123 -0
  41. data/samples/elaborate/tic_tac_toe.rb +4 -4
  42. data/samples/hello/hello_canvas_transform.rb +40 -0
  43. data/samples/hello/hello_link.rb +1 -1
  44. metadata +12 -4
@@ -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, :game
31
+
32
+ before_body {
33
+ @font_name = FONT_NAME
34
+ @font_height = FONT_TITLE_HEIGHT
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: FONT_TITLE_STYLE
50
+ }
51
+ playfield(game_playfield: game.preview_playfield, playfield_width: Model::Game::PREVIEW_PLAYFIELD_WIDTH, playfield_height: Model::Game::PREVIEW_PLAYFIELD_HEIGHT, block_size: block_size)
52
+
53
+ label(:center) {
54
+ text 'Score'
55
+ font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
56
+ }
57
+ label(:center) {
58
+ text bind(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: FONT_TITLE_STYLE
67
+ }
68
+ label(:center) {
69
+ text bind(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: FONT_TITLE_STYLE
78
+ }
79
+ label(:center) {
80
+ text bind(game, :level)
81
+ font height: @font_height
82
+ }
83
+ }
84
+ }
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,123 @@
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 TetrisMenuBar
25
+ include Glimmer::UI::CustomWidget
26
+
27
+ options :game
28
+
29
+ body {
30
+ menu_bar {
31
+ menu {
32
+ text '&Game'
33
+
34
+ menu_item {
35
+ text '&Start'
36
+ enabled bind(game, :game_over)
37
+ accelerator :command, :s
38
+
39
+ on_widget_selected {
40
+ game.start!
41
+ }
42
+ }
43
+ menu_item(:check) {
44
+ text '&Pause'
45
+ accelerator :command, :p
46
+ enabled bind(game, :game_over, on_read: :!)
47
+ selection bind(game, :paused)
48
+ }
49
+ menu_item {
50
+ text '&Restart'
51
+ accelerator :command, :r
52
+
53
+ on_widget_selected {
54
+ game.restart!
55
+ }
56
+ }
57
+ menu_item(:separator)
58
+ menu_item {
59
+ text '&Exit'
60
+ accelerator :command, :x
61
+
62
+ on_widget_selected {
63
+ parent_proxy.close
64
+ }
65
+ }
66
+ } # end of menu
67
+
68
+ menu {
69
+ text '&View'
70
+
71
+ menu {
72
+ text '&High Scores'
73
+ menu_item {
74
+ text '&Show'
75
+ accelerator :command, :shift, :h
76
+
77
+ on_widget_selected {
78
+ parent_custom_shell&.show_high_score_dialog
79
+ }
80
+ }
81
+ menu_item {
82
+ text '&Clear'
83
+ accelerator :command, :shift, :c
84
+
85
+ on_widget_selected {
86
+ game.clear_high_scores!
87
+ }
88
+ }
89
+ }
90
+ } # end of menu
91
+
92
+ menu {
93
+ text '&Options'
94
+ menu_item(:check) {
95
+ text '&Beeping'
96
+ accelerator :command, :b
97
+ selection bind(game, :beeping)
98
+ }
99
+ } # end of menu
100
+
101
+ menu {
102
+ text '&Help'
103
+
104
+ menu_item {
105
+ text '&About'
106
+ accelerator :command, :shift, :a
107
+
108
+ on_widget_selected {
109
+ parent_custom_shell&.show_about_dialog
110
+ }
111
+ }
112
+ } # end of menu
113
+ }
114
+ }
115
+
116
+ def parent_custom_shell
117
+ # grab custom shell widget wrapping parent widget proxy (i.e. Tetris) and invoke method on it
118
+ the_parent_custom_shell = parent_proxy&.get_data('custom_shell')
119
+ the_parent_custom_shell if the_parent_custom_shell&.visible?
120
+ end
121
+ end
122
+ end
123
+ 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
@@ -28,7 +28,7 @@ class TicTacToe
28
28
  @tic_tac_toe_board = Board.new
29
29
  @shell = shell {
30
30
  text "Tic-Tac-Toe"
31
- minimum_size 150, 178
31
+ minimum_size 176, 200
32
32
  composite {
33
33
  grid_layout 3, true
34
34
  (1..3).each { |row|
@@ -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 {
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
@@ -49,7 +49,7 @@ shell { |main_shell|
49
49
  }
50
50
  on_mouse_up { |mouse_event|
51
51
  unless @selected_link.nil?
52
- @help_shell.close unless @help_shell.nil? || @help_shell.is_disposed
52
+ @help_shell.close unless @help_shell.nil? || @help_shell.disposed?
53
53
  @help_shell = shell(:no_trim) {
54
54
  grid_layout {
55
55
  margin_width 10
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.2.3
4
+ version: 4.18.3.2
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-23 00:00:00.000000000 Z
11
+ date: 2021-01-28 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.8
18
+ version: 1.0.11
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.8
26
+ version: 1.0.11
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
@@ -468,9 +471,13 @@ files:
468
471
  - samples/elaborate/tetris.rb
469
472
  - samples/elaborate/tetris/model/block.rb
470
473
  - samples/elaborate/tetris/model/game.rb
474
+ - samples/elaborate/tetris/model/past_game.rb
471
475
  - samples/elaborate/tetris/model/tetromino.rb
472
476
  - samples/elaborate/tetris/view/block.rb
477
+ - samples/elaborate/tetris/view/high_score_dialog.rb
473
478
  - samples/elaborate/tetris/view/playfield.rb
479
+ - samples/elaborate/tetris/view/score_lane.rb
480
+ - samples/elaborate/tetris/view/tetris_menu_bar.rb
474
481
  - samples/elaborate/tic_tac_toe.rb
475
482
  - samples/elaborate/tic_tac_toe/board.rb
476
483
  - samples/elaborate/tic_tac_toe/cell.rb
@@ -479,6 +486,7 @@ files:
479
486
  - samples/hello/hello_button.rb
480
487
  - samples/hello/hello_canvas.rb
481
488
  - samples/hello/hello_canvas_animation.rb
489
+ - samples/hello/hello_canvas_transform.rb
482
490
  - samples/hello/hello_checkbox.rb
483
491
  - samples/hello/hello_checkbox_group.rb
484
492
  - samples/hello/hello_combo.rb