glimmer-dsl-swt 4.19.0.2 → 4.20.0.4

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/README.md +26 -27
  4. data/RUBY_VERSION +1 -1
  5. data/VERSION +1 -1
  6. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +44 -15
  7. data/docs/reference/GLIMMER_SAMPLES.md +157 -17
  8. data/glimmer-dsl-swt.gemspec +0 -0
  9. data/lib/glimmer/data_binding/shine.rb +41 -26
  10. data/lib/glimmer/dsl/swt/dsl.rb +2 -1
  11. data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +49 -0
  12. data/lib/glimmer/dsl/swt/widget_expression.rb +2 -0
  13. data/lib/glimmer/launcher.rb +6 -0
  14. data/lib/glimmer/rake_task/scaffold.rb +0 -2
  15. data/lib/glimmer/swt/combo_proxy.rb +48 -0
  16. data/lib/glimmer/swt/custom/code_text.rb +13 -9
  17. data/lib/glimmer/swt/tool_bar_proxy.rb +51 -0
  18. data/lib/glimmer/swt/widget_proxy.rb +6 -0
  19. data/samples/elaborate/contact_manager.rb +7 -5
  20. data/samples/elaborate/login.rb +18 -16
  21. data/samples/elaborate/mandelbrot_fractal.rb +2 -2
  22. data/samples/elaborate/metronome.rb +3 -3
  23. data/samples/elaborate/tetris/model/game.rb +0 -3
  24. data/samples/elaborate/tic_tac_toe.rb +2 -2
  25. data/samples/elaborate/weather.rb +164 -0
  26. data/samples/hello/hello_button.rb +1 -1
  27. data/samples/hello/hello_c_combo.rb +2 -1
  28. data/samples/hello/hello_c_tab.rb +1 -0
  29. data/samples/hello/hello_canvas.rb +5 -5
  30. data/samples/hello/hello_canvas_animation_data_binding.rb +1 -1
  31. data/samples/hello/hello_canvas_data_binding.rb +16 -16
  32. data/samples/hello/hello_checkbox.rb +4 -4
  33. data/samples/hello/hello_code_text.rb +3 -57
  34. data/samples/hello/hello_color_dialog.rb +1 -1
  35. data/samples/hello/hello_combo.rb +1 -1
  36. data/samples/hello/hello_composite.rb +71 -0
  37. data/samples/hello/hello_computed.rb +5 -5
  38. data/samples/hello/hello_cool_bar.rb +147 -0
  39. data/samples/hello/hello_custom_widget.rb +1 -1
  40. data/samples/hello/hello_date_time.rb +4 -4
  41. data/samples/hello/hello_dialog.rb +3 -2
  42. data/samples/hello/hello_drag_and_drop.rb +1 -1
  43. data/samples/hello/hello_file_dialog.rb +1 -1
  44. data/samples/hello/hello_font_dialog.rb +3 -3
  45. data/samples/hello/hello_group.rb +6 -6
  46. data/samples/hello/hello_layout.rb +243 -0
  47. data/samples/hello/hello_link.rb +56 -50
  48. data/samples/hello/hello_list_multi_selection.rb +1 -1
  49. data/samples/hello/hello_list_single_selection.rb +1 -1
  50. data/samples/hello/hello_progress_bar.rb +10 -10
  51. data/samples/hello/hello_radio.rb +6 -6
  52. data/samples/hello/hello_sash_form.rb +4 -4
  53. data/samples/hello/hello_shell.rb +205 -0
  54. data/samples/hello/hello_spinner.rb +6 -2
  55. data/samples/hello/hello_styled_text.rb +11 -11
  56. data/samples/hello/hello_tool_bar.rb +143 -0
  57. data/vendor/swt/linux/swt.jar +0 -0
  58. data/vendor/swt/linux_aarch64/swt.jar +0 -0
  59. data/vendor/swt/mac/swt.jar +0 -0
  60. data/vendor/swt/mac_aarch64/swt.jar +0 -0
  61. data/vendor/swt/windows/swt.jar +0 -0
  62. metadata +14 -3
@@ -60,12 +60,12 @@ class HelloRadio
60
60
 
61
61
  radio {
62
62
  text 'Male'
63
- selection bind(@person, :male)
63
+ selection <=> [@person, :male]
64
64
  }
65
65
 
66
66
  radio {
67
67
  text 'Female'
68
- selection bind(@person, :female)
68
+ selection <=> [@person, :female]
69
69
  }
70
70
  }
71
71
 
@@ -79,22 +79,22 @@ class HelloRadio
79
79
 
80
80
  radio {
81
81
  text 'Child'
82
- selection bind(@person, :child)
82
+ selection <=> [@person, :child]
83
83
  }
84
84
 
85
85
  radio {
86
86
  text 'Teen'
87
- selection bind(@person, :teen)
87
+ selection <=> [@person, :teen]
88
88
  }
89
89
 
90
90
  radio {
91
91
  text 'Adult'
92
- selection bind(@person, :adult)
92
+ selection <=> [@person, :adult]
93
93
  }
94
94
 
95
95
  radio {
96
96
  text 'Senior'
97
- selection bind(@person, :senior)
97
+ selection <=> [@person, :senior]
98
98
  }
99
99
  }
100
100
 
@@ -54,8 +54,8 @@ shell {
54
54
  layout_data(:fill, :fill, true, true) {
55
55
  height_hint 200
56
56
  }
57
- sash_width bind(@presenter, :sash_width)
58
- orientation bind(@presenter, :orientation_style)
57
+ sash_width <=> [@presenter, :sash_width]
58
+ orientation <=> [@presenter, :orientation_style]
59
59
  weights 1, 2
60
60
 
61
61
  @green_label = label {
@@ -86,7 +86,7 @@ shell {
86
86
  layout_data(:fill, :center, true, false) {
87
87
  width_hint 100
88
88
  }
89
- selection bind(@presenter, :sash_width)
89
+ selection <=> [@presenter, :sash_width]
90
90
  font height: 16
91
91
  }
92
92
 
@@ -99,7 +99,7 @@ shell {
99
99
  layout_data(:fill, :center, true, false) {
100
100
  width_hint 100
101
101
  }
102
- selection bind(@presenter, :orientation)
102
+ selection <=> [@presenter, :orientation]
103
103
  font height: 16
104
104
  }
105
105
 
@@ -0,0 +1,205 @@
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-swt'
23
+
24
+ class HelloShell
25
+ include Glimmer::UI::CustomShell
26
+
27
+ body {
28
+ # this is the initial shell that opens. If you close it, you close the app.
29
+ shell { |root_shell_proxy|
30
+ row_layout(:vertical)
31
+ text 'Hello, Shell!'
32
+
33
+ button {
34
+ layout_data {
35
+ width 200
36
+ height 50
37
+ }
38
+ text "Nested Shell"
39
+
40
+ on_widget_selected {
41
+ # build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
42
+ shell(root_shell_proxy) {
43
+ # shell has fill_layout(:horizontal) by default with no margins
44
+ text 'Nested Shell'
45
+
46
+ label {
47
+ font height: 20
48
+ text "Since this shell is nested, \nyou can hit ESC to close"
49
+ }
50
+ }.open
51
+ }
52
+ }
53
+
54
+ button {
55
+ layout_data {
56
+ width 200
57
+ height 50
58
+ }
59
+ text "Independent Shell"
60
+
61
+ on_widget_selected {
62
+ # build an independent shell, meaning a shell that is independent of its parent
63
+ shell {
64
+ # shell has fill_layout(:horizontal) by default with no margins
65
+ text 'Independent Shell'
66
+
67
+ label {
68
+ font height: 20
69
+ text "Since this shell is independent, \nyou cannot close by hitting ESC"
70
+ }
71
+ }.open
72
+ }
73
+ }
74
+
75
+ button {
76
+ layout_data {
77
+ width 200
78
+ height 50
79
+ }
80
+ text "Close-Button Shell"
81
+
82
+ on_widget_selected {
83
+ shell(:close) {
84
+ # shell has fill_layout(:horizontal) by default with no margins
85
+ text 'Nested Shell'
86
+
87
+ label {
88
+ font height: 20
89
+ text "Shell with close button only\n(varies per platform)"
90
+ }
91
+ }.open
92
+ }
93
+ }
94
+
95
+ button {
96
+ layout_data {
97
+ width 200
98
+ height 50
99
+ }
100
+ text "Minimize-Button Shell"
101
+
102
+ on_widget_selected {
103
+ # build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
104
+ shell(root_shell_proxy, :min) {
105
+ # shell has fill_layout(:horizontal) by default with no margins
106
+ text 'Minimize-Button Shell'
107
+
108
+ label {
109
+ font height: 20
110
+ text "Shell with minimize button only\n(varies per platform)"
111
+ }
112
+ }.open
113
+ }
114
+ }
115
+
116
+ button {
117
+ layout_data {
118
+ width 200
119
+ height 50
120
+ }
121
+ text "Maximize-Button Shell"
122
+
123
+ on_widget_selected {
124
+ # build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
125
+ shell(root_shell_proxy, :max) {
126
+ # shell has fill_layout(:horizontal) by default with no margins
127
+ text 'Maximize-Button Shell'
128
+
129
+ label {
130
+ font height: 20
131
+ text "Shell with maximize button only\n(varies per platform)"
132
+ }
133
+ }.open
134
+ }
135
+ }
136
+
137
+ button {
138
+ layout_data {
139
+ width 200
140
+ height 50
141
+ }
142
+ text "Buttonless Shell"
143
+
144
+ on_widget_selected {
145
+ # build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
146
+ shell(root_shell_proxy, :title) {
147
+ # shell has fill_layout(:horizontal) by default with no margins
148
+ text 'Buttonless Shell'
149
+
150
+ label {
151
+ font height: 20
152
+ text "Buttonless shell (title only)\n(varies per platform)"
153
+ }
154
+ }.open
155
+ }
156
+ }
157
+
158
+ button {
159
+ layout_data {
160
+ width 200
161
+ height 50
162
+ }
163
+ text "No Trim Shell"
164
+
165
+ on_widget_selected {
166
+ # build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
167
+ shell(root_shell_proxy, :no_trim) {
168
+ # shell has fill_layout(:horizontal) by default with no margins
169
+ text 'No Trim Shell'
170
+
171
+ label {
172
+ font height: 20
173
+ text "No trim shell, meaning no buttons or title bar.\n(varies per platform)"
174
+ }
175
+ }.open
176
+ }
177
+ }
178
+
179
+ button {
180
+ layout_data {
181
+ width 200
182
+ height 50
183
+ }
184
+ text "Always On Top Shell"
185
+
186
+ on_widget_selected {
187
+ # build a nested shell, meaning a shell that specifies its parent shell (root_shell_proxy)
188
+ shell(root_shell_proxy, :on_top) {
189
+ # shell has fill_layout(:horizontal) by default with no margins
190
+ text 'Always On Top Shell'
191
+
192
+ label {
193
+ font height: 20
194
+ text "Always on top shell.\n(varies per platform)"
195
+ }
196
+ }.open
197
+ }
198
+ }
199
+
200
+ }
201
+
202
+ }
203
+ end
204
+
205
+ HelloShell.launch
@@ -47,6 +47,9 @@ class HelloSpinner
47
47
  grid_layout 3, false
48
48
 
49
49
  label {
50
+ layout_data {
51
+ width_hint 240
52
+ }
50
53
  text 'Amount:'
51
54
  font style: :bold
52
55
  }
@@ -61,11 +64,12 @@ class HelloSpinner
61
64
  maximum 15000 # maximum value (including digits after the decimal point)
62
65
  increment 500 # increment on up and down (including digits after the decimal point)
63
66
  page_increment 5000 # page increment on page up and page down (including digits after the decimal point)
64
- selection bind(@person, :donation) # selection must be set last if other properties are configured to ensure value is within bounds
67
+ selection <=> [@person, :donation] # selection must be set last if other properties are configured to ensure value is within bounds
65
68
  }
66
69
 
67
70
  label {
68
- text bind(@person, :donation) {|value| "Thank you for your donation of $#{"%.2f" % (value.to_f / 100.0)}"}
71
+ layout_data(:fill, :center, true, false)
72
+ text <=> [@person, :donation, on_read: ->(value) { "Thank you for your donation of $#{"%.2f" % (value.to_f / 100.0)}"}]
69
73
  }
70
74
 
71
75
  }
@@ -49,7 +49,7 @@ end
49
49
  include Glimmer
50
50
 
51
51
  @presenter = StyledTextPresenter.new
52
- @presenter.text = verbiage*8
52
+ @presenter.text = verbiage*4
53
53
  @presenter.caret_offset = 0
54
54
  @presenter.selection_count = 0
55
55
  @presenter.selection = Point.new(0, 0)
@@ -61,19 +61,19 @@ shell {
61
61
  composite {
62
62
  @styled_text = styled_text {
63
63
  layout_data :fill, :fill, true, true
64
- text bind(@presenter, :text)
64
+ text <=> [@presenter, :text]
65
65
  left_margin 5
66
66
  top_margin 5
67
67
  right_margin 5
68
68
  bottom_margin 5
69
69
  # caret offset scrolls text to view when out of page
70
- caret_offset bind(@presenter, :caret_offset)
70
+ caret_offset <=> [@presenter, :caret_offset]
71
71
  # selection_count is not needed if selection is used
72
- selection_count bind(@presenter, :selection_count)
72
+ selection_count <=> [@presenter, :selection_count]
73
73
  # selection contains both caret_offset and selection_count, but setting it does not scroll text into view if out of page
74
- selection bind(@presenter, :selection)
74
+ selection <=> [@presenter, :selection]
75
75
  # top_pixel indicates vertically what pixel scrolling is at in a long multi-page text document
76
- top_pixel bind(@presenter, :top_pixel)
76
+ top_pixel <=> [@presenter, :top_pixel]
77
77
 
78
78
  # This demonstrates how to set styles via a listener
79
79
  on_line_get_style { |line_style_event|
@@ -109,31 +109,31 @@ shell {
109
109
  text 'Caret Offset:'
110
110
  }
111
111
  text {
112
- text bind(@presenter, :caret_offset, on_read: ->(o) {"%04d" % [o] })
112
+ text <=> [@presenter, :caret_offset, on_read: ->(o) {"%04d" % [o] }]
113
113
  }
114
114
  label {
115
115
  text 'Selection Count:'
116
116
  }
117
117
  text {
118
- text bind(@presenter, :selection_count, on_read: ->(o) {"%04d" % [o] })
118
+ text <=> [@presenter, :selection_count, on_read: ->(o) {"%04d" % [o] }]
119
119
  }
120
120
  label {
121
121
  text 'Selection Start:'
122
122
  }
123
123
  text {
124
- text bind(@presenter, 'selection.x', on_read: ->(o) {"%04d" % [o] })
124
+ text <=> [@presenter, 'selection.x', on_read: ->(o) {"%04d" % [o] }]
125
125
  }
126
126
  label {
127
127
  text 'Selection End:'
128
128
  }
129
129
  text {
130
- text bind(@presenter, 'selection.y', on_read: ->(o) {"%04d" % [o] })
130
+ text <=> [@presenter, 'selection.y', on_read: ->(o) {"%04d" % [o] }]
131
131
  }
132
132
  label {
133
133
  text 'Top Pixel:'
134
134
  }
135
135
  text {
136
- text bind(@presenter, :top_pixel, on_read: ->(o) {"%04d" % [o] })
136
+ text <=> [@presenter, :top_pixel, on_read: ->(o) {"%04d" % [o] }]
137
137
  }
138
138
  }
139
139
  }
@@ -0,0 +1,143 @@
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-swt'
23
+
24
+ class HelloToolBar
25
+ include Glimmer::UI::CustomShell
26
+
27
+ attr_accessor :operation, :font_size
28
+
29
+ def font_size_options
30
+ (10..30).to_a.map(&:to_s)
31
+ end
32
+
33
+ before_body {
34
+ self.font_size = '10'
35
+ }
36
+
37
+ body {
38
+ shell {
39
+ fill_layout(:vertical) {
40
+ margin_width 0
41
+ margin_height 0
42
+ }
43
+
44
+ text 'Hello, Tool Bar!'
45
+
46
+ tool_bar { # optionally takes a :flat style, :wrap style if you need wrapping upon shrinking window, and :vertical style if you need vertical layout
47
+ tool_item {
48
+ image cut_image # alternatively you can pass an image file path
49
+
50
+ on_widget_selected do
51
+ self.operation = 'Cut'
52
+ end
53
+ }
54
+ tool_item {
55
+ image copy_image # alternatively you can pass an image file path
56
+
57
+ on_widget_selected do
58
+ self.operation = 'Copy'
59
+ end
60
+ }
61
+ tool_item {
62
+ image paste_image # alternatively you can pass an image file path
63
+
64
+ on_widget_selected do
65
+ self.operation = 'Paste'
66
+ end
67
+ }
68
+ tool_item(:separator)
69
+ tool_item {
70
+ text 'Font Size'
71
+ }
72
+ # a combo can be nested in a tool_bar (it auto-generates a tool_item for itself behind the scenes)
73
+ combo {
74
+ selection bind(self, :font_size)
75
+ }
76
+ }
77
+
78
+ label {
79
+ font height: 30
80
+ text bind(self, :operation)
81
+ text bind(self, :font_size)
82
+ }
83
+ }
84
+ }
85
+
86
+ def cut_image
87
+ # building image on the fly with Canvas Shape DSL
88
+ image(25, 25) {
89
+ rectangle(0, 0, 25, 25) {
90
+ background_pattern 0, 0, 0, 25, :white, :gray
91
+ line(20, 2, 9, 15) {
92
+ line_width 2
93
+ }
94
+ line(5, 2, 16, 15) {
95
+ line_width 2
96
+ }
97
+ oval(2, 15, 8, 8) {
98
+ line_width 2
99
+ }
100
+ oval(16, 15, 8, 8) {
101
+ line_width 2
102
+ }
103
+ }
104
+ }
105
+ end
106
+
107
+ def copy_image
108
+ # building image on the fly with Canvas Shape DSL
109
+ image(25, 25) {
110
+ rectangle(0, 0, 25, 25) {
111
+ background_pattern 0, 0, 0, 25, :white, :gray
112
+ rectangle([:default, 2], [:default, -2], 14, 14, 5, 5) {
113
+ line_width 2
114
+ }
115
+ rectangle([:default, -2], [:default, 2], 14, 14, 5, 5) {
116
+ line_width 2
117
+ }
118
+ }
119
+ }
120
+ end
121
+
122
+ def paste_image
123
+ image(25, 25) {
124
+ rectangle(0, 0, 25, 25) {
125
+ background_pattern 0, 0, 0, 25, :white, :gray
126
+ rectangle(:default, [:default, 1], 15, 20, 5, 5) {
127
+ line_width 2
128
+ }
129
+ line(7, 8, 18, 8) {
130
+ line_width 2
131
+ }
132
+ line(7, 13, 18, 13) {
133
+ line_width 2
134
+ }
135
+ line(7, 18, 18, 18) {
136
+ line_width 2
137
+ }
138
+ }
139
+ }
140
+ end
141
+ end
142
+
143
+ HelloToolBar.launch