glimmer-dsl-opal 0.12.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +179 -1296
- data/VERSION +1 -1
- data/app/controllers/glimmer/application_controller.rb +4 -0
- data/app/controllers/glimmer/image_paths_controller.rb +46 -0
- data/app/views/glimmer/image_paths/index.html.erb +1 -0
- data/{lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb → config/routes.rb} +2 -20
- data/lib/glimmer-dsl-opal.rb +9 -3
- data/lib/glimmer-dsl-opal/ext/file.rb +25 -0
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +0 -2
- data/lib/glimmer-dsl-opal/samples/elaborate/weather.rb +157 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +7 -7
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +16 -14
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +14 -9
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +24 -22
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -9
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +15 -11
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +18 -16
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +17 -12
- data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +29 -21
- data/lib/glimmer-dsl-opal/samples/hello/hello_table/baseball_park.png +0 -0
- data/lib/glimmer/config.rb +11 -0
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +2 -2
- data/lib/glimmer/engine.rb +21 -0
- data/lib/glimmer/swt/composite_proxy.rb +34 -0
- data/lib/glimmer/swt/label_proxy.rb +15 -2
- data/lib/glimmer/swt/shell_proxy.rb +43 -0
- data/lib/glimmer/swt/table_item_proxy.rb +3 -0
- data/lib/glimmer/ui/custom_widget.rb +11 -2
- data/lib/net/http.rb +15 -6
- metadata +9 -3
@@ -19,45 +19,47 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
class
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
class HelloCombo
|
23
|
+
class Person
|
24
|
+
attr_accessor :country, :country_options
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
self.country_options = ['', 'Canada', 'US', 'Mexico']
|
28
|
+
reset_country!
|
29
|
+
end
|
30
|
+
|
31
|
+
def reset_country!
|
32
|
+
self.country = 'Canada'
|
33
|
+
end
|
32
34
|
end
|
33
|
-
end
|
34
35
|
|
35
|
-
|
36
|
-
include Glimmer
|
36
|
+
include Glimmer::UI::CustomShell
|
37
37
|
|
38
|
-
|
39
|
-
person = Person.new
|
40
|
-
|
38
|
+
before_body {
|
39
|
+
@person = Person.new
|
40
|
+
}
|
41
|
+
|
42
|
+
body {
|
41
43
|
shell {
|
42
44
|
row_layout(:vertical) {
|
43
|
-
|
45
|
+
fill true
|
44
46
|
}
|
45
47
|
|
46
48
|
text 'Hello, Combo!'
|
47
49
|
|
48
50
|
combo(:read_only) {
|
49
|
-
selection <=> [person, :country]
|
51
|
+
selection <=> [@person, :country] # also binds to country_options by convention
|
50
52
|
}
|
51
53
|
|
52
54
|
button {
|
53
55
|
text 'Reset Selection'
|
54
56
|
|
55
57
|
on_widget_selected do
|
56
|
-
person.reset_country
|
58
|
+
@person.reset_country!
|
57
59
|
end
|
58
60
|
}
|
59
|
-
}
|
60
|
-
|
61
|
+
}
|
62
|
+
}
|
61
63
|
end
|
62
64
|
|
63
|
-
HelloCombo.
|
65
|
+
HelloCombo.launch
|
@@ -19,20 +19,38 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
require_relative 'hello_computed/contact'
|
23
|
-
|
24
22
|
class HelloComputed
|
25
|
-
|
23
|
+
class Contact
|
24
|
+
attr_accessor :first_name, :last_name, :year_of_birth
|
25
|
+
|
26
|
+
def initialize(attribute_map)
|
27
|
+
@first_name = attribute_map[:first_name]
|
28
|
+
@last_name = attribute_map[:last_name]
|
29
|
+
@year_of_birth = attribute_map[:year_of_birth]
|
30
|
+
end
|
31
|
+
|
32
|
+
def name
|
33
|
+
"#{last_name}, #{first_name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def age
|
37
|
+
Time.now.year - year_of_birth.to_i
|
38
|
+
rescue
|
39
|
+
0
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
include Glimmer::UI::CustomShell
|
26
44
|
|
27
|
-
|
45
|
+
before_body {
|
28
46
|
@contact = Contact.new(
|
29
47
|
first_name: 'Barry',
|
30
48
|
last_name: 'McKibbin',
|
31
49
|
year_of_birth: 1985
|
32
50
|
)
|
33
|
-
|
51
|
+
}
|
34
52
|
|
35
|
-
|
53
|
+
body {
|
36
54
|
shell {
|
37
55
|
text 'Hello, Computed!'
|
38
56
|
|
@@ -89,8 +107,8 @@ class HelloComputed
|
|
89
107
|
}
|
90
108
|
}
|
91
109
|
}
|
92
|
-
}
|
93
|
-
|
110
|
+
}
|
111
|
+
}
|
94
112
|
end
|
95
113
|
|
96
|
-
HelloComputed.
|
114
|
+
HelloComputed.launch
|
@@ -24,10 +24,11 @@ require 'date'
|
|
24
24
|
# This class declares an `email_shell` custom shell, aka custom window (by convention)
|
25
25
|
# Used to view an email message
|
26
26
|
class EmailShell
|
27
|
+
# including Glimmer::UI::CustomShell enables declaring as an `email_shell` custom widget Glimmer GUI DSL keyword
|
27
28
|
include Glimmer::UI::CustomShell
|
28
29
|
|
29
30
|
# multiple options without default values
|
30
|
-
options :date, :subject, :from, :message
|
31
|
+
options :parent_shell, :date, :subject, :from, :message
|
31
32
|
|
32
33
|
# single option with default value
|
33
34
|
option :to, default: '"John Irwin" <john.irwin@example.com>'
|
@@ -38,7 +39,7 @@ class EmailShell
|
|
38
39
|
|
39
40
|
body {
|
40
41
|
# pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
|
41
|
-
shell(swt_style) {
|
42
|
+
shell(parent_shell, swt_style) {
|
42
43
|
grid_layout(2, false)
|
43
44
|
|
44
45
|
text subject
|
@@ -73,7 +74,7 @@ class EmailShell
|
|
73
74
|
|
74
75
|
label {
|
75
76
|
layout_data(:fill, :fill, true, true) {
|
76
|
-
horizontal_span 2
|
77
|
+
horizontal_span 2
|
77
78
|
vertical_indent 10
|
78
79
|
}
|
79
80
|
|
@@ -86,9 +87,8 @@ class EmailShell
|
|
86
87
|
end
|
87
88
|
|
88
89
|
class HelloCustomShell
|
89
|
-
# including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `email_shell` custom widget
|
90
90
|
include Glimmer
|
91
|
-
|
91
|
+
|
92
92
|
Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
|
93
93
|
EmailSystem = Struct.new(:emails, keyword_init: true)
|
94
94
|
|
@@ -106,7 +106,7 @@ class HelloCustomShell
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def launch
|
109
|
-
shell {
|
109
|
+
shell { |shell_proxy|
|
110
110
|
grid_layout
|
111
111
|
|
112
112
|
text 'Hello, Custom Shell!'
|
@@ -141,11 +141,15 @@ class HelloCustomShell
|
|
141
141
|
|
142
142
|
on_mouse_up { |event|
|
143
143
|
email = event.table_item.get_data
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
|
145
|
+
# open a custom email shell
|
146
|
+
email_shell(
|
147
|
+
parent_shell: shell_proxy,
|
148
|
+
date: email.date,
|
149
|
+
subject: email.subject,
|
150
|
+
from: email.from,
|
151
|
+
message: email.message
|
152
|
+
).open
|
149
153
|
}
|
150
154
|
}
|
151
155
|
}.open
|
@@ -24,10 +24,10 @@ class HelloRadio
|
|
24
24
|
attr_accessor :male, :female, :child, :teen, :adult, :senior
|
25
25
|
|
26
26
|
def initialize
|
27
|
-
reset
|
27
|
+
reset!
|
28
28
|
end
|
29
29
|
|
30
|
-
def reset
|
30
|
+
def reset!
|
31
31
|
self.male = nil
|
32
32
|
self.female = nil
|
33
33
|
self.child = nil
|
@@ -37,11 +37,13 @@ class HelloRadio
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
include Glimmer
|
40
|
+
include Glimmer::UI::CustomShell
|
41
41
|
|
42
|
-
|
43
|
-
person = Person.new
|
44
|
-
|
42
|
+
before_body {
|
43
|
+
@person = Person.new
|
44
|
+
}
|
45
|
+
|
46
|
+
body {
|
45
47
|
shell {
|
46
48
|
text 'Hello, Radio!'
|
47
49
|
row_layout :vertical
|
@@ -56,12 +58,12 @@ class HelloRadio
|
|
56
58
|
|
57
59
|
radio {
|
58
60
|
text 'Male'
|
59
|
-
selection <=> [person, :male]
|
61
|
+
selection <=> [@person, :male]
|
60
62
|
}
|
61
63
|
|
62
64
|
radio {
|
63
65
|
text 'Female'
|
64
|
-
selection <=> [person, :female]
|
66
|
+
selection <=> [@person, :female]
|
65
67
|
}
|
66
68
|
}
|
67
69
|
|
@@ -75,22 +77,22 @@ class HelloRadio
|
|
75
77
|
|
76
78
|
radio {
|
77
79
|
text 'Child'
|
78
|
-
selection <=> [person, :child]
|
80
|
+
selection <=> [@person, :child]
|
79
81
|
}
|
80
82
|
|
81
83
|
radio {
|
82
84
|
text 'Teen'
|
83
|
-
selection <=> [person, :teen]
|
85
|
+
selection <=> [@person, :teen]
|
84
86
|
}
|
85
87
|
|
86
88
|
radio {
|
87
89
|
text 'Adult'
|
88
|
-
selection <=> [person, :adult]
|
90
|
+
selection <=> [@person, :adult]
|
89
91
|
}
|
90
92
|
|
91
93
|
radio {
|
92
94
|
text 'Senior'
|
93
|
-
selection <=> [person, :senior]
|
95
|
+
selection <=> [@person, :senior]
|
94
96
|
}
|
95
97
|
}
|
96
98
|
|
@@ -98,11 +100,11 @@ class HelloRadio
|
|
98
100
|
text 'Reset'
|
99
101
|
|
100
102
|
on_widget_selected do
|
101
|
-
person.reset
|
103
|
+
@person.reset!
|
102
104
|
end
|
103
105
|
}
|
104
|
-
}
|
105
|
-
|
106
|
+
}
|
107
|
+
}
|
106
108
|
end
|
107
109
|
|
108
|
-
HelloRadio.
|
110
|
+
HelloRadio.launch
|
@@ -19,12 +19,15 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
# This sample demonstrates the use of a `radio_group` in Glimmer, which provides terser syntax
|
23
|
+
# than HelloRadio for representing multiple radio buttons by relying on data-binding to
|
24
|
+
# automatically spawn the `radio` widgets based on available options on the model.
|
22
25
|
class HelloRadioGroup
|
23
26
|
class Person
|
24
27
|
attr_accessor :gender, :age_group
|
25
28
|
|
26
29
|
def initialize
|
27
|
-
reset
|
30
|
+
reset!
|
28
31
|
end
|
29
32
|
|
30
33
|
def gender_options
|
@@ -35,17 +38,19 @@ class HelloRadioGroup
|
|
35
38
|
['Child', 'Teen', 'Adult', 'Senior']
|
36
39
|
end
|
37
40
|
|
38
|
-
def reset
|
41
|
+
def reset!
|
39
42
|
self.gender = nil
|
40
43
|
self.age_group = 'Adult'
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
|
-
include Glimmer
|
47
|
+
include Glimmer::UI::CustomShell
|
45
48
|
|
46
|
-
|
47
|
-
person = Person.new
|
48
|
-
|
49
|
+
before_body {
|
50
|
+
@person = Person.new
|
51
|
+
}
|
52
|
+
|
53
|
+
body {
|
49
54
|
shell {
|
50
55
|
text 'Hello, Radio Group!'
|
51
56
|
row_layout :vertical
|
@@ -57,7 +62,7 @@ class HelloRadioGroup
|
|
57
62
|
|
58
63
|
radio_group {
|
59
64
|
row_layout :horizontal
|
60
|
-
selection
|
65
|
+
selection <=> [@person, :gender]
|
61
66
|
}
|
62
67
|
|
63
68
|
label {
|
@@ -67,18 +72,18 @@ class HelloRadioGroup
|
|
67
72
|
|
68
73
|
radio_group {
|
69
74
|
row_layout :horizontal
|
70
|
-
selection
|
75
|
+
selection <=> [@person, :age_group]
|
71
76
|
}
|
72
77
|
|
73
78
|
button {
|
74
79
|
text 'Reset'
|
75
80
|
|
76
81
|
on_widget_selected do
|
77
|
-
person.reset
|
82
|
+
@person.reset!
|
78
83
|
end
|
79
84
|
}
|
80
|
-
}
|
81
|
-
|
85
|
+
}
|
86
|
+
}
|
82
87
|
end
|
83
88
|
|
84
|
-
HelloRadioGroup.
|
89
|
+
HelloRadioGroup.launch
|
@@ -179,25 +179,33 @@ class HelloTable
|
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
-
include Glimmer
|
183
|
-
|
184
|
-
|
182
|
+
include Glimmer::UI::CustomShell
|
183
|
+
|
184
|
+
before_body {
|
185
|
+
Display.app_name = 'Hello, Table!'
|
186
|
+
}
|
187
|
+
|
188
|
+
body {
|
185
189
|
shell {
|
186
190
|
grid_layout
|
187
191
|
|
188
192
|
text 'Hello, Table!'
|
193
|
+
background_image File.expand_path('hello_table/baseball_park.png', __dir__)
|
194
|
+
image File.expand_path('hello_table/baseball_park.png', __dir__)
|
189
195
|
|
190
196
|
label {
|
191
197
|
layout_data :center, :center, true, false
|
192
198
|
|
193
|
-
text '
|
194
|
-
|
199
|
+
text 'BASEBALL PLAYOFF SCHEDULE'
|
200
|
+
background :transparent if OS.windows?
|
201
|
+
foreground rgb(94, 107, 103)
|
202
|
+
font name: 'Optima', height: 38, style: :bold
|
195
203
|
}
|
196
204
|
|
197
205
|
combo(:read_only) {
|
198
206
|
layout_data :center, :center, true, false
|
199
|
-
selection
|
200
|
-
font height:
|
207
|
+
selection <=> [BaseballGame, :playoff_type]
|
208
|
+
font height: 14
|
201
209
|
}
|
202
210
|
|
203
211
|
table(:editable) { |table_proxy|
|
@@ -248,29 +256,29 @@ class HelloTable
|
|
248
256
|
# Sort by these additional properties after handling sort by the column the user clicked
|
249
257
|
additional_sort_properties :date, :time, :home_team, :away_team, :ballpark, :promotion
|
250
258
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
259
|
+
menu {
|
260
|
+
menu_item {
|
261
|
+
text 'Book'
|
262
|
+
|
263
|
+
on_widget_selected {
|
264
|
+
book_selected_game
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
260
268
|
}
|
261
269
|
|
262
270
|
button {
|
263
271
|
text 'Book Selected Game'
|
264
272
|
layout_data :center, :center, true, false
|
265
|
-
font height:
|
266
|
-
enabled
|
273
|
+
font height: 14
|
274
|
+
enabled <= [BaseballGame, :selected_game]
|
267
275
|
|
268
276
|
on_widget_selected {
|
269
277
|
book_selected_game
|
270
278
|
}
|
271
279
|
}
|
272
|
-
}
|
273
|
-
|
280
|
+
}
|
281
|
+
}
|
274
282
|
|
275
283
|
def book_selected_game
|
276
284
|
message_box {
|
@@ -280,4 +288,4 @@ class HelloTable
|
|
280
288
|
end
|
281
289
|
end
|
282
290
|
|
283
|
-
HelloTable.
|
291
|
+
HelloTable.launch
|