glimmer-dsl-opal 0.10.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +34 -27
- data/VERSION +1 -1
- data/lib/display.rb +3 -0
- data/lib/glimmer-dsl-opal.rb +1 -1
- data/lib/glimmer-dsl-opal/ext/glimmer/dsl/engine.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +15 -13
- data/lib/glimmer-dsl-opal/samples/elaborate/login.rb +55 -28
- data/lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb +2 -2
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +1 -1
- 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 +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +5 -5
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +16 -12
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb +4 -4
- data/lib/glimmer-dsl-opal/samples/hello/hello_group.rb +6 -6
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_multi_selection.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_list_single_selection.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 +4 -4
- data/lib/glimmer/data_binding/table_items_binding.rb +3 -2
- data/lib/glimmer/dsl/opal/bind_expression.rb +24 -25
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +8 -8
- data/lib/glimmer/dsl/opal/dsl.rb +4 -0
- data/lib/glimmer/dsl/opal/menu_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/property_expression.rb +2 -1
- data/lib/glimmer/dsl/opal/shape_expression.rb +26 -0
- data/lib/glimmer/dsl/opal/shell_expression.rb +1 -1
- data/lib/glimmer/dsl/opal/shine_data_binding_expression.rb +49 -0
- data/lib/glimmer/dsl/opal/table_items_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/opal/widget_expression.rb +1 -1
- data/lib/glimmer/swt/combo_proxy.rb +1 -0
- data/lib/glimmer/swt/composite_proxy.rb +2 -0
- data/lib/glimmer/swt/dialog_proxy.rb +2 -5
- data/lib/glimmer/swt/display_proxy.rb +104 -10
- data/lib/glimmer/swt/grid_layout_proxy.rb +17 -17
- data/lib/glimmer/swt/layout_proxy.rb +23 -3
- data/lib/glimmer/swt/message_box_proxy.rb +4 -4
- data/lib/glimmer/swt/row_layout_proxy.rb +12 -3
- data/lib/glimmer/swt/table_proxy.rb +19 -3
- data/lib/glimmer/swt/widget_proxy.rb +3 -4
- data/lib/glimmer/ui/custom_shell.rb +22 -5
- data/lib/glimmer/ui/custom_widget.rb +11 -2
- data/lib/glimmer/util/proc_tracker.rb +5 -3
- metadata +11 -9
@@ -35,8 +35,8 @@ class TicTacToe
|
|
35
35
|
(1..3).each { |column|
|
36
36
|
button {
|
37
37
|
layout_data :fill, :fill, true, true
|
38
|
-
text
|
39
|
-
enabled
|
38
|
+
text <= [@tic_tac_toe_board[row, column], :sign]
|
39
|
+
enabled <= [@tic_tac_toe_board[row, column], :empty]
|
40
40
|
font style: :bold, height: 20
|
41
41
|
on_widget_selected {
|
42
42
|
@tic_tac_toe_board.mark(row, column)
|
@@ -24,10 +24,10 @@ class HelloCheckbox
|
|
24
24
|
attr_accessor :skiing, :snowboarding, :snowmobiling, :snowshoeing
|
25
25
|
|
26
26
|
def initialize
|
27
|
-
reset_activities
|
27
|
+
reset_activities!
|
28
28
|
end
|
29
29
|
|
30
|
-
def reset_activities
|
30
|
+
def reset_activities!
|
31
31
|
self.skiing = false
|
32
32
|
self.snowboarding = true
|
33
33
|
self.snowmobiling = false
|
@@ -35,11 +35,13 @@ class HelloCheckbox
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
include Glimmer
|
38
|
+
include Glimmer::UI::CustomShell
|
39
39
|
|
40
|
-
|
41
|
-
person = Person.new
|
42
|
-
|
40
|
+
before_body {
|
41
|
+
@person = Person.new
|
42
|
+
}
|
43
|
+
|
44
|
+
body {
|
43
45
|
shell {
|
44
46
|
text 'Hello, Checkbox!'
|
45
47
|
row_layout :vertical
|
@@ -52,22 +54,22 @@ class HelloCheckbox
|
|
52
54
|
composite {
|
53
55
|
checkbox {
|
54
56
|
text 'Skiing'
|
55
|
-
selection
|
57
|
+
selection <=> [@person, :skiing]
|
56
58
|
}
|
57
59
|
|
58
60
|
checkbox {
|
59
61
|
text 'Snowboarding'
|
60
|
-
selection
|
62
|
+
selection <=> [@person, :snowboarding]
|
61
63
|
}
|
62
64
|
|
63
65
|
checkbox {
|
64
66
|
text 'Snowmobiling'
|
65
|
-
selection
|
67
|
+
selection <=> [@person, :snowmobiling]
|
66
68
|
}
|
67
69
|
|
68
70
|
checkbox {
|
69
71
|
text 'Snowshoeing'
|
70
|
-
selection
|
72
|
+
selection <=> [@person, :snowshoeing]
|
71
73
|
}
|
72
74
|
}
|
73
75
|
|
@@ -75,11 +77,11 @@ class HelloCheckbox
|
|
75
77
|
text 'Reset Activities'
|
76
78
|
|
77
79
|
on_widget_selected do
|
78
|
-
person.reset_activities
|
80
|
+
@person.reset_activities!
|
79
81
|
end
|
80
82
|
}
|
81
|
-
}
|
82
|
-
|
83
|
+
}
|
84
|
+
}
|
83
85
|
end
|
84
86
|
|
85
|
-
HelloCheckbox.
|
87
|
+
HelloCheckbox.launch
|
@@ -19,6 +19,9 @@
|
|
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 `checkbox_group` (aka `check_group`) in Glimmer, which provides terser syntax
|
23
|
+
# than HelloCheckbox for representing multiple checkbox buttons (`button(:check)`) by relying on data-binding to
|
24
|
+
# automatically spawn the `checkbox` widgets (`button(:check)`) based on available options on the model.
|
22
25
|
class HelloCheckboxGroup
|
23
26
|
class Person
|
24
27
|
attr_accessor :activities
|
@@ -36,11 +39,13 @@ class HelloCheckboxGroup
|
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
|
-
include Glimmer
|
42
|
+
include Glimmer::UI::CustomShell
|
40
43
|
|
41
|
-
|
42
|
-
person = Person.new
|
43
|
-
|
44
|
+
before_body {
|
45
|
+
@person = Person.new
|
46
|
+
}
|
47
|
+
|
48
|
+
body {
|
44
49
|
shell {
|
45
50
|
text 'Hello, Checkbox Group!'
|
46
51
|
row_layout :vertical
|
@@ -51,18 +56,18 @@ class HelloCheckboxGroup
|
|
51
56
|
}
|
52
57
|
|
53
58
|
checkbox_group {
|
54
|
-
selection
|
59
|
+
selection <=> [@person, :activities]
|
55
60
|
}
|
56
61
|
|
57
62
|
button {
|
58
63
|
text 'Reset Activities'
|
59
64
|
|
60
65
|
on_widget_selected do
|
61
|
-
person.reset_activities
|
66
|
+
@person.reset_activities
|
62
67
|
end
|
63
68
|
}
|
64
|
-
}
|
65
|
-
|
69
|
+
}
|
70
|
+
}
|
66
71
|
end
|
67
72
|
|
68
|
-
HelloCheckboxGroup.
|
73
|
+
HelloCheckboxGroup.launch
|
@@ -46,7 +46,7 @@ class HelloComputed
|
|
46
46
|
|
47
47
|
label {text 'First &Name: '}
|
48
48
|
text {
|
49
|
-
text
|
49
|
+
text <=> [@contact, :first_name]
|
50
50
|
layout_data {
|
51
51
|
horizontal_alignment :fill
|
52
52
|
grab_excess_horizontal_space true
|
@@ -55,7 +55,7 @@ class HelloComputed
|
|
55
55
|
|
56
56
|
label {text '&Last Name: '}
|
57
57
|
text {
|
58
|
-
text
|
58
|
+
text <=> [@contact, :last_name]
|
59
59
|
layout_data {
|
60
60
|
horizontal_alignment :fill
|
61
61
|
grab_excess_horizontal_space true
|
@@ -64,7 +64,7 @@ class HelloComputed
|
|
64
64
|
|
65
65
|
label {text '&Year of Birth: '}
|
66
66
|
text {
|
67
|
-
text
|
67
|
+
text <=> [@contact, :year_of_birth]
|
68
68
|
layout_data {
|
69
69
|
horizontal_alignment :fill
|
70
70
|
grab_excess_horizontal_space true
|
@@ -73,7 +73,7 @@ class HelloComputed
|
|
73
73
|
|
74
74
|
label {text 'Name: '}
|
75
75
|
label {
|
76
|
-
text
|
76
|
+
text <= [@contact, :name, computed_by: [:first_name, :last_name]]
|
77
77
|
layout_data {
|
78
78
|
horizontal_alignment :fill
|
79
79
|
grab_excess_horizontal_space true
|
@@ -82,7 +82,7 @@ class HelloComputed
|
|
82
82
|
|
83
83
|
label {text 'Age: '}
|
84
84
|
label {
|
85
|
-
text
|
85
|
+
text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
86
86
|
layout_data {
|
87
87
|
horizontal_alignment :fill
|
88
88
|
grab_excess_horizontal_space true
|
@@ -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!'
|
@@ -137,15 +137,19 @@ class HelloCustomShell
|
|
137
137
|
width 360
|
138
138
|
}
|
139
139
|
|
140
|
-
items
|
140
|
+
items <=> [@email_system, :emails, column_attributes: [:date, :subject, :from]]
|
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
|
@@ -42,19 +42,19 @@ class HelloDateTime
|
|
42
42
|
}
|
43
43
|
|
44
44
|
date { # alias for date_time(:date)
|
45
|
-
date_time
|
45
|
+
date_time <=> [person, :date_of_birth]
|
46
46
|
}
|
47
47
|
|
48
48
|
date_drop_down { # alias for date_time(:date, :drop_down)
|
49
|
-
date_time
|
49
|
+
date_time <=> [person, :date_of_birth]
|
50
50
|
}
|
51
51
|
|
52
52
|
time { # alias for date_time(:time)
|
53
|
-
date_time
|
53
|
+
date_time <=> [person, :date_of_birth]
|
54
54
|
}
|
55
55
|
|
56
56
|
calendar { # alias for date_time(:calendar)
|
57
|
-
date_time
|
57
|
+
date_time <=> [person, :date_of_birth]
|
58
58
|
}
|
59
59
|
}.open
|
60
60
|
end
|
@@ -54,12 +54,12 @@ class HelloGroup
|
|
54
54
|
|
55
55
|
radio {
|
56
56
|
text 'Male'
|
57
|
-
selection
|
57
|
+
selection <=> [person, :male]
|
58
58
|
}
|
59
59
|
|
60
60
|
radio {
|
61
61
|
text 'Female'
|
62
|
-
selection
|
62
|
+
selection <=> [person, :female]
|
63
63
|
}
|
64
64
|
}
|
65
65
|
|
@@ -71,22 +71,22 @@ class HelloGroup
|
|
71
71
|
|
72
72
|
radio {
|
73
73
|
text 'Child'
|
74
|
-
selection
|
74
|
+
selection <=> [person, :child]
|
75
75
|
}
|
76
76
|
|
77
77
|
radio {
|
78
78
|
text 'Teen'
|
79
|
-
selection
|
79
|
+
selection <=> [person, :teen]
|
80
80
|
}
|
81
81
|
|
82
82
|
radio {
|
83
83
|
text 'Adult'
|
84
|
-
selection
|
84
|
+
selection <=> [person, :adult]
|
85
85
|
}
|
86
86
|
|
87
87
|
radio {
|
88
88
|
text 'Senior'
|
89
|
-
selection
|
89
|
+
selection <=> [person, :senior]
|
90
90
|
}
|
91
91
|
}
|
92
92
|
|
@@ -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
|
61
|
+
selection <=> [@person, :male]
|
60
62
|
}
|
61
63
|
|
62
64
|
radio {
|
63
65
|
text 'Female'
|
64
|
-
selection
|
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
|
80
|
+
selection <=> [@person, :child]
|
79
81
|
}
|
80
82
|
|
81
83
|
radio {
|
82
84
|
text 'Teen'
|
83
|
-
selection
|
85
|
+
selection <=> [@person, :teen]
|
84
86
|
}
|
85
87
|
|
86
88
|
radio {
|
87
89
|
text 'Adult'
|
88
|
-
selection
|
90
|
+
selection <=> [@person, :adult]
|
89
91
|
}
|
90
92
|
|
91
93
|
radio {
|
92
94
|
text 'Senior'
|
93
|
-
selection
|
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
|