glimmer-dsl-swt 4.20.0.5 → 4.20.4.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 +23 -0
- data/README.md +13 -7
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +5 -2
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer-dsl-swt.rb +1 -0
- data/lib/glimmer/data_binding/table_items_binding.rb +2 -2
- data/lib/glimmer/data_binding/tree_items_binding.rb +2 -2
- data/lib/glimmer/dsl/swt/bind_expression.rb +5 -25
- data/lib/glimmer/dsl/swt/custom_widget_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/radio_group_selection_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/swt/shine_data_binding_expression.rb +6 -5
- data/lib/glimmer/dsl/swt/table_items_data_binding_expression.rb +2 -2
- data/lib/glimmer/dsl/swt/tree_items_data_binding_expression.rb +17 -12
- data/lib/glimmer/rake_task/scaffold.rb +2 -2
- data/lib/glimmer/swt/custom/animation.rb +6 -0
- data/lib/glimmer/swt/custom/checkbox_group.rb +1 -1
- data/lib/glimmer/swt/custom/radio_group.rb +2 -1
- data/lib/glimmer/swt/proxy_properties.rb +7 -6
- data/lib/glimmer/swt/table_proxy.rb +15 -8
- data/lib/glimmer/swt/widget_proxy.rb +4 -1
- data/lib/glimmer/ui/custom_shape.rb +1 -1
- data/lib/glimmer/ui/custom_widget.rb +1 -1
- data/samples/elaborate/calculator.rb +1 -1
- data/samples/elaborate/contact_manager.rb +2 -2
- data/samples/elaborate/meta_sample.rb +5 -5
- data/samples/elaborate/tetris.rb +2 -2
- data/samples/elaborate/tetris/view/bevel.rb +11 -11
- data/samples/elaborate/tetris/view/block.rb +1 -1
- data/samples/elaborate/tetris/view/high_score_dialog.rb +4 -4
- data/samples/elaborate/tetris/view/score_lane.rb +3 -3
- data/samples/elaborate/tetris/view/tetris_menu_bar.rb +9 -9
- data/samples/elaborate/timer.rb +8 -8
- data/samples/hello/hello_canvas_animation_data_binding.rb +1 -1
- data/samples/hello/hello_checkbox_group.rb +1 -1
- data/samples/hello/hello_code_text.rb +3 -3
- data/samples/hello/hello_cool_bar.rb +1 -1
- data/samples/hello/hello_cursor.rb +1 -1
- data/samples/hello/hello_custom_shell.rb +1 -1
- data/samples/hello/hello_directory_dialog.rb +1 -1
- data/samples/hello/hello_radio_group.rb +2 -2
- data/samples/hello/hello_table.rb +4 -4
- data/samples/hello/hello_tool_bar.rb +1 -1
- data/samples/hello/hello_tree.rb +11 -11
- metadata +44 -25
- data/lib/glimmer/data_binding/shine.rb +0 -59
@@ -232,9 +232,12 @@ module Glimmer
|
|
232
232
|
def has_attribute?(attribute_name, *args)
|
233
233
|
# TODO test that attribute getter responds too
|
234
234
|
widget_custom_attribute = widget_custom_attribute_mapping[attribute_name.to_s]
|
235
|
+
property_type_converter = property_type_converters[attribute_name.to_s.to_sym]
|
235
236
|
auto_exec do
|
236
237
|
if widget_custom_attribute
|
237
238
|
@swt_widget.respond_to?(widget_custom_attribute[:setter][:name])
|
239
|
+
elsif property_type_converter
|
240
|
+
true
|
238
241
|
else
|
239
242
|
super
|
240
243
|
end
|
@@ -765,7 +768,7 @@ module Glimmer
|
|
765
768
|
|
766
769
|
def can_add_listener?(underscored_listener_name)
|
767
770
|
auto_exec do
|
768
|
-
!self.class.find_listener(@swt_widget.getClass, underscored_listener_name).empty?
|
771
|
+
@swt_widget && !self.class.find_listener(@swt_widget.getClass, underscored_listener_name).empty?
|
769
772
|
end
|
770
773
|
end
|
771
774
|
|
@@ -248,7 +248,7 @@ module Glimmer
|
|
248
248
|
# Otherwise, if a block is passed, it adds it as content to this custom shape
|
249
249
|
def content(&block)
|
250
250
|
if block_given?
|
251
|
-
|
251
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::CustomShapeExpression.new, self.class.keyword, &block)
|
252
252
|
else
|
253
253
|
@content
|
254
254
|
end
|
@@ -296,7 +296,7 @@ module Glimmer
|
|
296
296
|
# Otherwise, if a block is passed, it adds it as content to this custom widget
|
297
297
|
def content(&block)
|
298
298
|
if block_given?
|
299
|
-
|
299
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::SWT::CustomWidgetExpression.new, self.class.keyword, &block)
|
300
300
|
else
|
301
301
|
@content
|
302
302
|
end
|
@@ -45,7 +45,7 @@ class Calculator
|
|
45
45
|
|
46
46
|
# Setting styled_text to multi in order for alignment options to activate
|
47
47
|
styled_text(:multi, :wrap, :border) {
|
48
|
-
text
|
48
|
+
text <= [@presenter, :result]
|
49
49
|
alignment swt(:right)
|
50
50
|
right_margin 5
|
51
51
|
font height: 40
|
@@ -110,7 +110,7 @@ class ContactManager
|
|
110
110
|
}
|
111
111
|
}
|
112
112
|
|
113
|
-
table(:multi) { |table_proxy|
|
113
|
+
table(:editable, :multi) { |table_proxy|
|
114
114
|
layout_data {
|
115
115
|
horizontal_alignment :fill
|
116
116
|
vertical_alignment :fill
|
@@ -132,7 +132,7 @@ class ContactManager
|
|
132
132
|
width 200
|
133
133
|
}
|
134
134
|
|
135
|
-
items
|
135
|
+
items <=> [@contact_manager_presenter, :results, column_properties: [:first_name, :last_name, :email]]
|
136
136
|
|
137
137
|
on_mouse_up { |event|
|
138
138
|
table_proxy.edit_table_item(event.table_item, event.column_index)
|
@@ -226,7 +226,7 @@ class MetaSampleApplication
|
|
226
226
|
row_layout(:vertical) {
|
227
227
|
fill true
|
228
228
|
}
|
229
|
-
selection
|
229
|
+
selection <=> [sample_directory, :selected_sample_name]
|
230
230
|
font height: 20
|
231
231
|
}
|
232
232
|
}
|
@@ -242,7 +242,7 @@ class MetaSampleApplication
|
|
242
242
|
button {
|
243
243
|
text 'Launch'
|
244
244
|
font height: 25
|
245
|
-
enabled
|
245
|
+
enabled <= [SampleDirectory, 'selected_sample.launchable']
|
246
246
|
|
247
247
|
on_widget_selected {
|
248
248
|
begin
|
@@ -255,7 +255,7 @@ class MetaSampleApplication
|
|
255
255
|
button {
|
256
256
|
text 'Reset'
|
257
257
|
font height: 25
|
258
|
-
enabled
|
258
|
+
enabled <= [SampleDirectory, 'selected_sample.editable']
|
259
259
|
|
260
260
|
on_widget_selected {
|
261
261
|
SampleDirectory.selected_sample.reset_code!
|
@@ -277,8 +277,8 @@ class MetaSampleApplication
|
|
277
277
|
line_numbers {
|
278
278
|
background :white
|
279
279
|
}
|
280
|
-
text
|
281
|
-
editable
|
280
|
+
text <=> [SampleDirectory, 'selected_sample.code']
|
281
|
+
editable <= [SampleDirectory, 'selected_sample.editable']
|
282
282
|
left_margin 7
|
283
283
|
right_margin 7
|
284
284
|
}
|
data/samples/elaborate/tetris.rb
CHANGED
@@ -102,14 +102,14 @@ class Tetris
|
|
102
102
|
}
|
103
103
|
|
104
104
|
after_body {
|
105
|
-
|
105
|
+
observe(@game, :game_over) do |game_over|
|
106
106
|
if game_over
|
107
107
|
show_high_score_dialog
|
108
108
|
else
|
109
109
|
start_moving_tetrominos_down
|
110
110
|
end
|
111
111
|
end
|
112
|
-
|
112
|
+
observe(@game, :show_high_scores) do |show_high_scores|
|
113
113
|
if show_high_scores
|
114
114
|
show_high_score_dialog
|
115
115
|
else
|
@@ -35,44 +35,44 @@ class Tetris
|
|
35
35
|
|
36
36
|
body {
|
37
37
|
rectangle(x, y, size, size) {
|
38
|
-
background
|
38
|
+
background <= [self, :base_color]
|
39
39
|
polygon(0, 0, size, 0, size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
|
40
|
-
background
|
40
|
+
background <= [self, :base_color, on_read: ->(color_value) {
|
41
41
|
unless color_value.nil?
|
42
42
|
color = color(color_value)
|
43
43
|
rgb(color.red + 4*BEVEL_CONSTANT, color.green + 4*BEVEL_CONSTANT, color.blue + 4*BEVEL_CONSTANT)
|
44
44
|
end
|
45
|
-
}
|
45
|
+
}]
|
46
46
|
}
|
47
47
|
polygon(size, 0, size - bevel_pixel_size, bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size, size, size) {
|
48
|
-
background
|
48
|
+
background <= [self, :base_color, on_read: ->(color_value) {
|
49
49
|
unless color_value.nil?
|
50
50
|
color = color(color_value)
|
51
51
|
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
52
52
|
end
|
53
|
-
}
|
53
|
+
}]
|
54
54
|
}
|
55
55
|
polygon(size, size, 0, size, bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size, size - bevel_pixel_size) {
|
56
|
-
background
|
56
|
+
background <= [self, :base_color, on_read: ->(color_value) {
|
57
57
|
unless color_value.nil?
|
58
58
|
color = color(color_value)
|
59
59
|
rgb(color.red - 2*BEVEL_CONSTANT, color.green - 2*BEVEL_CONSTANT, color.blue - 2*BEVEL_CONSTANT)
|
60
60
|
end
|
61
|
-
}
|
61
|
+
}]
|
62
62
|
}
|
63
63
|
polygon(0, 0, 0, size, bevel_pixel_size, size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size) {
|
64
|
-
background
|
64
|
+
background <= [self, :base_color, on_read: ->(color_value) {
|
65
65
|
unless color_value.nil?
|
66
66
|
color = color(color_value)
|
67
67
|
rgb(color.red - BEVEL_CONSTANT, color.green - BEVEL_CONSTANT, color.blue - BEVEL_CONSTANT)
|
68
68
|
end
|
69
|
-
}
|
69
|
+
}]
|
70
70
|
}
|
71
71
|
rectangle(0, 0, size, size) {
|
72
|
-
foreground
|
72
|
+
foreground <= [self, :base_color, on_read: ->(color_value) {
|
73
73
|
# use gray instead of white for the border
|
74
74
|
color_value == Model::Block::COLOR_CLEAR ? :gray : color_value
|
75
|
-
}
|
75
|
+
}]
|
76
76
|
}
|
77
77
|
}
|
78
78
|
}
|
@@ -40,12 +40,12 @@ class Tetris
|
|
40
40
|
type :vertical
|
41
41
|
center true
|
42
42
|
}
|
43
|
-
text 'Tetris'
|
43
|
+
text 'Glimmer Tetris'
|
44
44
|
|
45
45
|
tetris_menu_bar(game: game)
|
46
46
|
|
47
47
|
label(:center) {
|
48
|
-
text
|
48
|
+
text <= [game, :game_over, on_read: ->(game_over) { game_over ? 'Game Over!' : 'High Scores' }]
|
49
49
|
font name: FONT_NAME, height: FONT_TITLE_HEIGHT, style: FONT_TITLE_STYLE
|
50
50
|
}
|
51
51
|
@high_score_table = table {
|
@@ -66,13 +66,13 @@ class Tetris
|
|
66
66
|
text 'Level'
|
67
67
|
}
|
68
68
|
|
69
|
-
items
|
69
|
+
items <=> [game, :high_scores, read_only_sort: true, column_properties: [:name, :score, :lines, :level]]
|
70
70
|
}
|
71
71
|
composite {
|
72
72
|
row_layout :horizontal
|
73
73
|
|
74
74
|
@play_close_button = button {
|
75
|
-
text
|
75
|
+
text <= [game, :game_over, on_read: ->(game_over) { game_over ? 'Play Again?' : 'Close'}]
|
76
76
|
focus true # initial focus
|
77
77
|
|
78
78
|
on_widget_selected {
|
@@ -55,7 +55,7 @@ class Tetris
|
|
55
55
|
font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
|
56
56
|
}
|
57
57
|
label(:center) {
|
58
|
-
text
|
58
|
+
text <= [game, :score]
|
59
59
|
font height: @font_height
|
60
60
|
}
|
61
61
|
|
@@ -66,7 +66,7 @@ class Tetris
|
|
66
66
|
font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
|
67
67
|
}
|
68
68
|
label(:center) {
|
69
|
-
text
|
69
|
+
text <= [game, :lines]
|
70
70
|
font height: @font_height
|
71
71
|
}
|
72
72
|
|
@@ -77,7 +77,7 @@ class Tetris
|
|
77
77
|
font name: @font_name, height: @font_height, style: FONT_TITLE_STYLE
|
78
78
|
}
|
79
79
|
label(:center) {
|
80
|
-
text
|
80
|
+
text <= [game, :level]
|
81
81
|
font height: @font_height
|
82
82
|
}
|
83
83
|
}
|
@@ -35,7 +35,7 @@ class Tetris
|
|
35
35
|
|
36
36
|
menu_item {
|
37
37
|
text '&Start'
|
38
|
-
enabled
|
38
|
+
enabled <= [game, :game_over]
|
39
39
|
accelerator COMMAND_KEY, :s
|
40
40
|
|
41
41
|
on_widget_selected {
|
@@ -45,9 +45,9 @@ class Tetris
|
|
45
45
|
menu_item(:check) {
|
46
46
|
text '&Pause'
|
47
47
|
accelerator COMMAND_KEY, :p
|
48
|
-
enabled
|
49
|
-
enabled
|
50
|
-
selection
|
48
|
+
enabled <= [game, :game_over, on_read: ->(value) { value && !game.show_high_scores }]
|
49
|
+
enabled <= [game, :show_high_scores, on_read: ->(value) { value && !game.game_over }]
|
50
|
+
selection <=> [game, :paused]
|
51
51
|
}
|
52
52
|
menu_item {
|
53
53
|
text '&Restart'
|
@@ -76,7 +76,7 @@ class Tetris
|
|
76
76
|
menu_item(:check) {
|
77
77
|
text '&Show'
|
78
78
|
accelerator COMMAND_KEY, :shift, :h
|
79
|
-
selection
|
79
|
+
selection <=> [game, :show_high_scores]
|
80
80
|
}
|
81
81
|
menu_item {
|
82
82
|
text '&Clear'
|
@@ -94,24 +94,24 @@ class Tetris
|
|
94
94
|
menu_item(:check) {
|
95
95
|
text '&Beeping'
|
96
96
|
accelerator COMMAND_KEY, :b
|
97
|
-
selection
|
97
|
+
selection <=> [game, :beeping]
|
98
98
|
}
|
99
99
|
menu {
|
100
100
|
text 'Up Arrow'
|
101
101
|
menu_item(:radio) {
|
102
102
|
text '&Instant Down'
|
103
103
|
accelerator COMMAND_KEY, :shift, :i
|
104
|
-
selection
|
104
|
+
selection <=> [game, :instant_down_on_up, computed_by: :up_arrow_action]
|
105
105
|
}
|
106
106
|
menu_item(:radio) {
|
107
107
|
text 'Rotate &Right'
|
108
108
|
accelerator COMMAND_KEY, :shift, :r
|
109
|
-
selection
|
109
|
+
selection <=> [game, :rotate_right_on_up, computed_by: :up_arrow_action]
|
110
110
|
}
|
111
111
|
menu_item(:radio) {
|
112
112
|
text 'Rotate &Left'
|
113
113
|
accelerator COMMAND_KEY, :shift, :l
|
114
|
-
selection
|
114
|
+
selection <=> [game, :rotate_left_on_up, computed_by: :up_arrow_action]
|
115
115
|
}
|
116
116
|
}
|
117
117
|
} # end of menu
|
data/samples/elaborate/timer.rb
CHANGED
@@ -84,7 +84,7 @@ class Timer
|
|
84
84
|
menu_item {
|
85
85
|
text '&Start'
|
86
86
|
accelerator COMMAND_KEY, 's'
|
87
|
-
enabled
|
87
|
+
enabled <= [self, :countdown, on_read: :!]
|
88
88
|
|
89
89
|
on_widget_selected {
|
90
90
|
start_countdown
|
@@ -92,7 +92,7 @@ class Timer
|
|
92
92
|
}
|
93
93
|
menu_item {
|
94
94
|
text 'St&op'
|
95
|
-
enabled
|
95
|
+
enabled <= [self, :countdown]
|
96
96
|
accelerator COMMAND_KEY, 'o'
|
97
97
|
|
98
98
|
on_widget_selected {
|
@@ -148,8 +148,8 @@ class Timer
|
|
148
148
|
text_limit 2
|
149
149
|
digits 0
|
150
150
|
maximum 59
|
151
|
-
selection
|
152
|
-
enabled
|
151
|
+
selection <=> [self, :min]
|
152
|
+
enabled <= [self, :countdown, on_read: :!]
|
153
153
|
on_widget_default_selected {
|
154
154
|
start_countdown
|
155
155
|
}
|
@@ -162,8 +162,8 @@ class Timer
|
|
162
162
|
text_limit 2
|
163
163
|
digits 0
|
164
164
|
maximum 59
|
165
|
-
selection
|
166
|
-
enabled
|
165
|
+
selection <=> [self, :sec]
|
166
|
+
enabled <= [self, :countdown, on_read: :!]
|
167
167
|
on_widget_default_selected {
|
168
168
|
start_countdown
|
169
169
|
}
|
@@ -179,7 +179,7 @@ class Timer
|
|
179
179
|
}
|
180
180
|
@start_button = button {
|
181
181
|
text '&Start'
|
182
|
-
enabled
|
182
|
+
enabled <= [self, :countdown, on_read: :!]
|
183
183
|
on_widget_selected {
|
184
184
|
start_countdown
|
185
185
|
}
|
@@ -189,7 +189,7 @@ class Timer
|
|
189
189
|
}
|
190
190
|
@stop_button = button {
|
191
191
|
text 'St&op'
|
192
|
-
enabled
|
192
|
+
enabled <= [self, :countdown]
|
193
193
|
on_widget_selected {
|
194
194
|
stop_countdown
|
195
195
|
}
|
@@ -49,7 +49,7 @@ class HelloAnimationDataBinding
|
|
49
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
|
-
every
|
52
|
+
every <= [self, :delay_time]
|
53
53
|
|
54
54
|
frame { |index|
|
55
55
|
background rgb(index%100, index%100 + 100, index%55 + 200)
|
@@ -85,7 +85,7 @@ class HelloCodeText
|
|
85
85
|
fill_layout
|
86
86
|
text 'Ruby (glimmer theme)'
|
87
87
|
code_text(language: 'ruby', theme: 'glimmer', lines: true) {
|
88
|
-
text
|
88
|
+
text <=> [self, :ruby_code]
|
89
89
|
}
|
90
90
|
}
|
91
91
|
tab_item {
|
@@ -101,14 +101,14 @@ class HelloCodeText
|
|
101
101
|
line_numbers {
|
102
102
|
background :white
|
103
103
|
}
|
104
|
-
text
|
104
|
+
text <=> [self, :js_code]
|
105
105
|
}
|
106
106
|
}
|
107
107
|
tab_item {
|
108
108
|
fill_layout
|
109
109
|
text 'HTML (github theme)'
|
110
110
|
code_text(language: 'html', theme: 'github') { # default is lines: false
|
111
|
-
text
|
111
|
+
text <=> [self, :html_code]
|
112
112
|
}
|
113
113
|
}
|
114
114
|
}
|
@@ -138,7 +138,7 @@ class HelloCustomShell
|
|
138
138
|
width 360
|
139
139
|
}
|
140
140
|
|
141
|
-
items
|
141
|
+
items <=> [@email_system, :emails, column_properties: [:date, :subject, :from]]
|
142
142
|
|
143
143
|
on_mouse_up { |event|
|
144
144
|
email = event.table_item.get_data
|