glimmer-dsl-libui 0.2.14 → 0.2.18
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 +22 -0
- data/README.md +532 -121
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/examples/area_gallery.rb +11 -18
- data/examples/area_gallery2.rb +31 -7
- data/examples/area_gallery3.rb +14 -21
- data/examples/area_gallery4.rb +34 -10
- data/examples/basic_transform.rb +8 -2
- data/examples/color_button.rb +1 -1
- data/examples/color_the_circles.rb +11 -9
- data/examples/histogram.rb +6 -13
- data/examples/meta_example.rb +5 -3
- data/examples/tetris/model/block.rb +48 -0
- data/examples/tetris/model/game.rb +306 -0
- data/examples/tetris/model/past_game.rb +39 -0
- data/examples/tetris/model/tetromino.rb +329 -0
- data/examples/tetris.rb +155 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/shape_expression.rb +1 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +25 -0
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +19 -7
- data/lib/glimmer/libui/shape/figure.rb +4 -2
- data/lib/glimmer/libui/shape/polybezier.rb +45 -0
- data/lib/glimmer/libui/shape/polygon.rb +46 -0
- data/lib/glimmer/libui/shape/polyline.rb +45 -0
- data/lib/glimmer/libui/shape.rb +9 -3
- data/lib/glimmer/libui.rb +2 -2
- metadata +10 -2
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.2.
|
1
|
+
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.2.18
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -28,7 +28,16 @@ include Glimmer
|
|
28
28
|
window('hello world').show
|
29
29
|
```
|
30
30
|
|
31
|
+
Mac
|
32
|
+
|
31
33
|

|
34
|
+
|
35
|
+
Windows
|
36
|
+
|
37
|
+

|
38
|
+
|
39
|
+
Linux
|
40
|
+
|
32
41
|

|
33
42
|
|
34
43
|
Basic Table Progress Bar
|
@@ -68,7 +77,16 @@ window('Task Progress', 300, 200) {
|
|
68
77
|
}.show
|
69
78
|
```
|
70
79
|
|
80
|
+
Mac
|
81
|
+
|
71
82
|

|
83
|
+
|
84
|
+
Windows
|
85
|
+
|
86
|
+

|
87
|
+
|
88
|
+
Linux
|
89
|
+
|
72
90
|

|
73
91
|
|
74
92
|
Area Gallery
|
@@ -94,31 +112,24 @@ window('Area Gallery', 400, 400) {
|
|
94
112
|
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
95
113
|
}
|
96
114
|
path { # declarative stable path
|
97
|
-
|
98
|
-
|
99
|
-
line(400, 100)
|
100
|
-
line(400, 400)
|
101
|
-
|
102
|
-
closed true
|
103
|
-
}
|
104
|
-
|
115
|
+
polygon(100, 100, 100, 400, 400, 100, 400, 400)
|
116
|
+
|
105
117
|
fill r: 202, g: 102, b: 104, a: 0.5
|
106
118
|
stroke r: 0, g: 0, b: 0
|
107
119
|
}
|
108
120
|
path { # declarative stable path
|
109
|
-
|
110
|
-
bezier(200, 100, 100, 200, 400, 100)
|
111
|
-
bezier(300, 100, 100, 300, 100, 400)
|
112
|
-
bezier(100, 300, 300, 100, 400, 400)
|
113
|
-
|
114
|
-
closed true
|
115
|
-
}
|
121
|
+
polybezier(0, 0, 200, 100, 100, 200, 400, 100, 300, 100, 100, 300, 100, 400, 100, 300, 300, 100, 400, 400)
|
116
122
|
|
117
123
|
fill r: 202, g: 102, b: 204, a: 0.5
|
118
124
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
119
125
|
}
|
120
126
|
path { # declarative stable path
|
121
|
-
|
127
|
+
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
128
|
+
|
129
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
130
|
+
}
|
131
|
+
path { # declarative stable path
|
132
|
+
arc(404, 216, 190, 90, 90, false)
|
122
133
|
|
123
134
|
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
124
135
|
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
@@ -130,9 +141,9 @@ window('Area Gallery', 400, 400) {
|
|
130
141
|
fill r: 202, g: 102, b: 204, a: 0.5
|
131
142
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
132
143
|
}
|
133
|
-
text(
|
144
|
+
text(161, 40, 100) { # x, y, width
|
134
145
|
string('Area Gallery') {
|
135
|
-
font family: '
|
146
|
+
font family: 'Arial', size: 14
|
136
147
|
color :black
|
137
148
|
}
|
138
149
|
}
|
@@ -188,7 +199,16 @@ window('Area Gallery', 400, 400) {
|
|
188
199
|
}.show
|
189
200
|
```
|
190
201
|
|
202
|
+
Mac
|
203
|
+
|
191
204
|

|
205
|
+
|
206
|
+
Windows
|
207
|
+
|
208
|
+

|
209
|
+
|
210
|
+
Linux
|
211
|
+
|
192
212
|

|
193
213
|
|
194
214
|
[Check Out Many More Examples Over Here!](#examples)
|
@@ -257,16 +277,19 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
257
277
|
- [Basic Draw Text](#basic-draw-text)
|
258
278
|
- [Custom Draw Text](#custom-draw-text)
|
259
279
|
- [Method-Based Custom Keyword](#method-based-custom-keyword)
|
280
|
+
- [Tetris](#tetris)
|
260
281
|
- [Applications](#applications)
|
261
282
|
- [Manga2PDF](#manga2pdf)
|
262
283
|
- [Befunge98 GUI](#befunge98-gui)
|
263
|
-
|
284
|
+
- [i3off Gtk Ruby](#i3off-gtk-ruby)
|
285
|
+
- [Process](#process)
|
286
|
+
- [Resources](#resources)
|
264
287
|
- [Help](#help)
|
265
288
|
- [Issues](#issues)
|
266
289
|
- [Chat](#chat)
|
267
|
-
- [Process](#process)
|
268
290
|
- [Planned Features and Feature Suggestions](#planned-features-and-feature-suggestions)
|
269
291
|
- [Change Log](#change-log)
|
292
|
+
- [Contributing](#contributing)
|
270
293
|
- [Contributors](#contributors)
|
271
294
|
- [License](#license)
|
272
295
|
|
@@ -347,7 +370,7 @@ gem install glimmer-dsl-libui
|
|
347
370
|
Or install via Bundler `Gemfile`:
|
348
371
|
|
349
372
|
```ruby
|
350
|
-
gem 'glimmer-dsl-libui', '~> 0.2.
|
373
|
+
gem 'glimmer-dsl-libui', '~> 0.2.18'
|
351
374
|
```
|
352
375
|
|
353
376
|
Add `require 'glimmer-dsl-libui'` at the top, and then `include Glimmer` into the top-level main object for testing or into an actual class for serious usage.
|
@@ -464,6 +487,9 @@ Keyword(Args) | Properties | Listeners
|
|
464
487
|
`non_wrapping_multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
465
488
|
`password_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
466
489
|
`path(draw_fill_mode = :winding)` | `fill` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `stroke` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `:cap` as (`:round`, `:square`, `:flat`), `:join` as (`:miter`, `:round`, `:bevel`), `:thickness` as `Numeric`, `:miter_limit` as `Numeric`, `:dashes` as `Array` of `Numeric` ) | None
|
490
|
+
`polygon(point_array as Array of Arrays of Numeric or Array of Numeric)` | `point_array` (`Array of Arrays of Numeric or Array of Numeric`) | None
|
491
|
+
`polyline(point_array as Array of Arrays of Numeric or Array of Numeric)` | `point_array` (`Array of Arrays of Numeric or Array of Numeric`) | None
|
492
|
+
`polybezier(point_array as Array of Arrays of Numeric or Array of Numeric)` | `point_array` (`Array of Arrays of Numeric or Array of Numeric`) | None
|
467
493
|
`preferences_menu_item` | None | `on_clicked`
|
468
494
|
`progress_bar` | `value` (`Numeric`) | None
|
469
495
|
`progress_bar_column(name as String)` | None | None
|
@@ -715,6 +741,9 @@ Available nested `path` shapes:
|
|
715
741
|
- `arc(x_center as Numeric, y_center as Numeric, radius as Numeric, start_angle as Numeric, sweep as Numeric, is_negative as Boolean)`
|
716
742
|
- `line(x as Numeric, y as Numeric)`
|
717
743
|
- `bezier(c1_x as Numeric, c1_y as Numeric, c2_x as Numeric, c2_y as Numeric, end_x as Numeric, end_y as Numeric)`
|
744
|
+
- `polygon(point_array as Array of Arrays of Numeric or Array of Numeric)`: closed figure of lines; can receive points as [[x1, y1], [x2, y2], ...] or [x1, y1, x2, y2, ...]
|
745
|
+
- `polyline(point_array as Array of Arrays of Numeric or Array of Numeric)`: open figure of lines; can receive points as [[x1, y1], [x2, y2], ...] or [x1, y1, x2, y2, ...]
|
746
|
+
- `polybezier(point_array as Array of Arrays of Numeric or Array of Numeric)`: open figure of beziers; can receive points as [[start_x1, start_y1], [c1_x2, c1_y2, c2_x2, c2_y2, end_x2, end_y2], [c1_x3, c1_y3, c2_x3, c2_y3, end_x3, end_y3], ...] or [start_x1, start_y1, c1_x2, c1_y2, c2_x2, c2_y2, end_x2, end_y2, c1_x3, c1_y3, c2_x3, c2_y3, end_x3, end_y3, ...]
|
718
747
|
- `figure(x=nil as Numeric, y=nil as Numeric)` (composite that can contain other shapes) (can set `closed true` to connect last point to first point automatically)
|
719
748
|
|
720
749
|
Check [examples/area_gallery.rb](#area-gallery) for an overiew of all `path` shapes.
|
@@ -769,6 +798,12 @@ Note that when nesting an `area` directly underneath `window` (without a layout
|
|
769
798
|
|
770
799
|
To redraw an `area`, you may call the `#queue_redraw_all` method, or simply `#redraw`.
|
771
800
|
|
801
|
+
`area` has the following Glimmer-added API methods/attributes:
|
802
|
+
- `request_auto_redraw`: requests auto redraw upon changes to nested stable `path` or shapes
|
803
|
+
- `pause_auto_redraw`: pause auto redraw upon changes to nested stable `path` or shapes (useful to avoid too many micro-change redraws, to group all redraws as one after many micro-changes)
|
804
|
+
- `resume_auto_redraw`: resume auto redraw upon changes to nested stable `path` or shapes
|
805
|
+
- `auto_redraw_enabled`/`auto_redraw_enabled?`/`auto_redraw_enabled=`: an attribute to disable/enable auto redraw on an `area` upon changes to nested stable `path` or shapes
|
806
|
+
|
772
807
|
A transform `matrix` can be set on a path by building a `matrix(m11 = nil, m12 = nil, m21 = nil, m22 = nil, m31 = nil, m32 = nil) {operations}` proxy object and then setting via `transform` property, or alternatively by building and setting the matrix in one call to `transform(m11 = nil, m12 = nil, m21 = nil, m22 = nil, m31 = nil, m32 = nil) {operations}` passing it the matrix arguments and/or content operations.
|
773
808
|
|
774
809
|
When instantiating a `matrix` object, it always starts with identity matrix.
|
@@ -1044,10 +1079,10 @@ window('Method-Based Custom Keyword') {
|
|
1044
1079
|
- `table` `checkbox_column` and `checkbox_text_column` checkbox editing only works on Linux and Windows (not Mac) due to a current limitation in [libui](https://github.com/andlabs/ui/issues/357).
|
1045
1080
|
- `text` `align` property seems not to work on the Mac ([libui](https://github.com/andlabs/libui) has an [issue](https://github.com/andlabs/libui/pull/407) about it)
|
1046
1081
|
- `text` `string` `background` does not work on Windows due to an [issue in libui](https://github.com/andlabs/libui/issues/347).
|
1047
|
-
- `arc` shape does not work on Windows unless a figure is started due to implementation of [libui](https://github.com/andlabs/libui).
|
1048
1082
|
- `table` controls on Windows intentionally get an extra empty row at the end because if any row were to be deleted for the first time, double-deletion happens due to an issue in [libui](https://github.com/andlabs/libui) on Windows.
|
1049
1083
|
- `table` `progress_bar` column on Windows cannot be updated with a positive value if it started initially with `-1` (it ignores update to avoid crashing due to an issue in [libui](https://github.com/andlabs/libui) on Windows.
|
1050
1084
|
- It seems that [libui](https://github.com/andlabs/libui) does not support nesting multiple `area` controls under a `grid` as only the first one shows up in that scenario. To workaround that limitation, use a `vertical_box` with nested `horizontal_box`s instead to include multiple `area`s in a GUI.
|
1085
|
+
- As per the code of [examples/basic_transform.rb](#basic-transform), Windows requires different ordering of transforms than Mac and Linux.
|
1051
1086
|
|
1052
1087
|
### Original API
|
1053
1088
|
|
@@ -1099,6 +1134,10 @@ Mac
|
|
1099
1134
|
|
1100
1135
|

|
1101
1136
|
|
1137
|
+
Windows
|
1138
|
+
|
1139
|
+

|
1140
|
+
|
1102
1141
|
Linux
|
1103
1142
|
|
1104
1143
|

|
@@ -1149,15 +1188,20 @@ class MetaExample
|
|
1149
1188
|
end
|
1150
1189
|
|
1151
1190
|
def run_example(example)
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1191
|
+
Thread.new do
|
1192
|
+
command = "ruby -r #{glimmer_dsl_libui_file} #{example} 2>&1"
|
1193
|
+
result = ''
|
1194
|
+
IO.popen(command) do |f|
|
1195
|
+
sleep(0.0001) # yield to main thread
|
1196
|
+
f.each_line do |line|
|
1197
|
+
result << line
|
1198
|
+
puts line
|
1199
|
+
$stdout.flush # for Windows
|
1200
|
+
sleep(0.0001) # yield to main thread
|
1201
|
+
end
|
1158
1202
|
end
|
1203
|
+
Glimmer::LibUI.queue_main { msg_box('Error Running Example', result) } if result.downcase.include?('error')
|
1159
1204
|
end
|
1160
|
-
msg_box('Error Running Example', result) if result.downcase.include?('error')
|
1161
1205
|
end
|
1162
1206
|
|
1163
1207
|
def launch
|
@@ -1258,6 +1302,10 @@ Mac
|
|
1258
1302
|
|
1259
1303
|

|
1260
1304
|
|
1305
|
+
Windows
|
1306
|
+
|
1307
|
+

|
1308
|
+
|
1261
1309
|
Linux
|
1262
1310
|
|
1263
1311
|

|
@@ -1338,6 +1386,11 @@ Mac
|
|
1338
1386
|

|
1339
1387
|

|
1340
1388
|
|
1389
|
+
Windows
|
1390
|
+
|
1391
|
+

|
1392
|
+

|
1393
|
+
|
1341
1394
|
Linux
|
1342
1395
|
|
1343
1396
|

|
@@ -1415,6 +1468,11 @@ Mac
|
|
1415
1468
|

|
1416
1469
|

|
1417
1470
|
|
1471
|
+
Windows
|
1472
|
+
|
1473
|
+

|
1474
|
+

|
1475
|
+
|
1418
1476
|
Linux
|
1419
1477
|
|
1420
1478
|

|
@@ -1515,6 +1573,10 @@ Mac
|
|
1515
1573
|
|
1516
1574
|

|
1517
1575
|
|
1576
|
+
Windows
|
1577
|
+
|
1578
|
+

|
1579
|
+
|
1518
1580
|
Linux
|
1519
1581
|
|
1520
1582
|

|
@@ -1588,6 +1650,11 @@ Mac
|
|
1588
1650
|

|
1589
1651
|

|
1590
1652
|
|
1653
|
+
Windows
|
1654
|
+
|
1655
|
+

|
1656
|
+

|
1657
|
+
|
1591
1658
|
Linux
|
1592
1659
|
|
1593
1660
|

|
@@ -1805,6 +1872,10 @@ Mac
|
|
1805
1872
|
|
1806
1873
|

|
1807
1874
|
|
1875
|
+
Windows
|
1876
|
+
|
1877
|
+

|
1878
|
+
|
1808
1879
|
Linux
|
1809
1880
|
|
1810
1881
|

|
@@ -2196,6 +2267,11 @@ Mac
|
|
2196
2267
|

|
2197
2268
|

|
2198
2269
|
|
2270
|
+
Windows
|
2271
|
+
|
2272
|
+

|
2273
|
+

|
2274
|
+
|
2199
2275
|
Linux
|
2200
2276
|
|
2201
2277
|

|
@@ -2280,6 +2356,11 @@ Mac
|
|
2280
2356
|

|
2281
2357
|

|
2282
2358
|
|
2359
|
+
Windows
|
2360
|
+
|
2361
|
+

|
2362
|
+

|
2363
|
+
|
2283
2364
|
Linux
|
2284
2365
|
|
2285
2366
|

|
@@ -2292,7 +2373,7 @@ require 'glimmer-dsl-libui'
|
|
2292
2373
|
|
2293
2374
|
include Glimmer
|
2294
2375
|
|
2295
|
-
window('color button',
|
2376
|
+
window('color button', 240) {
|
2296
2377
|
color_button { |cb|
|
2297
2378
|
color :blue
|
2298
2379
|
|
@@ -2324,6 +2405,10 @@ Mac
|
|
2324
2405
|
|
2325
2406
|

|
2326
2407
|
|
2408
|
+
Windows
|
2409
|
+
|
2410
|
+

|
2411
|
+
|
2327
2412
|
Linux
|
2328
2413
|
|
2329
2414
|

|
@@ -2416,6 +2501,12 @@ Mac
|
|
2416
2501
|

|
2417
2502
|

|
2418
2503
|
|
2504
|
+
Windows
|
2505
|
+
|
2506
|
+

|
2507
|
+

|
2508
|
+

|
2509
|
+
|
2419
2510
|
Linux
|
2420
2511
|
|
2421
2512
|

|
@@ -2554,6 +2645,11 @@ Mac
|
|
2554
2645
|

|
2555
2646
|

|
2556
2647
|
|
2648
|
+
Windows
|
2649
|
+
|
2650
|
+

|
2651
|
+

|
2652
|
+
|
2557
2653
|
Linux
|
2558
2654
|
|
2559
2655
|

|
@@ -2619,6 +2715,10 @@ Mac
|
|
2619
2715
|
|
2620
2716
|

|
2621
2717
|
|
2718
|
+
Windows
|
2719
|
+
|
2720
|
+

|
2721
|
+
|
2622
2722
|
Linux
|
2623
2723
|
|
2624
2724
|

|
@@ -2741,6 +2841,12 @@ Mac
|
|
2741
2841
|

|
2742
2842
|

|
2743
2843
|
|
2844
|
+
Windows
|
2845
|
+
|
2846
|
+

|
2847
|
+

|
2848
|
+

|
2849
|
+
|
2744
2850
|
Linux
|
2745
2851
|
|
2746
2852
|

|
@@ -2808,6 +2914,11 @@ Mac
|
|
2808
2914
|

|
2809
2915
|

|
2810
2916
|
|
2917
|
+
Windows
|
2918
|
+
|
2919
|
+

|
2920
|
+

|
2921
|
+
|
2811
2922
|
Linux
|
2812
2923
|
|
2813
2924
|

|
@@ -2875,6 +2986,10 @@ Mac
|
|
2875
2986
|
|
2876
2987
|

|
2877
2988
|
|
2989
|
+
Windows
|
2990
|
+
|
2991
|
+

|
2992
|
+
|
2878
2993
|
Linux
|
2879
2994
|
|
2880
2995
|

|
@@ -3033,6 +3148,10 @@ Mac
|
|
3033
3148
|
|
3034
3149
|

|
3035
3150
|
|
3151
|
+
Windows
|
3152
|
+
|
3153
|
+

|
3154
|
+
|
3036
3155
|
Linux
|
3037
3156
|
|
3038
3157
|

|
@@ -3104,6 +3223,11 @@ Mac
|
|
3104
3223
|

|
3105
3224
|

|
3106
3225
|
|
3226
|
+
Windows
|
3227
|
+
|
3228
|
+

|
3229
|
+

|
3230
|
+
|
3107
3231
|
Linux
|
3108
3232
|
|
3109
3233
|

|
@@ -3165,6 +3289,10 @@ Mac
|
|
3165
3289
|
|
3166
3290
|

|
3167
3291
|
|
3292
|
+
Windows
|
3293
|
+
|
3294
|
+

|
3295
|
+
|
3168
3296
|
Linux
|
3169
3297
|
|
3170
3298
|

|
@@ -3217,6 +3345,10 @@ Mac
|
|
3217
3345
|
|
3218
3346
|

|
3219
3347
|
|
3348
|
+
Windows
|
3349
|
+
|
3350
|
+

|
3351
|
+
|
3220
3352
|
Linux
|
3221
3353
|
|
3222
3354
|

|
@@ -3269,6 +3401,10 @@ Mac
|
|
3269
3401
|
|
3270
3402
|

|
3271
3403
|
|
3404
|
+
Windows
|
3405
|
+
|
3406
|
+

|
3407
|
+
|
3272
3408
|
Linux
|
3273
3409
|
|
3274
3410
|

|
@@ -3336,6 +3472,10 @@ Mac
|
|
3336
3472
|
|
3337
3473
|

|
3338
3474
|
|
3475
|
+
Windows
|
3476
|
+
|
3477
|
+

|
3478
|
+
|
3339
3479
|
Linux
|
3340
3480
|
|
3341
3481
|

|
@@ -3404,6 +3544,12 @@ Mac
|
|
3404
3544
|

|
3405
3545
|

|
3406
3546
|
|
3547
|
+
Windows
|
3548
|
+
|
3549
|
+

|
3550
|
+

|
3551
|
+

|
3552
|
+
|
3407
3553
|
Linux
|
3408
3554
|
|
3409
3555
|

|
@@ -3524,6 +3670,10 @@ Mac
|
|
3524
3670
|
|
3525
3671
|

|
3526
3672
|
|
3673
|
+
Windows
|
3674
|
+
|
3675
|
+

|
3676
|
+
|
3527
3677
|
Linux
|
3528
3678
|
|
3529
3679
|

|
@@ -3647,6 +3797,11 @@ Mac
|
|
3647
3797
|

|
3648
3798
|

|
3649
3799
|
|
3800
|
+
Windows
|
3801
|
+
|
3802
|
+

|
3803
|
+

|
3804
|
+
|
3650
3805
|
Linux
|
3651
3806
|
|
3652
3807
|

|
@@ -3878,6 +4033,10 @@ Mac
|
|
3878
4033
|
|
3879
4034
|

|
3880
4035
|
|
4036
|
+
Windows
|
4037
|
+
|
4038
|
+

|
4039
|
+
|
3881
4040
|
Linux
|
3882
4041
|
|
3883
4042
|

|
@@ -3905,31 +4064,24 @@ window('Area Gallery', 400, 400) {
|
|
3905
4064
|
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
3906
4065
|
}
|
3907
4066
|
path { # declarative stable path
|
3908
|
-
|
3909
|
-
|
3910
|
-
line(400, 100)
|
3911
|
-
line(400, 400)
|
3912
|
-
|
3913
|
-
closed true
|
3914
|
-
}
|
3915
|
-
|
4067
|
+
polygon(100, 100, 100, 400, 400, 100, 400, 400)
|
4068
|
+
|
3916
4069
|
fill r: 202, g: 102, b: 104, a: 0.5
|
3917
4070
|
stroke r: 0, g: 0, b: 0
|
3918
4071
|
}
|
3919
4072
|
path { # declarative stable path
|
3920
|
-
|
3921
|
-
bezier(200, 100, 100, 200, 400, 100)
|
3922
|
-
bezier(300, 100, 100, 300, 100, 400)
|
3923
|
-
bezier(100, 300, 300, 100, 400, 400)
|
3924
|
-
|
3925
|
-
closed true
|
3926
|
-
}
|
4073
|
+
polybezier(0, 0, 200, 100, 100, 200, 400, 100, 300, 100, 100, 300, 100, 400, 100, 300, 300, 100, 400, 400)
|
3927
4074
|
|
3928
4075
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3929
4076
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
3930
4077
|
}
|
3931
4078
|
path { # declarative stable path
|
3932
|
-
|
4079
|
+
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
4080
|
+
|
4081
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4082
|
+
}
|
4083
|
+
path { # declarative stable path
|
4084
|
+
arc(404, 216, 190, 90, 90, false)
|
3933
4085
|
|
3934
4086
|
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
3935
4087
|
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
@@ -3941,9 +4093,9 @@ window('Area Gallery', 400, 400) {
|
|
3941
4093
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3942
4094
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
3943
4095
|
}
|
3944
|
-
text(
|
4096
|
+
text(161, 40, 100) { # x, y, width
|
3945
4097
|
string('Area Gallery') {
|
3946
|
-
font family: '
|
4098
|
+
font family: 'Arial', size: 14
|
3947
4099
|
color :black
|
3948
4100
|
}
|
3949
4101
|
}
|
@@ -4092,18 +4244,42 @@ window('Area Gallery', 400, 400) {
|
|
4092
4244
|
end_x 400
|
4093
4245
|
end_y 400
|
4094
4246
|
}
|
4095
|
-
|
4096
|
-
closed true
|
4097
4247
|
}
|
4098
4248
|
|
4099
4249
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4100
4250
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4101
4251
|
}
|
4252
|
+
path { # declarative stable path
|
4253
|
+
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
4254
|
+
figure {
|
4255
|
+
x 100
|
4256
|
+
y 100
|
4257
|
+
|
4258
|
+
line {
|
4259
|
+
x 400
|
4260
|
+
y 100
|
4261
|
+
}
|
4262
|
+
line {
|
4263
|
+
x 100
|
4264
|
+
y 400
|
4265
|
+
}
|
4266
|
+
line {
|
4267
|
+
x 400
|
4268
|
+
y 400
|
4269
|
+
}
|
4270
|
+
line {
|
4271
|
+
x 0
|
4272
|
+
y 0
|
4273
|
+
}
|
4274
|
+
}
|
4275
|
+
|
4276
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4277
|
+
}
|
4102
4278
|
path { # declarative stable path
|
4103
4279
|
arc {
|
4104
|
-
x_center
|
4105
|
-
y_center
|
4106
|
-
radius
|
4280
|
+
x_center 404
|
4281
|
+
y_center 216
|
4282
|
+
radius 190
|
4107
4283
|
start_angle 90
|
4108
4284
|
sweep 90
|
4109
4285
|
is_negative false
|
@@ -4124,12 +4300,12 @@ window('Area Gallery', 400, 400) {
|
|
4124
4300
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
4125
4301
|
}
|
4126
4302
|
text {
|
4127
|
-
x
|
4303
|
+
x 161
|
4128
4304
|
y 40
|
4129
4305
|
width 100
|
4130
4306
|
|
4131
4307
|
string {
|
4132
|
-
font family: '
|
4308
|
+
font family: 'Arial', size: 14
|
4133
4309
|
color :black
|
4134
4310
|
|
4135
4311
|
'Area Gallery'
|
@@ -4200,42 +4376,35 @@ window('Area Gallery', 400, 400) {
|
|
4200
4376
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4201
4377
|
square(0, 0, 100)
|
4202
4378
|
square(100, 100, 400)
|
4203
|
-
|
4379
|
+
|
4204
4380
|
fill r: 102, g: 102, b: 204
|
4205
4381
|
}
|
4206
4382
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4207
4383
|
rectangle(0, 100, 100, 400)
|
4208
4384
|
rectangle(100, 0, 400, 100)
|
4209
|
-
|
4385
|
+
|
4210
4386
|
# linear gradient (has x0, y0, x1, y1, and stops)
|
4211
4387
|
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
4212
4388
|
}
|
4213
4389
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4214
|
-
|
4215
|
-
|
4216
|
-
line(400, 100)
|
4217
|
-
line(400, 400)
|
4218
|
-
|
4219
|
-
closed true
|
4220
|
-
}
|
4221
|
-
|
4390
|
+
polygon(100, 100, 100, 400, 400, 100, 400, 400)
|
4391
|
+
|
4222
4392
|
fill r: 202, g: 102, b: 104, a: 0.5
|
4223
4393
|
stroke r: 0, g: 0, b: 0
|
4224
4394
|
}
|
4225
4395
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4226
|
-
|
4227
|
-
|
4228
|
-
bezier(300, 100, 100, 300, 100, 400)
|
4229
|
-
bezier(100, 300, 300, 100, 400, 400)
|
4230
|
-
|
4231
|
-
closed true
|
4232
|
-
}
|
4233
|
-
|
4396
|
+
polybezier(0, 0, 200, 100, 100, 200, 400, 100, 300, 100, 100, 300, 100, 400, 100, 300, 300, 100, 400, 400)
|
4397
|
+
|
4234
4398
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4235
4399
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4236
4400
|
}
|
4237
4401
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4238
|
-
|
4402
|
+
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
4403
|
+
|
4404
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4405
|
+
}
|
4406
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4407
|
+
arc(404, 216, 190, 90, 90, false)
|
4239
4408
|
|
4240
4409
|
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4241
4410
|
fill outer_radius: 90, x0: 0, y0: 0, x1: 500, y1: 500, stops: [{pos: 0.25, r: 102, g: 102, b: 204, a: 0.5}, {pos: 0.75, r: 204, g: 102, b: 204}]
|
@@ -4247,9 +4416,9 @@ window('Area Gallery', 400, 400) {
|
|
4247
4416
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4248
4417
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
4249
4418
|
}
|
4250
|
-
text(
|
4419
|
+
text(161, 40, 100) { # x, y, width
|
4251
4420
|
string('Area Gallery') {
|
4252
|
-
font family: '
|
4421
|
+
font family: 'Arial', size: 14
|
4253
4422
|
color :black
|
4254
4423
|
}
|
4255
4424
|
}
|
@@ -4364,10 +4533,10 @@ window('Area Gallery', 400, 400) {
|
|
4364
4533
|
x 400
|
4365
4534
|
y 400
|
4366
4535
|
}
|
4367
|
-
|
4536
|
+
|
4368
4537
|
closed true
|
4369
4538
|
}
|
4370
|
-
|
4539
|
+
|
4371
4540
|
fill r: 202, g: 102, b: 104, a: 0.5
|
4372
4541
|
stroke r: 0, g: 0, b: 0
|
4373
4542
|
}
|
@@ -4400,18 +4569,42 @@ window('Area Gallery', 400, 400) {
|
|
4400
4569
|
end_x 400
|
4401
4570
|
end_y 400
|
4402
4571
|
}
|
4403
|
-
|
4404
|
-
closed true
|
4405
4572
|
}
|
4406
|
-
|
4573
|
+
|
4407
4574
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4408
4575
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4409
4576
|
}
|
4577
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4578
|
+
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
4579
|
+
figure {
|
4580
|
+
x 100
|
4581
|
+
y 100
|
4582
|
+
|
4583
|
+
line {
|
4584
|
+
x 400
|
4585
|
+
y 100
|
4586
|
+
}
|
4587
|
+
line {
|
4588
|
+
x 100
|
4589
|
+
y 400
|
4590
|
+
}
|
4591
|
+
line {
|
4592
|
+
x 400
|
4593
|
+
y 400
|
4594
|
+
}
|
4595
|
+
line {
|
4596
|
+
x 0
|
4597
|
+
y 0
|
4598
|
+
}
|
4599
|
+
}
|
4600
|
+
|
4601
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4602
|
+
}
|
4410
4603
|
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4411
4604
|
arc {
|
4412
|
-
x_center
|
4413
|
-
y_center
|
4414
|
-
radius
|
4605
|
+
x_center 404
|
4606
|
+
y_center 216
|
4607
|
+
radius 190
|
4415
4608
|
start_angle 90
|
4416
4609
|
sweep 90
|
4417
4610
|
is_negative false
|
@@ -4432,12 +4625,12 @@ window('Area Gallery', 400, 400) {
|
|
4432
4625
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
4433
4626
|
}
|
4434
4627
|
text {
|
4435
|
-
x
|
4628
|
+
x 161
|
4436
4629
|
y 40
|
4437
4630
|
width 100
|
4438
4631
|
|
4439
4632
|
string {
|
4440
|
-
font family: '
|
4633
|
+
font family: 'Arial', size: 14
|
4441
4634
|
color :black
|
4442
4635
|
|
4443
4636
|
'Area Gallery'
|
@@ -4516,6 +4709,10 @@ Mac
|
|
4516
4709
|
|
4517
4710
|

|
4518
4711
|
|
4712
|
+
Windows
|
4713
|
+
|
4714
|
+

|
4715
|
+
|
4519
4716
|
Linux
|
4520
4717
|
|
4521
4718
|

|
@@ -4750,20 +4947,13 @@ end
|
|
4750
4947
|
|
4751
4948
|
# method-based custom control representing a graph path
|
4752
4949
|
def graph_path(width, height, should_extend, &block)
|
4753
|
-
locations = point_locations(width, height)
|
4950
|
+
locations = point_locations(width, height).flatten
|
4754
4951
|
path {
|
4755
|
-
|
4756
|
-
|
4757
|
-
|
4758
|
-
|
4759
|
-
|
4760
|
-
if should_extend
|
4761
|
-
line(width, height)
|
4762
|
-
line(0, height)
|
4763
|
-
|
4764
|
-
closed true
|
4765
|
-
end
|
4766
|
-
}
|
4952
|
+
if should_extend
|
4953
|
+
polygon(locations + [width, height, 0, height])
|
4954
|
+
else
|
4955
|
+
polyline(locations)
|
4956
|
+
end
|
4767
4957
|
|
4768
4958
|
# apply a transform to the coordinate space for this path so (0, 0) is the top-left corner of the graph
|
4769
4959
|
transform {
|
@@ -4857,6 +5047,10 @@ Mac
|
|
4857
5047
|
|
4858
5048
|

|
4859
5049
|
|
5050
|
+
Windows
|
5051
|
+
|
5052
|
+

|
5053
|
+
|
4860
5054
|
Linux
|
4861
5055
|
|
4862
5056
|

|
@@ -4914,6 +5108,11 @@ Mac
|
|
4914
5108
|

|
4915
5109
|

|
4916
5110
|
|
5111
|
+
Windows
|
5112
|
+
|
5113
|
+

|
5114
|
+

|
5115
|
+
|
4917
5116
|
Linux
|
4918
5117
|
|
4919
5118
|

|
@@ -4990,6 +5189,11 @@ Mac
|
|
4990
5189
|

|
4991
5190
|

|
4992
5191
|
|
5192
|
+
Windows
|
5193
|
+
|
5194
|
+

|
5195
|
+

|
5196
|
+
|
4993
5197
|
Linux
|
4994
5198
|
|
4995
5199
|

|
@@ -5155,6 +5359,12 @@ Mac
|
|
5155
5359
|

|
5156
5360
|

|
5157
5361
|
|
5362
|
+
Windows
|
5363
|
+
|
5364
|
+

|
5365
|
+

|
5366
|
+

|
5367
|
+
|
5158
5368
|
Linux
|
5159
5369
|
|
5160
5370
|

|
@@ -5406,6 +5616,10 @@ Mac
|
|
5406
5616
|
|
5407
5617
|

|
5408
5618
|
|
5619
|
+
Windows
|
5620
|
+
|
5621
|
+

|
5622
|
+
|
5409
5623
|
Linux
|
5410
5624
|
|
5411
5625
|

|
@@ -5689,6 +5903,11 @@ Mac
|
|
5689
5903
|

|
5690
5904
|

|
5691
5905
|
|
5906
|
+
Windows
|
5907
|
+
|
5908
|
+

|
5909
|
+

|
5910
|
+
|
5692
5911
|
Linux
|
5693
5912
|
|
5694
5913
|

|
@@ -5903,6 +6122,10 @@ Mac
|
|
5903
6122
|
|
5904
6123
|

|
5905
6124
|
|
6125
|
+
Windows
|
6126
|
+
|
6127
|
+

|
6128
|
+
|
5906
6129
|
Linux
|
5907
6130
|
|
5908
6131
|

|
@@ -6009,6 +6232,186 @@ window('Method-Based Custom Keyword') {
|
|
6009
6232
|
}.show
|
6010
6233
|
```
|
6011
6234
|
|
6235
|
+
### Tetris
|
6236
|
+
|
6237
|
+
[examples/tetris.rb](examples/tetris.rb)
|
6238
|
+
|
6239
|
+
Run with this command from the root of the project if you cloned the project:
|
6240
|
+
|
6241
|
+
```
|
6242
|
+
ruby -r './lib/glimmer-dsl-libui' examples/tetris.rb
|
6243
|
+
```
|
6244
|
+
|
6245
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
6246
|
+
|
6247
|
+
```
|
6248
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/tetris'"
|
6249
|
+
```
|
6250
|
+
|
6251
|
+
Mac
|
6252
|
+
|
6253
|
+

|
6254
|
+
|
6255
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
6256
|
+
|
6257
|
+
```ruby
|
6258
|
+
require 'glimmer-dsl-libui'
|
6259
|
+
|
6260
|
+
require_relative 'tetris/model/game'
|
6261
|
+
|
6262
|
+
class Tetris
|
6263
|
+
include Glimmer
|
6264
|
+
|
6265
|
+
BLOCK_SIZE = 25
|
6266
|
+
BEVEL_CONSTANT = 20
|
6267
|
+
COLOR_GRAY = {r: 192, g: 192, b: 192}
|
6268
|
+
|
6269
|
+
attr_reader :game
|
6270
|
+
|
6271
|
+
def initialize
|
6272
|
+
@game = Model::Game.new
|
6273
|
+
create_gui
|
6274
|
+
register_observers
|
6275
|
+
end
|
6276
|
+
|
6277
|
+
def launch
|
6278
|
+
@game.start!
|
6279
|
+
@main_window.show
|
6280
|
+
end
|
6281
|
+
|
6282
|
+
def create_gui
|
6283
|
+
@main_window = window('Glimmer Tetris', Model::Game::PLAYFIELD_WIDTH * BLOCK_SIZE, Model::Game::PLAYFIELD_HEIGHT * BLOCK_SIZE) {
|
6284
|
+
playfield(playfield_width: Model::Game::PLAYFIELD_WIDTH, playfield_height: Model::Game::PLAYFIELD_HEIGHT, block_size: BLOCK_SIZE)
|
6285
|
+
}
|
6286
|
+
end
|
6287
|
+
|
6288
|
+
def register_observers
|
6289
|
+
Glimmer::DataBinding::Observer.proc do |game_over|
|
6290
|
+
if game_over
|
6291
|
+
show_game_over_dialog
|
6292
|
+
else
|
6293
|
+
start_moving_tetrominos_down
|
6294
|
+
end
|
6295
|
+
end.observe(@game, :game_over)
|
6296
|
+
|
6297
|
+
Model::Game::PLAYFIELD_HEIGHT.times do |row|
|
6298
|
+
Model::Game::PLAYFIELD_HEIGHT.times do |column|
|
6299
|
+
Glimmer::DataBinding::Observer.proc do |new_color|
|
6300
|
+
Glimmer::LibUI.queue_main do
|
6301
|
+
color = Glimmer::LibUI.interpret_color(new_color)
|
6302
|
+
block = @blocks[row][column]
|
6303
|
+
block[:background_square].fill = color
|
6304
|
+
block[:top_bevel_edge].fill = {r: color[:r] + 4*BEVEL_CONSTANT, g: color[:g] + 4*BEVEL_CONSTANT, b: color[:b] + 4*BEVEL_CONSTANT}
|
6305
|
+
block[:right_bevel_edge].fill = {r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT}
|
6306
|
+
block[:bottom_bevel_edge].fill = {r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT}
|
6307
|
+
block[:left_bevel_edge].fill = {r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT}
|
6308
|
+
block[:border_square].stroke = new_color == Model::Block::COLOR_CLEAR ? COLOR_GRAY : color
|
6309
|
+
end
|
6310
|
+
end.observe(@game.playfield[row][column], :color)
|
6311
|
+
end
|
6312
|
+
end
|
6313
|
+
end
|
6314
|
+
|
6315
|
+
def playfield(playfield_width: , playfield_height: , block_size: )
|
6316
|
+
@blocks = []
|
6317
|
+
vertical_box {
|
6318
|
+
padded false
|
6319
|
+
|
6320
|
+
playfield_height.times.map do |row|
|
6321
|
+
@blocks << []
|
6322
|
+
horizontal_box {
|
6323
|
+
padded false
|
6324
|
+
|
6325
|
+
playfield_width.times.map do |column|
|
6326
|
+
@blocks.last << block(row: row, column: column, block_size: block_size)
|
6327
|
+
end
|
6328
|
+
}
|
6329
|
+
end
|
6330
|
+
}
|
6331
|
+
end
|
6332
|
+
|
6333
|
+
def block(row: , column: , block_size: )
|
6334
|
+
block = {}
|
6335
|
+
bevel_pixel_size = 0.16 * block_size.to_f
|
6336
|
+
color = Glimmer::LibUI.interpret_color(Model::Block::COLOR_CLEAR)
|
6337
|
+
area {
|
6338
|
+
block[:background_square] = path {
|
6339
|
+
square(0, 0, block_size)
|
6340
|
+
|
6341
|
+
fill color
|
6342
|
+
}
|
6343
|
+
block[:top_bevel_edge] = path {
|
6344
|
+
polygon(0, 0, block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size)
|
6345
|
+
|
6346
|
+
fill r: color[:r] + 4*BEVEL_CONSTANT, g: color[:g] + 4*BEVEL_CONSTANT, b: color[:b] + 4*BEVEL_CONSTANT
|
6347
|
+
}
|
6348
|
+
block[:right_bevel_edge] = path {
|
6349
|
+
polygon(block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size, block_size)
|
6350
|
+
|
6351
|
+
fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
|
6352
|
+
}
|
6353
|
+
block[:bottom_bevel_edge] = path {
|
6354
|
+
polygon(block_size, block_size, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size)
|
6355
|
+
|
6356
|
+
fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
|
6357
|
+
}
|
6358
|
+
block[:left_bevel_edge] = path {
|
6359
|
+
polygon(0, 0, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size)
|
6360
|
+
|
6361
|
+
fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
|
6362
|
+
}
|
6363
|
+
block[:border_square] = path {
|
6364
|
+
square(0, 0, block_size)
|
6365
|
+
|
6366
|
+
stroke COLOR_GRAY
|
6367
|
+
}
|
6368
|
+
|
6369
|
+
on_key_down do |key_event|
|
6370
|
+
case key_event
|
6371
|
+
in ext_key: :down
|
6372
|
+
game.down!
|
6373
|
+
in ext_key: :up
|
6374
|
+
case game.up_arrow_action
|
6375
|
+
when :instant_down
|
6376
|
+
game.down!(instant: true)
|
6377
|
+
when :rotate_right
|
6378
|
+
game.rotate!(:right)
|
6379
|
+
when :rotate_left
|
6380
|
+
game.rotate!(:left)
|
6381
|
+
end
|
6382
|
+
in ext_key: :left
|
6383
|
+
game.left!
|
6384
|
+
in ext_key: :right
|
6385
|
+
game.right!
|
6386
|
+
in modifier: :shift
|
6387
|
+
game.rotate!(:right)
|
6388
|
+
in modifier: :control
|
6389
|
+
game.rotate!(:left)
|
6390
|
+
else
|
6391
|
+
# Do Nothing
|
6392
|
+
end
|
6393
|
+
end
|
6394
|
+
}
|
6395
|
+
block
|
6396
|
+
end
|
6397
|
+
|
6398
|
+
def start_moving_tetrominos_down
|
6399
|
+
Glimmer::LibUI.timer(@game.delay) do
|
6400
|
+
@game.down! if !@game.game_over? && !@game.paused?
|
6401
|
+
end
|
6402
|
+
end
|
6403
|
+
|
6404
|
+
def show_game_over_dialog
|
6405
|
+
Glimmer::LibUI.queue_main do
|
6406
|
+
msg_box('Game Over', "Score: #{@game.high_scores.first.score}\nLines: #{@game.high_scores.first.lines}\nLevel: #{@game.high_scores.first.level}")
|
6407
|
+
@game.restart!
|
6408
|
+
end
|
6409
|
+
end
|
6410
|
+
end
|
6411
|
+
|
6412
|
+
Tetris.new.launch
|
6413
|
+
```
|
6414
|
+
|
6012
6415
|
## Applications
|
6013
6416
|
|
6014
6417
|
Here are some applications built with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui)
|
@@ -6029,38 +6432,30 @@ https://github.com/AndyObtiva/befunge98/tree/gui
|
|
6029
6432
|
|
6030
6433
|

|
6031
6434
|
|
6032
|
-
|
6435
|
+
### i3off Gtk Ruby
|
6033
6436
|
|
6034
|
-
-
|
6035
|
-
|
6036
|
-
|
6037
|
-
|
6038
|
-
|
6039
|
-
|
6040
|
-
|
6041
|
-
|
6042
|
-
|
6043
|
-
-
|
6044
|
-
|
6045
|
-
is fine, but please isolate to its own commit so I can cherry-pick
|
6046
|
-
around it.
|
6437
|
+
https://github.com/iraamaro/i3off-gtk-ruby
|
6438
|
+
|
6439
|
+
## Process
|
6440
|
+
|
6441
|
+
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
6442
|
+
|
6443
|
+
## Resources
|
6444
|
+
|
6445
|
+
- [libui C Library](https://github.com/andlabs/libui)
|
6446
|
+
- [LibUI Ruby Bindings](https://github.com/kojix2/LibUI)
|
6447
|
+
- [Code Master Blog](https://andymaleh.blogspot.com/search/label/LibUI)
|
6047
6448
|
|
6048
6449
|
## Help
|
6049
6450
|
|
6050
6451
|
### Issues
|
6051
6452
|
|
6052
|
-
|
6053
|
-
|
6054
|
-
[Click here to submit an issue.](https://github.com/AndyObtiva/glimmer/issues)
|
6453
|
+
If you encounter [issues](https://github.com/AndyObtiva/glimmer-dsl-libui/issues) that are not reported, discover missing features that are not mentioned in [TODO.md](TODO.md), or think up better ways to use [libui](https://github.com/andlabs/libui) than what is possible with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui), you may submit an [issue](https://github.com/AndyObtiva/glimmer-dsl-libui/issues/new) or [pull request](https://github.com/AndyObtiva/glimmer-dsl-libui/compare) on [GitHub](https://github.com).
|
6055
6454
|
|
6056
6455
|
### Chat
|
6057
6456
|
|
6058
6457
|
If you need live help, try to [](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
6059
6458
|
|
6060
|
-
## Process
|
6061
|
-
|
6062
|
-
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
6063
|
-
|
6064
6459
|
## Planned Features and Feature Suggestions
|
6065
6460
|
|
6066
6461
|
These features have been planned or suggested. You might see them in a future version of [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui). You are welcome to contribute more feature suggestions.
|
@@ -6071,6 +6466,22 @@ These features have been planned or suggested. You might see them in a future ve
|
|
6071
6466
|
|
6072
6467
|
[CHANGELOG.md](CHANGELOG.md)
|
6073
6468
|
|
6469
|
+
## Contributing
|
6470
|
+
|
6471
|
+
- Check out the latest master to make sure the feature hasn't been
|
6472
|
+
implemented or the bug hasn't been fixed yet.
|
6473
|
+
- Check out the issue tracker to make sure someone already hasn't
|
6474
|
+
requested it and/or contributed it.
|
6475
|
+
- Fork the project.
|
6476
|
+
- Start a feature/bugfix branch.
|
6477
|
+
- Commit and push until you are happy with your contribution.
|
6478
|
+
- Make sure to add tests for it. This is important so I don't break it
|
6479
|
+
in a future version unintentionally.
|
6480
|
+
- Please try not to mess with the Rakefile, version, or history. If
|
6481
|
+
you want to have your own version, or is otherwise necessary, that
|
6482
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
6483
|
+
around it.
|
6484
|
+
|
6074
6485
|
## Contributors
|
6075
6486
|
|
6076
6487
|
* [Andy Maleh](https://github.com/AndyObtiva) (Founder)
|