glimmer-dsl-opal 0.16.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -2
  3. data/README.md +158 -4
  4. data/VERSION +1 -1
  5. data/lib/cgi.rb +14 -0
  6. data/lib/glimmer-dsl-opal.rb +1 -0
  7. data/lib/glimmer-dsl-opal/samples/hello/hello_arrow.rb +65 -0
  8. data/lib/glimmer-dsl-opal/samples/hello/hello_c_combo.rb +67 -0
  9. data/lib/glimmer-dsl-opal/samples/hello/hello_c_tab.rb +172 -0
  10. data/lib/glimmer-dsl-opal/samples/hello/hello_layout.rb +241 -0
  11. data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +10 -8
  12. data/lib/glimmer-dsl-opal/samples/hello/images/denmark.png +0 -0
  13. data/lib/glimmer-dsl-opal/samples/hello/images/finland.png +0 -0
  14. data/lib/glimmer-dsl-opal/samples/hello/images/france.png +0 -0
  15. data/lib/glimmer-dsl-opal/samples/hello/images/germany.png +0 -0
  16. data/lib/glimmer-dsl-opal/samples/hello/images/italy.png +0 -0
  17. data/lib/glimmer-dsl-opal/samples/hello/images/mexico.png +0 -0
  18. data/lib/glimmer-dsl-opal/samples/hello/images/netherlands.png +0 -0
  19. data/lib/glimmer-dsl-opal/samples/hello/images/norway.png +0 -0
  20. data/lib/glimmer-dsl-opal/samples/hello/images/usa.png +0 -0
  21. data/lib/glimmer/dsl/opal/menu_expression.rb +3 -0
  22. data/lib/glimmer/swt/arrow_proxy.rb +42 -0
  23. data/lib/glimmer/swt/button_proxy.rb +36 -1
  24. data/lib/glimmer/swt/c_combo_proxy.rb +51 -0
  25. data/lib/glimmer/swt/c_tab_folder_proxy.rb +43 -0
  26. data/lib/glimmer/swt/c_tab_item_proxy.rb +96 -0
  27. data/lib/glimmer/swt/combo_proxy.rb +3 -0
  28. data/lib/glimmer/swt/fill_layout_proxy.rb +9 -3
  29. data/lib/glimmer/swt/grid_layout_proxy.rb +33 -1
  30. data/lib/glimmer/swt/label_proxy.rb +2 -2
  31. data/lib/glimmer/swt/menu_proxy.rb +17 -1
  32. data/lib/glimmer/swt/row_layout_proxy.rb +33 -2
  33. data/lib/glimmer/swt/shell_proxy.rb +4 -0
  34. data/lib/glimmer/swt/tab_folder_proxy.rb +12 -10
  35. data/lib/glimmer/swt/tab_item_proxy.rb +52 -4
  36. data/lib/glimmer/swt/widget_proxy.rb +53 -12
  37. metadata +20 -2
@@ -0,0 +1,172 @@
1
+ # Copyright (c) 2020-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
+ # Country flag images were made by [Freepik](https://www.flaticon.com/authors/freepik) from [www.flaticon.com](http://www.flaticon.com)
23
+
24
+ # This is a sample for the Custom Tab widgets (c_tab_folder & c_tab_item), which are more customizable versions of tab_folder and tab_item.
25
+ class HelloCTab
26
+ include Glimmer::UI::CustomShell
27
+
28
+ body {
29
+ shell {
30
+ row_layout
31
+ text 'Hello, C Tab!'
32
+ minimum_size 200, 200
33
+
34
+ c_tab_folder { # accepts styles: :close
35
+ layout_data {
36
+ width 1024
37
+ height 200
38
+ }
39
+ c_tab_item(:close) {
40
+ text 'English'
41
+ tool_tip_text 'English Greeting'
42
+ foreground :blue
43
+ selection_foreground :dark_blue
44
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
45
+ image File.expand_path('images/usa.png', __dir__)
46
+
47
+ label {
48
+ text 'Hello, World!'
49
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
50
+ }
51
+ }
52
+
53
+ c_tab_item(:close) {
54
+ text 'French'
55
+ tool_tip_text 'French Greeting'
56
+ foreground :blue
57
+ selection_foreground :dark_blue
58
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
59
+ image File.expand_path('images/france.png', __dir__)
60
+
61
+ label {
62
+ text 'Bonjour, Univers!'
63
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
64
+ }
65
+ }
66
+
67
+ c_tab_item(:close) {
68
+ text 'Spanish'
69
+ tool_tip_text 'Spanish Greeting'
70
+ foreground :blue
71
+ selection_foreground :dark_blue
72
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
73
+ image File.expand_path('images/mexico.png', __dir__)
74
+
75
+ label {
76
+ text 'Hola, Mundo!'
77
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
78
+ }
79
+ }
80
+
81
+ c_tab_item(:close) {
82
+ text 'German'
83
+ tool_tip_text 'German Greeting'
84
+ foreground :blue
85
+ selection_foreground :dark_blue
86
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
87
+ image File.expand_path('images/germany.png', __dir__)
88
+
89
+ label {
90
+ text 'Hallo, Welt!'
91
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
92
+ }
93
+ }
94
+
95
+ c_tab_item(:close) {
96
+ text 'Italian'
97
+ tool_tip_text 'Italian Greeting'
98
+ foreground :blue
99
+ selection_foreground :dark_blue
100
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
101
+ image File.expand_path('images/italy.png', __dir__)
102
+
103
+ label {
104
+ text 'Ciao, Mondo!'
105
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
106
+ }
107
+ }
108
+
109
+ c_tab_item(:close) {
110
+ text 'Dutch'
111
+ tool_tip_text 'Dutch Greeting'
112
+ foreground :blue
113
+ selection_foreground :dark_blue
114
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
115
+ image File.expand_path('images/netherlands.png', __dir__)
116
+
117
+ label {
118
+ text 'Hallo, Wereld!'
119
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
120
+ }
121
+ }
122
+
123
+ c_tab_item(:close) {
124
+ text 'Danish'
125
+ tool_tip_text 'Danish Greeting'
126
+ foreground :blue
127
+ selection_foreground :dark_blue
128
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
129
+ image File.expand_path('images/denmark.png', __dir__)
130
+
131
+ label {
132
+ text 'Hej, Verden!'
133
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
134
+ }
135
+ }
136
+
137
+ c_tab_item(:close) {
138
+ text 'Finnish'
139
+ tool_tip_text 'Finnish Greeting'
140
+ foreground :blue
141
+ selection_foreground :dark_blue
142
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
143
+ image File.expand_path('images/finland.png', __dir__)
144
+
145
+ label {
146
+ text 'Hei, Maailma!'
147
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
148
+ }
149
+ }
150
+
151
+ c_tab_item(:close) {
152
+ text 'Norwegian'
153
+ tool_tip_text 'Norwegian Greeting'
154
+ foreground :blue
155
+ selection_foreground :dark_blue
156
+ font name: 'Times New Roman', height: 30, style: [:bold, :italic]
157
+ image File.expand_path('images/norway.png', __dir__)
158
+
159
+ label {
160
+ text 'Hei, Verden!'
161
+ font name: 'Times New Roman', height: 90, style: [:bold, :italic]
162
+ }
163
+ }
164
+
165
+ }
166
+
167
+ }
168
+
169
+ }
170
+ end
171
+
172
+ HelloCTab.launch
@@ -0,0 +1,241 @@
1
+ # Copyright (c) 2020-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 HelloLayout
23
+ include Glimmer::UI::CustomShell
24
+
25
+ body {
26
+ shell {
27
+ # shell (which is a composite) has fill_layout(:horizontal) by default with no margins
28
+ text 'Hello, Layout!'
29
+ tab_folder {
30
+
31
+ # every tab item has its own composite, which can set a layout
32
+ tab_item {
33
+ text 'Fill Layout (horizontal)'
34
+
35
+ fill_layout(:horizontal) {
36
+ margin_width 30
37
+ margin_height 40
38
+ spacing 5
39
+ }
40
+
41
+ 10.times { |n|
42
+ label {
43
+ text "<label #{n+1}>"
44
+ }
45
+
46
+ }
47
+
48
+ }
49
+
50
+ tab_item {
51
+ text 'Fill Layout (vertical)'
52
+
53
+ fill_layout {
54
+ type :vertical # alternative way of specifying orientation
55
+ margin_width 40
56
+ margin_height 30
57
+ spacing 10
58
+ }
59
+
60
+ 10.times { |n|
61
+ label(:center) {
62
+ text "<label #{n+1}>"
63
+ }
64
+
65
+ }
66
+
67
+ }
68
+
69
+ tab_item {
70
+ text 'Row Layout (horizontal)'
71
+
72
+ row_layout(:horizontal) {
73
+ # row layout has margin attributes for top, left, right, and bottom
74
+ # in addition to width and height (and sets margin_width and margin_height to 5 by default)
75
+ margin_top 40
76
+ margin_left 30
77
+ spacing 5
78
+ wrap false
79
+ center true
80
+ justify true
81
+ }
82
+
83
+ 10.times { |n|
84
+ label {
85
+ text "<label #{n+1}>"
86
+ }
87
+
88
+ }
89
+
90
+ }
91
+
92
+ tab_item {
93
+ text 'Row Layout (wrap on shrink)'
94
+
95
+ row_layout { # :horizontal is the default type
96
+ margin_height 40
97
+ margin_width 30
98
+ spacing 35
99
+ # wrap true # is the default
100
+ }
101
+
102
+ 10.times { |n|
103
+ label {
104
+ text "<label #{n+1}>"
105
+ }
106
+
107
+ }
108
+
109
+ }
110
+
111
+ tab_item {
112
+ text 'Row Layout (vertical)'
113
+ background :yellow
114
+
115
+ row_layout(:vertical) { |l|
116
+ margin_height 0
117
+ margin_width 0
118
+ spacing 10
119
+ fill true # fills horizontally to match the widest child (opposite to row layout orientation)
120
+ center false # enable and disable fill to see what this does
121
+ }
122
+
123
+ 10.times { |n|
124
+ label {
125
+ # layout_data allows a widget to tweak its layout configuration (generating RowData object for RowLayout)
126
+ layout_data {
127
+ height 30
128
+ # width unspecified yet calculated
129
+ }
130
+ text "<this is a ver#{'r'*(rand*200).to_i}y wide label #{n+1}>"
131
+ background :green
132
+ }
133
+
134
+ }
135
+
136
+ }
137
+
138
+ tab_item {
139
+ text 'Grid Layout'
140
+
141
+ grid_layout {
142
+ num_columns 5
143
+ make_columns_equal_width true
144
+ horizontal_spacing 15
145
+ vertical_spacing 10
146
+
147
+ # grid layout has margin attributes for top, left, right, and bottom
148
+ # in addition to width and height (and sets margin_width and margin_height to 5 by default)
149
+ margin_height 0
150
+ margin_top 20
151
+ }
152
+
153
+ 10.times { |n|
154
+ label {
155
+ text "<this label is wide enough to fill #{n+1}>"
156
+ background :white
157
+ }
158
+ }
159
+
160
+ label {
161
+ # layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
162
+ layout_data {
163
+ width_hint 120
164
+ height_hint 40
165
+ }
166
+ text "<this label is clipped>"
167
+ background :cyan
168
+ }
169
+
170
+ label {
171
+ # layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
172
+ layout_data {
173
+ horizontal_span 2
174
+ }
175
+ text "<this label spans two columns, so it can contain more text than normal>"
176
+ background :green
177
+ }
178
+
179
+ label {
180
+ # layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
181
+ layout_data {
182
+ vertical_span 2
183
+ vertical_alignment :fill
184
+ }
185
+ text "<this label spans two rows, \nso it can contain new lines\n1\n2\n3\n4\n5\n6\n7>"
186
+ background :yellow
187
+ }
188
+
189
+ 5.times { label } # just filler
190
+
191
+ label {
192
+
193
+ # layout_data allows a widget to tweak its layout configuration (generating GridData object for GridLayout)
194
+ layout_data {
195
+ horizontal_span 5
196
+ horizontal_alignment :fill # could be :beginning, :center or :end too
197
+ vertical_alignment :fill # could be :beginning, :center, or :end too
198
+ grab_excess_horizontal_space true
199
+ grab_excess_vertical_space true
200
+ }
201
+
202
+ # this is a short alternative for specifying what is above
203
+ # layout_data(:fill, :fill, true, true) {
204
+ # horizontal_span 5
205
+ # }
206
+
207
+ text "<this label fills all the space it can get\nhorizontally and vertically>"
208
+ background :magenta
209
+ }
210
+
211
+ }
212
+
213
+
214
+ tab_item {
215
+ text 'Grid Layout (non-equal columns)'
216
+
217
+ grid_layout(2, false) # alt syntax: (numColumns, make_columns_equal_width)
218
+
219
+ 10.times { |n|
220
+ label {
221
+ text "Field #{n+1}"
222
+ }
223
+ text {
224
+ layout_data {
225
+ width_hint 600
226
+ }
227
+
228
+ text "Please enter text"
229
+ }
230
+ }
231
+
232
+ }
233
+
234
+ }
235
+
236
+ }
237
+
238
+ }
239
+ end
240
+
241
+ HelloLayout.launch
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2020-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
@@ -20,15 +20,16 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  class HelloTab
23
- include Glimmer
23
+ include Glimmer::UI::CustomShell
24
24
 
25
- def launch
25
+ body {
26
26
  shell {
27
27
  text 'Hello, Tab!'
28
28
 
29
29
  tab_folder {
30
30
  tab_item {
31
31
  text 'English'
32
+ tool_tip_text 'English Greeting'
32
33
 
33
34
  label {
34
35
  text 'Hello, World!'
@@ -37,14 +38,15 @@ class HelloTab
37
38
 
38
39
  tab_item {
39
40
  text 'French'
41
+ tool_tip_text 'French Greeting'
40
42
 
41
43
  label {
42
44
  text 'Bonjour, Univers!'
43
45
  }
44
46
  }
45
47
  }
46
- }.open
47
- end
48
+ }
49
+ }
48
50
  end
49
51
 
50
- HelloTab.new.launch
52
+ HelloTab.launch