glimmer-dsl-swt 4.19.0.2 → 4.20.0.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 +7 -0
- data/README.md +14 -19
- data/RUBY_VERSION +1 -1
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +33 -8
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/data_binding/shine.rb +41 -26
- data/lib/glimmer/dsl/swt/dsl.rb +2 -1
- data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +49 -0
- data/lib/glimmer/launcher.rb +6 -0
- data/lib/glimmer/swt/custom/code_text.rb +13 -9
- data/samples/elaborate/contact_manager.rb +7 -5
- data/samples/elaborate/login.rb +7 -7
- data/samples/elaborate/mandelbrot_fractal.rb +2 -2
- data/samples/elaborate/metronome.rb +3 -3
- data/samples/elaborate/tic_tac_toe.rb +2 -2
- data/samples/hello/hello_button.rb +1 -1
- data/samples/hello/hello_c_combo.rb +2 -1
- data/samples/hello/hello_c_tab.rb +1 -0
- data/samples/hello/hello_canvas.rb +5 -5
- data/samples/hello/hello_canvas_animation_data_binding.rb +1 -1
- data/samples/hello/hello_canvas_data_binding.rb +16 -16
- data/samples/hello/hello_checkbox.rb +4 -4
- data/samples/hello/hello_code_text.rb +3 -57
- data/samples/hello/hello_color_dialog.rb +1 -1
- data/samples/hello/hello_combo.rb +1 -1
- data/samples/hello/hello_computed.rb +5 -5
- data/samples/hello/hello_custom_widget.rb +1 -1
- data/samples/hello/hello_date_time.rb +4 -4
- data/samples/hello/hello_dialog.rb +3 -2
- data/samples/hello/hello_drag_and_drop.rb +1 -1
- data/samples/hello/hello_file_dialog.rb +1 -1
- data/samples/hello/hello_font_dialog.rb +3 -3
- data/samples/hello/hello_group.rb +6 -6
- data/samples/hello/hello_link.rb +56 -50
- data/samples/hello/hello_list_multi_selection.rb +1 -1
- data/samples/hello/hello_list_single_selection.rb +1 -1
- data/samples/hello/hello_progress_bar.rb +10 -10
- data/samples/hello/hello_radio.rb +6 -6
- data/samples/hello/hello_sash_form.rb +4 -4
- data/samples/hello/hello_spinner.rb +6 -2
- data/samples/hello/hello_styled_text.rb +11 -11
- data/vendor/swt/linux/swt.jar +0 -0
- data/vendor/swt/linux_aarch64/swt.jar +0 -0
- data/vendor/swt/mac/swt.jar +0 -0
- data/vendor/swt/mac_aarch64/swt.jar +0 -0
- data/vendor/swt/windows/swt.jar +0 -0
- metadata +6 -3
data/samples/elaborate/login.rb
CHANGED
@@ -82,8 +82,8 @@ class Login
|
|
82
82
|
|
83
83
|
label { text "Username:" } # goes in column 1
|
84
84
|
@user_name_text = text { # goes in column 2
|
85
|
-
text
|
86
|
-
enabled
|
85
|
+
text <=> [@presenter, :user_name]
|
86
|
+
enabled <= [@presenter, :logged_out]
|
87
87
|
on_key_pressed { |event|
|
88
88
|
@password_text.set_focus if event.keyCode == swt(:cr)
|
89
89
|
}
|
@@ -91,19 +91,19 @@ class Login
|
|
91
91
|
|
92
92
|
label { text "Password:" }
|
93
93
|
@password_text = text(:password, :border) {
|
94
|
-
text
|
95
|
-
enabled
|
94
|
+
text <=> [@presenter, :password]
|
95
|
+
enabled <= [@presenter, :logged_out]
|
96
96
|
on_key_pressed { |event|
|
97
97
|
@presenter.login! if event.keyCode == swt(:cr)
|
98
98
|
}
|
99
99
|
}
|
100
100
|
|
101
101
|
label { text "Status:" }
|
102
|
-
label { text
|
102
|
+
label { text <= [@presenter, :status] }
|
103
103
|
|
104
104
|
button {
|
105
105
|
text "Login"
|
106
|
-
enabled
|
106
|
+
enabled <= [@presenter, :logged_out]
|
107
107
|
on_widget_selected { @presenter.login! }
|
108
108
|
on_key_pressed { |event|
|
109
109
|
@presenter.login! if event.keyCode == swt(:cr)
|
@@ -112,7 +112,7 @@ class Login
|
|
112
112
|
|
113
113
|
button {
|
114
114
|
text "Logout"
|
115
|
-
enabled
|
115
|
+
enabled <= [@presenter, :logged_in]
|
116
116
|
on_widget_selected { @presenter.logout! }
|
117
117
|
on_key_pressed { |event|
|
118
118
|
if event.keyCode == swt(:cr)
|
@@ -180,7 +180,7 @@ class MandelbrotFractal
|
|
180
180
|
body {
|
181
181
|
shell(:no_resize) {
|
182
182
|
grid_layout
|
183
|
-
text
|
183
|
+
text <= [self, :mandelbrot_shell_title]
|
184
184
|
minimum_size mandelbrot.width + 29, mandelbrot.height + 77
|
185
185
|
image @mandelbrot_image
|
186
186
|
|
@@ -194,7 +194,7 @@ class MandelbrotFractal
|
|
194
194
|
|
195
195
|
minimum 0
|
196
196
|
maximum Mandelbrot::PROGRESS_MAX
|
197
|
-
selection
|
197
|
+
selection <= [Mandelbrot, :progress]
|
198
198
|
}
|
199
199
|
|
200
200
|
@scrolled_composite = scrolled_composite {
|
@@ -83,7 +83,7 @@ class Metronome
|
|
83
83
|
spinner {
|
84
84
|
minimum 1
|
85
85
|
maximum 64
|
86
|
-
selection
|
86
|
+
selection <=> [self, 'rhythm.beat_count', after_write: ->(v) {restart_metronome}]
|
87
87
|
font height: 30
|
88
88
|
}
|
89
89
|
|
@@ -95,7 +95,7 @@ class Metronome
|
|
95
95
|
spinner {
|
96
96
|
minimum 30
|
97
97
|
maximum 1000
|
98
|
-
selection
|
98
|
+
selection <=> [self, 'rhythm.bpm']
|
99
99
|
font height: 30
|
100
100
|
}
|
101
101
|
|
@@ -122,7 +122,7 @@ class Metronome
|
|
122
122
|
height_hint 50
|
123
123
|
}
|
124
124
|
rectangle(0, 0, :default, :default, 36, 36) {
|
125
|
-
background
|
125
|
+
background <= [self, "rhythm.beats[#{n}].on", on_read: ->(on) { on ? :red : :yellow}]
|
126
126
|
}
|
127
127
|
}
|
128
128
|
}
|
@@ -47,8 +47,8 @@ class TicTacToe
|
|
47
47
|
(1..3).each { |column|
|
48
48
|
button {
|
49
49
|
layout_data :fill, :fill, true, true
|
50
|
-
text
|
51
|
-
enabled
|
50
|
+
text <= [@tic_tac_toe_board[row, column], :sign]
|
51
|
+
enabled <= [@tic_tac_toe_board[row, column], :empty]
|
52
52
|
font style: :bold, height: 20
|
53
53
|
on_widget_selected {
|
54
54
|
@tic_tac_toe_board.mark(row, column)
|
@@ -21,6 +21,7 @@
|
|
21
21
|
|
22
22
|
require 'glimmer-dsl-swt'
|
23
23
|
|
24
|
+
# This is a sample for the c_combo widget, a more customizable version of combo
|
24
25
|
class HelloCCombo
|
25
26
|
class Person
|
26
27
|
attr_accessor :country, :country_options
|
@@ -50,7 +51,7 @@ class HelloCCombo
|
|
50
51
|
text 'Hello, C Combo!'
|
51
52
|
|
52
53
|
c_combo(:read_only) {
|
53
|
-
selection
|
54
|
+
selection <=> [@person, :country] # also binds to country_options by convention
|
54
55
|
font height: 45 # unlike `combo`, `c_combo` changes height when setting the font height
|
55
56
|
}
|
56
57
|
|
@@ -59,7 +59,7 @@ class HelloCanvas
|
|
59
59
|
rectangle([:default, -70], :default, :default, [:default, 1]) {
|
60
60
|
foreground :cyan
|
61
61
|
text {
|
62
|
-
string
|
62
|
+
string <=> [self, :artist]
|
63
63
|
x :default, 1 # add 1 pixel to default x (shape centered within parent horizontally)
|
64
64
|
y :default, 1 # add 1 pixel to default y (shape centered within parent vertically)
|
65
65
|
background :yellow
|
@@ -105,7 +105,7 @@ class HelloCanvas
|
|
105
105
|
menu {
|
106
106
|
menu_item {
|
107
107
|
text 'Change Background Color...'
|
108
|
-
enabled
|
108
|
+
enabled <=> [self, :selected_shape, on_read: ->(shape) { shape.respond_to?(:background) && shape.background }]
|
109
109
|
on_widget_selected {
|
110
110
|
@selected_shape&.background = color_dialog.open
|
111
111
|
self.selected_shape = nil
|
@@ -113,7 +113,7 @@ class HelloCanvas
|
|
113
113
|
}
|
114
114
|
menu_item {
|
115
115
|
text 'Change Background Pattern Color 1...'
|
116
|
-
enabled
|
116
|
+
enabled <=> [self, :selected_shape, on_read: ->(shape) { shape.respond_to?(:background_pattern) && shape.background_pattern }]
|
117
117
|
on_widget_selected {
|
118
118
|
if @selected_shape
|
119
119
|
background_pattern_args = @selected_shape.background_pattern_args
|
@@ -125,7 +125,7 @@ class HelloCanvas
|
|
125
125
|
}
|
126
126
|
menu_item {
|
127
127
|
text 'Change Background Pattern Color 2...'
|
128
|
-
enabled
|
128
|
+
enabled <=> [self, :selected_shape, on_read: ->(shape) { shape.respond_to?(:background_pattern) && shape.background_pattern }]
|
129
129
|
on_widget_selected {
|
130
130
|
if @selected_shape
|
131
131
|
background_pattern_args = @selected_shape.background_pattern_args
|
@@ -138,7 +138,7 @@ class HelloCanvas
|
|
138
138
|
menu_item(:separator)
|
139
139
|
menu_item {
|
140
140
|
text 'Change Foreground Color...'
|
141
|
-
enabled
|
141
|
+
enabled <=> [self, :selected_shape, on_read: ->(shape) { shape.respond_to?(:foreground) && shape.foreground }]
|
142
142
|
on_widget_selected {
|
143
143
|
@selected_shape&.foreground = color_dialog.open
|
144
144
|
self.selected_shape = nil
|
@@ -46,7 +46,7 @@ class HelloAnimationDataBinding
|
|
46
46
|
digits 3
|
47
47
|
minimum 1
|
48
48
|
maximum 100
|
49
|
-
selection
|
49
|
+
selection <=> [self, :delay_time, on_read: ->(v) {(BigDecimal(v.to_s)*1000).to_f}, on_write: ->(v) {(BigDecimal(v.to_s)/1000).to_f}]
|
50
50
|
}
|
51
51
|
animation {
|
52
52
|
every bind(self, :delay_time)
|
@@ -81,7 +81,7 @@ class HelloCanvasDataBinding
|
|
81
81
|
}
|
82
82
|
maximum CANVAS_WIDTH
|
83
83
|
increment 3
|
84
|
-
selection
|
84
|
+
selection <=> [self, :x1_value]
|
85
85
|
}
|
86
86
|
spinner {
|
87
87
|
layout_data(:fill, :center, false, false) {
|
@@ -89,7 +89,7 @@ class HelloCanvasDataBinding
|
|
89
89
|
}
|
90
90
|
maximum CANVAS_HEIGHT
|
91
91
|
increment 3
|
92
|
-
selection
|
92
|
+
selection <=> [self, :y1_value]
|
93
93
|
}
|
94
94
|
label {
|
95
95
|
layout_data(:fill, :center, false, false) {
|
@@ -109,7 +109,7 @@ class HelloCanvasDataBinding
|
|
109
109
|
}
|
110
110
|
maximum CANVAS_WIDTH
|
111
111
|
increment 3
|
112
|
-
selection
|
112
|
+
selection <=> [self, :x2_value]
|
113
113
|
}
|
114
114
|
spinner {
|
115
115
|
layout_data(:fill, :center, false, false) {
|
@@ -117,7 +117,7 @@ class HelloCanvasDataBinding
|
|
117
117
|
}
|
118
118
|
maximum CANVAS_HEIGHT
|
119
119
|
increment 3
|
120
|
-
selection
|
120
|
+
selection <=> [self, :y2_value]
|
121
121
|
}
|
122
122
|
label {
|
123
123
|
layout_data(:fill, :center, false, false) {
|
@@ -143,7 +143,7 @@ class HelloCanvasDataBinding
|
|
143
143
|
}
|
144
144
|
maximum 255
|
145
145
|
increment 10
|
146
|
-
selection
|
146
|
+
selection <=> [self, :foreground_red]
|
147
147
|
}
|
148
148
|
spinner {
|
149
149
|
layout_data(:fill, :center, false, false) {
|
@@ -151,7 +151,7 @@ class HelloCanvasDataBinding
|
|
151
151
|
}
|
152
152
|
maximum 255
|
153
153
|
increment 10
|
154
|
-
selection
|
154
|
+
selection <=> [self, :foreground_green]
|
155
155
|
}
|
156
156
|
spinner {
|
157
157
|
layout_data(:fill, :center, false, false) {
|
@@ -159,7 +159,7 @@ class HelloCanvasDataBinding
|
|
159
159
|
}
|
160
160
|
maximum 255
|
161
161
|
increment 10
|
162
|
-
selection
|
162
|
+
selection <=> [self, :foreground_blue]
|
163
163
|
}
|
164
164
|
label {
|
165
165
|
layout_data(:fill, :center, false, false) {
|
@@ -178,13 +178,13 @@ class HelloCanvasDataBinding
|
|
178
178
|
horizontal_span 3
|
179
179
|
}
|
180
180
|
maximum 255
|
181
|
-
selection
|
181
|
+
selection <=> [self, :line_width_value]
|
182
182
|
}
|
183
183
|
combo(:read_only) {
|
184
184
|
layout_data(:fill, :center, false, false) {
|
185
185
|
horizontal_span 3
|
186
186
|
}
|
187
|
-
selection
|
187
|
+
selection <=> [self, :line_style_value]
|
188
188
|
}
|
189
189
|
canvas {
|
190
190
|
layout_data(:center, :center, false, false) {
|
@@ -195,13 +195,13 @@ class HelloCanvasDataBinding
|
|
195
195
|
background :white
|
196
196
|
|
197
197
|
line {
|
198
|
-
x1
|
199
|
-
y1
|
200
|
-
x2
|
201
|
-
y2
|
202
|
-
foreground
|
203
|
-
line_width
|
204
|
-
line_style
|
198
|
+
x1 <=> [self, :x1_value]
|
199
|
+
y1 <=> [self, :y1_value]
|
200
|
+
x2 <=> [self, :x2_value]
|
201
|
+
y2 <=> [self, :y2_value]
|
202
|
+
foreground <=> [self, :foreground_value, computed_by: [:foreground_red, :foreground_green, :foreground_blue]]
|
203
|
+
line_width <=> [self, :line_width_value]
|
204
|
+
line_style <=> [self, :line_style_value]
|
205
205
|
}
|
206
206
|
}
|
207
207
|
}
|
@@ -56,22 +56,22 @@ class HelloCheckbox
|
|
56
56
|
composite {
|
57
57
|
checkbox {
|
58
58
|
text 'Skiing'
|
59
|
-
selection
|
59
|
+
selection <=> [@person, :skiing]
|
60
60
|
}
|
61
61
|
|
62
62
|
checkbox {
|
63
63
|
text 'Snowboarding'
|
64
|
-
selection
|
64
|
+
selection <=> [@person, :snowboarding]
|
65
65
|
}
|
66
66
|
|
67
67
|
checkbox {
|
68
68
|
text 'Snowmobiling'
|
69
|
-
selection
|
69
|
+
selection <=> [@person, :snowmobiling]
|
70
70
|
}
|
71
71
|
|
72
72
|
checkbox {
|
73
73
|
text 'Snowshoeing'
|
74
|
-
selection
|
74
|
+
selection <=> [@person, :snowshoeing]
|
75
75
|
}
|
76
76
|
}
|
77
77
|
|
@@ -83,47 +83,14 @@ class HelloCodeText
|
|
83
83
|
tab_folder {
|
84
84
|
tab_item {
|
85
85
|
fill_layout
|
86
|
-
text 'Ruby (glimmer)'
|
86
|
+
text 'Ruby (glimmer theme)'
|
87
87
|
code_text(language: 'ruby', theme: 'glimmer', lines: true) {
|
88
88
|
text bind(self, :ruby_code)
|
89
89
|
}
|
90
90
|
}
|
91
91
|
tab_item {
|
92
92
|
fill_layout
|
93
|
-
text '
|
94
|
-
code_text(language: 'ruby', theme: 'pastie', lines: {width: 2}) {
|
95
|
-
text bind(self, :ruby_code)
|
96
|
-
}
|
97
|
-
}
|
98
|
-
tab_item {
|
99
|
-
fill_layout
|
100
|
-
text 'Ruby (github)'
|
101
|
-
code_text(language: 'ruby', theme: 'github', lines: false) {
|
102
|
-
text bind(self, :ruby_code)
|
103
|
-
}
|
104
|
-
}
|
105
|
-
tab_item {
|
106
|
-
fill_layout
|
107
|
-
text 'JavaScript (glimmer)'
|
108
|
-
# No border (SWT styles are passed explicitly)
|
109
|
-
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'glimmer', lines: true) {
|
110
|
-
# With lines, the custom widget has a root composite, which can be configured separately
|
111
|
-
root {
|
112
|
-
grid_layout(2, false) {
|
113
|
-
margin_width 2
|
114
|
-
}
|
115
|
-
background :white
|
116
|
-
}
|
117
|
-
# With lines, the line numbers widget can be configured separately
|
118
|
-
line_numbers {
|
119
|
-
background :white
|
120
|
-
}
|
121
|
-
text bind(self, :js_code)
|
122
|
-
}
|
123
|
-
}
|
124
|
-
tab_item {
|
125
|
-
fill_layout
|
126
|
-
text 'JavaScript (pastie)'
|
93
|
+
text 'JavaScript (pastie theme)'
|
127
94
|
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'pastie', lines: {width: 2}) {
|
128
95
|
root {
|
129
96
|
grid_layout(2, false) {
|
@@ -139,28 +106,7 @@ class HelloCodeText
|
|
139
106
|
}
|
140
107
|
tab_item {
|
141
108
|
fill_layout
|
142
|
-
text '
|
143
|
-
code_text(:multi, :h_scroll, :v_scroll, language: 'javascript', theme: 'github') { # default is lines: false
|
144
|
-
text bind(self, :js_code)
|
145
|
-
}
|
146
|
-
}
|
147
|
-
tab_item {
|
148
|
-
fill_layout
|
149
|
-
text 'HTML (glimmer)'
|
150
|
-
code_text(language: 'html', theme: 'glimmer', lines: true) {
|
151
|
-
text bind(self, :html_code)
|
152
|
-
}
|
153
|
-
}
|
154
|
-
tab_item {
|
155
|
-
fill_layout
|
156
|
-
text 'HTML (pastie)'
|
157
|
-
code_text(language: 'html', theme: 'pastie', lines: {width: 2}) {
|
158
|
-
text bind(self, :html_code)
|
159
|
-
}
|
160
|
-
}
|
161
|
-
tab_item {
|
162
|
-
fill_layout
|
163
|
-
text 'HTML (github)'
|
109
|
+
text 'HTML (github theme)'
|
164
110
|
code_text(language: 'html', theme: 'github') { # default is lines: false
|
165
111
|
text bind(self, :html_code)
|
166
112
|
}
|
@@ -48,7 +48,7 @@ class HelloComputed
|
|
48
48
|
|
49
49
|
label {text 'First &Name: '}
|
50
50
|
text {
|
51
|
-
text
|
51
|
+
text <=> [@contact, :first_name]
|
52
52
|
layout_data {
|
53
53
|
horizontal_alignment :fill
|
54
54
|
grab_excess_horizontal_space true
|
@@ -57,7 +57,7 @@ class HelloComputed
|
|
57
57
|
|
58
58
|
label {text '&Last Name: '}
|
59
59
|
text {
|
60
|
-
text
|
60
|
+
text <=> [@contact, :last_name]
|
61
61
|
layout_data {
|
62
62
|
horizontal_alignment :fill
|
63
63
|
grab_excess_horizontal_space true
|
@@ -66,7 +66,7 @@ class HelloComputed
|
|
66
66
|
|
67
67
|
label {text '&Year of Birth: '}
|
68
68
|
text {
|
69
|
-
text
|
69
|
+
text <=> [@contact, :year_of_birth]
|
70
70
|
layout_data {
|
71
71
|
horizontal_alignment :fill
|
72
72
|
grab_excess_horizontal_space true
|
@@ -75,7 +75,7 @@ class HelloComputed
|
|
75
75
|
|
76
76
|
label {text 'Name: '}
|
77
77
|
label {
|
78
|
-
text
|
78
|
+
text <= [@contact, :name, computed_by: [:first_name, :last_name]]
|
79
79
|
layout_data {
|
80
80
|
horizontal_alignment :fill
|
81
81
|
grab_excess_horizontal_space true
|
@@ -84,7 +84,7 @@ class HelloComputed
|
|
84
84
|
|
85
85
|
label {text 'Age: '}
|
86
86
|
label {
|
87
|
-
text
|
87
|
+
text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
88
88
|
layout_data {
|
89
89
|
horizontal_alignment :fill
|
90
90
|
grab_excess_horizontal_space true
|