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
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.5.0
|
data/lib/glimmer-dsl-opal.rb
CHANGED
@@ -1,13 +1,52 @@
|
|
1
1
|
require 'opal'
|
2
|
-
require 'opal-async'
|
3
|
-
require 'browser'
|
4
|
-
require 'browser/effects'
|
5
|
-
require 'glimmer'
|
6
2
|
|
7
|
-
|
8
|
-
|
3
|
+
if RUBY_PLATFORM == 'opal'
|
4
|
+
GLIMMER_DSL_OPAL_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
GLIMMER_DSL_OPAL_LIB = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib')
|
6
|
+
# GLIMMER_DSL_OPAL_MISSING = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib', 'glimmer-dsl-opal', 'missing')
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift(GLIMMER_DSL_OPAL_LIB)
|
9
|
+
# $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_MISSING) # missing Ruby classes/methods
|
10
|
+
# TODO look into making append_path work (causing some trouble right now)
|
11
|
+
# Opal.append_path pd File.expand_path('../glimmer-dsl-opal/missing', __FILE__)
|
12
|
+
# Opal.append_path GLIMMER_DSL_OPAL_MISSING
|
13
|
+
|
14
|
+
require 'opal-parser'
|
15
|
+
require 'native' # move this to opal-async
|
16
|
+
require 'opal-async'
|
17
|
+
require 'async/ext'
|
18
|
+
require 'glimmer-dsl-opal/vendor/jquery'
|
19
|
+
require 'opal-jquery'
|
20
|
+
require 'glimmer'
|
21
|
+
require 'facets/hash/symbolize_keys'
|
22
|
+
require 'glimmer-dsl-opal/ext/exception'
|
23
|
+
require 'glimmer-dsl-opal/ext/date'
|
24
|
+
require 'uri'
|
9
25
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
26
|
+
# Spiking async logging
|
27
|
+
# logger = Glimmer::Config.logger
|
28
|
+
# original_add_method = logger.class.instance_method(:add)
|
29
|
+
# logger.define_singleton_method("__original_add", original_add_method)
|
30
|
+
# logger.singleton_class.send(:define_method, :add) do |*args|
|
31
|
+
# Async::Timeout.new 10000 do
|
32
|
+
# __original_add(*args)
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
|
36
|
+
require 'glimmer/dsl/opal/dsl'
|
37
|
+
require 'glimmer/data_binding/ext/observable_model'
|
38
|
+
|
39
|
+
require 'glimmer-dsl-xml'
|
40
|
+
require 'glimmer-dsl-css'
|
41
|
+
Element.alias_native :replace_with, :replaceWith
|
42
|
+
|
43
|
+
# Glimmer::Config.loop_max_count = 20
|
44
|
+
|
45
|
+
Glimmer::Config.excluded_keyword_checkers << lambda do |method_symbol, *args|
|
46
|
+
method = method_symbol.to_s
|
47
|
+
result = false
|
48
|
+
result ||= method == '<<'
|
49
|
+
result ||= method == 'handle'
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
class DateTime < Date
|
5
|
+
def initialize(*args, &block)
|
6
|
+
@time = Time.new(*args, &block)
|
7
|
+
@time.methods.each do |method|
|
8
|
+
singleton_class.define_method(method) do |*args, &block|
|
9
|
+
@time.send(method, *args, &block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -82,7 +82,7 @@ class ContactManager
|
|
82
82
|
}
|
83
83
|
}
|
84
84
|
items bind(@contact_manager_presenter, :results), column_properties(:first_name, :last_name, :email)
|
85
|
-
|
85
|
+
on_mouse_up { |event|
|
86
86
|
table_proxy.edit_table_item(event.table_item, event.column_index)
|
87
87
|
}
|
88
88
|
}
|
File without changes
|
data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_manager_presenter.rb
RENAMED
File without changes
|
data/lib/{samples → glimmer-dsl-opal/samples}/elaborate/contact_manager/contact_repository.rb
RENAMED
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2007-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
|
+
|
1
22
|
require_relative "contact"
|
2
23
|
|
3
24
|
class ContactManager
|
@@ -103,105 +124,8 @@ class ContactManager
|
|
103
124
|
Jason
|
104
125
|
Emma
|
105
126
|
Olivia
|
106
|
-
Ava
|
107
|
-
Isabella
|
108
|
-
Sophia
|
109
|
-
Charlotte
|
110
|
-
Mia
|
111
|
-
Amelia
|
112
|
-
Harper
|
113
|
-
Evelyn
|
114
|
-
Abigail
|
115
|
-
Emily
|
116
|
-
Elizabeth
|
117
|
-
Mila
|
118
|
-
Ella
|
119
|
-
Avery
|
120
|
-
Sofia
|
121
|
-
Camila
|
122
|
-
Aria
|
123
|
-
Scarlett
|
124
|
-
Victoria
|
125
|
-
Madison
|
126
|
-
Luna
|
127
|
-
Grace
|
128
|
-
Chloe
|
129
|
-
Penelope
|
130
|
-
Layla
|
131
|
-
Riley
|
132
|
-
Zoey
|
133
|
-
Nora
|
134
|
-
Lily
|
135
|
-
Eleanor
|
136
|
-
Hannah
|
137
|
-
Lillian
|
138
|
-
Addison
|
139
|
-
Aubrey
|
140
|
-
Ellie
|
141
|
-
Stella
|
142
|
-
Natalie
|
143
|
-
Zoe
|
144
|
-
Leah
|
145
|
-
Hazel
|
146
|
-
Violet
|
147
|
-
Aurora
|
148
|
-
Savannah
|
149
|
-
Audrey
|
150
|
-
Brooklyn
|
151
|
-
Bella
|
152
|
-
Claire
|
153
|
-
Skylar
|
154
|
-
Lucy
|
155
|
-
Paisley
|
156
|
-
Everly
|
157
|
-
Anna
|
158
|
-
Caroline
|
159
|
-
Nova
|
160
|
-
Genesis
|
161
|
-
Emilia
|
162
|
-
Kennedy
|
163
|
-
Samantha
|
164
|
-
Maya
|
165
|
-
Willow
|
166
|
-
Kinsley
|
167
|
-
Naomi
|
168
|
-
Aaliyah
|
169
|
-
Elena
|
170
|
-
Sarah
|
171
|
-
Ariana
|
172
|
-
Allison
|
173
|
-
Gabriella
|
174
|
-
Alice
|
175
|
-
Madelyn
|
176
|
-
Cora
|
177
|
-
Ruby
|
178
|
-
Eva
|
179
|
-
Serenity
|
180
|
-
Autumn
|
181
|
-
Adeline
|
182
|
-
Hailey
|
183
|
-
Gianna
|
184
|
-
Valentina
|
185
|
-
Isla
|
186
|
-
Eliana
|
187
|
-
Quinn
|
188
|
-
Nevaeh
|
189
|
-
Ivy
|
190
|
-
Sadie
|
191
|
-
Piper
|
192
|
-
Lydia
|
193
|
-
Alexa
|
194
|
-
Josephine
|
195
|
-
Emery
|
196
|
-
Julia
|
197
|
-
Delilah
|
198
|
-
Arianna
|
199
|
-
Vivian
|
200
|
-
Kaylee
|
201
|
-
Sophie
|
202
|
-
Brielle
|
203
|
-
Madeline
|
204
127
|
]
|
128
|
+
|
205
129
|
NAMES_LAST = %w[
|
206
130
|
Smith
|
207
131
|
Johnson
|
@@ -214,8 +138,9 @@ class ContactManager
|
|
214
138
|
Anderson
|
215
139
|
Taylor
|
216
140
|
]
|
141
|
+
|
217
142
|
def initialize(contacts = nil)
|
218
|
-
@contacts = contacts ||
|
143
|
+
@contacts = contacts || 100.times.map do |n|
|
219
144
|
random_first_name_index = (rand*NAMES_FIRST.size).to_i
|
220
145
|
random_last_name_index = (rand*NAMES_LAST.size).to_i
|
221
146
|
first_name = NAMES_FIRST[random_first_name_index]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,85 @@
|
|
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 HelloCheckbox
|
23
|
+
class Person
|
24
|
+
attr_accessor :skiing, :snowboarding, :snowmobiling, :snowshoeing
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
reset_activities
|
28
|
+
end
|
29
|
+
|
30
|
+
def reset_activities
|
31
|
+
self.skiing = false
|
32
|
+
self.snowboarding = true
|
33
|
+
self.snowmobiling = false
|
34
|
+
self.snowshoeing = false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
include Glimmer
|
39
|
+
|
40
|
+
def launch
|
41
|
+
person = Person.new
|
42
|
+
|
43
|
+
shell {
|
44
|
+
text 'Hello, Checkbox!'
|
45
|
+
row_layout :vertical
|
46
|
+
|
47
|
+
label {
|
48
|
+
text 'Check all snow activities you are interested in:'
|
49
|
+
font style: :bold
|
50
|
+
}
|
51
|
+
|
52
|
+
composite {
|
53
|
+
checkbox {
|
54
|
+
text 'Skiing'
|
55
|
+
selection bind(person, :skiing)
|
56
|
+
}
|
57
|
+
|
58
|
+
checkbox {
|
59
|
+
text 'Snowboarding'
|
60
|
+
selection bind(person, :snowboarding)
|
61
|
+
}
|
62
|
+
|
63
|
+
checkbox {
|
64
|
+
text 'Snowmobiling'
|
65
|
+
selection bind(person, :snowmobiling)
|
66
|
+
}
|
67
|
+
|
68
|
+
checkbox {
|
69
|
+
text 'Snowshoeing'
|
70
|
+
selection bind(person, :snowshoeing)
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
button {
|
75
|
+
text 'Reset Activities'
|
76
|
+
|
77
|
+
on_widget_selected do
|
78
|
+
person.reset_activities
|
79
|
+
end
|
80
|
+
}
|
81
|
+
}.open
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
HelloCheckbox.new.launch
|
@@ -0,0 +1,68 @@
|
|
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 HelloCheckboxGroup
|
23
|
+
class Person
|
24
|
+
attr_accessor :activities
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
reset_activities
|
28
|
+
end
|
29
|
+
|
30
|
+
def activities_options
|
31
|
+
['Skiing', 'Snowboarding', 'Snowmobiling', 'Snowshoeing']
|
32
|
+
end
|
33
|
+
|
34
|
+
def reset_activities
|
35
|
+
self.activities = ['Snowboarding']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
include Glimmer
|
40
|
+
|
41
|
+
def launch
|
42
|
+
person = Person.new
|
43
|
+
|
44
|
+
shell {
|
45
|
+
text 'Hello, Checkbox Group!'
|
46
|
+
row_layout :vertical
|
47
|
+
|
48
|
+
label {
|
49
|
+
text 'Check all snow activities you are interested in:'
|
50
|
+
font style: :bold
|
51
|
+
}
|
52
|
+
|
53
|
+
checkbox_group {
|
54
|
+
selection bind(person, :activities)
|
55
|
+
}
|
56
|
+
|
57
|
+
button {
|
58
|
+
text 'Reset Activities'
|
59
|
+
|
60
|
+
on_widget_selected do
|
61
|
+
person.reset_activities
|
62
|
+
end
|
63
|
+
}
|
64
|
+
}.open
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
HelloCheckboxGroup.new.launch
|
@@ -0,0 +1,63 @@
|
|
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 Person
|
23
|
+
attr_accessor :country, :country_options
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
self.country_options = ['', 'Canada', 'US', 'Mexico']
|
27
|
+
reset_country
|
28
|
+
end
|
29
|
+
|
30
|
+
def reset_country
|
31
|
+
self.country = 'Canada'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class HelloCombo
|
36
|
+
include Glimmer
|
37
|
+
|
38
|
+
def launch
|
39
|
+
person = Person.new
|
40
|
+
|
41
|
+
shell {
|
42
|
+
row_layout(:vertical) {
|
43
|
+
pack false
|
44
|
+
}
|
45
|
+
|
46
|
+
text 'Hello, Combo!'
|
47
|
+
|
48
|
+
combo(:read_only) {
|
49
|
+
selection bind(person, :country)
|
50
|
+
}
|
51
|
+
|
52
|
+
button {
|
53
|
+
text 'Reset Selection'
|
54
|
+
|
55
|
+
on_widget_selected do
|
56
|
+
person.reset_country
|
57
|
+
end
|
58
|
+
}
|
59
|
+
}.open
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
HelloCombo.new.launch
|