glimmer-dsl-swt 4.20.0.4 → 4.20.3.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 +30 -0
- data/README.md +13 -7
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +5 -2
- data/docs/reference/GLIMMER_SAMPLES.md +13 -0
- data/docs/reference/GLIMMER_STYLE_GUIDE.md +4 -3
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/data_binding/shine.rb +2 -1
- 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/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/dsl/swt/widget_listener_expression.rb +3 -3
- 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/display_proxy.rb +11 -8
- 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 +5 -2
- data/lib/glimmer/ui/custom_shape.rb +1 -1
- data/lib/glimmer/ui/custom_shell.rb +3 -3
- data/lib/glimmer/ui/custom_widget.rb +6 -3
- data/samples/elaborate/calculator.rb +116 -0
- data/samples/elaborate/calculator/model/command.rb +105 -0
- data/samples/elaborate/calculator/model/command/all_clear.rb +17 -0
- data/samples/elaborate/calculator/model/command/command_history.rb +0 -0
- data/samples/elaborate/calculator/model/command/equals.rb +18 -0
- data/samples/elaborate/calculator/model/command/number.rb +20 -0
- data/samples/elaborate/calculator/model/command/operation.rb +27 -0
- data/samples/elaborate/calculator/model/command/operation/add.rb +15 -0
- data/samples/elaborate/calculator/model/command/operation/divide.rb +15 -0
- data/samples/elaborate/calculator/model/command/operation/multiply.rb +15 -0
- data/samples/elaborate/calculator/model/command/operation/subtract.rb +15 -0
- data/samples/elaborate/calculator/model/command/point.rb +20 -0
- data/samples/elaborate/calculator/model/presenter.rb +30 -0
- data/samples/elaborate/contact_manager.rb +2 -2
- data/samples/elaborate/meta_sample.rb +5 -5
- data/samples/elaborate/tetris.rb +6 -6
- 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 +233 -0
- data/samples/elaborate/timer/alarm1.wav +0 -0
- data/samples/elaborate/timer/sounds/alarm1.wav +0 -0
- data/samples/elaborate/user_profile.rb +4 -2
- data/samples/elaborate/weather.rb +1 -1
- 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 +5 -5
- 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_text.rb +120 -0
- data/samples/hello/hello_tool_bar.rb +5 -5
- data/samples/hello/hello_tree.rb +11 -11
- metadata +19 -2
Binary file
|
Binary file
|
@@ -23,7 +23,9 @@ require 'glimmer-dsl-swt'
|
|
23
23
|
|
24
24
|
include Glimmer
|
25
25
|
|
26
|
-
|
26
|
+
# A version of this was featured in a dzone article as an intro to Glimmer syntax:
|
27
|
+
# https://dzone.com/articles/an-introduction-glimmer
|
28
|
+
shell { |shell_proxy|
|
27
29
|
text "User Profile"
|
28
30
|
|
29
31
|
composite {
|
@@ -72,7 +74,7 @@ shell {
|
|
72
74
|
button {
|
73
75
|
text "close"
|
74
76
|
layout_data :left, :center, true, true
|
75
|
-
on_widget_selected {
|
77
|
+
on_widget_selected { shell_proxy.close }
|
76
78
|
}
|
77
79
|
}
|
78
80
|
}.open
|
@@ -19,10 +19,10 @@
|
|
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
|
+
require 'glimmer-dsl-swt'
|
22
23
|
require 'net/http'
|
23
24
|
require 'json'
|
24
25
|
require 'facets/string/titlecase'
|
25
|
-
require 'glimmer-dsl-swt'
|
26
26
|
|
27
27
|
class Weather
|
28
28
|
include Glimmer::UI::CustomShell
|
@@ -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
|
}
|
@@ -31,7 +31,7 @@ class HelloCoolBar
|
|
31
31
|
end
|
32
32
|
|
33
33
|
before_body {
|
34
|
-
self.font_size = '
|
34
|
+
self.font_size = '30'
|
35
35
|
}
|
36
36
|
|
37
37
|
body {
|
@@ -73,16 +73,16 @@ class HelloCoolBar
|
|
73
73
|
}
|
74
74
|
# a combo can be nested in a tool_bar (it auto-generates a tool_item for itself behind the scenes)
|
75
75
|
combo {
|
76
|
-
selection
|
76
|
+
selection <=> [self, :font_size]
|
77
77
|
}
|
78
78
|
}
|
79
79
|
}
|
80
80
|
|
81
81
|
|
82
82
|
label {
|
83
|
-
font height:
|
84
|
-
text
|
85
|
-
text
|
83
|
+
font <= [self, :font_size, on_read: ->(size) { {height: size.to_i} }]
|
84
|
+
text <= [self, :operation]
|
85
|
+
text <= [self, :font_size]
|
86
86
|
}
|
87
87
|
}
|
88
88
|
}
|
@@ -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
|
@@ -64,7 +64,7 @@ class HelloRadioGroup
|
|
64
64
|
|
65
65
|
radio_group {
|
66
66
|
row_layout :horizontal
|
67
|
-
selection
|
67
|
+
selection <=> [@person, :gender]
|
68
68
|
}
|
69
69
|
|
70
70
|
label {
|
@@ -74,7 +74,7 @@ class HelloRadioGroup
|
|
74
74
|
|
75
75
|
radio_group {
|
76
76
|
row_layout :horizontal
|
77
|
-
selection
|
77
|
+
selection <=> [@person, :age_group]
|
78
78
|
}
|
79
79
|
|
80
80
|
button {
|
@@ -206,7 +206,7 @@ class HelloTable
|
|
206
206
|
|
207
207
|
combo(:read_only) {
|
208
208
|
layout_data :center, :center, true, false
|
209
|
-
selection
|
209
|
+
selection <=> [BaseballGame, :playoff_type]
|
210
210
|
font height: 14
|
211
211
|
}
|
212
212
|
|
@@ -247,10 +247,10 @@ class HelloTable
|
|
247
247
|
}
|
248
248
|
|
249
249
|
# Data-bind table items (rows) to a model collection property, specifying column properties ordering per nested model
|
250
|
-
items
|
250
|
+
items <=> [BaseballGame, :schedule, column_properties: [:game_date, :game_time, :ballpark, :home_team, :away_team, :promotion]]
|
251
251
|
|
252
252
|
# Data-bind table selection
|
253
|
-
selection
|
253
|
+
selection <=> [BaseballGame, :selected_game]
|
254
254
|
|
255
255
|
# Default initial sort property
|
256
256
|
sort_property :date
|
@@ -273,7 +273,7 @@ class HelloTable
|
|
273
273
|
text 'Book Selected Game'
|
274
274
|
layout_data :center, :center, true, false
|
275
275
|
font height: 14
|
276
|
-
enabled
|
276
|
+
enabled <= [BaseballGame, :selected_game]
|
277
277
|
|
278
278
|
on_widget_selected {
|
279
279
|
book_selected_game
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'glimmer-dsl-swt'
|
2
|
+
|
3
|
+
class HelloText
|
4
|
+
include Glimmer::UI::CustomShell
|
5
|
+
|
6
|
+
attr_accessor :default, :center, :left, :right, :password, :telephone, :read_only, :wrap, :multi
|
7
|
+
|
8
|
+
before_body {
|
9
|
+
self.default = 'default is :border style'
|
10
|
+
self.center = 'centered'
|
11
|
+
self.left = 'left-aligned'
|
12
|
+
self.right = 'right-aligned'
|
13
|
+
self.password = 'password'
|
14
|
+
self.telephone = '555-555-5555'
|
15
|
+
self.read_only = 'Telephone area code is 555'
|
16
|
+
self.wrap = 'wraps if text content is too long like this example'
|
17
|
+
self.multi = "multi-line enables hitting enter,\nbut does not wrap by default"
|
18
|
+
}
|
19
|
+
|
20
|
+
body {
|
21
|
+
shell {
|
22
|
+
grid_layout 2, false
|
23
|
+
|
24
|
+
text 'Hello, Text!'
|
25
|
+
minimum_size 350, 100
|
26
|
+
|
27
|
+
label {
|
28
|
+
text 'text'
|
29
|
+
}
|
30
|
+
text { # includes :border style by default
|
31
|
+
layout_data :fill, :center, true, false
|
32
|
+
text <=> [self, :default]
|
33
|
+
}
|
34
|
+
|
35
|
+
label {
|
36
|
+
text 'text(:center, :border)'
|
37
|
+
}
|
38
|
+
text(:center, :border) {
|
39
|
+
layout_data :fill, :center, true, false
|
40
|
+
text <=> [self, :center]
|
41
|
+
}
|
42
|
+
|
43
|
+
label {
|
44
|
+
text 'text(:left, :border)'
|
45
|
+
}
|
46
|
+
text(:left, :border) {
|
47
|
+
layout_data :fill, :center, true, false
|
48
|
+
text <=> [self, :left]
|
49
|
+
}
|
50
|
+
|
51
|
+
label {
|
52
|
+
text 'text(:right, :border)'
|
53
|
+
}
|
54
|
+
text(:right, :border) {
|
55
|
+
layout_data :fill, :center, true, false
|
56
|
+
text <=> [self, :right]
|
57
|
+
}
|
58
|
+
|
59
|
+
label {
|
60
|
+
text 'text(:password, :border)'
|
61
|
+
}
|
62
|
+
text(:password, :border) {
|
63
|
+
layout_data :fill, :center, true, false
|
64
|
+
text <=> [self, :password]
|
65
|
+
}
|
66
|
+
|
67
|
+
label {
|
68
|
+
text 'text(:read_only, :border)'
|
69
|
+
}
|
70
|
+
text(:read_only, :border) {
|
71
|
+
layout_data :fill, :center, true, false
|
72
|
+
text <=> [self, :read_only]
|
73
|
+
}
|
74
|
+
|
75
|
+
label {
|
76
|
+
text 'text with event handlers'
|
77
|
+
}
|
78
|
+
text {
|
79
|
+
layout_data :fill, :center, true, false
|
80
|
+
text <=> [self, :telephone]
|
81
|
+
|
82
|
+
# this event kicks in just after the user typed and before modifying the text attribute value
|
83
|
+
on_verify_text do |verify_event|
|
84
|
+
new_text = verify_event.widget.text.clone
|
85
|
+
new_text[verify_event.start...verify_event.end] = verify_event.text
|
86
|
+
verify_event.doit = telephone?(new_text)
|
87
|
+
end
|
88
|
+
|
89
|
+
# this event kicks in just after the text widget is verified and modified
|
90
|
+
on_modify_text do |modify_event|
|
91
|
+
self.read_only = "Telephone area code is #{modify_event.widget.text.gsub(/[^0-9]/, '')[0...3]}"
|
92
|
+
end
|
93
|
+
}
|
94
|
+
|
95
|
+
label {
|
96
|
+
text 'text(:wrap, :border)'
|
97
|
+
}
|
98
|
+
text(:wrap, :border) {
|
99
|
+
layout_data(:fill, :center, true, false) {
|
100
|
+
width_hint 100
|
101
|
+
}
|
102
|
+
text <=> [self, :wrap]
|
103
|
+
}
|
104
|
+
|
105
|
+
label {
|
106
|
+
text 'text(:multi, :border)'
|
107
|
+
}
|
108
|
+
text(:multi, :border) {
|
109
|
+
layout_data :fill, :center, true, false
|
110
|
+
text <=> [self, :multi]
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
def telephone?(text)
|
116
|
+
!!text.match(/^\d{0,3}[-.\/]?\d{0,3}[-.\/]?\d{0,4}$/)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
HelloText.launch
|
@@ -31,7 +31,7 @@ class HelloToolBar
|
|
31
31
|
end
|
32
32
|
|
33
33
|
before_body {
|
34
|
-
self.font_size = '
|
34
|
+
self.font_size = '30'
|
35
35
|
}
|
36
36
|
|
37
37
|
body {
|
@@ -71,14 +71,14 @@ class HelloToolBar
|
|
71
71
|
}
|
72
72
|
# a combo can be nested in a tool_bar (it auto-generates a tool_item for itself behind the scenes)
|
73
73
|
combo {
|
74
|
-
selection
|
74
|
+
selection <=> [self, :font_size]
|
75
75
|
}
|
76
76
|
}
|
77
77
|
|
78
78
|
label {
|
79
|
-
font height:
|
80
|
-
text
|
81
|
-
text
|
79
|
+
font <= [self, :font_size, on_read: ->(size) { {height: size.to_i} }]
|
80
|
+
text <= [self, :operation]
|
81
|
+
text <= [self, :font_size]
|
82
82
|
}
|
83
83
|
}
|
84
84
|
}
|
data/samples/hello/hello_tree.rb
CHANGED
@@ -314,8 +314,8 @@ class HelloTree
|
|
314
314
|
margin_height 5
|
315
315
|
}
|
316
316
|
@tree = tree {
|
317
|
-
items
|
318
|
-
selection
|
317
|
+
items <= [Employee, :ceo, tree_properties: {children: :subordinates, text: :to_s}]
|
318
|
+
selection <=> [Employee, :selected_employee]
|
319
319
|
}
|
320
320
|
}
|
321
321
|
|
@@ -329,7 +329,7 @@ class HelloTree
|
|
329
329
|
}
|
330
330
|
text {
|
331
331
|
layout_data(:fill, :center, true, false)
|
332
|
-
text
|
332
|
+
text <=> [Employee, "selected_employee.first_name"]
|
333
333
|
font height: 16
|
334
334
|
}
|
335
335
|
|
@@ -340,7 +340,7 @@ class HelloTree
|
|
340
340
|
}
|
341
341
|
text {
|
342
342
|
layout_data(:fill, :center, true, false)
|
343
|
-
text
|
343
|
+
text <=> [Employee, "selected_employee.last_name"]
|
344
344
|
font height: 16
|
345
345
|
}
|
346
346
|
|
@@ -351,7 +351,7 @@ class HelloTree
|
|
351
351
|
}
|
352
352
|
combo {
|
353
353
|
layout_data(:fill, :center, true, false)
|
354
|
-
selection
|
354
|
+
selection <=> [Employee, "selected_employee.position"]
|
355
355
|
font height: 16
|
356
356
|
}
|
357
357
|
|
@@ -373,7 +373,7 @@ class HelloTree
|
|
373
373
|
spinner {
|
374
374
|
maximum 999_999
|
375
375
|
minimum 0
|
376
|
-
selection
|
376
|
+
selection <=> [Employee, "selected_employee.salary"]
|
377
377
|
font height: 16
|
378
378
|
}
|
379
379
|
}
|
@@ -385,7 +385,7 @@ class HelloTree
|
|
385
385
|
}
|
386
386
|
combo(:read_only) {
|
387
387
|
layout_data(:fill, :center, true, false)
|
388
|
-
selection
|
388
|
+
selection <=> [Employee, "selected_employee.health_insurance"]
|
389
389
|
font height: 16
|
390
390
|
}
|
391
391
|
|
@@ -396,7 +396,7 @@ class HelloTree
|
|
396
396
|
}
|
397
397
|
combo(:read_only) {
|
398
398
|
layout_data(:fill, :center, true, false)
|
399
|
-
selection
|
399
|
+
selection <=> [Employee, "selected_employee.desk_location"]
|
400
400
|
font height: 16
|
401
401
|
}
|
402
402
|
|
@@ -414,7 +414,7 @@ class HelloTree
|
|
414
414
|
spinner {
|
415
415
|
maximum 100
|
416
416
|
minimum 0
|
417
|
-
selection
|
417
|
+
selection <=> [Employee, "selected_employee.sales_bonus_percentage"]
|
418
418
|
font height: 16
|
419
419
|
}
|
420
420
|
label {
|
@@ -441,7 +441,7 @@ class HelloTree
|
|
441
441
|
spinner {
|
442
442
|
maximum 999_999
|
443
443
|
minimum 0
|
444
|
-
selection
|
444
|
+
selection <=> [Employee, "selected_employee.merit_bonus"]
|
445
445
|
font height: 16
|
446
446
|
}
|
447
447
|
}
|
@@ -467,7 +467,7 @@ class HelloTree
|
|
467
467
|
maximum 999_999_00
|
468
468
|
minimum 0
|
469
469
|
increment 100
|
470
|
-
selection
|
470
|
+
selection <=> [Employee, "selected_employee.#{attribute}", on_read: ->(v) {v.to_f * 100}, on_write: ->(v) {v.to_f / 100}]
|
471
471
|
font height: 16
|
472
472
|
}
|
473
473
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-swt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.20.0
|
4
|
+
version: 4.20.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -505,6 +505,19 @@ files:
|
|
505
505
|
- lib/glimmer/ui/custom_shell.rb
|
506
506
|
- lib/glimmer/ui/custom_widget.rb
|
507
507
|
- lib/glimmer/util/proc_tracker.rb
|
508
|
+
- samples/elaborate/calculator.rb
|
509
|
+
- samples/elaborate/calculator/model/command.rb
|
510
|
+
- samples/elaborate/calculator/model/command/all_clear.rb
|
511
|
+
- samples/elaborate/calculator/model/command/command_history.rb
|
512
|
+
- samples/elaborate/calculator/model/command/equals.rb
|
513
|
+
- samples/elaborate/calculator/model/command/number.rb
|
514
|
+
- samples/elaborate/calculator/model/command/operation.rb
|
515
|
+
- samples/elaborate/calculator/model/command/operation/add.rb
|
516
|
+
- samples/elaborate/calculator/model/command/operation/divide.rb
|
517
|
+
- samples/elaborate/calculator/model/command/operation/multiply.rb
|
518
|
+
- samples/elaborate/calculator/model/command/operation/subtract.rb
|
519
|
+
- samples/elaborate/calculator/model/command/point.rb
|
520
|
+
- samples/elaborate/calculator/model/presenter.rb
|
508
521
|
- samples/elaborate/contact_manager.rb
|
509
522
|
- samples/elaborate/contact_manager/contact.rb
|
510
523
|
- samples/elaborate/contact_manager/contact_manager_presenter.rb
|
@@ -528,6 +541,9 @@ files:
|
|
528
541
|
- samples/elaborate/tic_tac_toe.rb
|
529
542
|
- samples/elaborate/tic_tac_toe/board.rb
|
530
543
|
- samples/elaborate/tic_tac_toe/cell.rb
|
544
|
+
- samples/elaborate/timer.rb
|
545
|
+
- samples/elaborate/timer/alarm1.wav
|
546
|
+
- samples/elaborate/timer/sounds/alarm1.wav
|
531
547
|
- samples/elaborate/user_profile.rb
|
532
548
|
- samples/elaborate/weather.rb
|
533
549
|
- samples/hello/hello_browser.rb
|
@@ -588,6 +604,7 @@ files:
|
|
588
604
|
- samples/hello/hello_tab.rb
|
589
605
|
- samples/hello/hello_table.rb
|
590
606
|
- samples/hello/hello_table/baseball_park.png
|
607
|
+
- samples/hello/hello_text.rb
|
591
608
|
- samples/hello/hello_tool_bar.rb
|
592
609
|
- samples/hello/hello_tree.rb
|
593
610
|
- samples/hello/hello_world.rb
|