glimmer-dsl-swt 4.19.0.2 → 4.20.0.4

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -58,12 +58,12 @@ class HelloGroup
58
58
 
59
59
  radio {
60
60
  text 'Male'
61
- selection bind(@person, :male)
61
+ selection <=> [@person, :male]
62
62
  }
63
63
 
64
64
  radio {
65
65
  text 'Female'
66
- selection bind(@person, :female)
66
+ selection <=> [@person, :female]
67
67
  }
68
68
  }
69
69
 
@@ -75,22 +75,22 @@ class HelloGroup
75
75
 
76
76
  radio {
77
77
  text 'Child'
78
- selection bind(@person, :child)
78
+ selection <=> [@person, :child]
79
79
  }
80
80
 
81
81
  radio {
82
82
  text 'Teen'
83
- selection bind(@person, :teen)
83
+ selection <=> [@person, :teen]
84
84
  }
85
85
 
86
86
  radio {
87
87
  text 'Adult'
88
- selection bind(@person, :adult)
88
+ selection <=> [@person, :adult]
89
89
  }
90
90
 
91
91
  radio {
92
92
  text 'Senior'
93
- selection bind(@person, :senior)
93
+ selection <=> [@person, :senior]
94
94
  }
95
95
  }
96
96
 
@@ -0,0 +1,243 @@
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 HelloLayout
25
+ include Glimmer::UI::CustomShell
26
+
27
+ body {
28
+ shell {
29
+ # shell (which is a composite) has fill_layout(:horizontal) by default with no margins
30
+ text 'Hello, Layout!'
31
+ tab_folder {
32
+
33
+ # every tab item has its own composite, which can set a layout
34
+ tab_item {
35
+ text 'Fill Layout (horizontal)'
36
+
37
+ fill_layout(:horizontal) {
38
+ margin_width 30
39
+ margin_height 40
40
+ spacing 5
41
+ }
42
+
43
+ 10.times { |n|
44
+ label {
45
+ text "<label #{n+1}>"
46
+ }
47
+
48
+ }
49
+
50
+ }
51
+
52
+ tab_item {
53
+ text 'Fill Layout (vertical)'
54
+
55
+ fill_layout {
56
+ type :vertical # alternative way of specifying orientation
57
+ margin_width 40
58
+ margin_height 30
59
+ spacing 10
60
+ }
61
+
62
+ 10.times { |n|
63
+ label(:center) {
64
+ text "<label #{n+1}>"
65
+ }
66
+
67
+ }
68
+
69
+ }
70
+
71
+ tab_item {
72
+ text 'Row Layout (horizontal)'
73
+
74
+ row_layout(:horizontal) {
75
+ # row layout has margin attributes for top, left, right, and bottom
76
+ # in addition to width and height (and sets margin_width and margin_height to 5 by default)
77
+ margin_top 40
78
+ margin_left 30
79
+ spacing 5
80
+ wrap false
81
+ center true
82
+ justify true
83
+ }
84
+
85
+ 10.times { |n|
86
+ label {
87
+ text "<label #{n+1}>"
88
+ }
89
+
90
+ }
91
+
92
+ }
93
+
94
+ tab_item {
95
+ text 'Row Layout (wrap on shrink)'
96
+
97
+ row_layout { # :horizontal is the default type
98
+ margin_height 40
99
+ margin_width 30
100
+ spacing 35
101
+ # wrap true # is the default
102
+ }
103
+
104
+ 10.times { |n|
105
+ label {
106
+ text "<label #{n+1}>"
107
+ }
108
+
109
+ }
110
+
111
+ }
112
+
113
+ tab_item {
114
+ text 'Row Layout (vertical)'
115
+ background :yellow
116
+
117
+ row_layout(:vertical) { |l|
118
+ margin_height 0
119
+ margin_width 0
120
+ spacing 10
121
+ fill true # fills horizontally to match the widest child (opposite to row layout orientation)
122
+ center false # enable and disable fill to see what this does
123
+ }
124
+
125
+ 10.times { |n|
126
+ label {
127
+ # layout_data allows a widget to tweak its layout configuration (generating RowData object for RowLayout)
128
+ layout_data {
129
+ height 30
130
+ # width unspecified yet calculated
131
+ }
132
+ text "<this is a ver#{'r'*(rand*200).to_i}y wide label #{n+1}>"
133
+ background :green
134
+ }
135
+
136
+ }
137
+
138
+ }
139
+
140
+ tab_item {
141
+ text 'Grid Layout'
142
+
143
+ grid_layout {
144
+ num_columns 5
145
+ make_columns_equal_width true
146
+ horizontal_spacing 15
147
+ vertical_spacing 10
148
+
149
+ # grid layout has margin attributes for top, left, right, and bottom
150
+ # in addition to width and height (and sets margin_width and margin_height to 5 by default)
151
+ margin_height 0
152
+ margin_top 20
153
+ }
154
+
155
+ 10.times { |n|
156
+ label {
157
+ text "<this label is wide enough to fill #{n+1}>"
158
+ background :white
159
+ }
160
+ }
161
+
162
+ label {
163
+ # layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
164
+ layout_data {
165
+ width_hint 120
166
+ height_hint 40
167
+ }
168
+ text "<this label is clipped>"
169
+ background :cyan
170
+ }
171
+
172
+ label {
173
+ # layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
174
+ layout_data {
175
+ horizontal_span 2
176
+ }
177
+ text "<this label spans two columns, so it can contain more text than normal>"
178
+ background :green
179
+ }
180
+
181
+ label {
182
+ # layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
183
+ layout_data {
184
+ vertical_span 2
185
+ vertical_alignment :fill
186
+ }
187
+ text "<this label spans two rows, \nso it can contain new lines\n1\n2\n3\n4\n5\n6\n7>"
188
+ background :yellow
189
+ }
190
+
191
+ 5.times { label } # just filler
192
+
193
+ label {
194
+
195
+ # layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
196
+ layout_data {
197
+ horizontal_span 5
198
+ horizontal_alignment :fill # could be :beginning, :center or :end too
199
+ vertical_alignment :fill # could be :beginning, :center, or :end too
200
+ grab_excess_horizontal_space true
201
+ grab_excess_vertical_space true
202
+ }
203
+
204
+ # this is a short alternative for specifying what is above
205
+ # layout_data(:fill, :fill, true, true) {
206
+ # horizontal_span 5
207
+ # }
208
+
209
+ text "<this label fills all the space it can get\nhorizontally and vertically>"
210
+ background :magenta
211
+ }
212
+
213
+ }
214
+
215
+
216
+ tab_item {
217
+ text 'Grid Layout (non-equal columns)'
218
+
219
+ grid_layout(2, false) # alt syntax: (numColumns, make_columns_equal_width)
220
+
221
+ 10.times { |n|
222
+ label {
223
+ text "Field #{n+1}"
224
+ }
225
+ text {
226
+ layout_data {
227
+ width_hint 600
228
+ }
229
+
230
+ text "Please enter text"
231
+ }
232
+ }
233
+
234
+ }
235
+
236
+ }
237
+
238
+ }
239
+
240
+ }
241
+ end
242
+
243
+ HelloLayout.launch
@@ -21,62 +21,68 @@
21
21
 
22
22
  require 'glimmer-dsl-swt'
23
23
 
24
- include Glimmer
25
-
26
- shell { |main_shell|
27
- grid_layout {
28
- margin_width 20
29
- margin_height 10
30
- }
24
+ class HelloLink
25
+ include Glimmer::UI::CustomShell
31
26
 
32
- background :white
33
- text 'Hello, Link!'
34
-
35
- @link = link {
36
- background :white
37
- link_foreground :dark_green
38
- font height: 16
39
- text <<~MULTI_LINE_STRING
40
-
41
- You may click on any <a>link</a> to get help.
27
+ body {
28
+ shell { |main_shell|
29
+ grid_layout {
30
+ margin_width 20
31
+ margin_height 10
32
+ }
42
33
 
43
- How do you know <a href="which-link-href-value">which link</a> you clicked?
34
+ background :white
35
+ text 'Hello, Link!'
44
36
 
45
- Just keep clicking <a href="all links">links</a> to find out!
46
- MULTI_LINE_STRING
37
+ @link = link {
38
+ background :white
39
+ link_foreground :dark_green
40
+ font height: 16
41
+ text <<~MULTI_LINE_STRING
47
42
 
48
- on_widget_selected { |selection_event|
49
- # This retrieves the clicked link href (or contained text if no href is set)
50
- @selected_link = selection_event.text
51
- }
52
- on_mouse_up { |mouse_event|
53
- unless @selected_link.nil?
54
- @help_shell.close unless @help_shell.nil? || @help_shell.disposed?
55
- @help_shell = shell(:no_trim) {
56
- grid_layout {
57
- margin_width 10
58
- margin_height 10
59
- }
43
+ You may click on any <a>link</a> to get help.
60
44
 
61
- background :yellow
45
+ How do you know <a href="which-link-href-value">which link</a> you clicked?
62
46
 
63
- label {
64
- background :yellow
65
- text "Did someone ask for help about \"#{@selected_link}\"?\nYou don't really need help. You did it!"
66
- }
67
-
68
- on_swt_show {
69
- x = main_shell.location.x + @link.location.x + mouse_event.x
70
- y = main_shell.location.y + @link.location.y + mouse_event.y + 20
71
- @help_shell.location = Point.new(x, y)
72
- }
73
- on_focus_lost {
74
- @selected_link = nil
75
- @help_shell.close
76
- }
47
+ Just keep clicking <a href="all links">links</a> to find out!
48
+ MULTI_LINE_STRING
49
+
50
+ on_widget_selected { |selection_event|
51
+ # This retrieves the clicked link href (or contained text if no href is set)
52
+ @selected_link = selection_event.text
53
+ }
54
+ on_mouse_up { |mouse_event|
55
+ unless @selected_link.nil?
56
+ @help_shell.close unless @help_shell.nil? || @help_shell.disposed?
57
+ @help_shell = shell(:no_trim) {
58
+ grid_layout {
59
+ margin_width 10
60
+ margin_height 10
61
+ }
62
+
63
+ background :yellow
64
+
65
+ label {
66
+ background :yellow
67
+ text "Did someone ask for help about \"#{@selected_link}\"?\nYou don't really need help. You did it!"
68
+ }
69
+
70
+ on_swt_show {
71
+ x = main_shell.location.x + @link.location.x + mouse_event.x
72
+ y = main_shell.location.y + @link.location.y + mouse_event.y + 20
73
+ @help_shell.location = Point.new(x, y)
74
+ }
75
+ on_focus_lost {
76
+ @selected_link = nil
77
+ @help_shell.close
78
+ }
79
+ }
80
+ @help_shell.open
81
+ end
77
82
  }
78
- @help_shell.open
79
- end
83
+ }
80
84
  }
81
85
  }
82
- }.open
86
+ end
87
+
88
+ HelloLink.launch
@@ -63,7 +63,7 @@ class HelloListMultiSelection
63
63
  text 'Hello, List Multi Selection!'
64
64
 
65
65
  list(:multi) {
66
- selection bind(@person, :provinces) # also binds to provinces_options by convention
66
+ selection <=> [@person, :provinces] # also binds to provinces_options by convention
67
67
  }
68
68
 
69
69
  button {
@@ -48,7 +48,7 @@ class HelloListSingleSelection
48
48
  text 'Hello, List Single Selection!'
49
49
 
50
50
  list {
51
- selection bind(@person, :country) # also binds to country_options by convention
51
+ selection <=> [@person, :country] # also binds to country_options by convention
52
52
  }
53
53
 
54
54
  button {
@@ -65,40 +65,40 @@ class HelloProgressBar
65
65
  }
66
66
 
67
67
  spinner {
68
- selection bind(@progress_model, :minimum)
68
+ selection <=> [@progress_model, :minimum]
69
69
  }
70
70
 
71
71
  spinner {
72
- selection bind(@progress_model, :maximum)
72
+ selection <=> [@progress_model, :maximum]
73
73
  }
74
74
 
75
75
  spinner {
76
- selection bind(@progress_model, :selection)
76
+ selection <=> [@progress_model, :selection]
77
77
  }
78
78
 
79
79
  spinner {
80
80
  digits 2
81
81
  minimum 1
82
82
  maximum 200
83
- selection bind(@progress_model, :delay, on_read: ->(v) {v.to_f*100.0}, on_write: ->(v) {v.to_f/100.0})
83
+ selection <=> [@progress_model, :delay, on_read: ->(v) {v.to_f*100.0}, on_write: ->(v) {v.to_f/100.0}]
84
84
  }
85
85
 
86
86
  progress_bar {
87
87
  layout_data(:fill, :center, true, false) {
88
88
  horizontal_span 4
89
89
  }
90
- minimum bind(@progress_model, :minimum)
91
- maximum bind(@progress_model, :maximum)
92
- selection bind(@progress_model, :selection)
90
+ minimum <= [@progress_model, :minimum]
91
+ maximum <= [@progress_model, :maximum]
92
+ selection <= [@progress_model, :selection]
93
93
  }
94
94
 
95
95
  progress_bar(:vertical) {
96
96
  layout_data(:fill, :center, true, false) {
97
97
  horizontal_span 4
98
98
  }
99
- minimum bind(@progress_model, :minimum)
100
- maximum bind(@progress_model, :maximum)
101
- selection bind(@progress_model, :selection)
99
+ minimum <= [@progress_model, :minimum]
100
+ maximum <= [@progress_model, :maximum]
101
+ selection <= [@progress_model, :selection]
102
102
  }
103
103
 
104
104
  button {