glimmer-dsl-swt 4.22.2.4 → 4.23.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +69 -15
  4. data/VERSION +1 -1
  5. data/docs/reference/GLIMMER_COMMAND.md +3 -1
  6. data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +33 -31
  7. data/docs/reference/GLIMMER_SAMPLES.md +11 -19
  8. data/glimmer-dsl-swt.gemspec +0 -0
  9. data/lib/glimmer/launcher.rb +7 -4
  10. data/lib/glimmer/rake_task/package.rb +1 -1
  11. data/lib/glimmer/rake_task/scaffold.rb +25 -13
  12. data/lib/glimmer/swt/custom/shape.rb +6 -2
  13. data/samples/elaborate/calculator.rb +12 -12
  14. data/samples/elaborate/contact_manager.rb +26 -14
  15. data/samples/elaborate/game_of_life.rb +8 -8
  16. data/samples/elaborate/klondike_solitaire/view/action_panel.rb +2 -2
  17. data/samples/elaborate/klondike_solitaire/view/klondike_solitaire_menu_bar.rb +15 -10
  18. data/samples/elaborate/login.rb +16 -10
  19. data/samples/elaborate/mandelbrot_fractal.rb +26 -20
  20. data/samples/elaborate/meta_sample.rb +6 -6
  21. data/samples/elaborate/metronome.rb +4 -4
  22. data/samples/elaborate/stock_ticker.rb +12 -12
  23. data/samples/elaborate/tetris.rb +4 -4
  24. data/samples/elaborate/timer.rb +36 -26
  25. data/samples/elaborate/user_profile.rb +53 -14
  26. data/samples/elaborate/weather.rb +2 -2
  27. data/samples/hello/hello_button.rb +3 -3
  28. data/samples/hello/hello_canvas_animation.rb +2 -2
  29. data/samples/hello/hello_color_dialog.rb +4 -4
  30. data/samples/hello/hello_custom_shell.rb +2 -2
  31. data/samples/hello/hello_dialog.rb +4 -4
  32. data/samples/hello/hello_directory_dialog.rb +2 -2
  33. data/samples/hello/hello_expand_bar.rb +4 -5
  34. data/samples/hello/hello_file_dialog.rb +2 -2
  35. data/samples/hello/hello_font_dialog.rb +2 -2
  36. data/samples/hello/hello_link.rb +5 -4
  37. data/samples/hello/hello_list_multi_selection.rb +3 -1
  38. data/samples/hello/hello_list_single_selection.rb +3 -1
  39. data/samples/hello/hello_menu_bar.rb +28 -28
  40. data/samples/hello/hello_message_box.rb +2 -2
  41. data/samples/hello/hello_pop_up_context_menu.rb +18 -8
  42. data/samples/hello/hello_shell.rb +16 -16
  43. data/samples/hello/hello_styled_text.rb +2 -2
  44. data/samples/hello/hello_table.rb +4 -4
  45. data/samples/hello/hello_tray_item.rb +2 -2
  46. data/vendor/swt/linux/swt.jar +0 -0
  47. data/vendor/swt/linux_aarch64/swt.jar +0 -0
  48. data/vendor/swt/mac/swt.jar +0 -0
  49. data/vendor/swt/mac_aarch64/swt.jar +0 -0
  50. data/vendor/swt/windows/swt.jar +0 -0
  51. metadata +2 -2
@@ -24,12 +24,13 @@ class Timer
24
24
  Display.setAppName('Glimmer Timer')
25
25
 
26
26
  @display = display {
27
- on_about {
27
+ on_about do
28
28
  display_about_dialog
29
- }
30
- on_preferences {
29
+ end
30
+
31
+ on_preferences do
31
32
  display_about_dialog
32
- }
33
+ end
33
34
  }
34
35
 
35
36
  @min = 0
@@ -43,7 +44,7 @@ class Timer
43
44
  loop do
44
45
  sleep(1)
45
46
  if @countdown
46
- sync_exec {
47
+ sync_exec do
47
48
  @countdown_time = Time.new(1, 1, 1, 0, min, sec)
48
49
  @countdown_time -= 1
49
50
  self.min = @countdown_time.min
@@ -52,7 +53,7 @@ class Timer
52
53
  stop_countdown
53
54
  play_countdown_done_sound
54
55
  end
55
- }
56
+ end
56
57
  end
57
58
  end
58
59
  end
@@ -85,31 +86,34 @@ class Timer
85
86
  accelerator COMMAND_KEY, 's'
86
87
  enabled <= [self, :countdown, on_read: :!]
87
88
 
88
- on_widget_selected {
89
+ on_widget_selected do
89
90
  start_countdown
90
- }
91
+ end
91
92
  }
93
+
92
94
  menu_item {
93
95
  text 'St&op'
94
96
  enabled <= [self, :countdown]
95
97
  accelerator COMMAND_KEY, 'o'
96
98
 
97
- on_widget_selected {
99
+ on_widget_selected do
98
100
  stop_countdown
99
- }
101
+ end
100
102
  }
103
+
101
104
  unless OS.mac?
102
105
  menu_item(:separator)
103
106
  menu_item {
104
107
  text 'E&xit'
105
108
  accelerator :alt, :f4
106
109
 
107
- on_widget_selected {
110
+ on_widget_selected do
108
111
  exit(0)
109
- }
112
+ end
110
113
  }
111
114
  end
112
115
  }
116
+
113
117
  menu {
114
118
  text '&Help'
115
119
 
@@ -117,9 +121,9 @@ class Timer
117
121
  text '&About'
118
122
  accelerator COMMAND_KEY, :shift, 'a'
119
123
 
120
- on_widget_selected {
124
+ on_widget_selected do
121
125
  display_about_dialog
122
- }
126
+ end
123
127
  }
124
128
  }
125
129
  }
@@ -149,9 +153,10 @@ class Timer
149
153
  maximum 59
150
154
  selection <=> [self, :min]
151
155
  enabled <= [self, :countdown, on_read: :!]
152
- on_widget_default_selected {
156
+
157
+ on_widget_default_selected do
153
158
  start_countdown
154
- }
159
+ end
155
160
  }
156
161
  label {
157
162
  text ':'
@@ -163,9 +168,10 @@ class Timer
163
168
  maximum 59
164
169
  selection <=> [self, :sec]
165
170
  enabled <= [self, :countdown, on_read: :!]
166
- on_widget_default_selected {
171
+
172
+ on_widget_default_selected do
167
173
  start_countdown
168
- }
174
+ end
169
175
  }
170
176
  }
171
177
  end
@@ -179,22 +185,26 @@ class Timer
179
185
  @start_button = button {
180
186
  text '&Start'
181
187
  enabled <= [self, :countdown, on_read: :!]
182
- on_widget_selected {
188
+
189
+ on_widget_selected do
183
190
  start_countdown
184
- }
185
- on_key_pressed { |event|
191
+ end
192
+
193
+ on_key_pressed do |event|
186
194
  start_countdown if event.keyCode == swt(:cr)
187
- }
195
+ end
188
196
  }
189
197
  @stop_button = button {
190
198
  text 'St&op'
191
199
  enabled <= [self, :countdown]
192
- on_widget_selected {
200
+
201
+ on_widget_selected do
193
202
  stop_countdown
194
- }
195
- on_key_pressed { |event|
203
+ end
204
+
205
+ on_key_pressed do |event|
196
206
  stop_countdown if event.keyCode == swt(:cr)
197
- }
207
+ end
198
208
  }
199
209
  }
200
210
  end
@@ -32,49 +32,88 @@ shell { |shell_proxy|
32
32
  grid_layout 2, false
33
33
 
34
34
  group {
35
- text "Name"
36
35
  grid_layout 2, false
36
+
37
37
  layout_data :fill, :fill, true, true
38
- label {text "First"}; text {text "Bullet"}
39
- label {text "Last"}; text {text "Tooth"}
38
+ text "Name"
39
+
40
+ label {
41
+ text "First"
42
+ }
43
+ text {
44
+ text "Bullet"
45
+ }
46
+
47
+ label {
48
+ text "Last"
49
+ }
50
+ text {
51
+ text "Tooth"
52
+ }
40
53
  }
41
54
 
42
55
  group {
43
56
  layout_data :fill, :fill, true, true
44
57
  text "Gender"
45
- radio {text "Male"; selection true}
46
- radio {text "Female"}
58
+
59
+ radio {
60
+ text "Male"
61
+ selection true
62
+ }
63
+
64
+ radio {
65
+ text "Female"
66
+ }
47
67
  }
48
68
 
49
69
  group {
50
70
  layout_data :fill, :fill, true, true
51
71
  text "Role"
52
- check {text "Student"; selection true}
53
- check {text "Employee"; selection true}
72
+
73
+ check {
74
+ text "Student"
75
+ selection true
76
+ }
77
+
78
+ check {
79
+ text "Employee"
80
+ selection true
81
+ }
54
82
  }
55
83
 
56
84
  group {
57
- text "Experience"
58
85
  row_layout
86
+
59
87
  layout_data :fill, :fill, true, true
60
- spinner {selection 5}; label {text "years"}
88
+ text "Experience"
89
+
90
+ spinner {
91
+ selection 5
92
+ }
93
+ label {
94
+ text "years"
95
+ }
61
96
  }
62
97
 
63
98
  button {
64
- text "save"
65
99
  layout_data :right, :center, true, true
66
- on_widget_selected {
100
+ text "save"
101
+
102
+ on_widget_selected do
67
103
  message_box {
68
104
  text 'Profile Saved!'
69
105
  message 'User profile has been saved!'
70
106
  }.open
71
- }
107
+ end
72
108
  }
73
109
 
74
110
  button {
75
- text "close"
76
111
  layout_data :left, :center, true, true
77
- on_widget_selected { shell_proxy.close }
112
+ text "close"
113
+
114
+ on_widget_selected do
115
+ shell_proxy.close
116
+ end
78
117
  }
79
118
  }
80
119
  }.open
@@ -62,13 +62,13 @@ class Weather
62
62
 
63
63
  text <=> [self, :city]
64
64
 
65
- on_key_pressed {|event|
65
+ on_key_pressed do |event|
66
66
  if event.keyCode == swt(:cr) # carriage return
67
67
  Thread.new do
68
68
  fetch_weather!
69
69
  end
70
70
  end
71
- }
71
+ end
72
72
  }
73
73
 
74
74
  tab_folder {
@@ -27,7 +27,7 @@ class HelloButton
27
27
  attr_accessor :count
28
28
 
29
29
  before_body do
30
- @count = 0
30
+ self.count = 0
31
31
  end
32
32
 
33
33
  body {
@@ -37,9 +37,9 @@ class HelloButton
37
37
  button {
38
38
  text <= [self, :count, on_read: ->(value) { "Click To Increment: #{value} " }]
39
39
 
40
- on_widget_selected {
40
+ on_widget_selected do
41
41
  self.count += 1
42
- }
42
+ end
43
43
  }
44
44
  }
45
45
  }
@@ -123,12 +123,12 @@ class HelloCanvasAnimation
123
123
  started <=> [self, :animation_started]
124
124
  finished <=> [self, :animation_finished]
125
125
 
126
- frame { |index|
126
+ frame do |index|
127
127
  background rgb(index%100, index%100 + 100, index%55 + 200)
128
128
  oval(index*3%300, index*3%300, 20, 20) {
129
129
  background :yellow
130
130
  }
131
- }
131
+ end
132
132
  }
133
133
  }
134
134
  }
@@ -47,18 +47,18 @@ class HelloColorDialog
47
47
  layout_data :center, :center, true, false
48
48
  background <=> [self, :selected_color]
49
49
 
50
- on_mouse_up {
50
+ on_mouse_up do
51
51
  self.selected_color = color_dialog.open
52
- }
52
+ end
53
53
  }
54
54
 
55
55
  button {
56
56
  layout_data :center, :center, true, false
57
57
  text "Choose Color..."
58
58
 
59
- on_widget_selected {
59
+ on_widget_selected do
60
60
  self.selected_color = color_dialog.open
61
- }
61
+ end
62
62
  }
63
63
 
64
64
  }
@@ -140,7 +140,7 @@ class HelloCustomShell
140
140
 
141
141
  items <=> [@email_system, :emails, column_properties: [:date, :subject, :from]]
142
142
 
143
- on_mouse_up { |event|
143
+ on_mouse_up do |event|
144
144
  email = event.table_item.get_data
145
145
 
146
146
  # open a custom email shell
@@ -151,7 +151,7 @@ class HelloCustomShell
151
151
  from: email.from,
152
152
  message: email.message
153
153
  ).open
154
- }
154
+ end
155
155
  }
156
156
  }.open
157
157
  end
@@ -38,7 +38,7 @@ shell { |shell_proxy|
38
38
  }
39
39
  text "Dialog #{dialog_number}"
40
40
 
41
- on_widget_selected {
41
+ on_widget_selected do
42
42
  # pass the shell proxy as a parent to make the dialog support hitting the escape button for closing alone without closing app
43
43
  dialog(shell_proxy) { |dialog_proxy|
44
44
  row_layout(:vertical) {
@@ -70,12 +70,12 @@ shell { |shell_proxy|
70
70
  button {
71
71
  text 'Close'
72
72
 
73
- on_widget_selected {
73
+ on_widget_selected do
74
74
  dialog_proxy.close
75
- }
75
+ end
76
76
  }
77
77
  }.open
78
- }
78
+ end
79
79
  }
80
80
  }
81
81
  }.open
@@ -51,9 +51,9 @@ class HelloDirectoryDialog
51
51
  button {
52
52
  text "Browse..."
53
53
 
54
- on_widget_selected {
54
+ on_widget_selected do
55
55
  self.selected_directory = directory_dialog.open
56
- }
56
+ end
57
57
  }
58
58
  }
59
59
  }
@@ -96,14 +96,13 @@ class HelloExpandBar
96
96
  composite # just filler
97
97
  }
98
98
 
99
- on_item_expanded { |expand_event|
99
+ on_item_expanded do |expand_event|
100
100
  @status_label.text = "#{expand_event.item.text} Expanded!"
101
- }
101
+ end
102
102
 
103
- on_item_collapsed { |expand_event|
103
+ on_item_collapsed do |expand_event|
104
104
  @status_label.text = "#{expand_event.item.text} Collapsed!"
105
- }
106
-
105
+ end
107
106
  }
108
107
  }
109
108
  }
@@ -51,9 +51,9 @@ class HelloFileDialog
51
51
  button {
52
52
  text "Browse..."
53
53
 
54
- on_widget_selected {
54
+ on_widget_selected do
55
55
  self.selected_file = file_dialog.open
56
- }
56
+ end
57
57
  }
58
58
  }
59
59
  }
@@ -70,11 +70,11 @@ class HelloFontDialog
70
70
  button {
71
71
  text "Choose Font..."
72
72
 
73
- on_widget_selected {
73
+ on_widget_selected do
74
74
  self.selected_font_data = font_dialog {
75
75
  font_list [@selected_font_data]
76
76
  }.open
77
- }
77
+ end
78
78
  }
79
79
 
80
80
  }
@@ -47,11 +47,12 @@ class HelloLink
47
47
  Just keep clicking <a href="all links">links</a> to find out!
48
48
  MULTI_LINE_STRING
49
49
 
50
- on_widget_selected { |selection_event|
50
+ on_widget_selected do |selection_event|
51
51
  # This retrieves the clicked link href (or contained text if no href is set)
52
52
  @selected_link = selection_event.text
53
- }
54
- on_mouse_up { |mouse_event|
53
+ end
54
+
55
+ on_mouse_up do |mouse_event|
55
56
  unless @selected_link.nil?
56
57
  @help_shell.close unless @help_shell.nil? || @help_shell.disposed?
57
58
  @help_shell = shell(:no_trim) {
@@ -79,7 +80,7 @@ class HelloLink
79
80
  }
80
81
  @help_shell.open
81
82
  end
82
- }
83
+ end
83
84
  }
84
85
  }
85
86
  }
@@ -69,7 +69,9 @@ class HelloListMultiSelection
69
69
  button {
70
70
  text 'Reset Selections To Default Values'
71
71
 
72
- on_widget_selected { @person.reset_provinces! }
72
+ on_widget_selected do
73
+ @person.reset_provinces!
74
+ end
73
75
  }
74
76
  }
75
77
  }
@@ -54,7 +54,9 @@ class HelloListSingleSelection
54
54
  button {
55
55
  text 'Reset Selection To Default Value'
56
56
 
57
- on_widget_selected { @person.reset_country! }
57
+ on_widget_selected do
58
+ @person.reset_country!
59
+ end
58
60
  }
59
61
  }
60
62
  }
@@ -45,52 +45,52 @@ shell {
45
45
  text '&New'
46
46
  accelerator :command, :N
47
47
 
48
- on_widget_selected {
48
+ on_widget_selected do
49
49
  message_box {
50
50
  text 'New'
51
51
  message 'New file created.'
52
52
  }.open
53
- }
53
+ end
54
54
  }
55
55
  menu_item {
56
56
  text '&Open...'
57
57
  accelerator :command, :O
58
58
 
59
- on_widget_selected {
59
+ on_widget_selected do
60
60
  message_box {
61
61
  text 'Open'
62
62
  message 'Opening File...'
63
63
  }.open
64
- }
64
+ end
65
65
  }
66
66
  menu {
67
67
  text 'Open &Recent'
68
68
  menu_item {
69
69
  text 'File 1'
70
- on_widget_selected {
70
+ on_widget_selected do
71
71
  message_box {
72
72
  text 'File 1'
73
73
  message 'File 1 Contents'
74
74
  }.open
75
- }
75
+ end
76
76
  }
77
77
  menu_item {
78
78
  text 'File 2'
79
- on_widget_selected {
79
+ on_widget_selected do
80
80
  message_box {
81
81
  text 'File 2'
82
82
  message 'File 2 Contents'
83
83
  }.open
84
- }
84
+ end
85
85
  }
86
86
  }
87
87
  menu_item(:separator)
88
88
  menu_item {
89
89
  text 'E&xit'
90
90
 
91
- on_widget_selected {
91
+ on_widget_selected do
92
92
  exit(0)
93
- }
93
+ end
94
94
  }
95
95
  }
96
96
  menu {
@@ -114,10 +114,10 @@ shell {
114
114
  menu_item(:radio) {
115
115
  text '&Enabled'
116
116
 
117
- on_widget_selected {
117
+ on_widget_selected do
118
118
  @select_one_menu.enabled = true
119
119
  @select_multiple_menu.enabled = true
120
- }
120
+ end
121
121
  }
122
122
  @select_one_menu = menu {
123
123
  text '&Select One'
@@ -156,9 +156,9 @@ shell {
156
156
  menu_item(:radio) {
157
157
  text color_style.to_s.split('_').map(&:capitalize).join(' ')
158
158
 
159
- on_widget_selected {
159
+ on_widget_selected do
160
160
  @label.background = color_style
161
- }
161
+ end
162
162
  }
163
163
  }
164
164
  }
@@ -168,9 +168,9 @@ shell {
168
168
  menu_item(:radio) {
169
169
  text color_style.to_s.split('_').map(&:capitalize).join(' ')
170
170
 
171
- on_widget_selected {
171
+ on_widget_selected do
172
172
  @label.foreground = color_style
173
- }
173
+ end
174
174
  }
175
175
  }
176
176
  }
@@ -180,27 +180,27 @@ shell {
180
180
  menu_item(:radio) {
181
181
  text 'Small'
182
182
 
183
- on_widget_selected {
183
+ on_widget_selected do
184
184
  @label.font = {height: 25}
185
185
  @label.parent.pack
186
- }
186
+ end
187
187
  }
188
188
  menu_item(:radio) {
189
189
  text 'Medium'
190
190
  selection true
191
191
 
192
- on_widget_selected {
192
+ on_widget_selected do
193
193
  @label.font = {height: 50}
194
194
  @label.parent.pack
195
- }
195
+ end
196
196
  }
197
197
  menu_item(:radio) {
198
198
  text 'Large'
199
199
 
200
- on_widget_selected {
200
+ on_widget_selected do
201
201
  @label.font = {height: 75}
202
202
  @label.parent.pack
203
- }
203
+ end
204
204
  }
205
205
  }
206
206
  menu {
@@ -209,34 +209,34 @@ shell {
209
209
  text '&Manual'
210
210
  accelerator :command, :shift, :M
211
211
 
212
- on_widget_selected {
212
+ on_widget_selected do
213
213
  message_box {
214
214
  text 'Manual'
215
215
  message 'Manual Contents'
216
216
  }.open
217
- }
217
+ end
218
218
  }
219
219
  menu_item {
220
220
  text '&Tutorial'
221
221
  accelerator :command, :shift, :T
222
222
 
223
- on_widget_selected {
223
+ on_widget_selected do
224
224
  message_box {
225
225
  text 'Tutorial'
226
226
  message 'Tutorial Contents'
227
227
  }.open
228
- }
228
+ end
229
229
  }
230
230
  menu_item(:separator)
231
231
  menu_item {
232
232
  text '&Report an Issue...'
233
233
 
234
- on_widget_selected {
234
+ on_widget_selected do
235
235
  message_box {
236
236
  text 'Report an Issue'
237
237
  message 'Reporting an issue...'
238
238
  }.open
239
- }
239
+ end
240
240
  }
241
241
  }
242
242
  }
@@ -29,11 +29,11 @@ shell {
29
29
  button {
30
30
  text 'Please Click To Win a Surprise'
31
31
 
32
- on_widget_selected {
32
+ on_widget_selected do
33
33
  message_box {
34
34
  text 'Surprise'
35
35
  message "Congratulations!\n\nYou won $1,000,000!"
36
36
  }.open
37
- }
37
+ end
38
38
  }
39
39
  }.open