glimmer-dsl-libui 0.2.13 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +562 -197
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/examples/area_gallery.rb +13 -15
- data/examples/area_gallery2.rb +22 -24
- data/examples/area_gallery3.rb +13 -15
- data/examples/area_gallery4.rb +22 -24
- data/examples/basic_transform.rb +8 -2
- data/examples/color_button.rb +1 -1
- data/examples/{color_the_shapes.rb → color_the_circles.rb} +48 -47
- data/examples/meta_example.rb +15 -9
- 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 +124 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/control_expression.rb +2 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +37 -4
- data/lib/glimmer/libui/control_proxy.rb +17 -2
- data/lib/glimmer/libui/shape/arc.rb +5 -1
- data/lib/glimmer/libui/shape/circle.rb +5 -1
- data/lib/glimmer/libui.rb +2 -2
- metadata +11 -6
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.17
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
@@ -9,13 +9,11 @@
|
|
9
9
|
|
10
10
|
The main trade-off in using [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) as opposed to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) or [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) is the fact that [SWT](https://www.eclipse.org/swt/) and [Tk](https://www.tcl.tk/) are more mature than mid-alpha [libui](https://github.com/andlabs/libui) as GUI toolkits. Still, if there is only a need to build a small simple application, [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) could be a good convenient choice due to having zero prerequisites beyond the dependencies included in the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui). Also, just like [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk), its apps start instantly and have a small memory footprint. [LibUI](https://github.com/kojix2/LibUI) is a promising new GUI toolkit that might prove quite worthy in the future.
|
11
11
|
|
12
|
-
**(Note: although LibUI works on Windows, this project has not been tested on Windows yet. It has only been verified on Mac x64 and Linux x64. Issue reporting for Windows is appreciated in the meantime.)**
|
13
|
-
|
14
12
|
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
|
15
13
|
- Declarative DSL syntax that visually maps to the GUI control hierarchy
|
16
14
|
- Convention over configuration via smart defaults and automation of low-level details
|
17
15
|
- Requiring the least amount of syntax possible to build GUI
|
18
|
-
- Custom
|
16
|
+
- Custom Keyword support
|
19
17
|
- [Far Future Plan] Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models
|
20
18
|
- [Far Future Plan] Scaffolding for new custom controls, apps, and gems
|
21
19
|
- [Far Future Plan] Native-Executable packaging on Mac, Windows, and Linux.
|
@@ -30,7 +28,16 @@ include Glimmer
|
|
30
28
|
window('hello world').show
|
31
29
|
```
|
32
30
|
|
31
|
+
Mac
|
32
|
+
|
33
33
|
![glimmer-dsl-libui-mac-basic-window.png](images/glimmer-dsl-libui-mac-basic-window.png)
|
34
|
+
|
35
|
+
Windows
|
36
|
+
|
37
|
+
![glimmer-dsl-libui-windows-basic-window.png](images/glimmer-dsl-libui-windows-basic-window.png)
|
38
|
+
|
39
|
+
Linux
|
40
|
+
|
34
41
|
![glimmer-dsl-libui-linux-basic-window.png](images/glimmer-dsl-libui-linux-basic-window.png)
|
35
42
|
|
36
43
|
Basic Table Progress Bar
|
@@ -70,7 +77,16 @@ window('Task Progress', 300, 200) {
|
|
70
77
|
}.show
|
71
78
|
```
|
72
79
|
|
80
|
+
Mac
|
81
|
+
|
73
82
|
![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png)
|
83
|
+
|
84
|
+
Windows
|
85
|
+
|
86
|
+
![glimmer-dsl-libui-windows-basic-table-progress-bar.png](images/glimmer-dsl-libui-windows-basic-table-progress-bar.png)
|
87
|
+
|
88
|
+
Linux
|
89
|
+
|
74
90
|
![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
|
75
91
|
|
76
92
|
Area Gallery
|
@@ -119,21 +135,19 @@ window('Area Gallery', 400, 400) {
|
|
119
135
|
fill r: 202, g: 102, b: 204, a: 0.5
|
120
136
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
121
137
|
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
}
|
136
|
-
end
|
138
|
+
path { # declarative stable path
|
139
|
+
arc(400, 220, 180, 90, 90, false)
|
140
|
+
|
141
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
142
|
+
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}]
|
143
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
144
|
+
}
|
145
|
+
path { # declarative stable path
|
146
|
+
circle(200, 200, 90)
|
147
|
+
|
148
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
149
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
150
|
+
}
|
137
151
|
text(160, 40, 100) { # x, y, width
|
138
152
|
string('Area Gallery') {
|
139
153
|
font family: 'Times', size: 14
|
@@ -192,7 +206,16 @@ window('Area Gallery', 400, 400) {
|
|
192
206
|
}.show
|
193
207
|
```
|
194
208
|
|
209
|
+
Mac
|
210
|
+
|
195
211
|
![glimmer-dsl-libui-mac-area-gallery.png](images/glimmer-dsl-libui-mac-area-gallery.png)
|
212
|
+
|
213
|
+
Windows
|
214
|
+
|
215
|
+
![glimmer-dsl-libui-windows-area-gallery.png](images/glimmer-dsl-libui-windows-area-gallery.png)
|
216
|
+
|
217
|
+
Linux
|
218
|
+
|
196
219
|
![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
197
220
|
|
198
221
|
[Check Out Many More Examples Over Here!](#examples)
|
@@ -213,7 +236,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
213
236
|
- [Usage](#usage)
|
214
237
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
215
238
|
- [API](#api)
|
216
|
-
- [Supported
|
239
|
+
- [Supported Keywords](#supported-keywords)
|
217
240
|
- [Common Control Properties](#common-control-properties)
|
218
241
|
- [Common Control Operations](#common-control-operations)
|
219
242
|
- [LibUI Operations](#libui-operations)
|
@@ -257,17 +280,23 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
257
280
|
- [Basic Transform](#basic-transform)
|
258
281
|
- [Login](#login)
|
259
282
|
- [Timer](#timer)
|
260
|
-
- [Color The
|
283
|
+
- [Color The Circles](#color-the-circles)
|
261
284
|
- [Basic Draw Text](#basic-draw-text)
|
262
285
|
- [Custom Draw Text](#custom-draw-text)
|
263
286
|
- [Method-Based Custom Keyword](#method-based-custom-keyword)
|
264
|
-
|
287
|
+
- [Tetris](#tetris)
|
288
|
+
- [Applications](#applications)
|
289
|
+
- [Manga2PDF](#manga2pdf)
|
290
|
+
- [Befunge98 GUI](#befunge98-gui)
|
291
|
+
- [i3off Gtk Ruby](#i3off-gtk-ruby)
|
292
|
+
- [Process](#process)
|
293
|
+
- [Resources](#resources)
|
265
294
|
- [Help](#help)
|
266
295
|
- [Issues](#issues)
|
267
296
|
- [Chat](#chat)
|
268
|
-
- [Process](#process)
|
269
297
|
- [Planned Features and Feature Suggestions](#planned-features-and-feature-suggestions)
|
270
298
|
- [Change Log](#change-log)
|
299
|
+
- [Contributing](#contributing)
|
271
300
|
- [Contributors](#contributors)
|
272
301
|
- [License](#license)
|
273
302
|
|
@@ -281,10 +310,10 @@ The Glimmer GUI DSL provides object-oriented declarative hierarchical syntax for
|
|
281
310
|
- Requires the minimum amount of syntax needed to describe an app's GUI
|
282
311
|
|
283
312
|
The Glimmer GUI DSL follows these simple concepts in mapping from [LibUI](https://github.com/kojix2/LibUI) syntax:
|
284
|
-
- **
|
285
|
-
- **Content
|
286
|
-
- **Property**: Control properties may be declared inside keyword blocks with lower-case underscored name followed by property value args (e.g. `title "hello world"` inside `group`). Behind the scenes, properties correspond to `control_set_property` methods.
|
287
|
-
- **Listener**: Control listeners may be declared inside keyword blocks with listener lower-case underscored name beginning with `on_` and receiving required block handler (e.g. `on_clicked {puts 'clicked'}` inside `button`). Behind the scenes, listeners correspond to `control_on_event` methods.
|
313
|
+
- **Keyword(args)**: [LibUI](https://github.com/kojix2/LibUI) controls may be declared by lower-case underscored name (aka keyword) (e.g. `window` or `button`). Behind the scenes, they are represented by keyword methods that map to corresponding `LibUI.new_keyword` methods receiving args (e.g. `window('hello world', 300, 200, true)`).
|
314
|
+
- **Content Block** (Properties/Listeners/Controls): Any keyword may be optionally followed by a Ruby curly-brace multi-line content block containing properties (attributes), listeners, and/or nested controls (e.g. `window {title 'hello world'; on_closing {puts 'Bye'}; button('greet')}`). Content block optionally receives one arg representing the control (e.g. `button('greet') {|b| on_clicked { puts b.text}}`)
|
315
|
+
- **Property**: Control properties may be declared inside keyword blocks with lower-case underscored name followed by property value args (e.g. `title "hello world"` inside `group`). Behind the scenes, properties correspond to `LibUI.control_set_property` methods.
|
316
|
+
- **Listener**: Control listeners may be declared inside keyword blocks with listener lower-case underscored name beginning with `on_` and receiving required block handler (e.g. `on_clicked {puts 'clicked'}` inside `button`). Optionally, the listener block can receive an arg representing the control (e.g. `on_clicked {|btn| puts btn.text}`). Behind the scenes, listeners correspond to `LibUI.control_on_event` methods.
|
288
317
|
|
289
318
|
Example of an app written in [LibUI](https://github.com/kojix2/LibUI)'s procedural imperative syntax:
|
290
319
|
|
@@ -348,7 +377,7 @@ gem install glimmer-dsl-libui
|
|
348
377
|
Or install via Bundler `Gemfile`:
|
349
378
|
|
350
379
|
```ruby
|
351
|
-
gem 'glimmer-dsl-libui', '~> 0.2.
|
380
|
+
gem 'glimmer-dsl-libui', '~> 0.2.17'
|
352
381
|
```
|
353
382
|
|
354
383
|
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.
|
@@ -408,7 +437,7 @@ w.set_title 'aloha'
|
|
408
437
|
puts w.title # => aloha
|
409
438
|
```
|
410
439
|
|
411
|
-
Controls are wrapped as Ruby proxy objects, having a `#libui` method to obtain the wrapped Fiddle pointer object. Ruby proxy objects rely on composition (via [Proxy Design Pattern](https://en.wikipedia.org/wiki/Proxy_pattern)) instead of inheritance to shield consumers from having to deal with lower-level details unless absolutely needed.
|
440
|
+
Controls are wrapped as Ruby proxy objects, having a `#libui` method to obtain the wrapped [LibUI](https://github.com/kojix2/LibUI) Fiddle pointer object. Ruby proxy objects rely on composition (via [Proxy Design Pattern](https://en.wikipedia.org/wiki/Proxy_pattern)) instead of inheritance to shield consumers from having to deal with lower-level details unless absolutely needed.
|
412
441
|
|
413
442
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
414
443
|
|
@@ -417,9 +446,11 @@ w = window('hello world') # => #<Glimmer::LibUI::WindowProxy:0x00007fde4ea39fb0
|
|
417
446
|
w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0 free=0x0000000000000000>
|
418
447
|
```
|
419
448
|
|
420
|
-
### Supported
|
449
|
+
### Supported Keywords
|
450
|
+
|
451
|
+
These are all the supported keywords. Note that some keywords do not represent controls, but produce objects that are used as the property values of controls (e.g. `image` builds objects to use in `cell_rows` for a `table` with an image column)
|
421
452
|
|
422
|
-
|
453
|
+
Keyword(Args) | Properties | Listeners
|
423
454
|
------------- | ---------- | ---------
|
424
455
|
`about_menu_item` | None | `on_clicked`
|
425
456
|
`area` | None | `on_draw(area_draw_params)`, `on_mouse_event(area_mouse_event)`, `on_mouse_down(area_mouse_event)`, `on_mouse_up(area_mouse_event)`, `on_mouse_drag_started(area_mouse_event)`, `on_mouse_dragged(area_mouse_event)`, `on_mouse_dropped(area_mouse_event)`, `on_mouse_entered`, `on_mouse_exited`, `on_key_event(area_key_event)`, `on_key_down(area_key_event)`, `on_key_up(area_key_event)`
|
@@ -455,6 +486,8 @@ Control(Args) | Properties | Listeners
|
|
455
486
|
`matrix(m11 = nil as Numeric, m12 = nil as Numeric, m21 = nil as Numeric, m22 = nil as Numeric, m31 = nil as Numeric, m32 = nil as Numeric)` | `m11` (`Numeric`), `m12` (`Numeric`), `m21` (`Numeric`), `m22` (`Numeric`), `m31` (`Numeric`), `m32` (`Numeric`) | None
|
456
487
|
`menu(text as String)` | None | None
|
457
488
|
`menu_item(text as String)` | `checked` (Boolean) | `on_clicked`
|
489
|
+
`message_box` (alias for `msg_box`; see for arguments) | None | None
|
490
|
+
`message_box_error` (alias for `msg_box_error`; see for arguments) | None | None
|
458
491
|
`multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
459
492
|
`msg_box(window = main_window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
460
493
|
`msg_box_error(window = main_window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
@@ -516,8 +549,8 @@ All operations that could normally be called on `LibUI` can also be called on `G
|
|
516
549
|
|
517
550
|
### Extra Dialogs
|
518
551
|
|
519
|
-
- `open_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
|
520
|
-
- `save_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
|
552
|
+
- `open_file(window as Glimmer::LibUI::WindowProxy = ControlProxy::main_window_proxy)`: returns selected file (`String`) or `nil` if cancelled
|
553
|
+
- `save_file(window as Glimmer::LibUI::WindowProxy = ControlProxy::main_window_proxy)`: returns selected file (`String`) or `nil` if cancelled
|
521
554
|
|
522
555
|
### Extra Operations
|
523
556
|
|
@@ -530,13 +563,13 @@ All operations that could normally be called on `LibUI` can also be called on `G
|
|
530
563
|
|
531
564
|
### Table API
|
532
565
|
|
533
|
-
The `table` control must first declare its columns via one of these column keywords (mentioned in [Supported
|
566
|
+
The `table` control must first declare its columns via one of these column keywords (mentioned in [Supported Keywords](#supported-keywords)):
|
534
567
|
- `background_color_column`: expects color cell values
|
535
568
|
- `button_column`: expects `String` cell values
|
536
569
|
- `checkbox_column`: expects Boolean cell values
|
537
570
|
- `checkbox_text_column`: expects dual-element `Array` of Boolean and `String` cell values
|
538
571
|
- `checkbox_text_color_column`: expects triple-element `Array` of Boolean, `String`, and color cell values
|
539
|
-
- `image_column`: expects `image` cell values (produced by `image` and `image_part` keywords as per [Supported
|
572
|
+
- `image_column`: expects `image` cell values (produced by `image` and `image_part` keywords as per [Supported Keywords](#supported-keywords))
|
540
573
|
- `image_text_column`: expects dual-element `Array` of `image` and `String` cell values
|
541
574
|
- `image_text_color_column`: expects triple-element `Array` of `image`, `String`, and color cell values
|
542
575
|
- `text_column`: expects `String` cell values
|
@@ -598,6 +631,7 @@ window('Contacts', 600, 600) { |w|
|
|
598
631
|
msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
599
632
|
else
|
600
633
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
634
|
+
@unfiltered_data = data.dup
|
601
635
|
@name_entry.text = ''
|
602
636
|
@email_entry.text = ''
|
603
637
|
@phone_entry.text = ''
|
@@ -607,6 +641,25 @@ window('Contacts', 600, 600) { |w|
|
|
607
641
|
end
|
608
642
|
}
|
609
643
|
|
644
|
+
search_entry { |se|
|
645
|
+
stretchy false
|
646
|
+
|
647
|
+
on_changed do
|
648
|
+
filter_value = se.text
|
649
|
+
@unfiltered_data ||= data.dup
|
650
|
+
# Unfilter first to remove any previous filters
|
651
|
+
data.replace(@unfiltered_data) # affects table indirectly through implicit data-binding
|
652
|
+
# Now, apply filter if entered
|
653
|
+
unless filter_value.empty?
|
654
|
+
data.filter! do |row_data| # affects table indirectly through implicit data-binding
|
655
|
+
row_data.any? do |cell|
|
656
|
+
cell.to_s.downcase.include?(filter_value.downcase)
|
657
|
+
end
|
658
|
+
end
|
659
|
+
end
|
660
|
+
end
|
661
|
+
}
|
662
|
+
|
610
663
|
table {
|
611
664
|
text_column('Name')
|
612
665
|
text_column('Email')
|
@@ -615,6 +668,10 @@ window('Contacts', 600, 600) { |w|
|
|
615
668
|
text_column('State')
|
616
669
|
|
617
670
|
cell_rows data # implicit data-binding
|
671
|
+
|
672
|
+
on_changed do |row, type, row_data|
|
673
|
+
puts "Row #{row} #{type}: #{row_data}"
|
674
|
+
end
|
618
675
|
}
|
619
676
|
}
|
620
677
|
}.show
|
@@ -627,8 +684,8 @@ Learn more by checking out [examples](#examples).
|
|
627
684
|
### Area API
|
628
685
|
|
629
686
|
The `area` control is a canvas-like control for drawing paths that can be used in one of two ways:
|
630
|
-
- Declaratively via stable paths: useful for stable paths that will not change later on. Simply nest `path` and figures like `rectangle` and all drawing logic is generated automatically. Path proxy objects are preserved across redraws assuming there would be few stable paths (mostly for decorative reasons).
|
631
|
-
- Semi-declaratively via on_draw listener dynamic paths: useful for more dynamic paths that will definitely change. Open an `on_draw` listener block that receives a `area_draw_params` argument and nest `path` and figures like `rectangle` and all drawing logic is generated automatically. Path proxy objects are destroyed (thrown-away) at the end of drawing, thus having less memory overhead for drawing thousands of dynamic paths.
|
687
|
+
- Declaratively via stable paths: useful for stable paths that will not change often later on. Simply nest `path` and figures like `rectangle` and all drawing logic is generated automatically. Path proxy objects are preserved across redraws assuming there would be relatively few stable paths (mostly for decorative reasons).
|
688
|
+
- Semi-declaratively via on_draw listener dynamic paths: useful for more dynamic paths that will definitely change very often. Open an `on_draw` listener block that receives a `area_draw_params` argument and nest `path` and figures like `rectangle` and all drawing logic is generated automatically. Path proxy objects are destroyed (thrown-away) at the end of drawing, thus having less memory overhead for drawing thousands of dynamic paths.
|
632
689
|
|
633
690
|
Here is an example of a declarative `area` with a stable path (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
634
691
|
|
@@ -892,6 +949,7 @@ window('area text drawing') {
|
|
892
949
|
- Table `cell_rows` data has implicit data-binding to table cell values for deletion, insertion, and change (done by diffing `cell_rows` value before and after change and auto-informing `table` of deletions [`LibUI.table_model_row_deleted`], insertions [`LibUI.table_model_row_deleted`], and changes [`LibUI.table_model_row_changed`]). When deleting data rows from `cell_rows` array, then actual rows from the `table` are automatically deleted. When inserting data rows into `cell_rows` array, then actual `table` rows are automatically inserted. When updating data rows in `cell_rows` array, then actual `table` rows are automatically updated.
|
893
950
|
- `image` instances are automatically freed from memory after `window` is destroyed.
|
894
951
|
- `image` `width` and `height` can be left off if it has one `image_part` only as they default to the same `width` and `height` of the `image_part`
|
952
|
+
- Automatically provide shifted `:key` characters in `area_key_event` provided in `area` key listeners `on_key_event`, `on_key_down`, and `on_key_up`
|
895
953
|
- `area` paths are specified declaratively with figures underneath (e.g. `rectangle`) and `area` draw listener is automatically generated
|
896
954
|
- Observe figure properties (e.g. `rectangle` `width`) for changes and automatically redraw containing area accordingly
|
897
955
|
- Observe `path` `fill` and `stroke` hashes for changes and automatically redraw containing area accordingly
|
@@ -1013,12 +1071,13 @@ window('Method-Based Custom Keyword') {
|
|
1013
1071
|
### API Gotchas
|
1014
1072
|
|
1015
1073
|
- There is no proper way to destroy `grid` children due to [libui](https://github.com/andlabs/libui) not offering any API for deleting them from `grid` (no `grid_delete` similar to `box_delete` for `horizontal_box` and `vertical_box`).
|
1016
|
-
- `table` `checkbox_column` and `checkbox_text_column` checkbox editing only works on
|
1074
|
+
- `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).
|
1017
1075
|
- `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)
|
1018
|
-
- `text` `string` `background` does not work on Windows due to an issue in
|
1019
|
-
- `arc` shape does not work on Windows due to an issue in [libui](https://github.com/andlabs/libui).
|
1076
|
+
- `text` `string` `background` does not work on Windows due to an [issue in libui](https://github.com/andlabs/libui/issues/347).
|
1020
1077
|
- `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.
|
1021
1078
|
- `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.
|
1079
|
+
- 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.
|
1080
|
+
- As per the code of [examples/basic_transform.rb](#basic-transform), Windows requires different ordering of transforms than Mac and Linux.
|
1022
1081
|
|
1023
1082
|
### Original API
|
1024
1083
|
|
@@ -1033,7 +1092,7 @@ I am documenting options for packaging, which I have not tried myself, but figur
|
|
1033
1092
|
|
1034
1093
|
For Windows, the [LibUI](https://github.com/kojix2/LibUI) project recommends [OCRA](https://github.com/larsch/ocra) (One-Click Ruby Application), which builds Windows executables from Ruby source.
|
1035
1094
|
|
1036
|
-
For Mac, consider [
|
1095
|
+
For Mac, consider [Platypus](https://github.com/sveinbjornt/Platypus) (builds a native Mac app from a Ruby script)
|
1037
1096
|
|
1038
1097
|
For Linux, simply package your app as a [Ruby Gem](https://guides.rubygems.org/what-is-a-gem/) and [build rpm package from Ruby Gem](https://www.redpill-linpro.com/sysadvent/2015/12/07/building-rpms-from-gems.html) or [build deb package from Ruby Gem](https://openpreservation.org/blogs/building-debian-package-ruby-program/).
|
1039
1098
|
|
@@ -1070,6 +1129,10 @@ Mac
|
|
1070
1129
|
|
1071
1130
|
![glimmer-dsl-libui-mac-meta-example.png](images/glimmer-dsl-libui-mac-meta-example.png)
|
1072
1131
|
|
1132
|
+
Windows
|
1133
|
+
|
1134
|
+
![glimmer-dsl-libui-windows-meta-example.png](images/glimmer-dsl-libui-windows-meta-example.png)
|
1135
|
+
|
1073
1136
|
Linux
|
1074
1137
|
|
1075
1138
|
![glimmer-dsl-libui-linux-meta-example.png](images/glimmer-dsl-libui-linux-meta-example.png)
|
@@ -1120,15 +1183,20 @@ class MetaExample
|
|
1120
1183
|
end
|
1121
1184
|
|
1122
1185
|
def run_example(example)
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1186
|
+
Thread.new do
|
1187
|
+
command = "ruby -r #{glimmer_dsl_libui_file} #{example} 2>&1"
|
1188
|
+
result = ''
|
1189
|
+
IO.popen(command) do |f|
|
1190
|
+
sleep(0.0001) # yield to main thread
|
1191
|
+
f.each_line do |line|
|
1192
|
+
result << line
|
1193
|
+
puts line
|
1194
|
+
$stdout.flush # for Windows
|
1195
|
+
sleep(0.0001) # yield to main thread
|
1196
|
+
end
|
1129
1197
|
end
|
1198
|
+
Glimmer::LibUI.queue_main { msg_box('Error Running Example', result) } if result.downcase.include?('error')
|
1130
1199
|
end
|
1131
|
-
msg_box('Error Running Example', result) if result.downcase.include?('error')
|
1132
1200
|
end
|
1133
1201
|
|
1134
1202
|
def launch
|
@@ -1229,6 +1297,10 @@ Mac
|
|
1229
1297
|
|
1230
1298
|
![glimmer-dsl-libui-mac-basic-window.png](images/glimmer-dsl-libui-mac-basic-window.png)
|
1231
1299
|
|
1300
|
+
Windows
|
1301
|
+
|
1302
|
+
![glimmer-dsl-libui-windows-basic-window.png](images/glimmer-dsl-libui-windows-basic-window.png)
|
1303
|
+
|
1232
1304
|
Linux
|
1233
1305
|
|
1234
1306
|
![glimmer-dsl-libui-linux-basic-window.png](images/glimmer-dsl-libui-linux-basic-window.png)
|
@@ -1309,6 +1381,11 @@ Mac
|
|
1309
1381
|
![glimmer-dsl-libui-mac-basic-button.png](images/glimmer-dsl-libui-mac-basic-button.png)
|
1310
1382
|
![glimmer-dsl-libui-mac-basic-button-msg-box.png](images/glimmer-dsl-libui-mac-basic-button-msg-box.png)
|
1311
1383
|
|
1384
|
+
Windows
|
1385
|
+
|
1386
|
+
![glimmer-dsl-libui-windows-basic-button.png](images/glimmer-dsl-libui-windows-basic-button.png)
|
1387
|
+
![glimmer-dsl-libui-windows-basic-button-msg-box.png](images/glimmer-dsl-libui-windows-basic-button-msg-box.png)
|
1388
|
+
|
1312
1389
|
Linux
|
1313
1390
|
|
1314
1391
|
![glimmer-dsl-libui-linux-basic-button.png](images/glimmer-dsl-libui-linux-basic-button.png)
|
@@ -1386,6 +1463,11 @@ Mac
|
|
1386
1463
|
![glimmer-dsl-libui-mac-basic-entry.png](images/glimmer-dsl-libui-mac-basic-entry.png)
|
1387
1464
|
![glimmer-dsl-libui-mac-basic-entry-msg-box.png](images/glimmer-dsl-libui-mac-basic-entry-msg-box.png)
|
1388
1465
|
|
1466
|
+
Windows
|
1467
|
+
|
1468
|
+
![glimmer-dsl-libui-windows-basic-entry.png](images/glimmer-dsl-libui-windows-basic-entry.png)
|
1469
|
+
![glimmer-dsl-libui-windows-basic-entry-msg-box.png](images/glimmer-dsl-libui-windows-basic-entry-msg-box.png)
|
1470
|
+
|
1389
1471
|
Linux
|
1390
1472
|
|
1391
1473
|
![glimmer-dsl-libui-linux-basic-entry.png](images/glimmer-dsl-libui-linux-basic-entry.png)
|
@@ -1486,6 +1568,10 @@ Mac
|
|
1486
1568
|
|
1487
1569
|
![glimmer-dsl-libui-mac-simple-notepad.png](images/glimmer-dsl-libui-mac-simple-notepad.png)
|
1488
1570
|
|
1571
|
+
Windows
|
1572
|
+
|
1573
|
+
![glimmer-dsl-libui-windows-simple-notepad.png](images/glimmer-dsl-libui-windows-simple-notepad.png)
|
1574
|
+
|
1489
1575
|
Linux
|
1490
1576
|
|
1491
1577
|
![glimmer-dsl-libui-linux-simple-notepad.png](images/glimmer-dsl-libui-linux-simple-notepad.png)
|
@@ -1559,6 +1645,11 @@ Mac
|
|
1559
1645
|
![glimmer-dsl-libui-mac-midi-player.png](images/glimmer-dsl-libui-mac-midi-player.png)
|
1560
1646
|
![glimmer-dsl-libui-mac-midi-player-msg-box.png](images/glimmer-dsl-libui-mac-midi-player-msg-box.png)
|
1561
1647
|
|
1648
|
+
Windows
|
1649
|
+
|
1650
|
+
![glimmer-dsl-libui-windows-midi-player.png](images/glimmer-dsl-libui-windows-midi-player.png)
|
1651
|
+
![glimmer-dsl-libui-windows-midi-player-msg-box.png](images/glimmer-dsl-libui-windows-midi-player-msg-box.png)
|
1652
|
+
|
1562
1653
|
Linux
|
1563
1654
|
|
1564
1655
|
![glimmer-dsl-libui-linux-midi-player.png](images/glimmer-dsl-libui-linux-midi-player.png)
|
@@ -1776,6 +1867,10 @@ Mac
|
|
1776
1867
|
|
1777
1868
|
![glimmer-dsl-libui-mac-control-gallery.png](images/glimmer-dsl-libui-mac-control-gallery.png)
|
1778
1869
|
|
1870
|
+
Windows
|
1871
|
+
|
1872
|
+
![glimmer-dsl-libui-windows-control-gallery.png](images/glimmer-dsl-libui-windows-control-gallery.png)
|
1873
|
+
|
1779
1874
|
Linux
|
1780
1875
|
|
1781
1876
|
![glimmer-dsl-libui-linux-control-gallery.png](images/glimmer-dsl-libui-linux-control-gallery.png)
|
@@ -2167,6 +2262,11 @@ Mac
|
|
2167
2262
|
![glimmer-dsl-libui-mac-font-button.png](images/glimmer-dsl-libui-mac-font-button.png)
|
2168
2263
|
![glimmer-dsl-libui-mac-font-button-selection.png](images/glimmer-dsl-libui-mac-font-button-selection.png)
|
2169
2264
|
|
2265
|
+
Windows
|
2266
|
+
|
2267
|
+
![glimmer-dsl-libui-windows-font-button.png](images/glimmer-dsl-libui-windows-font-button.png)
|
2268
|
+
![glimmer-dsl-libui-windows-font-button-selection.png](images/glimmer-dsl-libui-windows-font-button-selection.png)
|
2269
|
+
|
2170
2270
|
Linux
|
2171
2271
|
|
2172
2272
|
![glimmer-dsl-libui-linux-font-button.png](images/glimmer-dsl-libui-linux-font-button.png)
|
@@ -2251,6 +2351,11 @@ Mac
|
|
2251
2351
|
![glimmer-dsl-libui-mac-color-button.png](images/glimmer-dsl-libui-mac-color-button.png)
|
2252
2352
|
![glimmer-dsl-libui-mac-color-button-selection.png](images/glimmer-dsl-libui-mac-color-button-selection.png)
|
2253
2353
|
|
2354
|
+
Windows
|
2355
|
+
|
2356
|
+
![glimmer-dsl-libui-windows-color-button.png](images/glimmer-dsl-libui-windows-color-button.png)
|
2357
|
+
![glimmer-dsl-libui-windows-color-button-selection.png](images/glimmer-dsl-libui-windows-color-button-selection.png)
|
2358
|
+
|
2254
2359
|
Linux
|
2255
2360
|
|
2256
2361
|
![glimmer-dsl-libui-linux-color-button.png](images/glimmer-dsl-libui-linux-color-button.png)
|
@@ -2263,7 +2368,7 @@ require 'glimmer-dsl-libui'
|
|
2263
2368
|
|
2264
2369
|
include Glimmer
|
2265
2370
|
|
2266
|
-
window('color button',
|
2371
|
+
window('color button', 240) {
|
2267
2372
|
color_button { |cb|
|
2268
2373
|
color :blue
|
2269
2374
|
|
@@ -2295,6 +2400,10 @@ Mac
|
|
2295
2400
|
|
2296
2401
|
![glimmer-dsl-libui-mac-date-time-picker.png](images/glimmer-dsl-libui-mac-date-time-picker.png)
|
2297
2402
|
|
2403
|
+
Windows
|
2404
|
+
|
2405
|
+
![glimmer-dsl-libui-windows-date-time-picker.png](images/glimmer-dsl-libui-windows-date-time-picker.png)
|
2406
|
+
|
2298
2407
|
Linux
|
2299
2408
|
|
2300
2409
|
![glimmer-dsl-libui-linux-date-time-picker.png](images/glimmer-dsl-libui-linux-date-time-picker.png)
|
@@ -2387,6 +2496,12 @@ Mac
|
|
2387
2496
|
![glimmer-dsl-libui-mac-grid-expand.png](images/glimmer-dsl-libui-mac-grid-expand.png)
|
2388
2497
|
![glimmer-dsl-libui-mac-grid-align.png](images/glimmer-dsl-libui-mac-grid-align.png)
|
2389
2498
|
|
2499
|
+
Windows
|
2500
|
+
|
2501
|
+
![glimmer-dsl-libui-windows-grid-span.png](images/glimmer-dsl-libui-windows-grid-span.png)
|
2502
|
+
![glimmer-dsl-libui-windows-grid-expand.png](images/glimmer-dsl-libui-windows-grid-expand.png)
|
2503
|
+
![glimmer-dsl-libui-windows-grid-align.png](images/glimmer-dsl-libui-windows-grid-align.png)
|
2504
|
+
|
2390
2505
|
Linux
|
2391
2506
|
|
2392
2507
|
![glimmer-dsl-libui-linux-grid-span.png](images/glimmer-dsl-libui-linux-grid-span.png)
|
@@ -2525,6 +2640,11 @@ Mac
|
|
2525
2640
|
![glimmer-dsl-libui-mac-form.png](images/glimmer-dsl-libui-mac-form.png)
|
2526
2641
|
![glimmer-dsl-libui-mac-form-msg-box.png](images/glimmer-dsl-libui-mac-form-msg-box.png)
|
2527
2642
|
|
2643
|
+
Windows
|
2644
|
+
|
2645
|
+
![glimmer-dsl-libui-windows-form.png](images/glimmer-dsl-libui-windows-form.png)
|
2646
|
+
![glimmer-dsl-libui-windows-form-msg-box.png](images/glimmer-dsl-libui-windows-form-msg-box.png)
|
2647
|
+
|
2528
2648
|
Linux
|
2529
2649
|
|
2530
2650
|
![glimmer-dsl-libui-linux-form.png](images/glimmer-dsl-libui-linux-form.png)
|
@@ -2590,6 +2710,10 @@ Mac
|
|
2590
2710
|
|
2591
2711
|
![glimmer-dsl-libui-mac-basic-table.png](images/glimmer-dsl-libui-mac-basic-table.png)
|
2592
2712
|
|
2713
|
+
Windows
|
2714
|
+
|
2715
|
+
![glimmer-dsl-libui-windows-basic-table.png](images/glimmer-dsl-libui-windows-basic-table.png)
|
2716
|
+
|
2593
2717
|
Linux
|
2594
2718
|
|
2595
2719
|
![glimmer-dsl-libui-linux-basic-table.png](images/glimmer-dsl-libui-linux-basic-table.png)
|
@@ -2712,6 +2836,12 @@ Mac
|
|
2712
2836
|
![glimmer-dsl-libui-mac-editable-table-editing.png](images/glimmer-dsl-libui-mac-editable-table-editing.png)
|
2713
2837
|
![glimmer-dsl-libui-mac-editable-table-edited.png](images/glimmer-dsl-libui-mac-editable-table-edited.png)
|
2714
2838
|
|
2839
|
+
Windows
|
2840
|
+
|
2841
|
+
![glimmer-dsl-libui-windows-editable-table.png](images/glimmer-dsl-libui-windows-editable-table.png)
|
2842
|
+
![glimmer-dsl-libui-windows-editable-table-editing.png](images/glimmer-dsl-libui-windows-editable-table-editing.png)
|
2843
|
+
![glimmer-dsl-libui-windows-editable-table-edited.png](images/glimmer-dsl-libui-windows-editable-table-edited.png)
|
2844
|
+
|
2715
2845
|
Linux
|
2716
2846
|
|
2717
2847
|
![glimmer-dsl-libui-linux-editable-table.png](images/glimmer-dsl-libui-linux-editable-table.png)
|
@@ -2779,6 +2909,11 @@ Mac
|
|
2779
2909
|
![glimmer-dsl-libui-mac-editable-column-table-editing.png](images/glimmer-dsl-libui-mac-editable-column-table-editing.png)
|
2780
2910
|
![glimmer-dsl-libui-mac-editable-column-table-edited.png](images/glimmer-dsl-libui-mac-editable-column-table-edited.png)
|
2781
2911
|
|
2912
|
+
Windows
|
2913
|
+
|
2914
|
+
![glimmer-dsl-libui-windows-editable-column-table-editing.png](images/glimmer-dsl-libui-windows-editable-column-table-editing.png)
|
2915
|
+
![glimmer-dsl-libui-windows-editable-column-table-edited.png](images/glimmer-dsl-libui-windows-editable-column-table-edited.png)
|
2916
|
+
|
2782
2917
|
Linux
|
2783
2918
|
|
2784
2919
|
![glimmer-dsl-libui-linux-editable-column-table-editing.png](images/glimmer-dsl-libui-linux-editable-column-table-editing.png)
|
@@ -2846,6 +2981,10 @@ Mac
|
|
2846
2981
|
|
2847
2982
|
![glimmer-dsl-libui-mac-basic-table-image.png](images/glimmer-dsl-libui-mac-basic-table-image.png)
|
2848
2983
|
|
2984
|
+
Windows
|
2985
|
+
|
2986
|
+
![glimmer-dsl-libui-windows-basic-table-image.png](images/glimmer-dsl-libui-windows-basic-table-image.png)
|
2987
|
+
|
2849
2988
|
Linux
|
2850
2989
|
|
2851
2990
|
![glimmer-dsl-libui-linux-basic-table-image.png](images/glimmer-dsl-libui-linux-basic-table-image.png)
|
@@ -3004,6 +3143,10 @@ Mac
|
|
3004
3143
|
|
3005
3144
|
![glimmer-dsl-libui-mac-basic-table-image-text.png](images/glimmer-dsl-libui-mac-basic-table-image-text.png)
|
3006
3145
|
|
3146
|
+
Windows
|
3147
|
+
|
3148
|
+
![glimmer-dsl-libui-windows-basic-table-image-text.png](images/glimmer-dsl-libui-windows-basic-table-image-text.png)
|
3149
|
+
|
3007
3150
|
Linux
|
3008
3151
|
|
3009
3152
|
![glimmer-dsl-libui-linux-basic-table-image-text.png](images/glimmer-dsl-libui-linux-basic-table-image-text.png)
|
@@ -3075,6 +3218,11 @@ Mac
|
|
3075
3218
|
![glimmer-dsl-libui-mac-basic-table-button.png](images/glimmer-dsl-libui-mac-basic-table-button.png)
|
3076
3219
|
![glimmer-dsl-libui-mac-basic-table-button-deleted.png](images/glimmer-dsl-libui-mac-basic-table-button-deleted.png)
|
3077
3220
|
|
3221
|
+
Windows
|
3222
|
+
|
3223
|
+
![glimmer-dsl-libui-windows-basic-table-button.png](images/glimmer-dsl-libui-windows-basic-table-button.png)
|
3224
|
+
![glimmer-dsl-libui-windows-basic-table-button-deleted.png](images/glimmer-dsl-libui-windows-basic-table-button-deleted.png)
|
3225
|
+
|
3078
3226
|
Linux
|
3079
3227
|
|
3080
3228
|
![glimmer-dsl-libui-linux-basic-table-button.png](images/glimmer-dsl-libui-linux-basic-table-button.png)
|
@@ -3136,6 +3284,10 @@ Mac
|
|
3136
3284
|
|
3137
3285
|
![glimmer-dsl-libui-mac-basic-table-checkbox.png](images/glimmer-dsl-libui-mac-basic-table-checkbox.png)
|
3138
3286
|
|
3287
|
+
Windows
|
3288
|
+
|
3289
|
+
![glimmer-dsl-libui-windows-basic-table-checkbox.png](images/glimmer-dsl-libui-windows-basic-table-checkbox.png)
|
3290
|
+
|
3139
3291
|
Linux
|
3140
3292
|
|
3141
3293
|
![glimmer-dsl-libui-linux-basic-table-checkbox.png](images/glimmer-dsl-libui-linux-basic-table-checkbox.png)
|
@@ -3188,6 +3340,10 @@ Mac
|
|
3188
3340
|
|
3189
3341
|
![glimmer-dsl-libui-mac-basic-table-checkbox-text.png](images/glimmer-dsl-libui-mac-basic-table-checkbox-text.png)
|
3190
3342
|
|
3343
|
+
Windows
|
3344
|
+
|
3345
|
+
![glimmer-dsl-libui-windows-basic-table-checkbox-text.png](images/glimmer-dsl-libui-windows-basic-table-checkbox-text.png)
|
3346
|
+
|
3191
3347
|
Linux
|
3192
3348
|
|
3193
3349
|
![glimmer-dsl-libui-linux-basic-table-checkbox-text.png](images/glimmer-dsl-libui-linux-basic-table-checkbox-text.png)
|
@@ -3240,6 +3396,10 @@ Mac
|
|
3240
3396
|
|
3241
3397
|
![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png)
|
3242
3398
|
|
3399
|
+
Windows
|
3400
|
+
|
3401
|
+
![glimmer-dsl-libui-windows-basic-table-progress-bar.png](images/glimmer-dsl-libui-windows-basic-table-progress-bar.png)
|
3402
|
+
|
3243
3403
|
Linux
|
3244
3404
|
|
3245
3405
|
![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
|
@@ -3307,6 +3467,10 @@ Mac
|
|
3307
3467
|
|
3308
3468
|
![glimmer-dsl-libui-mac-basic-table-color.png](images/glimmer-dsl-libui-mac-basic-table-color.png)
|
3309
3469
|
|
3470
|
+
Windows
|
3471
|
+
|
3472
|
+
![glimmer-dsl-libui-windows-basic-table-color.png](images/glimmer-dsl-libui-windows-basic-table-color.png)
|
3473
|
+
|
3310
3474
|
Linux
|
3311
3475
|
|
3312
3476
|
![glimmer-dsl-libui-linux-basic-table-color.png](images/glimmer-dsl-libui-linux-basic-table-color.png)
|
@@ -3375,6 +3539,12 @@ Mac
|
|
3375
3539
|
![glimmer-dsl-libui-mac-form-table-contact-entered.png](images/glimmer-dsl-libui-mac-form-table-contact-entered.png)
|
3376
3540
|
![glimmer-dsl-libui-mac-form-table-filtered.png](images/glimmer-dsl-libui-mac-form-table-filtered.png)
|
3377
3541
|
|
3542
|
+
Windows
|
3543
|
+
|
3544
|
+
![glimmer-dsl-libui-windows-form-table.png](images/glimmer-dsl-libui-windows-form-table.png)
|
3545
|
+
![glimmer-dsl-libui-windows-form-table-contact-entered.png](images/glimmer-dsl-libui-windows-form-table-contact-entered.png)
|
3546
|
+
![glimmer-dsl-libui-windows-form-table-filtered.png](images/glimmer-dsl-libui-windows-form-table-filtered.png)
|
3547
|
+
|
3378
3548
|
Linux
|
3379
3549
|
|
3380
3550
|
![glimmer-dsl-libui-linux-form-table.png](images/glimmer-dsl-libui-linux-form-table.png)
|
@@ -3384,8 +3554,6 @@ Linux
|
|
3384
3554
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3385
3555
|
|
3386
3556
|
```ruby
|
3387
|
-
# frozen_string_literal: true
|
3388
|
-
|
3389
3557
|
require 'glimmer-dsl-libui'
|
3390
3558
|
|
3391
3559
|
include Glimmer
|
@@ -3497,6 +3665,10 @@ Mac
|
|
3497
3665
|
|
3498
3666
|
![glimmer-dsl-libui-mac-basic-area.png](images/glimmer-dsl-libui-mac-basic-area.png)
|
3499
3667
|
|
3668
|
+
Windows
|
3669
|
+
|
3670
|
+
![glimmer-dsl-libui-windows-basic-area.png](images/glimmer-dsl-libui-windows-basic-area.png)
|
3671
|
+
|
3500
3672
|
Linux
|
3501
3673
|
|
3502
3674
|
![glimmer-dsl-libui-linux-basic-area.png](images/glimmer-dsl-libui-linux-basic-area.png)
|
@@ -3620,6 +3792,11 @@ Mac
|
|
3620
3792
|
![glimmer-dsl-libui-mac-dynamic-area.png](images/glimmer-dsl-libui-mac-dynamic-area.png)
|
3621
3793
|
![glimmer-dsl-libui-mac-dynamic-area-updated.png](images/glimmer-dsl-libui-mac-dynamic-area-updated.png)
|
3622
3794
|
|
3795
|
+
Windows
|
3796
|
+
|
3797
|
+
![glimmer-dsl-libui-windows-dynamic-area.png](images/glimmer-dsl-libui-windows-dynamic-area.png)
|
3798
|
+
![glimmer-dsl-libui-windows-dynamic-area-updated.png](images/glimmer-dsl-libui-windows-dynamic-area-updated.png)
|
3799
|
+
|
3623
3800
|
Linux
|
3624
3801
|
|
3625
3802
|
![glimmer-dsl-libui-linux-dynamic-area.png](images/glimmer-dsl-libui-linux-dynamic-area.png)
|
@@ -3851,6 +4028,10 @@ Mac
|
|
3851
4028
|
|
3852
4029
|
![glimmer-dsl-libui-mac-area-gallery.png](images/glimmer-dsl-libui-mac-area-gallery.png)
|
3853
4030
|
|
4031
|
+
Windows
|
4032
|
+
|
4033
|
+
![glimmer-dsl-libui-windows-area-gallery.png](images/glimmer-dsl-libui-windows-area-gallery.png)
|
4034
|
+
|
3854
4035
|
Linux
|
3855
4036
|
|
3856
4037
|
![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
@@ -3901,21 +4082,19 @@ window('Area Gallery', 400, 400) {
|
|
3901
4082
|
fill r: 202, g: 102, b: 204, a: 0.5
|
3902
4083
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
3903
4084
|
}
|
3904
|
-
|
3905
|
-
|
3906
|
-
|
3907
|
-
|
3908
|
-
|
3909
|
-
|
3910
|
-
|
3911
|
-
|
3912
|
-
|
3913
|
-
|
3914
|
-
|
3915
|
-
|
3916
|
-
|
3917
|
-
}
|
3918
|
-
end
|
4085
|
+
path { # declarative stable path
|
4086
|
+
arc(400, 220, 180, 90, 90, false)
|
4087
|
+
|
4088
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4089
|
+
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}]
|
4090
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4091
|
+
}
|
4092
|
+
path { # declarative stable path
|
4093
|
+
circle(200, 200, 90)
|
4094
|
+
|
4095
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4096
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4097
|
+
}
|
3919
4098
|
text(160, 40, 100) { # x, y, width
|
3920
4099
|
string('Area Gallery') {
|
3921
4100
|
font family: 'Times', size: 14
|
@@ -4074,32 +4253,30 @@ window('Area Gallery', 400, 400) {
|
|
4074
4253
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4075
4254
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4076
4255
|
}
|
4077
|
-
|
4078
|
-
|
4079
|
-
|
4080
|
-
|
4081
|
-
|
4082
|
-
|
4083
|
-
|
4084
|
-
|
4085
|
-
is_negative false
|
4086
|
-
}
|
4087
|
-
|
4088
|
-
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4089
|
-
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}]
|
4090
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4256
|
+
path { # declarative stable path
|
4257
|
+
arc {
|
4258
|
+
x_center 400
|
4259
|
+
y_center 220
|
4260
|
+
radius 180
|
4261
|
+
start_angle 90
|
4262
|
+
sweep 90
|
4263
|
+
is_negative false
|
4091
4264
|
}
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4265
|
+
|
4266
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4267
|
+
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}]
|
4268
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4269
|
+
}
|
4270
|
+
path { # declarative stable path
|
4271
|
+
circle {
|
4272
|
+
x_center 200
|
4273
|
+
y_center 200
|
4274
|
+
radius 90
|
4101
4275
|
}
|
4102
|
-
|
4276
|
+
|
4277
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4278
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4279
|
+
}
|
4103
4280
|
text {
|
4104
4281
|
x 160
|
4105
4282
|
y 40
|
@@ -4211,21 +4388,19 @@ window('Area Gallery', 400, 400) {
|
|
4211
4388
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4212
4389
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4213
4390
|
}
|
4214
|
-
|
4215
|
-
|
4216
|
-
|
4217
|
-
|
4218
|
-
|
4219
|
-
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4226
|
-
|
4227
|
-
}
|
4228
|
-
end
|
4391
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4392
|
+
arc(400, 220, 180, 90, 90, false)
|
4393
|
+
|
4394
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4395
|
+
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}]
|
4396
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4397
|
+
}
|
4398
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4399
|
+
circle(200, 200, 90)
|
4400
|
+
|
4401
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4402
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4403
|
+
}
|
4229
4404
|
text(160, 40, 100) { # x, y, width
|
4230
4405
|
string('Area Gallery') {
|
4231
4406
|
font family: 'Times', size: 14
|
@@ -4386,32 +4561,30 @@ window('Area Gallery', 400, 400) {
|
|
4386
4561
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4387
4562
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4388
4563
|
}
|
4389
|
-
|
4390
|
-
|
4391
|
-
|
4392
|
-
|
4393
|
-
|
4394
|
-
|
4395
|
-
|
4396
|
-
|
4397
|
-
is_negative false
|
4398
|
-
}
|
4399
|
-
|
4400
|
-
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4401
|
-
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}]
|
4402
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4564
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4565
|
+
arc {
|
4566
|
+
x_center 400
|
4567
|
+
y_center 220
|
4568
|
+
radius 180
|
4569
|
+
start_angle 90
|
4570
|
+
sweep 90
|
4571
|
+
is_negative false
|
4403
4572
|
}
|
4404
|
-
|
4405
|
-
|
4406
|
-
|
4407
|
-
|
4408
|
-
|
4409
|
-
|
4410
|
-
|
4411
|
-
|
4412
|
-
|
4573
|
+
|
4574
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4575
|
+
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}]
|
4576
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4577
|
+
}
|
4578
|
+
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4579
|
+
circle {
|
4580
|
+
x_center 200
|
4581
|
+
y_center 200
|
4582
|
+
radius 90
|
4413
4583
|
}
|
4414
|
-
|
4584
|
+
|
4585
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4586
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4587
|
+
}
|
4415
4588
|
text {
|
4416
4589
|
x 160
|
4417
4590
|
y 40
|
@@ -4497,6 +4670,10 @@ Mac
|
|
4497
4670
|
|
4498
4671
|
![glimmer-dsl-libui-mac-histogram.png](images/glimmer-dsl-libui-mac-histogram.png)
|
4499
4672
|
|
4673
|
+
Windows
|
4674
|
+
|
4675
|
+
![glimmer-dsl-libui-windows-histogram.png](images/glimmer-dsl-libui-windows-histogram.png)
|
4676
|
+
|
4500
4677
|
Linux
|
4501
4678
|
|
4502
4679
|
![glimmer-dsl-libui-linux-histogram.png](images/glimmer-dsl-libui-linux-histogram.png)
|
@@ -4838,6 +5015,10 @@ Mac
|
|
4838
5015
|
|
4839
5016
|
![glimmer-dsl-libui-mac-basic-transform.png](images/glimmer-dsl-libui-mac-basic-transform.png)
|
4840
5017
|
|
5018
|
+
Windows
|
5019
|
+
|
5020
|
+
![glimmer-dsl-libui-windows-basic-transform.png](images/glimmer-dsl-libui-windows-basic-transform.png)
|
5021
|
+
|
4841
5022
|
Linux
|
4842
5023
|
|
4843
5024
|
![glimmer-dsl-libui-linux-basic-transform.png](images/glimmer-dsl-libui-linux-basic-transform.png)
|
@@ -4895,6 +5076,11 @@ Mac
|
|
4895
5076
|
![glimmer-dsl-libui-mac-login.png](images/glimmer-dsl-libui-mac-login.png)
|
4896
5077
|
![glimmer-dsl-libui-mac-login-logged-in.png](images/glimmer-dsl-libui-mac-login-logged-in.png)
|
4897
5078
|
|
5079
|
+
Windows
|
5080
|
+
|
5081
|
+
![glimmer-dsl-libui-windows-login.png](images/glimmer-dsl-libui-windows-login.png)
|
5082
|
+
![glimmer-dsl-libui-windows-login-logged-in.png](images/glimmer-dsl-libui-windows-login-logged-in.png)
|
5083
|
+
|
4898
5084
|
Linux
|
4899
5085
|
|
4900
5086
|
![glimmer-dsl-libui-linux-login.png](images/glimmer-dsl-libui-linux-login.png)
|
@@ -4971,6 +5157,11 @@ Mac
|
|
4971
5157
|
![glimmer-dsl-libui-mac-timer.png](images/glimmer-dsl-libui-mac-timer.png)
|
4972
5158
|
![glimmer-dsl-libui-mac-timer-in-progress.png](images/glimmer-dsl-libui-mac-timer-in-progress.png)
|
4973
5159
|
|
5160
|
+
Windows
|
5161
|
+
|
5162
|
+
![glimmer-dsl-libui-windows-timer.png](images/glimmer-dsl-libui-windows-timer.png)
|
5163
|
+
![glimmer-dsl-libui-windows-timer-in-progress.png](images/glimmer-dsl-libui-windows-timer-in-progress.png)
|
5164
|
+
|
4974
5165
|
Linux
|
4975
5166
|
|
4976
5167
|
![glimmer-dsl-libui-linux-timer.png](images/glimmer-dsl-libui-linux-timer.png)
|
@@ -5114,63 +5305,68 @@ end
|
|
5114
5305
|
Timer.new
|
5115
5306
|
```
|
5116
5307
|
|
5117
|
-
### Color The
|
5308
|
+
### Color The Circles
|
5118
5309
|
|
5119
|
-
[examples/
|
5310
|
+
[examples/color_the_circles.rb](examples/color_the_circles.rb)
|
5120
5311
|
|
5121
5312
|
Run with this command from the root of the project if you cloned the project:
|
5122
5313
|
|
5123
5314
|
```
|
5124
|
-
ruby -r './lib/glimmer-dsl-libui' examples/
|
5315
|
+
ruby -r './lib/glimmer-dsl-libui' examples/color_the_circles.rb
|
5125
5316
|
```
|
5126
5317
|
|
5127
5318
|
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
5128
5319
|
|
5129
5320
|
```
|
5130
|
-
ruby -r glimmer-dsl-libui -e "require 'examples/
|
5321
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/color_the_circles'"
|
5131
5322
|
```
|
5132
5323
|
|
5133
5324
|
Mac
|
5134
5325
|
|
5135
|
-
![glimmer-dsl-libui-mac-color-the-
|
5136
|
-
![glimmer-dsl-libui-mac-color-the-
|
5137
|
-
![glimmer-dsl-libui-mac-color-the-
|
5326
|
+
![glimmer-dsl-libui-mac-color-the-circles.png](images/glimmer-dsl-libui-mac-color-the-circles.png)
|
5327
|
+
![glimmer-dsl-libui-mac-color-the-circles-lost.png](images/glimmer-dsl-libui-mac-color-the-circles-lost.png)
|
5328
|
+
![glimmer-dsl-libui-mac-color-the-circles-won.png](images/glimmer-dsl-libui-mac-color-the-circles-won.png)
|
5329
|
+
|
5330
|
+
Windows
|
5331
|
+
|
5332
|
+
![glimmer-dsl-libui-windows-color-the-circles.png](images/glimmer-dsl-libui-windows-color-the-circles.png)
|
5333
|
+
![glimmer-dsl-libui-windows-color-the-circles-lost.png](images/glimmer-dsl-libui-windows-color-the-circles-lost.png)
|
5334
|
+
![glimmer-dsl-libui-windows-color-the-circles-won.png](images/glimmer-dsl-libui-windows-color-the-circles-won.png)
|
5138
5335
|
|
5139
5336
|
Linux
|
5140
5337
|
|
5141
|
-
![glimmer-dsl-libui-linux-color-the-
|
5142
|
-
![glimmer-dsl-libui-linux-color-the-
|
5143
|
-
![glimmer-dsl-libui-linux-color-the-
|
5338
|
+
![glimmer-dsl-libui-linux-color-the-circles.png](images/glimmer-dsl-libui-linux-color-the-circles.png)
|
5339
|
+
![glimmer-dsl-libui-linux-color-the-circles-lost.png](images/glimmer-dsl-libui-linux-color-the-circles-lost.png)
|
5340
|
+
![glimmer-dsl-libui-linux-color-the-circles-won.png](images/glimmer-dsl-libui-linux-color-the-circles-won.png)
|
5144
5341
|
|
5145
5342
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
5146
5343
|
|
5147
5344
|
```ruby
|
5148
5345
|
require 'glimmer-dsl-libui'
|
5149
5346
|
|
5150
|
-
class
|
5347
|
+
class ColorTheCircles
|
5151
5348
|
include Glimmer
|
5152
5349
|
|
5153
5350
|
WINDOW_WIDTH = 800
|
5154
5351
|
WINDOW_HEIGHT = 600
|
5155
5352
|
SHAPE_MIN_SIZE = 15
|
5156
|
-
SHAPE_MAX_SIZE =
|
5353
|
+
SHAPE_MAX_SIZE = 75
|
5157
5354
|
MARGIN_WIDTH = 55
|
5158
5355
|
MARGIN_HEIGHT = 155
|
5159
5356
|
TIME_MAX_EASY = 4
|
5160
5357
|
TIME_MAX_MEDIUM = 3
|
5161
5358
|
TIME_MAX_HARD = 2
|
5162
5359
|
TIME_MAX_INSANE = 1
|
5163
|
-
SHAPES = ['square'] + (OS.windows? ? [] : ['circle'])
|
5164
5360
|
|
5165
5361
|
attr_accessor :score
|
5166
5362
|
|
5167
5363
|
def initialize
|
5168
|
-
@
|
5364
|
+
@circles_data = []
|
5169
5365
|
@score = 0
|
5170
5366
|
@time_max = TIME_MAX_HARD
|
5171
5367
|
@game_over = false
|
5172
5368
|
register_observers
|
5173
|
-
|
5369
|
+
setup_circle_factory
|
5174
5370
|
end
|
5175
5371
|
|
5176
5372
|
def register_observers
|
@@ -5189,14 +5385,14 @@ class ColorTheShapes
|
|
5189
5385
|
observer.observe(self, :score) # automatically enhances self to become Glimmer::DataBinding::ObservableModel and notify observer on score attribute changes
|
5190
5386
|
end
|
5191
5387
|
|
5192
|
-
def
|
5388
|
+
def setup_circle_factory
|
5193
5389
|
consumer = Proc.new do
|
5194
5390
|
unless @game_over
|
5195
|
-
if @
|
5196
|
-
# start with 3
|
5197
|
-
|
5391
|
+
if @circles_data.empty?
|
5392
|
+
# start with 3 circles to make more challenging
|
5393
|
+
add_circle until @circles_data.size > 3
|
5198
5394
|
else
|
5199
|
-
|
5395
|
+
add_circle
|
5200
5396
|
end
|
5201
5397
|
end
|
5202
5398
|
delay = rand * @time_max
|
@@ -5205,13 +5401,13 @@ class ColorTheShapes
|
|
5205
5401
|
Glimmer::LibUI.queue_main(&consumer)
|
5206
5402
|
end
|
5207
5403
|
|
5208
|
-
def
|
5209
|
-
|
5210
|
-
|
5211
|
-
|
5404
|
+
def add_circle
|
5405
|
+
circle_x = rand * (WINDOW_WIDTH - MARGIN_WIDTH - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
5406
|
+
circle_y = rand * (WINDOW_HEIGHT - MARGIN_HEIGHT - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
5407
|
+
circle_size = rand * (SHAPE_MAX_SIZE - SHAPE_MIN_SIZE) + SHAPE_MIN_SIZE
|
5212
5408
|
stroke_color = Glimmer::LibUI.x11_colors.sample
|
5213
|
-
@
|
5214
|
-
args: [
|
5409
|
+
@circles_data << {
|
5410
|
+
args: [circle_x, circle_y, circle_size],
|
5215
5411
|
fill: nil,
|
5216
5412
|
stroke: stroke_color
|
5217
5413
|
}
|
@@ -5221,27 +5417,27 @@ class ColorTheShapes
|
|
5221
5417
|
|
5222
5418
|
def restart_game
|
5223
5419
|
@score = 0 # update variable directly to avoid notifying observers
|
5224
|
-
@
|
5420
|
+
@circles_data.clear
|
5225
5421
|
@game_over = false
|
5226
5422
|
end
|
5227
5423
|
|
5228
|
-
def
|
5229
|
-
|
5230
|
-
|
5424
|
+
def color_circle(x, y)
|
5425
|
+
clicked_circle_data = @circles_data.find do |circle_data|
|
5426
|
+
circle_data[:fill].nil? && circle_data[:circle]&.include?(x, y)
|
5231
5427
|
end
|
5232
|
-
if
|
5233
|
-
|
5234
|
-
|
5428
|
+
if clicked_circle_data
|
5429
|
+
clicked_circle_data[:fill] = clicked_circle_data[:stroke]
|
5430
|
+
push_colored_circle_behind_uncolored_circles(clicked_circle_data)
|
5235
5431
|
@area.queue_redraw_all
|
5236
5432
|
self.score += 1 # notifies score observers automatically of change
|
5237
5433
|
end
|
5238
5434
|
end
|
5239
5435
|
|
5240
|
-
def
|
5241
|
-
|
5242
|
-
|
5243
|
-
|
5244
|
-
@
|
5436
|
+
def push_colored_circle_behind_uncolored_circles(colored_circle_data)
|
5437
|
+
removed_colored_circle_data = @circles_data.delete(colored_circle_data)
|
5438
|
+
last_colored_circle_data = @circles_data.select {|cd| cd[:fill]}.last
|
5439
|
+
last_colored_circle_data_index = @circles_data.index(last_colored_circle_data) || -1
|
5440
|
+
@circles_data.insert(last_colored_circle_data_index + 1, removed_colored_circle_data)
|
5245
5441
|
end
|
5246
5442
|
|
5247
5443
|
def launch
|
@@ -5286,12 +5482,12 @@ class ColorTheShapes
|
|
5286
5482
|
menu('Help') {
|
5287
5483
|
menu_item('Instructions') {
|
5288
5484
|
on_clicked do
|
5289
|
-
msg_box('Instructions', "Score goes down as
|
5485
|
+
msg_box('Instructions', "Score goes down as circles are added.\nIf it reaches -20, you lose!\n\nClick circles to color and score!\nOnce score reaches 0, you win!\n\nBeware of concealed light-colored circles!\nThey are revealed once darker circles intersect them.\n\nThere are four levels of difficulty.\nChange via difficulty menu if the game gets too tough.")
|
5290
5486
|
end
|
5291
5487
|
}
|
5292
5488
|
}
|
5293
5489
|
|
5294
|
-
window('Color The
|
5490
|
+
window('Color The Circles', WINDOW_WIDTH, WINDOW_HEIGHT) {
|
5295
5491
|
margined true
|
5296
5492
|
|
5297
5493
|
grid {
|
@@ -5305,13 +5501,13 @@ class ColorTheShapes
|
|
5305
5501
|
end
|
5306
5502
|
}
|
5307
5503
|
|
5308
|
-
label('Score goes down as
|
5504
|
+
label('Score goes down as circles are added. If it reaches -20, you lose!') {
|
5309
5505
|
left 0
|
5310
5506
|
top 1
|
5311
5507
|
halign :center
|
5312
5508
|
}
|
5313
5509
|
|
5314
|
-
label('Click
|
5510
|
+
label('Click circles to color and score! Once score reaches 0, you win!') {
|
5315
5511
|
left 0
|
5316
5512
|
top 2
|
5317
5513
|
halign :center
|
@@ -5346,18 +5542,18 @@ class ColorTheShapes
|
|
5346
5542
|
fill :white
|
5347
5543
|
}
|
5348
5544
|
|
5349
|
-
@
|
5545
|
+
@circles_data.each do |circle_data|
|
5350
5546
|
path {
|
5351
|
-
|
5547
|
+
circle_data[:circle] = circle(*circle_data[:args])
|
5352
5548
|
|
5353
|
-
fill
|
5354
|
-
stroke
|
5549
|
+
fill circle_data[:fill]
|
5550
|
+
stroke circle_data[:stroke]
|
5355
5551
|
}
|
5356
5552
|
end
|
5357
5553
|
end
|
5358
5554
|
|
5359
5555
|
on_mouse_down do |area_mouse_event|
|
5360
|
-
|
5556
|
+
color_circle(area_mouse_event[:x], area_mouse_event[:y])
|
5361
5557
|
end
|
5362
5558
|
}
|
5363
5559
|
}
|
@@ -5365,7 +5561,7 @@ class ColorTheShapes
|
|
5365
5561
|
end
|
5366
5562
|
end
|
5367
5563
|
|
5368
|
-
|
5564
|
+
ColorTheCircles.new.launch
|
5369
5565
|
```
|
5370
5566
|
|
5371
5567
|
### Basic Draw Text
|
@@ -5388,6 +5584,10 @@ Mac
|
|
5388
5584
|
|
5389
5585
|
![glimmer-dsl-libui-mac-basic-draw-text.png](images/glimmer-dsl-libui-mac-basic-draw-text.png)
|
5390
5586
|
|
5587
|
+
Windows
|
5588
|
+
|
5589
|
+
![glimmer-dsl-libui-windows-basic-draw-text.png](images/glimmer-dsl-libui-windows-basic-draw-text.png)
|
5590
|
+
|
5391
5591
|
Linux
|
5392
5592
|
|
5393
5593
|
![glimmer-dsl-libui-linux-basic-draw-text.png](images/glimmer-dsl-libui-linux-basic-draw-text.png)
|
@@ -5671,6 +5871,11 @@ Mac
|
|
5671
5871
|
![glimmer-dsl-libui-mac-custom-draw-text.png](images/glimmer-dsl-libui-mac-custom-draw-text.png)
|
5672
5872
|
![glimmer-dsl-libui-mac-custom-draw-text-changed.png](images/glimmer-dsl-libui-mac-custom-draw-text-changed.png)
|
5673
5873
|
|
5874
|
+
Windows
|
5875
|
+
|
5876
|
+
![glimmer-dsl-libui-windows-custom-draw-text.png](images/glimmer-dsl-libui-windows-custom-draw-text.png)
|
5877
|
+
![glimmer-dsl-libui-windows-custom-draw-text-changed.png](images/glimmer-dsl-libui-windows-custom-draw-text-changed.png)
|
5878
|
+
|
5674
5879
|
Linux
|
5675
5880
|
|
5676
5881
|
![glimmer-dsl-libui-linux-custom-draw-text.png](images/glimmer-dsl-libui-linux-custom-draw-text.png)
|
@@ -5885,6 +6090,10 @@ Mac
|
|
5885
6090
|
|
5886
6091
|
![glimmer-dsl-libui-mac-method-based-custom-keyword.png](images/glimmer-dsl-libui-mac-method-based-custom-keyword.png)
|
5887
6092
|
|
6093
|
+
Windows
|
6094
|
+
|
6095
|
+
![glimmer-dsl-libui-windows-method-based-custom-keyword.png](images/glimmer-dsl-libui-windows-method-based-custom-keyword.png)
|
6096
|
+
|
5888
6097
|
Linux
|
5889
6098
|
|
5890
6099
|
![glimmer-dsl-libui-linux-method-based-custom-keyword.png](images/glimmer-dsl-libui-linux-method-based-custom-keyword.png)
|
@@ -5991,38 +6200,178 @@ window('Method-Based Custom Keyword') {
|
|
5991
6200
|
}.show
|
5992
6201
|
```
|
5993
6202
|
|
5994
|
-
|
6203
|
+
### Tetris
|
5995
6204
|
|
5996
|
-
|
5997
|
-
implemented or the bug hasn't been fixed yet.
|
5998
|
-
- Check out the issue tracker to make sure someone already hasn't
|
5999
|
-
requested it and/or contributed it.
|
6000
|
-
- Fork the project.
|
6001
|
-
- Start a feature/bugfix branch.
|
6002
|
-
- Commit and push until you are happy with your contribution.
|
6003
|
-
- Make sure to add tests for it. This is important so I don't break it
|
6004
|
-
in a future version unintentionally.
|
6005
|
-
- Please try not to mess with the Rakefile, version, or history. If
|
6006
|
-
you want to have your own version, or is otherwise necessary, that
|
6007
|
-
is fine, but please isolate to its own commit so I can cherry-pick
|
6008
|
-
around it.
|
6205
|
+
[examples/tetris.rb](examples/tetris.rb)
|
6009
6206
|
|
6010
|
-
|
6207
|
+
Run with this command from the root of the project if you cloned the project:
|
6011
6208
|
|
6012
|
-
|
6209
|
+
```
|
6210
|
+
ruby -r './lib/glimmer-dsl-libui' examples/tetris.rb
|
6211
|
+
```
|
6013
6212
|
|
6014
|
-
|
6213
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
6015
6214
|
|
6016
|
-
|
6215
|
+
```
|
6216
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/tetris'"
|
6217
|
+
```
|
6017
6218
|
|
6018
|
-
|
6219
|
+
Mac
|
6019
6220
|
|
6020
|
-
|
6221
|
+
![glimmer-dsl-libui-mac-tetris.png](images/glimmer-dsl-libui-mac-tetris.png)
|
6222
|
+
|
6223
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
6224
|
+
|
6225
|
+
```ruby
|
6226
|
+
require 'glimmer-dsl-libui'
|
6227
|
+
|
6228
|
+
require_relative 'tetris/model/game'
|
6229
|
+
|
6230
|
+
class Tetris
|
6231
|
+
include Glimmer
|
6232
|
+
|
6233
|
+
BLOCK_SIZE = 25
|
6234
|
+
BEVEL_CONSTANT = 20
|
6235
|
+
|
6236
|
+
attr_reader :game
|
6237
|
+
|
6238
|
+
def initialize
|
6239
|
+
@game = Model::Game.new
|
6240
|
+
create_gui
|
6241
|
+
register_observers
|
6242
|
+
end
|
6243
|
+
|
6244
|
+
def launch
|
6245
|
+
@game.start!
|
6246
|
+
@main_window.show
|
6247
|
+
end
|
6248
|
+
|
6249
|
+
def create_gui
|
6250
|
+
@main_window = window('Glimmer Tetris', Model::Game::PLAYFIELD_WIDTH * BLOCK_SIZE, Model::Game::PLAYFIELD_HEIGHT * BLOCK_SIZE) {
|
6251
|
+
playfield(playfield_width: Model::Game::PLAYFIELD_WIDTH, playfield_height: Model::Game::PLAYFIELD_HEIGHT, block_size: BLOCK_SIZE)
|
6252
|
+
}
|
6253
|
+
end
|
6254
|
+
|
6255
|
+
def register_observers
|
6256
|
+
Glimmer::DataBinding::Observer.proc do |game_over|
|
6257
|
+
if game_over
|
6258
|
+
show_game_over_dialog
|
6259
|
+
else
|
6260
|
+
start_moving_tetrominos_down
|
6261
|
+
end
|
6262
|
+
end.observe(@game, :game_over)
|
6263
|
+
|
6264
|
+
Model::Game::PLAYFIELD_HEIGHT.times do |row|
|
6265
|
+
Model::Game::PLAYFIELD_HEIGHT.times do |column|
|
6266
|
+
Glimmer::DataBinding::Observer.proc do |new_color|
|
6267
|
+
@blocks[row][column].fill = new_color
|
6268
|
+
end.observe(@game.playfield[row][column], :color)
|
6269
|
+
end
|
6270
|
+
end
|
6271
|
+
end
|
6272
|
+
|
6273
|
+
def playfield(playfield_width: , playfield_height: , block_size: )
|
6274
|
+
area {
|
6275
|
+
@blocks = playfield_height.times.map do |row|
|
6276
|
+
playfield_width.times.map do |column|
|
6277
|
+
block(row: row, column: column, block_size: block_size)
|
6278
|
+
end
|
6279
|
+
end
|
6280
|
+
|
6281
|
+
on_key_down do |key_event|
|
6282
|
+
case key_event
|
6283
|
+
in ext_key: :down
|
6284
|
+
game.down!
|
6285
|
+
in ext_key: :up
|
6286
|
+
case game.up_arrow_action
|
6287
|
+
when :instant_down
|
6288
|
+
game.down!(instant: true)
|
6289
|
+
when :rotate_right
|
6290
|
+
game.rotate!(:right)
|
6291
|
+
when :rotate_left
|
6292
|
+
game.rotate!(:left)
|
6293
|
+
end
|
6294
|
+
in ext_key: :left
|
6295
|
+
game.left!
|
6296
|
+
in ext_key: :right
|
6297
|
+
game.right!
|
6298
|
+
in modifier: :shift
|
6299
|
+
game.rotate!(:right)
|
6300
|
+
in modifier: :control
|
6301
|
+
game.rotate!(:left)
|
6302
|
+
else
|
6303
|
+
# Do Nothing
|
6304
|
+
end
|
6305
|
+
end
|
6306
|
+
}
|
6307
|
+
end
|
6308
|
+
|
6309
|
+
def block(row: , column: , block_size: )
|
6310
|
+
path {
|
6311
|
+
square(column * block_size, row * block_size, block_size)
|
6312
|
+
|
6313
|
+
fill Model::Block::COLOR_CLEAR
|
6314
|
+
}
|
6315
|
+
end
|
6316
|
+
|
6317
|
+
def start_moving_tetrominos_down
|
6318
|
+
Glimmer::LibUI.timer(@game.delay) do
|
6319
|
+
@game.down! if !@game.game_over? && !@game.paused?
|
6320
|
+
end
|
6321
|
+
end
|
6322
|
+
|
6323
|
+
def show_game_over_dialog
|
6324
|
+
msg_box('Game Over', "Score: #{@game.high_scores.first.score}")
|
6325
|
+
end
|
6326
|
+
end
|
6327
|
+
|
6328
|
+
Tetris.new.launch
|
6329
|
+
```
|
6330
|
+
|
6331
|
+
## Applications
|
6332
|
+
|
6333
|
+
Here are some applications built with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui)
|
6334
|
+
|
6335
|
+
### Manga2PDF
|
6336
|
+
|
6337
|
+
Download and merge manga images into a single pdf file.
|
6338
|
+
|
6339
|
+
https://github.com/PinGunter/manga2pdf
|
6340
|
+
|
6341
|
+
![manga2pdf screenshot](https://raw.githubusercontent.com/PinGunter/manga2pdf/master/screenshots/manga2pdf-gui.png)
|
6342
|
+
|
6343
|
+
### Befunge98 GUI
|
6344
|
+
|
6345
|
+
Ruby implementation of the Befunge-98 programmming language.
|
6346
|
+
|
6347
|
+
https://github.com/AndyObtiva/befunge98/tree/gui
|
6348
|
+
|
6349
|
+
![befunge98 gui screenshot](https://raw.githubusercontent.com/AndyObtiva/befunge98/master/gui/glimmer-dsl-libui/befunge98_gui_glimmer_dsl_libui/screenshots/befunge98_gui_glimmer_dsl_libui_example.png)
|
6350
|
+
|
6351
|
+
### i3off Gtk Ruby
|
6352
|
+
|
6353
|
+
https://github.com/iraamaro/i3off-gtk-ruby
|
6021
6354
|
|
6022
6355
|
## Process
|
6023
6356
|
|
6024
6357
|
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
6025
6358
|
|
6359
|
+
## Resources
|
6360
|
+
|
6361
|
+
- [libui C Library](https://github.com/andlabs/libui)
|
6362
|
+
- [LibUI Ruby Bindings](https://github.com/kojix2/LibUI)
|
6363
|
+
- [Code Master Blog](https://andymaleh.blogspot.com/search/label/LibUI)
|
6364
|
+
|
6365
|
+
## Help
|
6366
|
+
|
6367
|
+
### Issues
|
6368
|
+
|
6369
|
+
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).
|
6370
|
+
|
6371
|
+
### Chat
|
6372
|
+
|
6373
|
+
If you need live help, try to [![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
6374
|
+
|
6026
6375
|
## Planned Features and Feature Suggestions
|
6027
6376
|
|
6028
6377
|
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.
|
@@ -6033,6 +6382,22 @@ These features have been planned or suggested. You might see them in a future ve
|
|
6033
6382
|
|
6034
6383
|
[CHANGELOG.md](CHANGELOG.md)
|
6035
6384
|
|
6385
|
+
## Contributing
|
6386
|
+
|
6387
|
+
- Check out the latest master to make sure the feature hasn't been
|
6388
|
+
implemented or the bug hasn't been fixed yet.
|
6389
|
+
- Check out the issue tracker to make sure someone already hasn't
|
6390
|
+
requested it and/or contributed it.
|
6391
|
+
- Fork the project.
|
6392
|
+
- Start a feature/bugfix branch.
|
6393
|
+
- Commit and push until you are happy with your contribution.
|
6394
|
+
- Make sure to add tests for it. This is important so I don't break it
|
6395
|
+
in a future version unintentionally.
|
6396
|
+
- Please try not to mess with the Rakefile, version, or history. If
|
6397
|
+
you want to have your own version, or is otherwise necessary, that
|
6398
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
6399
|
+
around it.
|
6400
|
+
|
6036
6401
|
## Contributors
|
6037
6402
|
|
6038
6403
|
* [Andy Maleh](https://github.com/AndyObtiva) (Founder)
|