glimmer-dsl-swt 4.20.13.8 → 4.20.13.12
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 +16 -0
- data/README.md +5 -5
- data/VERSION +1 -1
- data/docs/reference/GLIMMER_SAMPLES.md +24 -0
- data/docs/reference/GLIMMER_STYLE_GUIDE.md +2 -1
- data/glimmer-dsl-swt.gemspec +0 -0
- data/lib/glimmer/rake_task/scaffold.rb +14 -14
- data/lib/glimmer/swt/custom/code_text.rb +4 -4
- data/lib/glimmer/swt/custom/shape.rb +1 -1
- data/samples/elaborate/calculator.rb +2 -2
- data/samples/elaborate/contact_manager.rb +2 -2
- data/samples/elaborate/game_of_life.rb +111 -0
- data/samples/elaborate/game_of_life/model/cell.rb +72 -0
- data/samples/elaborate/game_of_life/model/grid.rb +97 -0
- data/samples/elaborate/klondike_solitaire.rb +30 -23
- data/samples/elaborate/klondike_solitaire/model/playing_card.rb +36 -0
- data/samples/elaborate/klondike_solitaire/view/empty_playing_card.rb +12 -4
- data/samples/elaborate/klondike_solitaire/view/foundation_pile.rb +4 -4
- data/samples/elaborate/klondike_solitaire/view/hidden_playing_card.rb +8 -1
- data/samples/elaborate/klondike_solitaire/view/playing_card.rb +3 -3
- data/samples/elaborate/klondike_solitaire/view/tableau.rb +4 -4
- data/samples/elaborate/login.rb +2 -2
- data/samples/elaborate/mandelbrot_fractal.rb +12 -12
- data/samples/elaborate/meta_sample.rb +2 -2
- data/samples/elaborate/metronome.rb +2 -2
- data/samples/elaborate/stock_ticker.rb +8 -8
- data/samples/elaborate/tetris.rb +4 -4
- data/samples/elaborate/tetris/view/bevel.rb +2 -2
- data/samples/elaborate/tetris/view/score_lane.rb +2 -2
- data/samples/elaborate/tic_tac_toe.rb +6 -6
- data/samples/elaborate/timer.rb +4 -4
- data/samples/elaborate/weather.rb +4 -4
- data/samples/hello/hello_button.rb +2 -2
- data/samples/hello/hello_c_combo.rb +2 -2
- data/samples/hello/hello_canvas.rb +4 -4
- data/samples/hello/hello_canvas_animation.rb +2 -2
- data/samples/hello/hello_canvas_data_binding.rb +2 -2
- data/samples/hello/hello_checkbox.rb +2 -2
- data/samples/hello/hello_checkbox_group.rb +2 -2
- data/samples/hello/hello_code_text.rb +2 -2
- data/samples/hello/hello_color_dialog.rb +2 -2
- data/samples/hello/hello_combo.rb +2 -2
- data/samples/hello/hello_computed.rb +14 -22
- data/samples/hello/hello_cool_bar.rb +2 -2
- data/samples/hello/hello_cursor.rb +2 -2
- data/samples/hello/hello_custom_shape.rb +2 -2
- data/samples/hello/hello_custom_shell.rb +2 -2
- data/samples/hello/hello_custom_widget.rb +4 -4
- data/samples/hello/hello_date_time.rb +2 -2
- data/samples/hello/hello_directory_dialog.rb +2 -2
- data/samples/hello/hello_file_dialog.rb +2 -2
- data/samples/hello/hello_font_dialog.rb +2 -2
- data/samples/hello/hello_group.rb +2 -2
- data/samples/hello/hello_list_multi_selection.rb +2 -2
- data/samples/hello/hello_list_single_selection.rb +2 -2
- data/samples/hello/hello_progress_bar.rb +2 -2
- data/samples/hello/hello_radio.rb +2 -2
- data/samples/hello/hello_radio_group.rb +2 -2
- data/samples/hello/hello_scale.rb +2 -2
- data/samples/hello/hello_spinner.rb +2 -2
- data/samples/hello/hello_table.rb +2 -2
- data/samples/hello/hello_text.rb +2 -2
- data/samples/hello/hello_tool_bar.rb +2 -2
- data/samples/hello/hello_tray_item.rb +2 -2
- data/samples/hello/hello_tree.rb +4 -4
- metadata +5 -2
data/samples/elaborate/tetris.rb
CHANGED
@@ -43,7 +43,7 @@ class Tetris
|
|
43
43
|
|
44
44
|
attr_reader :game
|
45
45
|
|
46
|
-
before_body
|
46
|
+
before_body do
|
47
47
|
@mutex = Mutex.new
|
48
48
|
@game = Model::Game.new(playfield_width, playfield_height)
|
49
49
|
|
@@ -99,9 +99,9 @@ class Tetris
|
|
99
99
|
exit(0)
|
100
100
|
}
|
101
101
|
}
|
102
|
-
|
102
|
+
end
|
103
103
|
|
104
|
-
after_body
|
104
|
+
after_body do
|
105
105
|
observe(@game, :game_over) do |game_over|
|
106
106
|
if game_over
|
107
107
|
show_high_score_dialog
|
@@ -117,7 +117,7 @@ class Tetris
|
|
117
117
|
end
|
118
118
|
end
|
119
119
|
@game.start!
|
120
|
-
|
120
|
+
end
|
121
121
|
|
122
122
|
body {
|
123
123
|
shell(:no_resize) {
|
@@ -26,16 +26,16 @@ require_relative "tic_tac_toe/board"
|
|
26
26
|
class TicTacToe
|
27
27
|
include Glimmer::UI::CustomShell
|
28
28
|
|
29
|
-
before_body
|
29
|
+
before_body do
|
30
30
|
@tic_tac_toe_board = Board.new
|
31
|
-
|
31
|
+
end
|
32
32
|
|
33
|
-
after_body
|
34
|
-
observe(@tic_tac_toe_board, :game_status)
|
33
|
+
after_body do
|
34
|
+
observe(@tic_tac_toe_board, :game_status) do |game_status|
|
35
35
|
display_win_message if game_status == Board::WIN
|
36
36
|
display_draw_message if game_status == Board::DRAW
|
37
|
-
|
38
|
-
|
37
|
+
end
|
38
|
+
end
|
39
39
|
|
40
40
|
body {
|
41
41
|
shell {
|
data/samples/elaborate/timer.rb
CHANGED
@@ -20,7 +20,7 @@ class Timer
|
|
20
20
|
## Use before_body block to pre-initialize variables to use in body
|
21
21
|
#
|
22
22
|
#
|
23
|
-
before_body
|
23
|
+
before_body do
|
24
24
|
Display.setAppName('Glimmer Timer')
|
25
25
|
|
26
26
|
@display = display {
|
@@ -34,11 +34,11 @@ class Timer
|
|
34
34
|
|
35
35
|
@min = 0
|
36
36
|
@sec = 0
|
37
|
-
|
37
|
+
end
|
38
38
|
|
39
39
|
## Use after_body block to setup observers for widgets in body
|
40
40
|
#
|
41
|
-
after_body
|
41
|
+
after_body do
|
42
42
|
Thread.new {
|
43
43
|
loop {
|
44
44
|
sleep(1)
|
@@ -56,7 +56,7 @@ class Timer
|
|
56
56
|
end
|
57
57
|
}
|
58
58
|
}
|
59
|
-
|
59
|
+
end
|
60
60
|
|
61
61
|
## Add widget content inside custom shell body
|
62
62
|
## Top-most widget must be a shell or another custom shell
|
@@ -33,13 +33,13 @@ class Weather
|
|
33
33
|
|
34
34
|
attr_accessor :city, :temp, :temp_min, :temp_max, :feels_like, :humidity
|
35
35
|
|
36
|
-
before_body
|
36
|
+
before_body do
|
37
37
|
@weather_mutex = Mutex.new
|
38
38
|
self.city = 'Montreal, QC, CA'
|
39
39
|
fetch_weather!
|
40
|
-
|
40
|
+
end
|
41
41
|
|
42
|
-
after_body
|
42
|
+
after_body do
|
43
43
|
Thread.new do
|
44
44
|
loop do
|
45
45
|
sleep(10)
|
@@ -47,7 +47,7 @@ class Weather
|
|
47
47
|
fetch_weather!
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
end
|
51
51
|
|
52
52
|
body {
|
53
53
|
shell(:no_resize) {
|
@@ -27,19 +27,19 @@ class HelloCanvas
|
|
27
27
|
attr_accessor :selected_shape
|
28
28
|
attr_accessor :artist
|
29
29
|
|
30
|
-
before_body
|
30
|
+
before_body do
|
31
31
|
@image_object = image(File.expand_path('../../icons/scaffold_app.png', __dir__), width: 50)
|
32
32
|
@artist = ''
|
33
|
-
|
33
|
+
end
|
34
34
|
|
35
|
-
after_body
|
35
|
+
after_body do
|
36
36
|
Thread.new {
|
37
37
|
'Picasso'.chars.each do |character|
|
38
38
|
sleep(1)
|
39
39
|
self.artist += character
|
40
40
|
end
|
41
41
|
}
|
42
|
-
|
42
|
+
end
|
43
43
|
|
44
44
|
body {
|
45
45
|
shell {
|
@@ -27,14 +27,14 @@ class HelloCanvasAnimation
|
|
27
27
|
|
28
28
|
attr_accessor :animation_every, :animation_fps, :animation_frame_count, :animation_duration_limit, :animation_started, :animation_finished
|
29
29
|
|
30
|
-
before_body
|
30
|
+
before_body do
|
31
31
|
@animation_every = 0.050 # seconds
|
32
32
|
@animation_fps = 0
|
33
33
|
@animation_frame_count = 100
|
34
34
|
@animation_duration_limit = 0 # seconds
|
35
35
|
@animation_started = true
|
36
36
|
@animation_finished = false
|
37
|
-
|
37
|
+
end
|
38
38
|
|
39
39
|
body {
|
40
40
|
shell {
|
@@ -37,7 +37,7 @@ class HelloCanvasDataBinding
|
|
37
37
|
[:solid, :dash, :dot, :dashdot, :dashdotdot]
|
38
38
|
end
|
39
39
|
|
40
|
-
before_body
|
40
|
+
before_body do
|
41
41
|
self.x1_value = 0
|
42
42
|
self.y1_value = 0
|
43
43
|
self.x2_value = CANVAS_WIDTH
|
@@ -47,7 +47,7 @@ class HelloCanvasDataBinding
|
|
47
47
|
self.foreground_blue = 228
|
48
48
|
self.line_width_value = 3
|
49
49
|
self.line_style_value = :dot
|
50
|
-
|
50
|
+
end
|
51
51
|
|
52
52
|
body {
|
53
53
|
shell {
|
@@ -26,7 +26,7 @@ class HelloCodeText
|
|
26
26
|
|
27
27
|
attr_accessor :ruby_code, :js_code, :html_code
|
28
28
|
|
29
|
-
before_body
|
29
|
+
before_body do
|
30
30
|
self.ruby_code = <<~RUBY
|
31
31
|
greeting = 'Hello, World!'
|
32
32
|
|
@@ -73,7 +73,7 @@ class HelloCodeText
|
|
73
73
|
</body>
|
74
74
|
</html>
|
75
75
|
HTML
|
76
|
-
|
76
|
+
end
|
77
77
|
|
78
78
|
body {
|
79
79
|
shell {
|
@@ -44,13 +44,13 @@ class HelloComputed
|
|
44
44
|
|
45
45
|
include Glimmer::UI::CustomShell
|
46
46
|
|
47
|
-
before_body
|
47
|
+
before_body do
|
48
48
|
@contact = Contact.new(
|
49
49
|
first_name: 'Barry',
|
50
50
|
last_name: 'McKibbin',
|
51
51
|
year_of_birth: 1985
|
52
52
|
)
|
53
|
-
|
53
|
+
end
|
54
54
|
|
55
55
|
body {
|
56
56
|
shell {
|
@@ -66,51 +66,43 @@ class HelloComputed
|
|
66
66
|
|
67
67
|
label {text 'First &Name: '}
|
68
68
|
text {
|
69
|
+
fill_horizontally_layout_data
|
69
70
|
text <=> [@contact, :first_name]
|
70
|
-
layout_data {
|
71
|
-
horizontal_alignment :fill
|
72
|
-
grab_excess_horizontal_space true
|
73
|
-
}
|
74
71
|
}
|
75
72
|
|
76
73
|
label {text '&Last Name: '}
|
77
74
|
text {
|
75
|
+
fill_horizontally_layout_data
|
78
76
|
text <=> [@contact, :last_name]
|
79
|
-
layout_data {
|
80
|
-
horizontal_alignment :fill
|
81
|
-
grab_excess_horizontal_space true
|
82
|
-
}
|
83
77
|
}
|
84
78
|
|
85
79
|
label {text '&Year of Birth: '}
|
86
80
|
text {
|
81
|
+
fill_horizontally_layout_data
|
87
82
|
text <=> [@contact, :year_of_birth]
|
88
|
-
layout_data {
|
89
|
-
horizontal_alignment :fill
|
90
|
-
grab_excess_horizontal_space true
|
91
|
-
}
|
92
83
|
}
|
93
84
|
|
94
85
|
label {text 'Name: '}
|
95
86
|
label {
|
87
|
+
fill_horizontally_layout_data
|
96
88
|
text <= [@contact, :name, computed_by: [:first_name, :last_name]]
|
97
|
-
layout_data {
|
98
|
-
horizontal_alignment :fill
|
99
|
-
grab_excess_horizontal_space true
|
100
|
-
}
|
101
89
|
}
|
102
90
|
|
103
91
|
label {text 'Age: '}
|
104
92
|
label {
|
93
|
+
fill_horizontally_layout_data
|
105
94
|
text <= [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
|
106
|
-
layout_data {
|
107
|
-
horizontal_alignment :fill
|
108
|
-
grab_excess_horizontal_space true
|
109
|
-
}
|
110
95
|
}
|
111
96
|
}
|
112
97
|
}
|
113
98
|
}
|
99
|
+
|
100
|
+
def fill_horizontally_layout_data
|
101
|
+
layout_data {
|
102
|
+
horizontal_alignment :fill
|
103
|
+
grab_excess_horizontal_space true
|
104
|
+
}
|
105
|
+
end
|
114
106
|
end
|
115
107
|
|
116
108
|
HelloComputed.launch
|
@@ -27,12 +27,12 @@ class StickFigure
|
|
27
27
|
|
28
28
|
options :x, :y, :width, :height
|
29
29
|
|
30
|
-
before_body
|
30
|
+
before_body do
|
31
31
|
@head_width = width*0.2
|
32
32
|
@head_height = height*0.2
|
33
33
|
@trunk_height = height*0.4
|
34
34
|
@extremity_length = height*0.4
|
35
|
-
|
35
|
+
end
|
36
36
|
|
37
37
|
body {
|
38
38
|
shape(x + @head_width/2.0 + @extremity_length, y) {
|
@@ -34,9 +34,9 @@ class EmailShell
|
|
34
34
|
# single option with default value
|
35
35
|
option :to, default: '"John Irwin" <john.irwin@example.com>'
|
36
36
|
|
37
|
-
before_body
|
37
|
+
before_body do
|
38
38
|
@swt_style |= swt(:shell_trim, :modeless)
|
39
|
-
|
39
|
+
end
|
40
40
|
|
41
41
|
body {
|
42
42
|
# pass received swt_style through to shell to customize it (e.g. :dialog_trim for a blocking shell)
|
@@ -34,12 +34,12 @@ class GreetingLabel
|
|
34
34
|
# internal attribute (not a custom widget option)
|
35
35
|
attr_accessor :color
|
36
36
|
|
37
|
-
before_body
|
37
|
+
before_body do
|
38
38
|
@font = {height: 24, style: :bold}
|
39
39
|
@color = :black
|
40
|
-
|
40
|
+
end
|
41
41
|
|
42
|
-
after_body
|
42
|
+
after_body do
|
43
43
|
return if colors.nil?
|
44
44
|
|
45
45
|
Thread.new {
|
@@ -48,7 +48,7 @@ class GreetingLabel
|
|
48
48
|
sleep(1)
|
49
49
|
}
|
50
50
|
}
|
51
|
-
|
51
|
+
end
|
52
52
|
|
53
53
|
body {
|
54
54
|
# pass received swt_style through to label to customize (e.g. :center to center text)
|