glimmer-dsl-libui 0.2.12 → 0.2.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -0
- data/README.md +358 -93
- data/VERSION +1 -1
- data/bin/girb +0 -0
- data/bin/girb_runner.rb +1 -1
- data/examples/basic_table_button.rb +1 -1
- data/examples/basic_table_checkbox.rb +1 -1
- data/examples/basic_table_image.rb +1 -0
- data/examples/basic_table_image_text.rb +1 -0
- data/examples/basic_transform.rb +8 -2
- data/examples/color_button.rb +1 -1
- data/examples/color_the_circles.rb +24 -22
- data/examples/control_gallery.rb +6 -0
- data/examples/meta_example.rb +12 -7
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/control_expression.rb +2 -0
- data/lib/glimmer/libui/attributed_string.rb +20 -10
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +37 -4
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +29 -9
- 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 +7 -7
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.16
|
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
|
@@ -190,7 +206,16 @@ window('Area Gallery', 400, 400) {
|
|
190
206
|
}.show
|
191
207
|
```
|
192
208
|
|
209
|
+
Mac
|
210
|
+
|
193
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
|
+
|
194
219
|
![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
195
220
|
|
196
221
|
[Check Out Many More Examples Over Here!](#examples)
|
@@ -211,7 +236,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
211
236
|
- [Usage](#usage)
|
212
237
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
213
238
|
- [API](#api)
|
214
|
-
- [Supported
|
239
|
+
- [Supported Keywords](#supported-keywords)
|
215
240
|
- [Common Control Properties](#common-control-properties)
|
216
241
|
- [Common Control Operations](#common-control-operations)
|
217
242
|
- [LibUI Operations](#libui-operations)
|
@@ -259,13 +284,18 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
259
284
|
- [Basic Draw Text](#basic-draw-text)
|
260
285
|
- [Custom Draw Text](#custom-draw-text)
|
261
286
|
- [Method-Based Custom Keyword](#method-based-custom-keyword)
|
262
|
-
- [
|
287
|
+
- [Applications](#applications)
|
288
|
+
- [Manga2PDF](#manga2pdf)
|
289
|
+
- [Befunge98 GUI](#befunge98-gui)
|
290
|
+
- [i3off Gtk Ruby](#i3off-gtk-ruby)
|
291
|
+
- [Process](#process)
|
292
|
+
- [Resources](#resources)
|
263
293
|
- [Help](#help)
|
264
294
|
- [Issues](#issues)
|
265
295
|
- [Chat](#chat)
|
266
|
-
- [Process](#process)
|
267
296
|
- [Planned Features and Feature Suggestions](#planned-features-and-feature-suggestions)
|
268
297
|
- [Change Log](#change-log)
|
298
|
+
- [Contributing](#contributing)
|
269
299
|
- [Contributors](#contributors)
|
270
300
|
- [License](#license)
|
271
301
|
|
@@ -279,10 +309,10 @@ The Glimmer GUI DSL provides object-oriented declarative hierarchical syntax for
|
|
279
309
|
- Requires the minimum amount of syntax needed to describe an app's GUI
|
280
310
|
|
281
311
|
The Glimmer GUI DSL follows these simple concepts in mapping from [LibUI](https://github.com/kojix2/LibUI) syntax:
|
282
|
-
- **
|
283
|
-
- **Content
|
284
|
-
- **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.
|
285
|
-
- **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.
|
312
|
+
- **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)`).
|
313
|
+
- **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}}`)
|
314
|
+
- **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.
|
315
|
+
- **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.
|
286
316
|
|
287
317
|
Example of an app written in [LibUI](https://github.com/kojix2/LibUI)'s procedural imperative syntax:
|
288
318
|
|
@@ -346,7 +376,7 @@ gem install glimmer-dsl-libui
|
|
346
376
|
Or install via Bundler `Gemfile`:
|
347
377
|
|
348
378
|
```ruby
|
349
|
-
gem 'glimmer-dsl-libui', '~> 0.2.
|
379
|
+
gem 'glimmer-dsl-libui', '~> 0.2.16'
|
350
380
|
```
|
351
381
|
|
352
382
|
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.
|
@@ -406,7 +436,7 @@ w.set_title 'aloha'
|
|
406
436
|
puts w.title # => aloha
|
407
437
|
```
|
408
438
|
|
409
|
-
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.
|
439
|
+
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.
|
410
440
|
|
411
441
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
412
442
|
|
@@ -415,9 +445,11 @@ w = window('hello world') # => #<Glimmer::LibUI::WindowProxy:0x00007fde4ea39fb0
|
|
415
445
|
w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0 free=0x0000000000000000>
|
416
446
|
```
|
417
447
|
|
418
|
-
### Supported
|
448
|
+
### Supported Keywords
|
449
|
+
|
450
|
+
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)
|
419
451
|
|
420
|
-
|
452
|
+
Keyword(Args) | Properties | Listeners
|
421
453
|
------------- | ---------- | ---------
|
422
454
|
`about_menu_item` | None | `on_clicked`
|
423
455
|
`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)`
|
@@ -453,6 +485,8 @@ Control(Args) | Properties | Listeners
|
|
453
485
|
`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
|
454
486
|
`menu(text as String)` | None | None
|
455
487
|
`menu_item(text as String)` | `checked` (Boolean) | `on_clicked`
|
488
|
+
`message_box` (alias for `msg_box`; see for arguments) | None | None
|
489
|
+
`message_box_error` (alias for `msg_box_error`; see for arguments) | None | None
|
456
490
|
`multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
457
491
|
`msg_box(window = main_window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
458
492
|
`msg_box_error(window = main_window as Glimmer::LibUI::WindowProxy, title as String, description as String)` | None | None
|
@@ -514,8 +548,8 @@ All operations that could normally be called on `LibUI` can also be called on `G
|
|
514
548
|
|
515
549
|
### Extra Dialogs
|
516
550
|
|
517
|
-
- `open_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
|
518
|
-
- `save_file(window as Glimmer::LibUI::WindowProxy)`: returns selected file (`String`) or `nil` if cancelled
|
551
|
+
- `open_file(window as Glimmer::LibUI::WindowProxy = ControlProxy::main_window_proxy)`: returns selected file (`String`) or `nil` if cancelled
|
552
|
+
- `save_file(window as Glimmer::LibUI::WindowProxy = ControlProxy::main_window_proxy)`: returns selected file (`String`) or `nil` if cancelled
|
519
553
|
|
520
554
|
### Extra Operations
|
521
555
|
|
@@ -528,13 +562,13 @@ All operations that could normally be called on `LibUI` can also be called on `G
|
|
528
562
|
|
529
563
|
### Table API
|
530
564
|
|
531
|
-
The `table` control must first declare its columns via one of these column keywords (mentioned in [Supported
|
565
|
+
The `table` control must first declare its columns via one of these column keywords (mentioned in [Supported Keywords](#supported-keywords)):
|
532
566
|
- `background_color_column`: expects color cell values
|
533
567
|
- `button_column`: expects `String` cell values
|
534
568
|
- `checkbox_column`: expects Boolean cell values
|
535
569
|
- `checkbox_text_column`: expects dual-element `Array` of Boolean and `String` cell values
|
536
570
|
- `checkbox_text_color_column`: expects triple-element `Array` of Boolean, `String`, and color cell values
|
537
|
-
- `image_column`: expects `image` cell values (produced by `image` and `image_part` keywords as per [Supported
|
571
|
+
- `image_column`: expects `image` cell values (produced by `image` and `image_part` keywords as per [Supported Keywords](#supported-keywords))
|
538
572
|
- `image_text_column`: expects dual-element `Array` of `image` and `String` cell values
|
539
573
|
- `image_text_color_column`: expects triple-element `Array` of `image`, `String`, and color cell values
|
540
574
|
- `text_column`: expects `String` cell values
|
@@ -596,6 +630,7 @@ window('Contacts', 600, 600) { |w|
|
|
596
630
|
msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
|
597
631
|
else
|
598
632
|
data << new_row # automatically inserts a row into the table due to implicit data-binding
|
633
|
+
@unfiltered_data = data.dup
|
599
634
|
@name_entry.text = ''
|
600
635
|
@email_entry.text = ''
|
601
636
|
@phone_entry.text = ''
|
@@ -605,6 +640,25 @@ window('Contacts', 600, 600) { |w|
|
|
605
640
|
end
|
606
641
|
}
|
607
642
|
|
643
|
+
search_entry { |se|
|
644
|
+
stretchy false
|
645
|
+
|
646
|
+
on_changed do
|
647
|
+
filter_value = se.text
|
648
|
+
@unfiltered_data ||= data.dup
|
649
|
+
# Unfilter first to remove any previous filters
|
650
|
+
data.replace(@unfiltered_data) # affects table indirectly through implicit data-binding
|
651
|
+
# Now, apply filter if entered
|
652
|
+
unless filter_value.empty?
|
653
|
+
data.filter! do |row_data| # affects table indirectly through implicit data-binding
|
654
|
+
row_data.any? do |cell|
|
655
|
+
cell.to_s.downcase.include?(filter_value.downcase)
|
656
|
+
end
|
657
|
+
end
|
658
|
+
end
|
659
|
+
end
|
660
|
+
}
|
661
|
+
|
608
662
|
table {
|
609
663
|
text_column('Name')
|
610
664
|
text_column('Email')
|
@@ -613,6 +667,10 @@ window('Contacts', 600, 600) { |w|
|
|
613
667
|
text_column('State')
|
614
668
|
|
615
669
|
cell_rows data # implicit data-binding
|
670
|
+
|
671
|
+
on_changed do |row, type, row_data|
|
672
|
+
puts "Row #{row} #{type}: #{row_data}"
|
673
|
+
end
|
616
674
|
}
|
617
675
|
}
|
618
676
|
}.show
|
@@ -625,8 +683,8 @@ Learn more by checking out [examples](#examples).
|
|
625
683
|
### Area API
|
626
684
|
|
627
685
|
The `area` control is a canvas-like control for drawing paths that can be used in one of two ways:
|
628
|
-
- 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).
|
629
|
-
- 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.
|
686
|
+
- 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).
|
687
|
+
- 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.
|
630
688
|
|
631
689
|
Here is an example of a declarative `area` with a stable path (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
632
690
|
|
@@ -890,6 +948,7 @@ window('area text drawing') {
|
|
890
948
|
- 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.
|
891
949
|
- `image` instances are automatically freed from memory after `window` is destroyed.
|
892
950
|
- `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`
|
951
|
+
- Automatically provide shifted `:key` characters in `area_key_event` provided in `area` key listeners `on_key_event`, `on_key_down`, and `on_key_up`
|
893
952
|
- `area` paths are specified declaratively with figures underneath (e.g. `rectangle`) and `area` draw listener is automatically generated
|
894
953
|
- Observe figure properties (e.g. `rectangle` `width`) for changes and automatically redraw containing area accordingly
|
895
954
|
- Observe `path` `fill` and `stroke` hashes for changes and automatically redraw containing area accordingly
|
@@ -1011,8 +1070,12 @@ window('Method-Based Custom Keyword') {
|
|
1011
1070
|
### API Gotchas
|
1012
1071
|
|
1013
1072
|
- 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`).
|
1014
|
-
- `table` `checkbox_column` and `checkbox_text_column` checkbox editing only works on
|
1073
|
+
- `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).
|
1015
1074
|
- `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)
|
1075
|
+
- `text` `string` `background` does not work on Windows due to an [issue in libui](https://github.com/andlabs/libui/issues/347).
|
1076
|
+
- `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.
|
1077
|
+
- `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.
|
1078
|
+
- 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.
|
1016
1079
|
|
1017
1080
|
### Original API
|
1018
1081
|
|
@@ -1027,7 +1090,7 @@ I am documenting options for packaging, which I have not tried myself, but figur
|
|
1027
1090
|
|
1028
1091
|
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.
|
1029
1092
|
|
1030
|
-
For Mac, consider [
|
1093
|
+
For Mac, consider [Platypus](https://github.com/sveinbjornt/Platypus) (builds a native Mac app from a Ruby script)
|
1031
1094
|
|
1032
1095
|
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/).
|
1033
1096
|
|
@@ -1064,6 +1127,10 @@ Mac
|
|
1064
1127
|
|
1065
1128
|
![glimmer-dsl-libui-mac-meta-example.png](images/glimmer-dsl-libui-mac-meta-example.png)
|
1066
1129
|
|
1130
|
+
Windows
|
1131
|
+
|
1132
|
+
![glimmer-dsl-libui-windows-meta-example.png](images/glimmer-dsl-libui-windows-meta-example.png)
|
1133
|
+
|
1067
1134
|
Linux
|
1068
1135
|
|
1069
1136
|
![glimmer-dsl-libui-linux-meta-example.png](images/glimmer-dsl-libui-linux-meta-example.png)
|
@@ -1114,15 +1181,20 @@ class MetaExample
|
|
1114
1181
|
end
|
1115
1182
|
|
1116
1183
|
def run_example(example)
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1184
|
+
Thread.new do
|
1185
|
+
command = "ruby -r #{glimmer_dsl_libui_file} #{example} 2>&1"
|
1186
|
+
result = ''
|
1187
|
+
IO.popen(command) do |f|
|
1188
|
+
sleep(0.0001) # yield to main thread
|
1189
|
+
f.each_line do |line|
|
1190
|
+
result << line
|
1191
|
+
puts line
|
1192
|
+
$stdout.flush # for Windows
|
1193
|
+
sleep(0.0001) # yield to main thread
|
1194
|
+
end
|
1123
1195
|
end
|
1196
|
+
Glimmer::LibUI.queue_main { msg_box('Error Running Example', result) } if result.downcase.include?('error')
|
1124
1197
|
end
|
1125
|
-
msg_box('Error Running Example', result) if result.downcase.include?('error')
|
1126
1198
|
end
|
1127
1199
|
|
1128
1200
|
def launch
|
@@ -1223,6 +1295,10 @@ Mac
|
|
1223
1295
|
|
1224
1296
|
![glimmer-dsl-libui-mac-basic-window.png](images/glimmer-dsl-libui-mac-basic-window.png)
|
1225
1297
|
|
1298
|
+
Windows
|
1299
|
+
|
1300
|
+
![glimmer-dsl-libui-windows-basic-window.png](images/glimmer-dsl-libui-windows-basic-window.png)
|
1301
|
+
|
1226
1302
|
Linux
|
1227
1303
|
|
1228
1304
|
![glimmer-dsl-libui-linux-basic-window.png](images/glimmer-dsl-libui-linux-basic-window.png)
|
@@ -1303,6 +1379,11 @@ Mac
|
|
1303
1379
|
![glimmer-dsl-libui-mac-basic-button.png](images/glimmer-dsl-libui-mac-basic-button.png)
|
1304
1380
|
![glimmer-dsl-libui-mac-basic-button-msg-box.png](images/glimmer-dsl-libui-mac-basic-button-msg-box.png)
|
1305
1381
|
|
1382
|
+
Windows
|
1383
|
+
|
1384
|
+
![glimmer-dsl-libui-windows-basic-button.png](images/glimmer-dsl-libui-windows-basic-button.png)
|
1385
|
+
![glimmer-dsl-libui-windows-basic-button-msg-box.png](images/glimmer-dsl-libui-windows-basic-button-msg-box.png)
|
1386
|
+
|
1306
1387
|
Linux
|
1307
1388
|
|
1308
1389
|
![glimmer-dsl-libui-linux-basic-button.png](images/glimmer-dsl-libui-linux-basic-button.png)
|
@@ -1380,6 +1461,11 @@ Mac
|
|
1380
1461
|
![glimmer-dsl-libui-mac-basic-entry.png](images/glimmer-dsl-libui-mac-basic-entry.png)
|
1381
1462
|
![glimmer-dsl-libui-mac-basic-entry-msg-box.png](images/glimmer-dsl-libui-mac-basic-entry-msg-box.png)
|
1382
1463
|
|
1464
|
+
Windows
|
1465
|
+
|
1466
|
+
![glimmer-dsl-libui-windows-basic-entry.png](images/glimmer-dsl-libui-windows-basic-entry.png)
|
1467
|
+
![glimmer-dsl-libui-windows-basic-entry-msg-box.png](images/glimmer-dsl-libui-windows-basic-entry-msg-box.png)
|
1468
|
+
|
1383
1469
|
Linux
|
1384
1470
|
|
1385
1471
|
![glimmer-dsl-libui-linux-basic-entry.png](images/glimmer-dsl-libui-linux-basic-entry.png)
|
@@ -1480,6 +1566,10 @@ Mac
|
|
1480
1566
|
|
1481
1567
|
![glimmer-dsl-libui-mac-simple-notepad.png](images/glimmer-dsl-libui-mac-simple-notepad.png)
|
1482
1568
|
|
1569
|
+
Windows
|
1570
|
+
|
1571
|
+
![glimmer-dsl-libui-windows-simple-notepad.png](images/glimmer-dsl-libui-windows-simple-notepad.png)
|
1572
|
+
|
1483
1573
|
Linux
|
1484
1574
|
|
1485
1575
|
![glimmer-dsl-libui-linux-simple-notepad.png](images/glimmer-dsl-libui-linux-simple-notepad.png)
|
@@ -1553,6 +1643,11 @@ Mac
|
|
1553
1643
|
![glimmer-dsl-libui-mac-midi-player.png](images/glimmer-dsl-libui-mac-midi-player.png)
|
1554
1644
|
![glimmer-dsl-libui-mac-midi-player-msg-box.png](images/glimmer-dsl-libui-mac-midi-player-msg-box.png)
|
1555
1645
|
|
1646
|
+
Windows
|
1647
|
+
|
1648
|
+
![glimmer-dsl-libui-windows-midi-player.png](images/glimmer-dsl-libui-windows-midi-player.png)
|
1649
|
+
![glimmer-dsl-libui-windows-midi-player-msg-box.png](images/glimmer-dsl-libui-windows-midi-player-msg-box.png)
|
1650
|
+
|
1556
1651
|
Linux
|
1557
1652
|
|
1558
1653
|
![glimmer-dsl-libui-linux-midi-player.png](images/glimmer-dsl-libui-linux-midi-player.png)
|
@@ -1770,6 +1865,10 @@ Mac
|
|
1770
1865
|
|
1771
1866
|
![glimmer-dsl-libui-mac-control-gallery.png](images/glimmer-dsl-libui-mac-control-gallery.png)
|
1772
1867
|
|
1868
|
+
Windows
|
1869
|
+
|
1870
|
+
![glimmer-dsl-libui-windows-control-gallery.png](images/glimmer-dsl-libui-windows-control-gallery.png)
|
1871
|
+
|
1773
1872
|
Linux
|
1774
1873
|
|
1775
1874
|
![glimmer-dsl-libui-linux-control-gallery.png](images/glimmer-dsl-libui-linux-control-gallery.png)
|
@@ -2161,6 +2260,11 @@ Mac
|
|
2161
2260
|
![glimmer-dsl-libui-mac-font-button.png](images/glimmer-dsl-libui-mac-font-button.png)
|
2162
2261
|
![glimmer-dsl-libui-mac-font-button-selection.png](images/glimmer-dsl-libui-mac-font-button-selection.png)
|
2163
2262
|
|
2263
|
+
Windows
|
2264
|
+
|
2265
|
+
![glimmer-dsl-libui-windows-font-button.png](images/glimmer-dsl-libui-windows-font-button.png)
|
2266
|
+
![glimmer-dsl-libui-windows-font-button-selection.png](images/glimmer-dsl-libui-windows-font-button-selection.png)
|
2267
|
+
|
2164
2268
|
Linux
|
2165
2269
|
|
2166
2270
|
![glimmer-dsl-libui-linux-font-button.png](images/glimmer-dsl-libui-linux-font-button.png)
|
@@ -2245,6 +2349,11 @@ Mac
|
|
2245
2349
|
![glimmer-dsl-libui-mac-color-button.png](images/glimmer-dsl-libui-mac-color-button.png)
|
2246
2350
|
![glimmer-dsl-libui-mac-color-button-selection.png](images/glimmer-dsl-libui-mac-color-button-selection.png)
|
2247
2351
|
|
2352
|
+
Windows
|
2353
|
+
|
2354
|
+
![glimmer-dsl-libui-windows-color-button.png](images/glimmer-dsl-libui-windows-color-button.png)
|
2355
|
+
![glimmer-dsl-libui-windows-color-button-selection.png](images/glimmer-dsl-libui-windows-color-button-selection.png)
|
2356
|
+
|
2248
2357
|
Linux
|
2249
2358
|
|
2250
2359
|
![glimmer-dsl-libui-linux-color-button.png](images/glimmer-dsl-libui-linux-color-button.png)
|
@@ -2257,7 +2366,7 @@ require 'glimmer-dsl-libui'
|
|
2257
2366
|
|
2258
2367
|
include Glimmer
|
2259
2368
|
|
2260
|
-
window('color button',
|
2369
|
+
window('color button', 240) {
|
2261
2370
|
color_button { |cb|
|
2262
2371
|
color :blue
|
2263
2372
|
|
@@ -2289,6 +2398,10 @@ Mac
|
|
2289
2398
|
|
2290
2399
|
![glimmer-dsl-libui-mac-date-time-picker.png](images/glimmer-dsl-libui-mac-date-time-picker.png)
|
2291
2400
|
|
2401
|
+
Windows
|
2402
|
+
|
2403
|
+
![glimmer-dsl-libui-windows-date-time-picker.png](images/glimmer-dsl-libui-windows-date-time-picker.png)
|
2404
|
+
|
2292
2405
|
Linux
|
2293
2406
|
|
2294
2407
|
![glimmer-dsl-libui-linux-date-time-picker.png](images/glimmer-dsl-libui-linux-date-time-picker.png)
|
@@ -2381,6 +2494,12 @@ Mac
|
|
2381
2494
|
![glimmer-dsl-libui-mac-grid-expand.png](images/glimmer-dsl-libui-mac-grid-expand.png)
|
2382
2495
|
![glimmer-dsl-libui-mac-grid-align.png](images/glimmer-dsl-libui-mac-grid-align.png)
|
2383
2496
|
|
2497
|
+
Windows
|
2498
|
+
|
2499
|
+
![glimmer-dsl-libui-windows-grid-span.png](images/glimmer-dsl-libui-windows-grid-span.png)
|
2500
|
+
![glimmer-dsl-libui-windows-grid-expand.png](images/glimmer-dsl-libui-windows-grid-expand.png)
|
2501
|
+
![glimmer-dsl-libui-windows-grid-align.png](images/glimmer-dsl-libui-windows-grid-align.png)
|
2502
|
+
|
2384
2503
|
Linux
|
2385
2504
|
|
2386
2505
|
![glimmer-dsl-libui-linux-grid-span.png](images/glimmer-dsl-libui-linux-grid-span.png)
|
@@ -2519,6 +2638,11 @@ Mac
|
|
2519
2638
|
![glimmer-dsl-libui-mac-form.png](images/glimmer-dsl-libui-mac-form.png)
|
2520
2639
|
![glimmer-dsl-libui-mac-form-msg-box.png](images/glimmer-dsl-libui-mac-form-msg-box.png)
|
2521
2640
|
|
2641
|
+
Windows
|
2642
|
+
|
2643
|
+
![glimmer-dsl-libui-windows-form.png](images/glimmer-dsl-libui-windows-form.png)
|
2644
|
+
![glimmer-dsl-libui-windows-form-msg-box.png](images/glimmer-dsl-libui-windows-form-msg-box.png)
|
2645
|
+
|
2522
2646
|
Linux
|
2523
2647
|
|
2524
2648
|
![glimmer-dsl-libui-linux-form.png](images/glimmer-dsl-libui-linux-form.png)
|
@@ -2584,6 +2708,10 @@ Mac
|
|
2584
2708
|
|
2585
2709
|
![glimmer-dsl-libui-mac-basic-table.png](images/glimmer-dsl-libui-mac-basic-table.png)
|
2586
2710
|
|
2711
|
+
Windows
|
2712
|
+
|
2713
|
+
![glimmer-dsl-libui-windows-basic-table.png](images/glimmer-dsl-libui-windows-basic-table.png)
|
2714
|
+
|
2587
2715
|
Linux
|
2588
2716
|
|
2589
2717
|
![glimmer-dsl-libui-linux-basic-table.png](images/glimmer-dsl-libui-linux-basic-table.png)
|
@@ -2706,6 +2834,12 @@ Mac
|
|
2706
2834
|
![glimmer-dsl-libui-mac-editable-table-editing.png](images/glimmer-dsl-libui-mac-editable-table-editing.png)
|
2707
2835
|
![glimmer-dsl-libui-mac-editable-table-edited.png](images/glimmer-dsl-libui-mac-editable-table-edited.png)
|
2708
2836
|
|
2837
|
+
Windows
|
2838
|
+
|
2839
|
+
![glimmer-dsl-libui-windows-editable-table.png](images/glimmer-dsl-libui-windows-editable-table.png)
|
2840
|
+
![glimmer-dsl-libui-windows-editable-table-editing.png](images/glimmer-dsl-libui-windows-editable-table-editing.png)
|
2841
|
+
![glimmer-dsl-libui-windows-editable-table-edited.png](images/glimmer-dsl-libui-windows-editable-table-edited.png)
|
2842
|
+
|
2709
2843
|
Linux
|
2710
2844
|
|
2711
2845
|
![glimmer-dsl-libui-linux-editable-table.png](images/glimmer-dsl-libui-linux-editable-table.png)
|
@@ -2773,6 +2907,11 @@ Mac
|
|
2773
2907
|
![glimmer-dsl-libui-mac-editable-column-table-editing.png](images/glimmer-dsl-libui-mac-editable-column-table-editing.png)
|
2774
2908
|
![glimmer-dsl-libui-mac-editable-column-table-edited.png](images/glimmer-dsl-libui-mac-editable-column-table-edited.png)
|
2775
2909
|
|
2910
|
+
Windows
|
2911
|
+
|
2912
|
+
![glimmer-dsl-libui-windows-editable-column-table-editing.png](images/glimmer-dsl-libui-windows-editable-column-table-editing.png)
|
2913
|
+
![glimmer-dsl-libui-windows-editable-column-table-edited.png](images/glimmer-dsl-libui-windows-editable-column-table-edited.png)
|
2914
|
+
|
2776
2915
|
Linux
|
2777
2916
|
|
2778
2917
|
![glimmer-dsl-libui-linux-editable-column-table-editing.png](images/glimmer-dsl-libui-linux-editable-column-table-editing.png)
|
@@ -2840,6 +2979,10 @@ Mac
|
|
2840
2979
|
|
2841
2980
|
![glimmer-dsl-libui-mac-basic-table-image.png](images/glimmer-dsl-libui-mac-basic-table-image.png)
|
2842
2981
|
|
2982
|
+
Windows
|
2983
|
+
|
2984
|
+
![glimmer-dsl-libui-windows-basic-table-image.png](images/glimmer-dsl-libui-windows-basic-table-image.png)
|
2985
|
+
|
2843
2986
|
Linux
|
2844
2987
|
|
2845
2988
|
![glimmer-dsl-libui-linux-basic-table-image.png](images/glimmer-dsl-libui-linux-basic-table-image.png)
|
@@ -2998,6 +3141,10 @@ Mac
|
|
2998
3141
|
|
2999
3142
|
![glimmer-dsl-libui-mac-basic-table-image-text.png](images/glimmer-dsl-libui-mac-basic-table-image-text.png)
|
3000
3143
|
|
3144
|
+
Windows
|
3145
|
+
|
3146
|
+
![glimmer-dsl-libui-windows-basic-table-image-text.png](images/glimmer-dsl-libui-windows-basic-table-image-text.png)
|
3147
|
+
|
3001
3148
|
Linux
|
3002
3149
|
|
3003
3150
|
![glimmer-dsl-libui-linux-basic-table-image-text.png](images/glimmer-dsl-libui-linux-basic-table-image-text.png)
|
@@ -3069,6 +3216,11 @@ Mac
|
|
3069
3216
|
![glimmer-dsl-libui-mac-basic-table-button.png](images/glimmer-dsl-libui-mac-basic-table-button.png)
|
3070
3217
|
![glimmer-dsl-libui-mac-basic-table-button-deleted.png](images/glimmer-dsl-libui-mac-basic-table-button-deleted.png)
|
3071
3218
|
|
3219
|
+
Windows
|
3220
|
+
|
3221
|
+
![glimmer-dsl-libui-windows-basic-table-button.png](images/glimmer-dsl-libui-windows-basic-table-button.png)
|
3222
|
+
![glimmer-dsl-libui-windows-basic-table-button-deleted.png](images/glimmer-dsl-libui-windows-basic-table-button-deleted.png)
|
3223
|
+
|
3072
3224
|
Linux
|
3073
3225
|
|
3074
3226
|
![glimmer-dsl-libui-linux-basic-table-button.png](images/glimmer-dsl-libui-linux-basic-table-button.png)
|
@@ -3130,6 +3282,10 @@ Mac
|
|
3130
3282
|
|
3131
3283
|
![glimmer-dsl-libui-mac-basic-table-checkbox.png](images/glimmer-dsl-libui-mac-basic-table-checkbox.png)
|
3132
3284
|
|
3285
|
+
Windows
|
3286
|
+
|
3287
|
+
![glimmer-dsl-libui-windows-basic-table-checkbox.png](images/glimmer-dsl-libui-windows-basic-table-checkbox.png)
|
3288
|
+
|
3133
3289
|
Linux
|
3134
3290
|
|
3135
3291
|
![glimmer-dsl-libui-linux-basic-table-checkbox.png](images/glimmer-dsl-libui-linux-basic-table-checkbox.png)
|
@@ -3182,6 +3338,10 @@ Mac
|
|
3182
3338
|
|
3183
3339
|
![glimmer-dsl-libui-mac-basic-table-checkbox-text.png](images/glimmer-dsl-libui-mac-basic-table-checkbox-text.png)
|
3184
3340
|
|
3341
|
+
Windows
|
3342
|
+
|
3343
|
+
![glimmer-dsl-libui-windows-basic-table-checkbox-text.png](images/glimmer-dsl-libui-windows-basic-table-checkbox-text.png)
|
3344
|
+
|
3185
3345
|
Linux
|
3186
3346
|
|
3187
3347
|
![glimmer-dsl-libui-linux-basic-table-checkbox-text.png](images/glimmer-dsl-libui-linux-basic-table-checkbox-text.png)
|
@@ -3234,6 +3394,10 @@ Mac
|
|
3234
3394
|
|
3235
3395
|
![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png)
|
3236
3396
|
|
3397
|
+
Windows
|
3398
|
+
|
3399
|
+
![glimmer-dsl-libui-windows-basic-table-progress-bar.png](images/glimmer-dsl-libui-windows-basic-table-progress-bar.png)
|
3400
|
+
|
3237
3401
|
Linux
|
3238
3402
|
|
3239
3403
|
![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
|
@@ -3301,6 +3465,10 @@ Mac
|
|
3301
3465
|
|
3302
3466
|
![glimmer-dsl-libui-mac-basic-table-color.png](images/glimmer-dsl-libui-mac-basic-table-color.png)
|
3303
3467
|
|
3468
|
+
Windows
|
3469
|
+
|
3470
|
+
![glimmer-dsl-libui-windows-basic-table-color.png](images/glimmer-dsl-libui-windows-basic-table-color.png)
|
3471
|
+
|
3304
3472
|
Linux
|
3305
3473
|
|
3306
3474
|
![glimmer-dsl-libui-linux-basic-table-color.png](images/glimmer-dsl-libui-linux-basic-table-color.png)
|
@@ -3369,6 +3537,12 @@ Mac
|
|
3369
3537
|
![glimmer-dsl-libui-mac-form-table-contact-entered.png](images/glimmer-dsl-libui-mac-form-table-contact-entered.png)
|
3370
3538
|
![glimmer-dsl-libui-mac-form-table-filtered.png](images/glimmer-dsl-libui-mac-form-table-filtered.png)
|
3371
3539
|
|
3540
|
+
Windows
|
3541
|
+
|
3542
|
+
![glimmer-dsl-libui-windows-form-table.png](images/glimmer-dsl-libui-windows-form-table.png)
|
3543
|
+
![glimmer-dsl-libui-windows-form-table-contact-entered.png](images/glimmer-dsl-libui-windows-form-table-contact-entered.png)
|
3544
|
+
![glimmer-dsl-libui-windows-form-table-filtered.png](images/glimmer-dsl-libui-windows-form-table-filtered.png)
|
3545
|
+
|
3372
3546
|
Linux
|
3373
3547
|
|
3374
3548
|
![glimmer-dsl-libui-linux-form-table.png](images/glimmer-dsl-libui-linux-form-table.png)
|
@@ -3378,8 +3552,6 @@ Linux
|
|
3378
3552
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3379
3553
|
|
3380
3554
|
```ruby
|
3381
|
-
# frozen_string_literal: true
|
3382
|
-
|
3383
3555
|
require 'glimmer-dsl-libui'
|
3384
3556
|
|
3385
3557
|
include Glimmer
|
@@ -3491,6 +3663,10 @@ Mac
|
|
3491
3663
|
|
3492
3664
|
![glimmer-dsl-libui-mac-basic-area.png](images/glimmer-dsl-libui-mac-basic-area.png)
|
3493
3665
|
|
3666
|
+
Windows
|
3667
|
+
|
3668
|
+
![glimmer-dsl-libui-windows-basic-area.png](images/glimmer-dsl-libui-windows-basic-area.png)
|
3669
|
+
|
3494
3670
|
Linux
|
3495
3671
|
|
3496
3672
|
![glimmer-dsl-libui-linux-basic-area.png](images/glimmer-dsl-libui-linux-basic-area.png)
|
@@ -3614,6 +3790,11 @@ Mac
|
|
3614
3790
|
![glimmer-dsl-libui-mac-dynamic-area.png](images/glimmer-dsl-libui-mac-dynamic-area.png)
|
3615
3791
|
![glimmer-dsl-libui-mac-dynamic-area-updated.png](images/glimmer-dsl-libui-mac-dynamic-area-updated.png)
|
3616
3792
|
|
3793
|
+
Windows
|
3794
|
+
|
3795
|
+
![glimmer-dsl-libui-windows-dynamic-area.png](images/glimmer-dsl-libui-windows-dynamic-area.png)
|
3796
|
+
![glimmer-dsl-libui-windows-dynamic-area-updated.png](images/glimmer-dsl-libui-windows-dynamic-area-updated.png)
|
3797
|
+
|
3617
3798
|
Linux
|
3618
3799
|
|
3619
3800
|
![glimmer-dsl-libui-linux-dynamic-area.png](images/glimmer-dsl-libui-linux-dynamic-area.png)
|
@@ -3845,6 +4026,10 @@ Mac
|
|
3845
4026
|
|
3846
4027
|
![glimmer-dsl-libui-mac-area-gallery.png](images/glimmer-dsl-libui-mac-area-gallery.png)
|
3847
4028
|
|
4029
|
+
Windows
|
4030
|
+
|
4031
|
+
![glimmer-dsl-libui-windows-area-gallery.png](images/glimmer-dsl-libui-windows-area-gallery.png)
|
4032
|
+
|
3848
4033
|
Linux
|
3849
4034
|
|
3850
4035
|
![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
@@ -4483,6 +4668,10 @@ Mac
|
|
4483
4668
|
|
4484
4669
|
![glimmer-dsl-libui-mac-histogram.png](images/glimmer-dsl-libui-mac-histogram.png)
|
4485
4670
|
|
4671
|
+
Windows
|
4672
|
+
|
4673
|
+
![glimmer-dsl-libui-windows-histogram.png](images/glimmer-dsl-libui-windows-histogram.png)
|
4674
|
+
|
4486
4675
|
Linux
|
4487
4676
|
|
4488
4677
|
![glimmer-dsl-libui-linux-histogram.png](images/glimmer-dsl-libui-linux-histogram.png)
|
@@ -4824,6 +5013,10 @@ Mac
|
|
4824
5013
|
|
4825
5014
|
![glimmer-dsl-libui-mac-basic-transform.png](images/glimmer-dsl-libui-mac-basic-transform.png)
|
4826
5015
|
|
5016
|
+
Windows
|
5017
|
+
|
5018
|
+
![glimmer-dsl-libui-windows-basic-transform.png](images/glimmer-dsl-libui-windows-basic-transform.png)
|
5019
|
+
|
4827
5020
|
Linux
|
4828
5021
|
|
4829
5022
|
![glimmer-dsl-libui-linux-basic-transform.png](images/glimmer-dsl-libui-linux-basic-transform.png)
|
@@ -4881,6 +5074,11 @@ Mac
|
|
4881
5074
|
![glimmer-dsl-libui-mac-login.png](images/glimmer-dsl-libui-mac-login.png)
|
4882
5075
|
![glimmer-dsl-libui-mac-login-logged-in.png](images/glimmer-dsl-libui-mac-login-logged-in.png)
|
4883
5076
|
|
5077
|
+
Windows
|
5078
|
+
|
5079
|
+
![glimmer-dsl-libui-windows-login.png](images/glimmer-dsl-libui-windows-login.png)
|
5080
|
+
![glimmer-dsl-libui-windows-login-logged-in.png](images/glimmer-dsl-libui-windows-login-logged-in.png)
|
5081
|
+
|
4884
5082
|
Linux
|
4885
5083
|
|
4886
5084
|
![glimmer-dsl-libui-linux-login.png](images/glimmer-dsl-libui-linux-login.png)
|
@@ -4957,6 +5155,11 @@ Mac
|
|
4957
5155
|
![glimmer-dsl-libui-mac-timer.png](images/glimmer-dsl-libui-mac-timer.png)
|
4958
5156
|
![glimmer-dsl-libui-mac-timer-in-progress.png](images/glimmer-dsl-libui-mac-timer-in-progress.png)
|
4959
5157
|
|
5158
|
+
Windows
|
5159
|
+
|
5160
|
+
![glimmer-dsl-libui-windows-timer.png](images/glimmer-dsl-libui-windows-timer.png)
|
5161
|
+
![glimmer-dsl-libui-windows-timer-in-progress.png](images/glimmer-dsl-libui-windows-timer-in-progress.png)
|
5162
|
+
|
4960
5163
|
Linux
|
4961
5164
|
|
4962
5165
|
![glimmer-dsl-libui-linux-timer.png](images/glimmer-dsl-libui-linux-timer.png)
|
@@ -5122,6 +5325,12 @@ Mac
|
|
5122
5325
|
![glimmer-dsl-libui-mac-color-the-circles-lost.png](images/glimmer-dsl-libui-mac-color-the-circles-lost.png)
|
5123
5326
|
![glimmer-dsl-libui-mac-color-the-circles-won.png](images/glimmer-dsl-libui-mac-color-the-circles-won.png)
|
5124
5327
|
|
5328
|
+
Windows
|
5329
|
+
|
5330
|
+
![glimmer-dsl-libui-windows-color-the-circles.png](images/glimmer-dsl-libui-windows-color-the-circles.png)
|
5331
|
+
![glimmer-dsl-libui-windows-color-the-circles-lost.png](images/glimmer-dsl-libui-windows-color-the-circles-lost.png)
|
5332
|
+
![glimmer-dsl-libui-windows-color-the-circles-won.png](images/glimmer-dsl-libui-windows-color-the-circles-won.png)
|
5333
|
+
|
5125
5334
|
Linux
|
5126
5335
|
|
5127
5336
|
![glimmer-dsl-libui-linux-color-the-circles.png](images/glimmer-dsl-libui-linux-color-the-circles.png)
|
@@ -5138,8 +5347,8 @@ class ColorTheCircles
|
|
5138
5347
|
|
5139
5348
|
WINDOW_WIDTH = 800
|
5140
5349
|
WINDOW_HEIGHT = 600
|
5141
|
-
|
5142
|
-
|
5350
|
+
SHAPE_MIN_SIZE = 15
|
5351
|
+
SHAPE_MAX_SIZE = 75
|
5143
5352
|
MARGIN_WIDTH = 55
|
5144
5353
|
MARGIN_HEIGHT = 155
|
5145
5354
|
TIME_MAX_EASY = 4
|
@@ -5153,6 +5362,7 @@ class ColorTheCircles
|
|
5153
5362
|
@circles_data = []
|
5154
5363
|
@score = 0
|
5155
5364
|
@time_max = TIME_MAX_HARD
|
5365
|
+
@game_over = false
|
5156
5366
|
register_observers
|
5157
5367
|
setup_circle_factory
|
5158
5368
|
end
|
@@ -5161,9 +5371,11 @@ class ColorTheCircles
|
|
5161
5371
|
observer = Glimmer::DataBinding::Observer.proc do |new_score|
|
5162
5372
|
@score_label.text = new_score.to_s
|
5163
5373
|
if new_score == -20
|
5374
|
+
@game_over = true
|
5164
5375
|
msg_box('You Lost!', 'Sorry! Your score reached -20')
|
5165
5376
|
restart_game
|
5166
5377
|
elsif new_score == 0
|
5378
|
+
@game_over = true
|
5167
5379
|
msg_box('You Won!', 'Congratulations! Your score reached 0')
|
5168
5380
|
restart_game
|
5169
5381
|
end
|
@@ -5173,11 +5385,13 @@ class ColorTheCircles
|
|
5173
5385
|
|
5174
5386
|
def setup_circle_factory
|
5175
5387
|
consumer = Proc.new do
|
5176
|
-
|
5177
|
-
|
5178
|
-
|
5179
|
-
|
5180
|
-
|
5388
|
+
unless @game_over
|
5389
|
+
if @circles_data.empty?
|
5390
|
+
# start with 3 circles to make more challenging
|
5391
|
+
add_circle until @circles_data.size > 3
|
5392
|
+
else
|
5393
|
+
add_circle
|
5394
|
+
end
|
5181
5395
|
end
|
5182
5396
|
delay = rand * @time_max
|
5183
5397
|
Glimmer::LibUI.timer(delay, repeat: false, &consumer)
|
@@ -5186,12 +5400,12 @@ class ColorTheCircles
|
|
5186
5400
|
end
|
5187
5401
|
|
5188
5402
|
def add_circle
|
5189
|
-
|
5190
|
-
|
5191
|
-
|
5403
|
+
circle_x = rand * (WINDOW_WIDTH - MARGIN_WIDTH - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
5404
|
+
circle_y = rand * (WINDOW_HEIGHT - MARGIN_HEIGHT - SHAPE_MAX_SIZE) + SHAPE_MAX_SIZE
|
5405
|
+
circle_size = rand * (SHAPE_MAX_SIZE - SHAPE_MIN_SIZE) + SHAPE_MIN_SIZE
|
5192
5406
|
stroke_color = Glimmer::LibUI.x11_colors.sample
|
5193
5407
|
@circles_data << {
|
5194
|
-
args: [
|
5408
|
+
args: [circle_x, circle_y, circle_size],
|
5195
5409
|
fill: nil,
|
5196
5410
|
stroke: stroke_color
|
5197
5411
|
}
|
@@ -5202,8 +5416,28 @@ class ColorTheCircles
|
|
5202
5416
|
def restart_game
|
5203
5417
|
@score = 0 # update variable directly to avoid notifying observers
|
5204
5418
|
@circles_data.clear
|
5419
|
+
@game_over = false
|
5420
|
+
end
|
5421
|
+
|
5422
|
+
def color_circle(x, y)
|
5423
|
+
clicked_circle_data = @circles_data.find do |circle_data|
|
5424
|
+
circle_data[:fill].nil? && circle_data[:circle]&.include?(x, y)
|
5425
|
+
end
|
5426
|
+
if clicked_circle_data
|
5427
|
+
clicked_circle_data[:fill] = clicked_circle_data[:stroke]
|
5428
|
+
push_colored_circle_behind_uncolored_circles(clicked_circle_data)
|
5429
|
+
@area.queue_redraw_all
|
5430
|
+
self.score += 1 # notifies score observers automatically of change
|
5431
|
+
end
|
5205
5432
|
end
|
5206
5433
|
|
5434
|
+
def push_colored_circle_behind_uncolored_circles(colored_circle_data)
|
5435
|
+
removed_colored_circle_data = @circles_data.delete(colored_circle_data)
|
5436
|
+
last_colored_circle_data = @circles_data.select {|cd| cd[:fill]}.last
|
5437
|
+
last_colored_circle_data_index = @circles_data.index(last_colored_circle_data) || -1
|
5438
|
+
@circles_data.insert(last_colored_circle_data_index + 1, removed_colored_circle_data)
|
5439
|
+
end
|
5440
|
+
|
5207
5441
|
def launch
|
5208
5442
|
menu('Actions') {
|
5209
5443
|
menu_item('Restart') {
|
@@ -5291,45 +5525,35 @@ class ColorTheCircles
|
|
5291
5525
|
}
|
5292
5526
|
}
|
5293
5527
|
|
5294
|
-
|
5528
|
+
@area = area {
|
5295
5529
|
left 0
|
5296
5530
|
top 4
|
5297
5531
|
hexpand true
|
5298
5532
|
vexpand true
|
5299
5533
|
halign :fill
|
5300
5534
|
valign :fill
|
5301
|
-
|
5302
|
-
|
5303
|
-
|
5535
|
+
|
5536
|
+
on_draw do |area_draw_params|
|
5537
|
+
path {
|
5538
|
+
rectangle(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT)
|
5539
|
+
|
5540
|
+
fill :white
|
5541
|
+
}
|
5542
|
+
|
5543
|
+
@circles_data.each do |circle_data|
|
5304
5544
|
path {
|
5305
|
-
|
5306
|
-
|
5307
|
-
fill :
|
5545
|
+
circle_data[:circle] = circle(*circle_data[:args])
|
5546
|
+
|
5547
|
+
fill circle_data[:fill]
|
5548
|
+
stroke circle_data[:stroke]
|
5308
5549
|
}
|
5309
|
-
|
5310
|
-
@circles_data.each do |circle_data|
|
5311
|
-
path {
|
5312
|
-
circle_data[:circle] = circle(*circle_data[:args])
|
5313
|
-
|
5314
|
-
fill circle_data[:fill]
|
5315
|
-
stroke circle_data[:stroke]
|
5316
|
-
}
|
5317
|
-
end
|
5318
|
-
end
|
5319
|
-
|
5320
|
-
on_mouse_down do |area_mouse_event|
|
5321
|
-
clicked_circle_data = @circles_data.find do |circle_data|
|
5322
|
-
circle_data[:fill].nil? && circle_data[:circle].include?(area_mouse_event[:x], area_mouse_event[:y])
|
5323
|
-
end
|
5324
|
-
if clicked_circle_data
|
5325
|
-
clicked_circle_data[:fill] = clicked_circle_data[:stroke]
|
5326
|
-
@area.queue_redraw_all
|
5327
|
-
self.score += 1 # notifies score observers automatically of change
|
5328
|
-
end
|
5329
5550
|
end
|
5330
|
-
|
5551
|
+
end
|
5552
|
+
|
5553
|
+
on_mouse_down do |area_mouse_event|
|
5554
|
+
color_circle(area_mouse_event[:x], area_mouse_event[:y])
|
5555
|
+
end
|
5331
5556
|
}
|
5332
|
-
|
5333
5557
|
}
|
5334
5558
|
}.show
|
5335
5559
|
end
|
@@ -5358,6 +5582,10 @@ Mac
|
|
5358
5582
|
|
5359
5583
|
![glimmer-dsl-libui-mac-basic-draw-text.png](images/glimmer-dsl-libui-mac-basic-draw-text.png)
|
5360
5584
|
|
5585
|
+
Windows
|
5586
|
+
|
5587
|
+
![glimmer-dsl-libui-windows-basic-draw-text.png](images/glimmer-dsl-libui-windows-basic-draw-text.png)
|
5588
|
+
|
5361
5589
|
Linux
|
5362
5590
|
|
5363
5591
|
![glimmer-dsl-libui-linux-basic-draw-text.png](images/glimmer-dsl-libui-linux-basic-draw-text.png)
|
@@ -5641,6 +5869,11 @@ Mac
|
|
5641
5869
|
![glimmer-dsl-libui-mac-custom-draw-text.png](images/glimmer-dsl-libui-mac-custom-draw-text.png)
|
5642
5870
|
![glimmer-dsl-libui-mac-custom-draw-text-changed.png](images/glimmer-dsl-libui-mac-custom-draw-text-changed.png)
|
5643
5871
|
|
5872
|
+
Windows
|
5873
|
+
|
5874
|
+
![glimmer-dsl-libui-windows-custom-draw-text.png](images/glimmer-dsl-libui-windows-custom-draw-text.png)
|
5875
|
+
![glimmer-dsl-libui-windows-custom-draw-text-changed.png](images/glimmer-dsl-libui-windows-custom-draw-text-changed.png)
|
5876
|
+
|
5644
5877
|
Linux
|
5645
5878
|
|
5646
5879
|
![glimmer-dsl-libui-linux-custom-draw-text.png](images/glimmer-dsl-libui-linux-custom-draw-text.png)
|
@@ -5855,6 +6088,10 @@ Mac
|
|
5855
6088
|
|
5856
6089
|
![glimmer-dsl-libui-mac-method-based-custom-keyword.png](images/glimmer-dsl-libui-mac-method-based-custom-keyword.png)
|
5857
6090
|
|
6091
|
+
Windows
|
6092
|
+
|
6093
|
+
![glimmer-dsl-libui-windows-method-based-custom-keyword.png](images/glimmer-dsl-libui-windows-method-based-custom-keyword.png)
|
6094
|
+
|
5858
6095
|
Linux
|
5859
6096
|
|
5860
6097
|
![glimmer-dsl-libui-linux-method-based-custom-keyword.png](images/glimmer-dsl-libui-linux-method-based-custom-keyword.png)
|
@@ -5961,38 +6198,50 @@ window('Method-Based Custom Keyword') {
|
|
5961
6198
|
}.show
|
5962
6199
|
```
|
5963
6200
|
|
5964
|
-
##
|
6201
|
+
## Applications
|
5965
6202
|
|
5966
|
-
|
5967
|
-
implemented or the bug hasn't been fixed yet.
|
5968
|
-
- Check out the issue tracker to make sure someone already hasn't
|
5969
|
-
requested it and/or contributed it.
|
5970
|
-
- Fork the project.
|
5971
|
-
- Start a feature/bugfix branch.
|
5972
|
-
- Commit and push until you are happy with your contribution.
|
5973
|
-
- Make sure to add tests for it. This is important so I don't break it
|
5974
|
-
in a future version unintentionally.
|
5975
|
-
- Please try not to mess with the Rakefile, version, or history. If
|
5976
|
-
you want to have your own version, or is otherwise necessary, that
|
5977
|
-
is fine, but please isolate to its own commit so I can cherry-pick
|
5978
|
-
around it.
|
6203
|
+
Here are some applications built with [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui)
|
5979
6204
|
|
5980
|
-
|
6205
|
+
### Manga2PDF
|
5981
6206
|
|
5982
|
-
|
6207
|
+
Download and merge manga images into a single pdf file.
|
5983
6208
|
|
5984
|
-
|
6209
|
+
https://github.com/PinGunter/manga2pdf
|
5985
6210
|
|
5986
|
-
[
|
6211
|
+
![manga2pdf screenshot](https://raw.githubusercontent.com/PinGunter/manga2pdf/master/screenshots/manga2pdf-gui.png)
|
5987
6212
|
|
5988
|
-
###
|
6213
|
+
### Befunge98 GUI
|
5989
6214
|
|
5990
|
-
|
6215
|
+
Ruby implementation of the Befunge-98 programmming language.
|
6216
|
+
|
6217
|
+
https://github.com/AndyObtiva/befunge98/tree/gui
|
6218
|
+
|
6219
|
+
![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)
|
6220
|
+
|
6221
|
+
### i3off Gtk Ruby
|
6222
|
+
|
6223
|
+
https://github.com/iraamaro/i3off-gtk-ruby
|
5991
6224
|
|
5992
6225
|
## Process
|
5993
6226
|
|
5994
6227
|
[Glimmer Process](https://github.com/AndyObtiva/glimmer/blob/master/PROCESS.md)
|
5995
6228
|
|
6229
|
+
## Resources
|
6230
|
+
|
6231
|
+
- [libui C Library](https://github.com/andlabs/libui)
|
6232
|
+
- [LibUI Ruby Bindings](https://github.com/kojix2/LibUI)
|
6233
|
+
- [Code Master Blog](https://andymaleh.blogspot.com/search/label/LibUI)
|
6234
|
+
|
6235
|
+
## Help
|
6236
|
+
|
6237
|
+
### Issues
|
6238
|
+
|
6239
|
+
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).
|
6240
|
+
|
6241
|
+
### Chat
|
6242
|
+
|
6243
|
+
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)
|
6244
|
+
|
5996
6245
|
## Planned Features and Feature Suggestions
|
5997
6246
|
|
5998
6247
|
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.
|
@@ -6003,6 +6252,22 @@ These features have been planned or suggested. You might see them in a future ve
|
|
6003
6252
|
|
6004
6253
|
[CHANGELOG.md](CHANGELOG.md)
|
6005
6254
|
|
6255
|
+
## Contributing
|
6256
|
+
|
6257
|
+
- Check out the latest master to make sure the feature hasn't been
|
6258
|
+
implemented or the bug hasn't been fixed yet.
|
6259
|
+
- Check out the issue tracker to make sure someone already hasn't
|
6260
|
+
requested it and/or contributed it.
|
6261
|
+
- Fork the project.
|
6262
|
+
- Start a feature/bugfix branch.
|
6263
|
+
- Commit and push until you are happy with your contribution.
|
6264
|
+
- Make sure to add tests for it. This is important so I don't break it
|
6265
|
+
in a future version unintentionally.
|
6266
|
+
- Please try not to mess with the Rakefile, version, or history. If
|
6267
|
+
you want to have your own version, or is otherwise necessary, that
|
6268
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
6269
|
+
around it.
|
6270
|
+
|
6006
6271
|
## Contributors
|
6007
6272
|
|
6008
6273
|
* [Andy Maleh](https://github.com/AndyObtiva) (Founder)
|