glimmer-dsl-opal 0.2.0 → 0.6.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 +47 -0
- data/README.md +1022 -190
- data/VERSION +1 -1
- data/app/assets/images/glimmer/images/calendar.gif +0 -0
- data/app/assets/images/glimmer/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_444444_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_555555_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_777620_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_777777_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_cc0000_256x240.png +0 -0
- data/app/assets/images/glimmer/images/ui-icons_ffffff_256x240.png +0 -0
- data/app/assets/stylesheets/glimmer.css +15 -0
- data/app/assets/stylesheets/glimmer/jquery-ui.css +1312 -0
- data/app/assets/stylesheets/glimmer/jquery-ui.structure.css +886 -0
- data/app/assets/stylesheets/glimmer/jquery-ui.theme.css +443 -0
- data/app/assets/stylesheets/glimmer/jquery.ui.timepicker.css +57 -0
- data/lib/glimmer-dsl-opal.rb +23 -8
- data/lib/glimmer-dsl-opal/ext/date.rb +48 -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 +5 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +3 -3
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +3 -3
- data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +63 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +104 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.rb +1 -1
- 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/vendor/jquery-ui-timepicker/GPL-LICENSE.txt +278 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt +20 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.css +57 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker.js +1496 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/AUTHORS.txt +333 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/LICENSE.txt +43 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_444444_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_555555_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777620_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_777777_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_cc0000_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css +7 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.js +13 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css +5 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css +5 -0
- data/lib/glimmer-dsl-opal/vendor/jquery-ui/package.json +74 -0
- data/lib/glimmer-dsl-swt.rb +37 -0
- data/lib/glimmer/data_binding/element_binding.rb +2 -1
- 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/custom_widget_expression.rb +42 -5
- data/lib/glimmer/dsl/opal/display_expression.rb +40 -0
- data/lib/glimmer/dsl/opal/dsl.rb +7 -0
- data/lib/glimmer/dsl/opal/exec_expression.rb +55 -0
- data/lib/glimmer/dsl/opal/layout_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/property_expression.rb +4 -3
- data/lib/glimmer/dsl/opal/radio_group_selection_data_binding_expression.rb +61 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +23 -1
- data/lib/glimmer/dsl/opal/swt_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/sync_exec_expression.rb +33 -0
- data/lib/glimmer/dsl/opal/widget_expression.rb +5 -0
- data/lib/glimmer/engine.rb +9 -0
- data/lib/glimmer/swt.rb +3 -3
- data/lib/glimmer/swt/button_proxy.rb +15 -1
- data/lib/glimmer/swt/checkbox_proxy.rb +81 -0
- data/lib/glimmer/swt/combo_proxy.rb +4 -4
- data/lib/glimmer/swt/custom/checkbox_group.rb +142 -0
- data/lib/glimmer/swt/custom/radio_group.rb +143 -0
- data/lib/glimmer/swt/date_time_proxy.rb +144 -0
- data/lib/glimmer/swt/display_proxy.rb +55 -1
- data/lib/glimmer/swt/fill_layout_proxy.rb +2 -2
- data/lib/glimmer/swt/grid_layout_proxy.rb +21 -10
- data/lib/glimmer/swt/group_proxy.rb +38 -0
- data/lib/glimmer/swt/label_proxy.rb +27 -7
- data/lib/glimmer/swt/layout_data_proxy.rb +59 -6
- data/lib/glimmer/swt/layout_proxy.rb +2 -1
- data/lib/glimmer/swt/list_proxy.rb +2 -2
- data/lib/glimmer/swt/make_shift_shell_proxy.rb +38 -0
- data/lib/glimmer/swt/message_box_proxy.rb +7 -7
- data/lib/glimmer/swt/radio_proxy.rb +82 -0
- data/lib/glimmer/swt/row_layout_proxy.rb +35 -12
- data/lib/glimmer/swt/scrolled_composite_proxy.rb +20 -0
- data/lib/glimmer/swt/shell_proxy.rb +25 -10
- data/lib/glimmer/swt/styled_text_proxy.rb +44 -0
- data/lib/glimmer/swt/tab_folder_proxy.rb +3 -3
- data/lib/glimmer/swt/table_proxy.rb +10 -10
- data/lib/glimmer/swt/text_proxy.rb +2 -2
- data/lib/glimmer/swt/widget_proxy.rb +67 -33
- data/lib/glimmer/ui/custom_shell.rb +21 -2
- data/lib/glimmer/ui/custom_widget.rb +3 -1
- data/lib/{glimmer-dsl-opal/missing/net → net}/http.rb +0 -0
- data/lib/uri.rb +64 -0
- metadata +57 -4
- data/lib/glimmer-dsl-opal/missing/uri.rb +0 -26
data/lib/glimmer-dsl-opal.rb
CHANGED
@@ -1,21 +1,34 @@
|
|
1
1
|
require 'opal'
|
2
2
|
|
3
|
+
GLIMMER_DSL_OPAL_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
GLIMMER_DSL_OPAL_LIB = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib')
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(GLIMMER_DSL_OPAL_LIB)
|
7
|
+
|
3
8
|
if RUBY_PLATFORM == 'opal'
|
4
|
-
|
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')
|
9
|
+
# GLIMMER_DSL_OPAL_MISSING = File.join(GLIMMER_DSL_OPAL_ROOT, 'lib', 'glimmer-dsl-opal', 'missing')
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
# $LOAD_PATH.unshift(GLIMMER_DSL_OPAL_MISSING) # missing Ruby classes/methods
|
12
|
+
# TODO look into making append_path work (causing some trouble right now)
|
13
|
+
# Opal.append_path pd File.expand_path('../glimmer-dsl-opal/missing', __FILE__)
|
14
|
+
# Opal.append_path GLIMMER_DSL_OPAL_MISSING
|
10
15
|
|
16
|
+
require 'opal-parser'
|
11
17
|
require 'native' # move this to opal-async
|
12
18
|
require 'opal-async'
|
13
19
|
require 'async/ext'
|
14
20
|
require 'glimmer-dsl-opal/vendor/jquery'
|
21
|
+
require 'glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min'
|
22
|
+
require 'glimmer-dsl-opal/vendor/jquery-ui-timepicker/jquery.ui.timepicker'
|
23
|
+
# require 'glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.min.css'
|
24
|
+
# require 'glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.structure.min.css'
|
25
|
+
# require 'glimmer-dsl-opal/vendor/jquery-ui/jquery-ui.theme.min.css'
|
15
26
|
require 'opal-jquery'
|
16
27
|
require 'glimmer'
|
17
|
-
require 'facets/hash/symbolize_keys'
|
28
|
+
require 'facets/hash/symbolize_keys'
|
18
29
|
require 'glimmer-dsl-opal/ext/exception'
|
30
|
+
require 'glimmer-dsl-opal/ext/date'
|
31
|
+
require 'uri'
|
19
32
|
|
20
33
|
# Spiking async logging
|
21
34
|
# logger = Glimmer::Config.logger
|
@@ -25,7 +38,7 @@ if RUBY_PLATFORM == 'opal'
|
|
25
38
|
# Async::Timeout.new 10000 do
|
26
39
|
# __original_add(*args)
|
27
40
|
# end
|
28
|
-
# end
|
41
|
+
# end
|
29
42
|
|
30
43
|
require 'glimmer/dsl/opal/dsl'
|
31
44
|
require 'glimmer/data_binding/ext/observable_model'
|
@@ -40,6 +53,8 @@ if RUBY_PLATFORM == 'opal'
|
|
40
53
|
method = method_symbol.to_s
|
41
54
|
result = false
|
42
55
|
result ||= method == '<<'
|
56
|
+
result ||= method == 'handle'
|
43
57
|
end
|
44
|
-
|
58
|
+
else
|
59
|
+
require "glimmer/engine"
|
45
60
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
class DateTime < Date
|
5
|
+
def initialize(*args, &block)
|
6
|
+
@time = Time.new(*args, &block)
|
7
|
+
methods_to_exclude = [:to_date, :to_time, :==, :eql?, :class]
|
8
|
+
methods_to_define = @time.methods - methods_to_exclude
|
9
|
+
methods_to_define.each do |method|
|
10
|
+
singleton_class.define_method(method) do |*args, &block|
|
11
|
+
@time.send(method, *args, &block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_date
|
17
|
+
@time.to_date
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_time
|
21
|
+
@time
|
22
|
+
end
|
23
|
+
|
24
|
+
def ==(other)
|
25
|
+
return false if other.class != self.class
|
26
|
+
year == other.year and
|
27
|
+
month == other.month and
|
28
|
+
day == other.day and
|
29
|
+
hour == other.hour and
|
30
|
+
min == other.min and
|
31
|
+
sec == other.sec
|
32
|
+
end
|
33
|
+
alias eql? ==
|
34
|
+
end
|
35
|
+
|
36
|
+
class Date
|
37
|
+
def to_datetime
|
38
|
+
# TODO support timezone
|
39
|
+
DateTime.new(year, month, day, hour, min, sec)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class Time
|
44
|
+
def to_datetime
|
45
|
+
# TODO support timezone
|
46
|
+
DateTime.new(year, month, day, hour, min, sec)
|
47
|
+
end
|
48
|
+
end
|
@@ -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
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2020 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
|
@@ -41,9 +41,9 @@ class HelloCombo
|
|
41
41
|
shell {
|
42
42
|
row_layout(:vertical) {
|
43
43
|
pack false
|
44
|
-
}
|
44
|
+
}
|
45
45
|
|
46
|
-
text 'Hello, Combo!'
|
46
|
+
text 'Hello, Combo!'
|
47
47
|
|
48
48
|
combo(:read_only) {
|
49
49
|
selection bind(person, :country)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2020 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
|
@@ -73,8 +73,8 @@ class EmailShell
|
|
73
73
|
|
74
74
|
label {
|
75
75
|
layout_data(:fill, :fill, true, true) {
|
76
|
-
horizontal_span 2
|
77
|
-
|
76
|
+
horizontal_span 2 #TODO implement
|
77
|
+
vertical_indent 10
|
78
78
|
}
|
79
79
|
|
80
80
|
background :white
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2020 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
|
@@ -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 HelloDateTime
|
23
|
+
class Person
|
24
|
+
attr_accessor :date_of_birth
|
25
|
+
end
|
26
|
+
|
27
|
+
include Glimmer
|
28
|
+
|
29
|
+
def launch
|
30
|
+
person = Person.new
|
31
|
+
person.date_of_birth = DateTime.new(2013, 7, 12, 18, 37, 23)
|
32
|
+
|
33
|
+
shell {
|
34
|
+
row_layout :vertical
|
35
|
+
|
36
|
+
text 'Hello, Date Time!'
|
37
|
+
minimum_size 180, 180
|
38
|
+
|
39
|
+
label {
|
40
|
+
text 'Date of Birth'
|
41
|
+
font height: 16, style: :bold
|
42
|
+
}
|
43
|
+
|
44
|
+
date { # alias for date_time(:date)
|
45
|
+
date_time bind(person, :date_of_birth)
|
46
|
+
}
|
47
|
+
|
48
|
+
date_drop_down { # alias for date_time(:date, :drop_down)
|
49
|
+
date_time bind(person, :date_of_birth)
|
50
|
+
}
|
51
|
+
|
52
|
+
time { # alias for date_time(:time)
|
53
|
+
date_time bind(person, :date_of_birth)
|
54
|
+
}
|
55
|
+
|
56
|
+
calendar { # alias for date_time(:calendar)
|
57
|
+
date_time bind(person, :date_of_birth)
|
58
|
+
}
|
59
|
+
}.open
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
HelloDateTime.new.launch
|
@@ -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
|