glimmer-dsl-opal 0.0.9 → 0.5.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 +50 -0
- data/README.md +999 -177
- data/VERSION +1 -1
- data/lib/glimmer-dsl-opal.rb +49 -10
- data/lib/glimmer-dsl-opal/ext/date.rb +13 -0
- data/lib/glimmer-dsl-opal/ext/exception.rb +5 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager.rb +1 -1
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb +24 -99
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/login.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/board.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/tic_tac_toe/cell.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_browser.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +85 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +68 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +63 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed.rb +19 -19
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_computed/contact.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +155 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +86 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +104 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_multi_selection.rb +0 -0
- data/lib/{samples → glimmer-dsl-opal/samples}/hello/hello_list_single_selection.rb +0 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +108 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +84 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_tab.rb +50 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_world.rb +29 -0
- data/lib/glimmer-dsl-opal/vendor/jquery.js +2 -0
- data/lib/glimmer-dsl-swt.rb +37 -0
- data/lib/glimmer/data_binding/element_binding.rb +1 -0
- data/lib/glimmer/data_binding/ext/observable_model.rb +5 -5
- data/lib/glimmer/data_binding/list_selection_binding.rb +1 -1
- data/lib/glimmer/data_binding/table_items_binding.rb +3 -3
- data/lib/glimmer/dsl/opal/async_exec_expression.rb +23 -7
- data/lib/glimmer/dsl/opal/checkbox_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/color_expression.rb +38 -0
- data/lib/glimmer/dsl/opal/column_properties_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/combo_selection_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +94 -0
- data/lib/glimmer/dsl/opal/display_expression.rb +40 -0
- data/lib/glimmer/dsl/opal/dsl.rb +18 -16
- data/lib/glimmer/dsl/opal/exec_expression.rb +55 -0
- data/lib/glimmer/dsl/opal/font_expression.rb +47 -0
- data/lib/glimmer/dsl/opal/layout_data_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/layout_expression.rb +22 -0
- data/lib/glimmer/dsl/opal/list_selection_data_binding_expression.rb +2 -3
- data/lib/glimmer/dsl/opal/message_box_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/property_expression.rb +6 -2
- data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/rgb_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/rgba_expression.rb +32 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +20 -3
- data/lib/glimmer/dsl/opal/swt_expression.rb +46 -0
- data/lib/glimmer/dsl/opal/sync_exec_expression.rb +33 -0
- data/lib/glimmer/dsl/opal/table_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/widget_expression.rb +24 -0
- data/lib/glimmer/dsl/opal/widget_listener_expression.rb +16 -3
- data/lib/glimmer/swt.rb +499 -0
- data/lib/glimmer/swt/browser_proxy.rb +27 -0
- data/lib/glimmer/swt/button_proxy.rb +54 -0
- data/lib/glimmer/swt/checkbox_proxy.rb +80 -0
- data/lib/glimmer/swt/color_proxy.rb +119 -0
- data/lib/glimmer/{opal/select_proxy.rb → swt/combo_proxy.rb} +23 -18
- data/lib/glimmer/swt/composite_proxy.rb +31 -0
- data/lib/glimmer/swt/custom/checkbox_group.rb +142 -0
- data/lib/glimmer/swt/custom/radio_group.rb +143 -0
- data/lib/glimmer/swt/display_proxy.rb +79 -0
- data/lib/glimmer/{opal → swt}/event_listener_proxy.rb +1 -1
- data/lib/glimmer/swt/fill_layout_proxy.rb +84 -0
- data/lib/glimmer/swt/font_proxy.rb +79 -0
- data/lib/glimmer/swt/grid_layout_proxy.rb +82 -0
- data/lib/glimmer/swt/group_proxy.rb +38 -0
- data/lib/glimmer/swt/label_proxy.rb +54 -0
- data/lib/glimmer/swt/layout_data_proxy.rb +105 -0
- data/lib/glimmer/swt/layout_proxy.rb +63 -0
- data/lib/glimmer/{opal → swt}/list_proxy.rb +30 -22
- data/lib/glimmer/swt/make_shift_shell_proxy.rb +38 -0
- data/lib/glimmer/swt/message_box_proxy.rb +143 -0
- data/lib/glimmer/{opal → swt}/point.rb +1 -1
- data/lib/glimmer/{opal → swt}/property_owner.rb +1 -1
- data/lib/glimmer/swt/radio_proxy.rb +81 -0
- data/lib/glimmer/swt/row_layout_proxy.rb +128 -0
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +20 -0
- data/lib/glimmer/swt/shell_proxy.rb +260 -0
- data/lib/glimmer/swt/style_constantizable.rb +154 -0
- data/lib/glimmer/swt/styled_text_proxy.rb +44 -0
- data/lib/glimmer/swt/swt_proxy.rb +53 -0
- data/lib/glimmer/{opal/tab_folder.rb → swt/tab_folder_proxy.rb} +20 -21
- data/lib/glimmer/swt/tab_item_proxy.rb +84 -0
- data/lib/glimmer/{opal/table_column.rb → swt/table_column_proxy.rb} +13 -7
- data/lib/glimmer/{opal/table_item.rb → swt/table_item_proxy.rb} +59 -48
- data/lib/glimmer/{opal → swt}/table_proxy.rb +66 -56
- data/lib/glimmer/swt/text_proxy.rb +46 -0
- data/lib/glimmer/swt/widget_proxy.rb +511 -0
- data/lib/glimmer/ui/custom_shell.rb +92 -0
- data/lib/glimmer/ui/custom_widget.rb +292 -0
- data/lib/glimmer/util/proc_tracker.rb +39 -0
- data/lib/net/http.rb +17 -0
- data/lib/uri.rb +64 -0
- metadata +142 -67
- data/lib/glimmer/dsl/opal/browser_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/button_expression.rb +0 -18
- data/lib/glimmer/dsl/opal/combo_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/composite_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/grid_layout_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/label_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/list_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_folder_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/tab_item_expression.rb +0 -17
- data/lib/glimmer/dsl/opal/text_expression.rb +0 -22
- data/lib/glimmer/opal/display_proxy.rb +0 -23
- data/lib/glimmer/opal/div_proxy.rb +0 -29
- data/lib/glimmer/opal/document_proxy.rb +0 -187
- data/lib/glimmer/opal/element_proxy.rb +0 -304
- data/lib/glimmer/opal/grid_layout_proxy.rb +0 -54
- data/lib/glimmer/opal/iframe_proxy.rb +0 -23
- data/lib/glimmer/opal/input_proxy.rb +0 -45
- data/lib/glimmer/opal/label_proxy.rb +0 -25
- data/lib/glimmer/opal/layout_data_proxy.rb +0 -52
- data/lib/glimmer/opal/modal.rb +0 -94
- data/lib/glimmer/opal/tab_item.rb +0 -98
- data/lib/samples/elaborate/launch +0 -6
- data/lib/samples/hello/hello_combo.rb +0 -34
- data/lib/samples/hello/hello_tab.rb +0 -24
- data/lib/samples/hello/hello_world.rb +0 -8
- data/lib/samples/hello/launch +0 -10
- data/lib/samples/launch +0 -4
@@ -1,19 +1,19 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative 'hello_computed/contact'
|
2
2
|
|
3
3
|
class HelloComputed
|
4
4
|
include Glimmer
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@contact = Contact.new(
|
8
|
-
first_name:
|
9
|
-
last_name:
|
8
|
+
first_name: 'Barry',
|
9
|
+
last_name: 'McKibbin',
|
10
10
|
year_of_birth: 1985
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
14
|
def launch
|
15
15
|
shell {
|
16
|
-
text
|
16
|
+
text 'Hello, Computed!'
|
17
17
|
composite {
|
18
18
|
grid_layout {
|
19
19
|
num_columns 2
|
@@ -21,44 +21,44 @@ class HelloComputed
|
|
21
21
|
horizontal_spacing 20
|
22
22
|
vertical_spacing 10
|
23
23
|
}
|
24
|
-
label {text
|
24
|
+
label {text 'First &Name: '}
|
25
25
|
text {
|
26
26
|
text bind(@contact, :first_name)
|
27
27
|
layout_data {
|
28
|
-
|
29
|
-
|
28
|
+
horizontal_alignment :fill
|
29
|
+
grab_excess_horizontal_space true
|
30
30
|
}
|
31
31
|
}
|
32
|
-
label {text
|
32
|
+
label {text '&Last Name: '}
|
33
33
|
text {
|
34
34
|
text bind(@contact, :last_name)
|
35
35
|
layout_data {
|
36
|
-
|
37
|
-
|
36
|
+
horizontal_alignment :fill
|
37
|
+
grab_excess_horizontal_space true
|
38
38
|
}
|
39
39
|
}
|
40
|
-
label {text
|
40
|
+
label {text '&Year of Birth: '}
|
41
41
|
text {
|
42
42
|
text bind(@contact, :year_of_birth)
|
43
43
|
layout_data {
|
44
|
-
|
45
|
-
|
44
|
+
horizontal_alignment :fill
|
45
|
+
grab_excess_horizontal_space true
|
46
46
|
}
|
47
47
|
}
|
48
|
-
label {text
|
48
|
+
label {text 'Name: '}
|
49
49
|
label {
|
50
50
|
text bind(@contact, :name, computed_by: [:first_name, :last_name])
|
51
51
|
layout_data {
|
52
|
-
|
53
|
-
|
52
|
+
horizontal_alignment :fill
|
53
|
+
grab_excess_horizontal_space true
|
54
54
|
}
|
55
55
|
}
|
56
|
-
label {text
|
56
|
+
label {text 'Age: '}
|
57
57
|
label {
|
58
58
|
text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
|
59
59
|
layout_data {
|
60
|
-
|
61
|
-
|
60
|
+
horizontal_alignment :fill
|
61
|
+
grab_excess_horizontal_space true
|
62
62
|
}
|
63
63
|
}
|
64
64
|
}
|
File without changes
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# Copyright (c) 2020 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 'date'
|
23
|
+
|
24
|
+
# This class declares an `email_shell` custom shell, aka custom window (by convention)
|
25
|
+
# Used to view an email message
|
26
|
+
class EmailShell
|
27
|
+
include Glimmer::UI::CustomShell
|
28
|
+
|
29
|
+
# multiple options without default values
|
30
|
+
options :date, :subject, :from, :message
|
31
|
+
|
32
|
+
# single option with default value
|
33
|
+
option :to, default: '"John Irwin" <john.irwin@example.com>'
|
34
|
+
|
35
|
+
before_body {
|
36
|
+
@swt_style |= swt(:shell_trim, :modeless)
|
37
|
+
}
|
38
|
+
|
39
|
+
body {
|
40
|
+
# pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
|
41
|
+
shell(swt_style) {
|
42
|
+
grid_layout(2, false)
|
43
|
+
|
44
|
+
text subject
|
45
|
+
|
46
|
+
label {
|
47
|
+
text 'Date:'
|
48
|
+
}
|
49
|
+
label {
|
50
|
+
text date
|
51
|
+
}
|
52
|
+
|
53
|
+
label {
|
54
|
+
text 'From:'
|
55
|
+
}
|
56
|
+
label {
|
57
|
+
text from
|
58
|
+
}
|
59
|
+
|
60
|
+
label {
|
61
|
+
text 'To:'
|
62
|
+
}
|
63
|
+
label {
|
64
|
+
text to
|
65
|
+
}
|
66
|
+
|
67
|
+
label {
|
68
|
+
text 'Subject:'
|
69
|
+
}
|
70
|
+
label {
|
71
|
+
text subject
|
72
|
+
}
|
73
|
+
|
74
|
+
label {
|
75
|
+
layout_data(:fill, :fill, true, true) {
|
76
|
+
horizontal_span 2 #TODO implement
|
77
|
+
vertical_indent 10
|
78
|
+
}
|
79
|
+
|
80
|
+
background :white
|
81
|
+
text message
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
class HelloCustomShell
|
89
|
+
# including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `email_shell` custom widget
|
90
|
+
include Glimmer
|
91
|
+
|
92
|
+
Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
|
93
|
+
EmailSystem = Struct.new(:emails, keyword_init: true)
|
94
|
+
|
95
|
+
def initialize
|
96
|
+
@email_system = EmailSystem.new(
|
97
|
+
emails: [
|
98
|
+
Email.new(date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'), subject: '3rd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
|
99
|
+
Email.new(date: DateTime.new(2029, 10, 21, 8, 1, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v100.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 100.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
|
100
|
+
Email.new(date: DateTime.new(2029, 10, 19, 16, 58, 0).strftime('%F %I:%M %p'), subject: 'Christmas Party', from: '"Lisa Ferreira" <lisa.ferreira@example.com>', message: "Merry Christmas,\n\nAll office Christmas Party arrangements have been set\n\nMake sure to bring a Secret Santa gift\n\nBest regards,\n\nLisa Ferreira"),
|
101
|
+
Email.new(date: DateTime.new(2029, 10, 16, 9, 43, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v99.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 99.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
|
102
|
+
Email.new(date: DateTime.new(2029, 10, 15, 11, 2, 0).strftime('%F %I:%M %p'), subject: '2nd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
|
103
|
+
Email.new(date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v98.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
|
104
|
+
]
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
def launch
|
109
|
+
shell {
|
110
|
+
grid_layout
|
111
|
+
|
112
|
+
text 'Hello, Custom Shell!'
|
113
|
+
|
114
|
+
label {
|
115
|
+
font height: 24, style: :bold
|
116
|
+
text 'Emails:'
|
117
|
+
}
|
118
|
+
|
119
|
+
label {
|
120
|
+
font height: 18
|
121
|
+
text 'Click an email to view its message'
|
122
|
+
}
|
123
|
+
|
124
|
+
table {
|
125
|
+
layout_data :fill, :fill, true, true
|
126
|
+
|
127
|
+
table_column {
|
128
|
+
text 'Date:'
|
129
|
+
width 180
|
130
|
+
}
|
131
|
+
table_column {
|
132
|
+
text 'Subject:'
|
133
|
+
width 180
|
134
|
+
}
|
135
|
+
table_column {
|
136
|
+
text 'From:'
|
137
|
+
width 360
|
138
|
+
}
|
139
|
+
|
140
|
+
items bind(@email_system, :emails), column_properties(:date, :subject, :from)
|
141
|
+
|
142
|
+
on_mouse_up { |event|
|
143
|
+
email = event.table_item.get_data
|
144
|
+
Thread.new do
|
145
|
+
async_exec {
|
146
|
+
email_shell(date: email.date, subject: email.subject, from: email.from, message: email.message).open
|
147
|
+
}
|
148
|
+
end
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}.open
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
HelloCustomShell.new.launch
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# Copyright (c) 2020 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
|
+
# This class declares a `greeting_label` custom widget (by convention)
|
23
|
+
class GreetingLabel
|
24
|
+
include Glimmer::UI::CustomWidget
|
25
|
+
|
26
|
+
# multiple options without default values
|
27
|
+
options :name, :colors
|
28
|
+
|
29
|
+
# single option with default value
|
30
|
+
option :greeting, default: 'Hello'
|
31
|
+
|
32
|
+
# internal attribute (not a custom widget option)
|
33
|
+
attr_accessor :color
|
34
|
+
|
35
|
+
before_body {
|
36
|
+
@font = {height: 24, style: :bold}
|
37
|
+
@color = :black
|
38
|
+
}
|
39
|
+
|
40
|
+
after_body {
|
41
|
+
return if colors.nil?
|
42
|
+
|
43
|
+
Thread.new {
|
44
|
+
colors.cycle { |color|
|
45
|
+
async_exec {
|
46
|
+
self.color = color
|
47
|
+
}
|
48
|
+
sleep(1)
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
body {
|
54
|
+
# pass received swt_style through to label to customize (e.g. :center to center text)
|
55
|
+
label(swt_style) {
|
56
|
+
text "#{greeting}, #{name}!"
|
57
|
+
font @font
|
58
|
+
foreground bind(self, :color)
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
# including Glimmer enables the Glimmer DSL syntax, including auto-discovery of the `greeting_label` custom widget
|
65
|
+
include Glimmer
|
66
|
+
|
67
|
+
shell {
|
68
|
+
fill_layout :vertical
|
69
|
+
|
70
|
+
minimum_size 215, 215
|
71
|
+
text 'Hello, Custom Widget!'
|
72
|
+
|
73
|
+
# custom widget options are passed in a hash
|
74
|
+
greeting_label(name: 'Sean')
|
75
|
+
|
76
|
+
# pass :center SWT style followed by custom widget options hash
|
77
|
+
greeting_label(:center, name: 'Laura', greeting: 'Aloha') #
|
78
|
+
|
79
|
+
greeting_label(:right, name: 'Rick') {
|
80
|
+
# you can nest attributes under custom widgets just like any standard widget
|
81
|
+
foreground :red
|
82
|
+
}
|
83
|
+
|
84
|
+
# the colors option cycles between colors for the label foreground every second
|
85
|
+
greeting_label(:center, name: 'Mary', greeting: 'Aloha', colors: [:red, :dark_green, :blue])
|
86
|
+
}.open
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# Copyright (c) 2020 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 HelloGroup
|
23
|
+
class Person
|
24
|
+
attr_accessor :male, :female, :child, :teen, :adult, :senior
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
reset
|
28
|
+
end
|
29
|
+
|
30
|
+
def reset
|
31
|
+
self.male = nil
|
32
|
+
self.female = nil
|
33
|
+
self.child = nil
|
34
|
+
self.teen = nil
|
35
|
+
self.adult = true
|
36
|
+
self.senior = nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
include Glimmer
|
41
|
+
|
42
|
+
def launch
|
43
|
+
person = Person.new
|
44
|
+
|
45
|
+
shell {
|
46
|
+
text 'Hello, Group!'
|
47
|
+
row_layout :vertical
|
48
|
+
|
49
|
+
group {
|
50
|
+
row_layout
|
51
|
+
|
52
|
+
text 'Gender'
|
53
|
+
font style: :bold
|
54
|
+
|
55
|
+
radio {
|
56
|
+
text 'Male'
|
57
|
+
selection bind(person, :male)
|
58
|
+
}
|
59
|
+
|
60
|
+
radio {
|
61
|
+
text 'Female'
|
62
|
+
selection bind(person, :female)
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
group {
|
67
|
+
row_layout
|
68
|
+
|
69
|
+
text 'Age Group'
|
70
|
+
font style: :bold
|
71
|
+
|
72
|
+
radio {
|
73
|
+
text 'Child'
|
74
|
+
selection bind(person, :child)
|
75
|
+
}
|
76
|
+
|
77
|
+
radio {
|
78
|
+
text 'Teen'
|
79
|
+
selection bind(person, :teen)
|
80
|
+
}
|
81
|
+
|
82
|
+
radio {
|
83
|
+
text 'Adult'
|
84
|
+
selection bind(person, :adult)
|
85
|
+
}
|
86
|
+
|
87
|
+
radio {
|
88
|
+
text 'Senior'
|
89
|
+
selection bind(person, :senior)
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
button {
|
94
|
+
text 'Reset'
|
95
|
+
|
96
|
+
on_widget_selected do
|
97
|
+
person.reset
|
98
|
+
end
|
99
|
+
}
|
100
|
+
}.open
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
HelloGroup.new.launch
|
File without changes
|
File without changes
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# Copyright (c) 2020 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 HelloRadio
|
23
|
+
class Person
|
24
|
+
attr_accessor :male, :female, :child, :teen, :adult, :senior
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
reset
|
28
|
+
end
|
29
|
+
|
30
|
+
def reset
|
31
|
+
self.male = nil
|
32
|
+
self.female = nil
|
33
|
+
self.child = nil
|
34
|
+
self.teen = nil
|
35
|
+
self.adult = true
|
36
|
+
self.senior = nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
include Glimmer
|
41
|
+
|
42
|
+
def launch
|
43
|
+
person = Person.new
|
44
|
+
|
45
|
+
shell {
|
46
|
+
text 'Hello, Radio!'
|
47
|
+
row_layout :vertical
|
48
|
+
|
49
|
+
label {
|
50
|
+
text 'Gender:'
|
51
|
+
font style: :bold
|
52
|
+
}
|
53
|
+
|
54
|
+
composite {
|
55
|
+
row_layout
|
56
|
+
|
57
|
+
radio {
|
58
|
+
text 'Male'
|
59
|
+
selection bind(person, :male)
|
60
|
+
}
|
61
|
+
|
62
|
+
radio {
|
63
|
+
text 'Female'
|
64
|
+
selection bind(person, :female)
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
label {
|
69
|
+
text 'Age Group:'
|
70
|
+
font style: :bold
|
71
|
+
}
|
72
|
+
|
73
|
+
composite {
|
74
|
+
row_layout
|
75
|
+
|
76
|
+
radio {
|
77
|
+
text 'Child'
|
78
|
+
selection bind(person, :child)
|
79
|
+
}
|
80
|
+
|
81
|
+
radio {
|
82
|
+
text 'Teen'
|
83
|
+
selection bind(person, :teen)
|
84
|
+
}
|
85
|
+
|
86
|
+
radio {
|
87
|
+
text 'Adult'
|
88
|
+
selection bind(person, :adult)
|
89
|
+
}
|
90
|
+
|
91
|
+
radio {
|
92
|
+
text 'Senior'
|
93
|
+
selection bind(person, :senior)
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
button {
|
98
|
+
text 'Reset'
|
99
|
+
|
100
|
+
on_widget_selected do
|
101
|
+
person.reset
|
102
|
+
end
|
103
|
+
}
|
104
|
+
}.open
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
HelloRadio.new.launch
|