glimmer-dsl-swt 4.20.2.1 → 4.20.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +6 -6
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_GUI_DSL_SYNTAX.md +5 -2
- data/docs/reference/GLIMMER_SAMPLES.md +23 -0
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer-dsl-swt.rb +1 -0
- data/lib/glimmer/data_binding/table_items_binding.rb +1 -0
- 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 +0 -2
- data/lib/glimmer/rake_task/scaffold.rb +2 -2
- 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 +5 -5
- data/lib/glimmer/swt/widget_proxy.rb +3 -0
- 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 +1 -1
- data/samples/elaborate/meta_sample.rb +5 -5
- 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 +3 -3
- 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 +9 -9
- data/samples/elaborate/weather.rb +8 -4
- data/samples/hello/hello_c_tab.rb +9 -9
- data/samples/hello/hello_checkbox_group.rb +1 -1
- data/samples/hello/hello_code_text.rb +3 -3
- data/samples/hello/hello_computed.rb +20 -2
- data/samples/hello/hello_cool_bar.rb +1 -1
- data/samples/hello/hello_cursor.rb +1 -1
- data/samples/hello/hello_custom_shell.rb +17 -11
- data/samples/hello/hello_directory_dialog.rb +1 -1
- data/samples/hello/hello_label.rb +194 -0
- data/samples/hello/hello_radio_group.rb +2 -2
- data/samples/hello/hello_table.rb +1 -1
- data/samples/hello/hello_tool_bar.rb +1 -1
- data/samples/hello/{hello_c_tab → images}/denmark.png +0 -0
- data/samples/hello/{hello_c_tab → images}/finland.png +0 -0
- data/samples/hello/{hello_c_tab → images}/france.png +0 -0
- data/samples/hello/{hello_c_tab → images}/germany.png +0 -0
- data/samples/hello/{hello_c_tab → images}/italy.png +0 -0
- data/samples/hello/{hello_c_tab → images}/mexico.png +0 -0
- data/samples/hello/{hello_c_tab → images}/netherlands.png +0 -0
- data/samples/hello/{hello_c_tab → images}/norway.png +0 -0
- data/samples/hello/{hello_c_tab → images}/usa.png +0 -0
- metadata +54 -36
- data/lib/glimmer/data_binding/shine.rb +0 -63
- data/samples/elaborate/timer/alarm1.wav +0 -0
- data/samples/hello/hello_computed/contact.rb +0 -42
@@ -45,7 +45,7 @@ class Tetris
|
|
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
@@ -6,7 +6,7 @@ class Timer
|
|
6
6
|
|
7
7
|
import 'javax.sound.sampled'
|
8
8
|
|
9
|
-
FILE_SOUND_ALARM = File.expand_path(File.join('timer', 'alarm1.wav'), __dir__)
|
9
|
+
FILE_SOUND_ALARM = File.expand_path(File.join('timer', 'sounds', 'alarm1.wav'), __dir__)
|
10
10
|
COMMAND_KEY = OS.mac? ? :command : :ctrl
|
11
11
|
|
12
12
|
## Add options like the following to configure CustomShell by outside consumers
|
@@ -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
|
}
|
@@ -29,6 +29,7 @@ class Weather
|
|
29
29
|
|
30
30
|
DEFAULT_FONT_HEIGHT = 30
|
31
31
|
DEFAULT_FOREGROUND = :white
|
32
|
+
DEFAULT_BACKGROUND = rgb(135, 176, 235)
|
32
33
|
|
33
34
|
attr_accessor :city, :temp, :temp_min, :temp_max, :feels_like, :humidity
|
34
35
|
|
@@ -54,7 +55,7 @@ class Weather
|
|
54
55
|
|
55
56
|
text 'Glimmer Weather'
|
56
57
|
minimum_size 400, 300
|
57
|
-
background
|
58
|
+
background DEFAULT_BACKGROUND
|
58
59
|
|
59
60
|
text {
|
60
61
|
layout_data(:center, :center, true, true)
|
@@ -78,7 +79,7 @@ class Weather
|
|
78
79
|
grid_layout 2, false
|
79
80
|
|
80
81
|
text temp_unit
|
81
|
-
background
|
82
|
+
background DEFAULT_BACKGROUND
|
82
83
|
|
83
84
|
rectangle(0, 0, [:default, -2], [:default, -2], 15, 15) {
|
84
85
|
foreground DEFAULT_FOREGROUND
|
@@ -128,8 +129,8 @@ class Weather
|
|
128
129
|
@weather_mutex.synchronize do
|
129
130
|
self.weather_data = JSON.parse(Net::HTTP.get('api.openweathermap.org', "/data/2.5/weather?q=#{city}&appid=1d16d70a9aec3570b5cbd27e6b421330"))
|
130
131
|
end
|
131
|
-
rescue
|
132
|
-
|
132
|
+
rescue => e
|
133
|
+
Glimmer::Config.logger.error "Unable to fetch weather due to error: #{e.full_message}"
|
133
134
|
end
|
134
135
|
|
135
136
|
def weather_data=(data)
|
@@ -148,14 +149,17 @@ class Weather
|
|
148
149
|
end
|
149
150
|
|
150
151
|
def kelvin_to_celsius(kelvin)
|
152
|
+
return nil if kelvin.nil?
|
151
153
|
kelvin - 273.15
|
152
154
|
end
|
153
155
|
|
154
156
|
def celsius_to_fahrenheit(celsius)
|
157
|
+
return nil if celsius.nil?
|
155
158
|
(celsius * 9 / 5 ) + 32
|
156
159
|
end
|
157
160
|
|
158
161
|
def kelvin_to_fahrenheit(kelvin)
|
162
|
+
return nil if kelvin.nil?
|
159
163
|
celsius_to_fahrenheit(kelvin_to_celsius(kelvin))
|
160
164
|
end
|
161
165
|
|
@@ -44,7 +44,7 @@ class HelloCTab
|
|
44
44
|
foreground :blue
|
45
45
|
selection_foreground :dark_blue
|
46
46
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
47
|
-
image File.expand_path('
|
47
|
+
image File.expand_path('images/usa.png', __dir__)
|
48
48
|
|
49
49
|
label {
|
50
50
|
text 'Hello, World!'
|
@@ -58,7 +58,7 @@ class HelloCTab
|
|
58
58
|
foreground :blue
|
59
59
|
selection_foreground :dark_blue
|
60
60
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
61
|
-
image File.expand_path('
|
61
|
+
image File.expand_path('images/france.png', __dir__)
|
62
62
|
|
63
63
|
label {
|
64
64
|
text 'Bonjour, Univers!'
|
@@ -72,7 +72,7 @@ class HelloCTab
|
|
72
72
|
foreground :blue
|
73
73
|
selection_foreground :dark_blue
|
74
74
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
75
|
-
image File.expand_path('
|
75
|
+
image File.expand_path('images/mexico.png', __dir__)
|
76
76
|
|
77
77
|
label {
|
78
78
|
text 'Hola, Mundo!'
|
@@ -86,7 +86,7 @@ class HelloCTab
|
|
86
86
|
foreground :blue
|
87
87
|
selection_foreground :dark_blue
|
88
88
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
89
|
-
image File.expand_path('
|
89
|
+
image File.expand_path('images/germany.png', __dir__)
|
90
90
|
|
91
91
|
label {
|
92
92
|
text 'Hallo, Welt!'
|
@@ -100,7 +100,7 @@ class HelloCTab
|
|
100
100
|
foreground :blue
|
101
101
|
selection_foreground :dark_blue
|
102
102
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
103
|
-
image File.expand_path('
|
103
|
+
image File.expand_path('images/italy.png', __dir__)
|
104
104
|
|
105
105
|
label {
|
106
106
|
text 'Ciao, Mondo!'
|
@@ -114,7 +114,7 @@ class HelloCTab
|
|
114
114
|
foreground :blue
|
115
115
|
selection_foreground :dark_blue
|
116
116
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
117
|
-
image File.expand_path('
|
117
|
+
image File.expand_path('images/netherlands.png', __dir__)
|
118
118
|
|
119
119
|
label {
|
120
120
|
text 'Hallo, Wereld!'
|
@@ -128,7 +128,7 @@ class HelloCTab
|
|
128
128
|
foreground :blue
|
129
129
|
selection_foreground :dark_blue
|
130
130
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
131
|
-
image File.expand_path('
|
131
|
+
image File.expand_path('images/denmark.png', __dir__)
|
132
132
|
|
133
133
|
label {
|
134
134
|
text 'Hej, Verden!'
|
@@ -142,7 +142,7 @@ class HelloCTab
|
|
142
142
|
foreground :blue
|
143
143
|
selection_foreground :dark_blue
|
144
144
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
145
|
-
image File.expand_path('
|
145
|
+
image File.expand_path('images/finland.png', __dir__)
|
146
146
|
|
147
147
|
label {
|
148
148
|
text 'Hei, Maailma!'
|
@@ -156,7 +156,7 @@ class HelloCTab
|
|
156
156
|
foreground :blue
|
157
157
|
selection_foreground :dark_blue
|
158
158
|
font name: 'Times New Roman', height: 30, style: [:bold, :italic]
|
159
|
-
image File.expand_path('
|
159
|
+
image File.expand_path('images/norway.png', __dir__)
|
160
160
|
|
161
161
|
label {
|
162
162
|
text 'Hei, Verden!'
|
@@ -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
|
}
|
@@ -21,9 +21,27 @@
|
|
21
21
|
|
22
22
|
require 'glimmer-dsl-swt'
|
23
23
|
|
24
|
-
require_relative 'hello_computed/contact'
|
25
|
-
|
26
24
|
class HelloComputed
|
25
|
+
class Contact
|
26
|
+
attr_accessor :first_name, :last_name, :year_of_birth
|
27
|
+
|
28
|
+
def initialize(attribute_map)
|
29
|
+
@first_name = attribute_map[:first_name]
|
30
|
+
@last_name = attribute_map[:last_name]
|
31
|
+
@year_of_birth = attribute_map[:year_of_birth]
|
32
|
+
end
|
33
|
+
|
34
|
+
def name
|
35
|
+
"#{last_name}, #{first_name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def age
|
39
|
+
Time.now.year - year_of_birth.to_i
|
40
|
+
rescue
|
41
|
+
0
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
27
45
|
include Glimmer::UI::CustomShell
|
28
46
|
|
29
47
|
before_body {
|
@@ -88,12 +88,10 @@ class EmailShell
|
|
88
88
|
end
|
89
89
|
|
90
90
|
class HelloCustomShell
|
91
|
-
include Glimmer::UI::CustomShell
|
92
|
-
|
93
91
|
Email = Struct.new(:date, :subject, :from, :message, keyword_init: true)
|
94
92
|
EmailSystem = Struct.new(:emails, keyword_init: true)
|
95
93
|
|
96
|
-
|
94
|
+
def initialize
|
97
95
|
@email_system = EmailSystem.new(
|
98
96
|
emails: [
|
99
97
|
Email.new(date: DateTime.new(2029, 10, 22, 11, 3, 0).strftime('%F %I:%M %p'), subject: '3rd Week Report', from: '"Dianne Tux" <dianne.tux@example.com>', message: "Hello,\n\nI was wondering if you'd like to go over the weekly report sometime this afternoon.\n\nDianne"),
|
@@ -104,10 +102,10 @@ class HelloCustomShell
|
|
104
102
|
Email.new(date: DateTime.new(2029, 10, 2, 10, 34, 0).strftime('%F %I:%M %p'), subject: 'Glimmer Upgrade v98.0', from: '"Robert McGabbins" <robert.mcgabbins@example.com>', message: "Team,\n\nWe are upgrading to Glimmer version 98.0.\n\nEveryone pull the latest code!\n\nRegards,\n\nRobert McGabbins"),
|
105
103
|
]
|
106
104
|
)
|
107
|
-
|
105
|
+
end
|
108
106
|
|
109
|
-
|
110
|
-
shell {
|
107
|
+
def launch
|
108
|
+
shell { |shell_proxy|
|
111
109
|
grid_layout
|
112
110
|
|
113
111
|
text 'Hello, Custom Shell!'
|
@@ -138,15 +136,23 @@ class HelloCustomShell
|
|
138
136
|
width 360
|
139
137
|
}
|
140
138
|
|
141
|
-
items
|
139
|
+
items <=> [@email_system, :emails, column_properties: [:date, :subject, :from]]
|
142
140
|
|
143
141
|
on_mouse_up { |event|
|
144
142
|
email = event.table_item.get_data
|
145
|
-
|
143
|
+
|
144
|
+
# open a custom email shell
|
145
|
+
email_shell(
|
146
|
+
parent_shell: shell_proxy,
|
147
|
+
date: email.date,
|
148
|
+
subject: email.subject,
|
149
|
+
from: email.from,
|
150
|
+
message: email.message
|
151
|
+
).open
|
146
152
|
}
|
147
153
|
}
|
148
|
-
}
|
149
|
-
|
154
|
+
}.open
|
155
|
+
end
|
150
156
|
end
|
151
157
|
|
152
|
-
HelloCustomShell.launch
|
158
|
+
HelloCustomShell.new.launch
|