glimmer-dsl-libui 0.4.18 → 0.4.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/LICENSE.txt +1 -1
- data/README.md +448 -74
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/bin/girb_runner.rb +1 -1
- data/examples/area_based_custom_controls.rb +282 -0
- data/examples/method_based_custom_keyword.rb +9 -9
- data/examples/method_based_custom_keyword2.rb +9 -9
- data/examples/snake/model/game.rb +18 -1
- data/examples/snake.rb +6 -2
- data/examples/snake2.rb +6 -2
- data/examples/tetris/model/block.rb +1 -1
- data/examples/tetris/model/game.rb +26 -24
- data/examples/tetris/model/past_game.rb +1 -1
- data/examples/tetris/model/tetromino.rb +1 -1
- data/examples/tetris.rb +51 -20
- data/examples/tic_tac_toe/board.rb +1 -1
- data/examples/tic_tac_toe/cell.rb +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/bind_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/control_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/dsl.rb +1 -1
- data/lib/glimmer/dsl/libui/file_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/listener_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/observe_expression.rb +2 -2
- data/lib/glimmer/dsl/libui/open_file_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/operation_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/property_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/save_file_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/shape_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/shine_data_binding_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/string_expression.rb +1 -1
- data/lib/glimmer/dsl/libui/tab_item_expression.rb +1 -1
- data/lib/glimmer/fiddle_consumer.rb +1 -1
- data/lib/glimmer/libui/attributed_string.rb +1 -1
- data/lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/box/horizontal_box_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/box/vertical_box_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/box.rb +2 -1
- data/lib/glimmer/libui/control_proxy/button_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/checkbox_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/image_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/column.rb +1 -1
- data/lib/glimmer/libui/control_proxy/combobox_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/dual_column.rb +1 -1
- data/lib/glimmer/libui/control_proxy/editable_column.rb +1 -1
- data/lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/enableable_column.rb +1 -1
- data/lib/glimmer/libui/control_proxy/entry_proxy/password_entry_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/entry_proxy/search_entry_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/entry_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/font_button_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/form_proxy.rb +2 -1
- data/lib/glimmer/libui/control_proxy/grid_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/group_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/image_part_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/image_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/label_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/matrix_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/about_menu_item_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/check_menu_item_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/preferences_menu_item_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/radio_menu_item_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/separator_menu_item_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/menu_item_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/menu_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/message_box/msg_box_error_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/message_box/msg_box_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/message_box.rb +1 -1
- data/lib/glimmer/libui/control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/multiline_entry_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/open_type_features_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/slider_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/spinbox_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/tab_item_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/text_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy/transformable.rb +1 -1
- data/lib/glimmer/libui/control_proxy/triple_column.rb +1 -1
- data/lib/glimmer/libui/control_proxy/window_proxy.rb +1 -1
- data/lib/glimmer/libui/control_proxy.rb +2 -1
- data/lib/glimmer/libui/data_bindable.rb +1 -1
- data/lib/glimmer/libui/parent.rb +1 -1
- data/lib/glimmer/libui/shape/arc.rb +1 -1
- data/lib/glimmer/libui/shape/bezier.rb +21 -4
- data/lib/glimmer/libui/shape/circle.rb +1 -1
- data/lib/glimmer/libui/shape/figure.rb +1 -1
- data/lib/glimmer/libui/shape/line.rb +24 -4
- data/lib/glimmer/libui/shape/polybezier.rb +1 -1
- data/lib/glimmer/libui/shape/polygon.rb +1 -1
- data/lib/glimmer/libui/shape/polyline.rb +1 -1
- data/lib/glimmer/libui/shape/rectangle.rb +1 -1
- data/lib/glimmer/libui/shape/square.rb +1 -1
- data/lib/glimmer/libui/shape.rb +1 -1
- data/lib/glimmer/libui.rb +1 -1
- data/lib/glimmer-dsl-libui.rb +1 -1
- metadata +8 -6
data/examples/tetris.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'tetris/model/game'
|
|
5
5
|
class Tetris
|
6
6
|
include Glimmer
|
7
7
|
|
8
|
-
BLOCK_SIZE = 25
|
8
|
+
BLOCK_SIZE = OS.linux? ? 28 : 25
|
9
9
|
BEVEL_CONSTANT = 20
|
10
10
|
COLOR_GRAY = {r: 192, g: 192, b: 192}
|
11
11
|
|
@@ -71,18 +71,31 @@ class Tetris
|
|
71
71
|
|
72
72
|
Model::Game::PREVIEW_PLAYFIELD_HEIGHT.times do |row|
|
73
73
|
Model::Game::PREVIEW_PLAYFIELD_WIDTH.times do |column|
|
74
|
-
|
74
|
+
preview_updater = proc do
|
75
75
|
Glimmer::LibUI.queue_main do
|
76
|
+
new_color = @game.preview_playfield[row][column].color
|
76
77
|
color = Glimmer::LibUI.interpret_color(new_color)
|
77
78
|
block = @preview_playfield_blocks[row][column]
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
if @game.show_preview_tetromino?
|
80
|
+
block[:background_square].fill = color
|
81
|
+
block[:top_bevel_edge].fill = {r: color[:r] + 4*BEVEL_CONSTANT, g: color[:g] + 4*BEVEL_CONSTANT, b: color[:b] + 4*BEVEL_CONSTANT}
|
82
|
+
block[:right_bevel_edge].fill = {r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT}
|
83
|
+
block[:bottom_bevel_edge].fill = {r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT}
|
84
|
+
block[:left_bevel_edge].fill = {r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT}
|
85
|
+
block[:border_square].stroke = new_color == Model::Block::COLOR_CLEAR ? COLOR_GRAY : color
|
86
|
+
else
|
87
|
+
transparent_color = {r: 255, g: 255, b: 255, a: 0}
|
88
|
+
block[:background_square].fill = transparent_color
|
89
|
+
block[:top_bevel_edge].fill = transparent_color
|
90
|
+
block[:right_bevel_edge].fill = transparent_color
|
91
|
+
block[:bottom_bevel_edge].fill = transparent_color
|
92
|
+
block[:left_bevel_edge].fill = transparent_color
|
93
|
+
block[:border_square].stroke = transparent_color
|
94
|
+
end
|
84
95
|
end
|
85
96
|
end
|
97
|
+
observe(@game.preview_playfield[row][column], :color, &preview_updater)
|
98
|
+
observe(@game, :show_preview_tetromino, &preview_updater)
|
86
99
|
end
|
87
100
|
end
|
88
101
|
|
@@ -130,6 +143,12 @@ class Tetris
|
|
130
143
|
}
|
131
144
|
|
132
145
|
menu('View') {
|
146
|
+
check_menu_item('Show Next Block Preview') {
|
147
|
+
checked <=> [@game, :show_preview_tetromino]
|
148
|
+
}
|
149
|
+
|
150
|
+
separator_menu_item
|
151
|
+
|
133
152
|
menu_item('Show High Scores') {
|
134
153
|
on_clicked do
|
135
154
|
show_high_scores
|
@@ -141,18 +160,28 @@ class Tetris
|
|
141
160
|
@game.clear_high_scores!
|
142
161
|
}
|
143
162
|
}
|
163
|
+
|
164
|
+
separator_menu_item
|
165
|
+
}
|
166
|
+
|
167
|
+
menu('Speed') {
|
168
|
+
Model::Game::SPEEDS.each do |speed|
|
169
|
+
radio_menu_item(speed.to_s.capitalize) {
|
170
|
+
checked <=> [@game, "speed_#{speed}"]
|
171
|
+
}
|
172
|
+
end
|
144
173
|
}
|
145
174
|
|
146
175
|
menu('Options') {
|
147
|
-
radio_menu_item('Instant Down on Up Arrow') {
|
176
|
+
radio_menu_item('Instant Down on Up Arrow') {
|
148
177
|
checked <=> [@game, :instant_down_on_up]
|
149
178
|
}
|
150
179
|
|
151
|
-
radio_menu_item('Rotate Right on Up Arrow') {
|
180
|
+
radio_menu_item('Rotate Right on Up Arrow') {
|
152
181
|
checked <=> [@game, :rotate_right_on_up]
|
153
182
|
}
|
154
183
|
|
155
|
-
radio_menu_item('Rotate Left on Up Arrow') {
|
184
|
+
radio_menu_item('Rotate Left on Up Arrow') {
|
156
185
|
checked <=> [@game, :rotate_left_on_up]
|
157
186
|
}
|
158
187
|
}
|
@@ -199,7 +228,7 @@ class Tetris
|
|
199
228
|
block = {}
|
200
229
|
bevel_pixel_size = 0.16 * block_size.to_f
|
201
230
|
color = Glimmer::LibUI.interpret_color(Model::Block::COLOR_CLEAR)
|
202
|
-
area {
|
231
|
+
block[:area] = area {
|
203
232
|
block[:background_square] = square(0, 0, block_size) {
|
204
233
|
fill color
|
205
234
|
}
|
@@ -275,12 +304,6 @@ class Tetris
|
|
275
304
|
|
276
305
|
def score_board(block_size: , &extra_content)
|
277
306
|
vertical_box {
|
278
|
-
horizontal_box {
|
279
|
-
label # filler
|
280
|
-
@preview_playfield_blocks = playfield(playfield_width: Model::Game::PREVIEW_PLAYFIELD_WIDTH, playfield_height: Model::Game::PREVIEW_PLAYFIELD_HEIGHT, block_size: block_size)
|
281
|
-
label # filler
|
282
|
-
}
|
283
|
-
|
284
307
|
horizontal_box {
|
285
308
|
label # filler
|
286
309
|
grid {
|
@@ -321,6 +344,12 @@ class Tetris
|
|
321
344
|
}
|
322
345
|
label # filler
|
323
346
|
}
|
347
|
+
|
348
|
+
horizontal_box {
|
349
|
+
label # filler
|
350
|
+
@preview_playfield_blocks = playfield(playfield_width: Model::Game::PREVIEW_PLAYFIELD_WIDTH, playfield_height: Model::Game::PREVIEW_PLAYFIELD_HEIGHT, block_size: block_size)
|
351
|
+
label # filler
|
352
|
+
}
|
324
353
|
|
325
354
|
extra_content&.call
|
326
355
|
}
|
@@ -329,9 +358,11 @@ class Tetris
|
|
329
358
|
def start_moving_tetrominos_down
|
330
359
|
unless @tetrominos_start_moving_down
|
331
360
|
@tetrominos_start_moving_down = true
|
332
|
-
|
361
|
+
tetromino_move = proc do
|
333
362
|
@game.down! if !@game.game_over? && !@game.paused?
|
363
|
+
Glimmer::LibUI.timer(@game.delay, repeat: false, &tetromino_move)
|
334
364
|
end
|
365
|
+
Glimmer::LibUI.timer(@game.delay, repeat: false, &tetromino_move)
|
335
366
|
end
|
336
367
|
end
|
337
368
|
|
@@ -360,7 +391,7 @@ class Tetris
|
|
360
391
|
|
361
392
|
def show_about_dialog
|
362
393
|
Glimmer::LibUI.queue_main do
|
363
|
-
msg_box('About', 'Glimmer Tetris - Glimmer DSL for LibUI Example - Copyright (c) 2021 Andy Maleh')
|
394
|
+
msg_box('About', 'Glimmer Tetris - Glimmer DSL for LibUI Example - Copyright (c) 2021-2022 Andy Maleh')
|
364
395
|
end
|
365
396
|
end
|
366
397
|
end
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2021 Andy Maleh
|
1
|
+
# Copyright (c) 2021-2022 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -25,7 +25,7 @@ require 'glimmer/dsl/observe_expression'
|
|
25
25
|
|
26
26
|
module Glimmer
|
27
27
|
module DSL
|
28
|
-
module
|
28
|
+
module Libui
|
29
29
|
class ObserveExpression < StaticExpression
|
30
30
|
include TopLevelExpression
|
31
31
|
include Glimmer::DSL::ObserveExpression
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2021 Andy Maleh
|
1
|
+
# Copyright (c) 2021-2022 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -45,6 +45,7 @@ module Glimmer
|
|
45
45
|
child.deregister_all_custom_listeners
|
46
46
|
::LibUI.send("box_delete", @libui, children.index(child))
|
47
47
|
ControlProxy.control_proxies.delete(child)
|
48
|
+
children.delete(child)
|
48
49
|
end
|
49
50
|
|
50
51
|
private
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2021 Andy Maleh
|
1
|
+
# Copyright (c) 2021-2022 Andy Maleh
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
@@ -42,6 +42,7 @@ module Glimmer
|
|
42
42
|
child.deregister_all_custom_listeners
|
43
43
|
::LibUI.send("form_delete", @libui, children.index(child))
|
44
44
|
ControlProxy.control_proxies.delete(child)
|
45
|
+
children.delete(child)
|
45
46
|
end
|
46
47
|
|
47
48
|
private
|