glimmer-dsl-libui 0.3.0 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -0
- data/README.md +1229 -1210
- data/VERSION +1 -1
- data/examples/area_gallery.rb +28 -28
- data/examples/area_gallery2.rb +113 -110
- data/examples/area_gallery3.rb +28 -28
- data/examples/area_gallery4.rb +112 -110
- data/examples/basic_area.rb +1 -3
- data/examples/basic_area2.rb +1 -3
- data/examples/basic_area3.rb +17 -0
- data/examples/basic_area4.rb +19 -0
- data/examples/basic_scrolling_area.rb +79 -0
- data/examples/basic_table_color.rb +1 -11
- data/examples/basic_table_color2.rb +39 -0
- data/examples/basic_table_image.rb +2 -14
- data/examples/basic_table_image2.rb +44 -0
- data/examples/basic_table_image_text.rb +2 -13
- data/examples/basic_table_image_text2.rb +44 -0
- data/examples/basic_transform.rb +3 -6
- data/examples/basic_transform2.rb +34 -0
- data/examples/color_the_circles.rb +1 -3
- data/examples/dynamic_area.rb +1 -3
- data/examples/dynamic_area2.rb +5 -7
- data/examples/form_table.rb +4 -0
- data/examples/grid.rb +4 -4
- data/examples/histogram.rb +4 -8
- data/examples/meta_example.rb +50 -10
- data/examples/snake.rb +1 -3
- data/examples/tetris.rb +15 -18
- data/examples/tic_tac_toe/board.rb +4 -2
- data/examples/tic_tac_toe.rb +1 -3
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/shape_expression.rb +6 -1
- data/lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb +35 -0
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +1 -0
- data/lib/glimmer/libui/control_proxy/column.rb +2 -2
- data/lib/glimmer/libui/control_proxy/image_proxy.rb +42 -35
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +15 -2
- data/lib/glimmer/libui/control_proxy/window_proxy.rb +20 -0
- data/lib/glimmer/libui/shape.rb +49 -1
- metadata +12 -19
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
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.3.
|
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.3.4
|
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)
|
5
5
|
|
6
6
|
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [LibUI](https://github.com/kojix2/LibUI) is a prerequisite-free Ruby desktop development GUI library. No need to pre-install any prerequisites. Just install the gem and have platform-independent native GUI that just works!
|
7
7
|
|
8
|
+
Mac | Windows | Linux
|
9
|
+
----|---------|------
|
10
|
+
![glimmer-dsl-libui-mac-control-gallery.png](images/glimmer-dsl-libui-mac-control-gallery.png) | ![glimmer-dsl-libui-windows-control-gallery.png](images/glimmer-dsl-libui-windows-control-gallery.png) | ![glimmer-dsl-libui-linux-control-gallery.png](images/glimmer-dsl-libui-linux-control-gallery.png)
|
11
|
+
|
8
12
|
[LibUI](https://github.com/kojix2/LibUI) is a thin [Ruby](https://www.ruby-lang.org/en/) wrapper around [libui](https://github.com/andlabs/libui), a relatively new C GUI library that renders native controls on every platform (similar to [SWT](https://www.eclipse.org/swt/), but without the heavy weight of the [Java Virtual Machine](https://www.java.com/en/)).
|
9
13
|
|
10
14
|
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.
|
@@ -28,17 +32,9 @@ include Glimmer
|
|
28
32
|
window('hello world').show
|
29
33
|
```
|
30
34
|
|
31
|
-
Mac
|
32
|
-
|
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
|
-
|
41
|
-
![glimmer-dsl-libui-linux-basic-window.png](images/glimmer-dsl-libui-linux-basic-window.png)
|
35
|
+
Mac | Windows | Linux
|
36
|
+
----|---------|------
|
37
|
+
![glimmer-dsl-libui-mac-basic-window.png](images/glimmer-dsl-libui-mac-basic-window.png) | ![glimmer-dsl-libui-windows-basic-window.png](images/glimmer-dsl-libui-windows-basic-window.png) | ![glimmer-dsl-libui-linux-basic-window.png](images/glimmer-dsl-libui-linux-basic-window.png)
|
42
38
|
|
43
39
|
Basic Table Progress Bar
|
44
40
|
|
@@ -77,17 +73,9 @@ window('Task Progress', 300, 200) {
|
|
77
73
|
}.show
|
78
74
|
```
|
79
75
|
|
80
|
-
Mac
|
81
|
-
|
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
|
-
|
90
|
-
![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
|
76
|
+
Mac | Windows | Linux
|
77
|
+
----|---------|------
|
78
|
+
![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png) | ![glimmer-dsl-libui-windows-basic-table-progress-bar.png](images/glimmer-dsl-libui-windows-basic-table-progress-bar.png) | ![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
|
91
79
|
|
92
80
|
Area Gallery
|
93
81
|
|
@@ -98,50 +86,50 @@ include Glimmer
|
|
98
86
|
|
99
87
|
window('Area Gallery', 400, 400) {
|
100
88
|
area {
|
101
|
-
|
102
|
-
square(0, 0, 100)
|
103
|
-
square(100, 100, 400)
|
104
|
-
|
105
|
-
fill r: 102, g: 102, b: 204
|
106
|
-
}
|
107
|
-
path { # declarative stable path
|
108
|
-
rectangle(0, 100, 100, 400)
|
109
|
-
rectangle(100, 0, 400, 100)
|
110
|
-
|
111
|
-
# linear gradient (has x0, y0, x1, y1, and stops)
|
112
|
-
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
113
|
-
}
|
114
|
-
path { # declarative stable path
|
115
|
-
polygon(100, 100, 100, 400, 400, 100, 400, 400)
|
116
|
-
|
89
|
+
polygon(100, 100, 100, 400, 400, 100, 400, 400) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
117
90
|
fill r: 202, g: 102, b: 104, a: 0.5
|
118
91
|
stroke r: 0, g: 0, b: 0
|
119
92
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
93
|
+
|
94
|
+
polybezier(0, 0,
|
95
|
+
200, 100, 100, 200, 400, 100,
|
96
|
+
300, 100, 100, 300, 100, 400,
|
97
|
+
100, 300, 300, 100, 400, 400) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
123
98
|
fill r: 202, g: 102, b: 204, a: 0.5
|
124
99
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
125
100
|
}
|
126
|
-
path { # declarative stable path
|
127
|
-
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
128
101
|
|
102
|
+
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
129
103
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
130
104
|
}
|
131
|
-
|
132
|
-
|
133
|
-
|
105
|
+
|
106
|
+
arc(404, 216, 190, 90, 90, false) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
134
107
|
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
135
108
|
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}]
|
136
109
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
137
110
|
}
|
138
|
-
|
139
|
-
|
140
|
-
|
111
|
+
|
112
|
+
circle(200, 200, 90) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
141
113
|
fill r: 202, g: 102, b: 204, a: 0.5
|
142
114
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
143
115
|
}
|
144
|
-
|
116
|
+
|
117
|
+
path { # declarative stable path (explicit path syntax for multiple shapes sharing attributes)
|
118
|
+
square(0, 0, 100)
|
119
|
+
square(100, 100, 400)
|
120
|
+
|
121
|
+
fill r: 102, g: 102, b: 204
|
122
|
+
}
|
123
|
+
|
124
|
+
path { # declarative stable path (explicit path syntax for multiple shapes sharing attributes)
|
125
|
+
rectangle(0, 100, 100, 400)
|
126
|
+
rectangle(100, 0, 400, 100)
|
127
|
+
|
128
|
+
# linear gradient (has x0, y0, x1, y1, and stops)
|
129
|
+
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
130
|
+
}
|
131
|
+
|
132
|
+
text(161, 40, 100) { # declarative stable text
|
145
133
|
string('Area Gallery') {
|
146
134
|
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
147
135
|
color :black
|
@@ -199,20 +187,16 @@ window('Area Gallery', 400, 400) {
|
|
199
187
|
}.show
|
200
188
|
```
|
201
189
|
|
202
|
-
Mac
|
203
|
-
|
204
|
-
![glimmer-dsl-libui-mac-area-gallery.png](images/glimmer-dsl-libui-mac-area-gallery.png)
|
205
|
-
|
206
|
-
Windows
|
207
|
-
|
208
|
-
![glimmer-dsl-libui-windows-area-gallery.png](images/glimmer-dsl-libui-windows-area-gallery.png)
|
209
|
-
|
210
|
-
Linux
|
211
|
-
|
212
|
-
![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
190
|
+
Mac | Windows | Linux
|
191
|
+
----|---------|------
|
192
|
+
![glimmer-dsl-libui-mac-area-gallery.png](images/glimmer-dsl-libui-mac-area-gallery.png) | ![glimmer-dsl-libui-windows-area-gallery.png](images/glimmer-dsl-libui-windows-area-gallery.png) | ![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
213
193
|
|
214
194
|
[Check Out Many More Examples Over Here!](#examples)
|
215
195
|
|
196
|
+
Mac | Windows | Linux
|
197
|
+
----|---------|------
|
198
|
+
![glimmer-dsl-libui-mac-tetris.png](images/glimmer-dsl-libui-mac-tetris.png) | ![glimmer-dsl-libui-windows-tetris.png](images/glimmer-dsl-libui-windows-tetris.png) | ![glimmer-dsl-libui-linux-tetris.png](images/glimmer-dsl-libui-linux-tetris.png)
|
199
|
+
|
216
200
|
NOTE: [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) is feature-complete and in beta mode (though the C [libui](https://github.com/andlabs/libui) is still mid-alpha). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. The more feedback and issues you report the better.
|
217
201
|
|
218
202
|
Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interested in:
|
@@ -238,7 +222,15 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
238
222
|
- [Extra Operations](#extra-operations)
|
239
223
|
- [Table API](#table-api)
|
240
224
|
- [Area API](#area-api)
|
241
|
-
- [
|
225
|
+
- [Scrolling Area](#scrolling_area)
|
226
|
+
- [Area Path Shapes](#area-path-shapes)
|
227
|
+
- [Area Text](#area-text)
|
228
|
+
- [Area Image](#area-image)
|
229
|
+
- [Colors](#colors)
|
230
|
+
- [Area Draw Params](#area-draw-params)
|
231
|
+
- [Area Listeners](#area-listeners)
|
232
|
+
- [Area Methods/Attributes](#area-methods-attributes)
|
233
|
+
- [Area Transform Matrix](#area-transform-matrix)
|
242
234
|
- [Smart Defaults and Conventions](#smart-defaults-and-conventions)
|
243
235
|
- [Custom Keywords](#custom-keywords)
|
244
236
|
- [API Gotchas](#api-gotchas)
|
@@ -270,6 +262,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
270
262
|
- [Form Table](#form-table)
|
271
263
|
- [Basic Area](#basic-area)
|
272
264
|
- [Dynamic Area](#dynamic-area)
|
265
|
+
- [Basic Scrolling Area](#basic-scrolling-area)
|
273
266
|
- [Area Gallery](#area-gallery)
|
274
267
|
- [Basic Image](#basic-image)
|
275
268
|
- [Histogram](#histogram)
|
@@ -375,7 +368,7 @@ gem install glimmer-dsl-libui
|
|
375
368
|
Or install via Bundler `Gemfile`:
|
376
369
|
|
377
370
|
```ruby
|
378
|
-
gem 'glimmer-dsl-libui', '~> 0.3.
|
371
|
+
gem 'glimmer-dsl-libui', '~> 0.3.4'
|
379
372
|
```
|
380
373
|
|
381
374
|
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.
|
@@ -446,7 +439,7 @@ w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0
|
|
446
439
|
|
447
440
|
### Supported Keywords
|
448
441
|
|
449
|
-
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`
|
442
|
+
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` can be used as a control under `area` or alternatively build objects to use in `cell_rows` for a `table` with an `image_column`)
|
450
443
|
|
451
444
|
Keyword(Args) | Properties | Listeners
|
452
445
|
------------- | ---------- | ---------
|
@@ -475,7 +468,7 @@ Keyword(Args) | Properties | Listeners
|
|
475
468
|
`group(text as String)` | `margined` (Boolean), `title` (`String`) | None
|
476
469
|
`horizontal_box` | `padded` (Boolean) | None
|
477
470
|
`horizontal_separator` | None | None
|
478
|
-
`image(file as String = nil, width as Numeric = nil, height as Numeric = nil)` |
|
471
|
+
`image(file as String = nil, width as Numeric = nil, height as Numeric = nil)` | `file` (`String` path or URL), `width`, `height` | None
|
479
472
|
`image_part(pixels as String [encoded image rgba byte array], width as Numeric, height as Numeric, byte_stride as Numeric [usually width*4])` | None | None
|
480
473
|
`image_column(name as String)` | None | None
|
481
474
|
`image_text_column(name as String)` | None | None
|
@@ -502,6 +495,7 @@ Keyword(Args) | Properties | Listeners
|
|
502
495
|
`quit_menu_item` | None | `on_clicked`
|
503
496
|
`radio_buttons` | `selected` (`Integer`) | `on_selected`
|
504
497
|
`rectangle(x as Numeric, y as Numeric, width as Numeric, height as Numeric)` | `x` (`Numeric`), `y` (`Numeric`), `width` (`Numeric`), `height` (`Numeric`) | None
|
498
|
+
`scrolling_area(width = main_window.width, height = main_window.height)` | `auto_draw_enabled` (Boolean), `size` (`Array` of `width` (`Numeric`) and `height` (`Numeric`)), `width` (`Numeric`), `height` (`Numeric`) | `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)`
|
505
499
|
`search_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
506
500
|
`separator_menu_item` | None | None
|
507
501
|
`slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
@@ -517,7 +511,7 @@ Keyword(Args) | Properties | Listeners
|
|
517
511
|
`time_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`) | `on_changed`
|
518
512
|
`vertical_box` | `padded` (Boolean) | None
|
519
513
|
`vertical_separator` | None | None
|
520
|
-
`window(title as String, width as Integer, height as Integer, has_menubar as Boolean)` | `borderless` (Boolean), `content_size` (width `Numeric`, height `Numeric`), `fullscreen` (Boolean), `margined` (Boolean), `title` (`String`), `resizable` (Boolean) | `on_closing`, `on_content_size_changed`, `on_destroy`
|
514
|
+
`window(title as String, width as Integer, height as Integer, has_menubar as Boolean)` | `borderless` (Boolean), `content_size` (width `Numeric`, height `Numeric`), `width` (`Numeric`), `height` (`Numeric`), `fullscreen` (Boolean), `margined` (Boolean), `title` (`String`), `resizable` (Boolean) | `on_closing`, `on_content_size_changed`, `on_destroy`
|
521
515
|
|
522
516
|
### Common Control Properties
|
523
517
|
- `enabled` (Boolean)
|
@@ -717,7 +711,9 @@ Learn more by checking out [examples](#examples).
|
|
717
711
|
|
718
712
|
The `area` control is a canvas-like control for drawing paths that can be used in one of two ways:
|
719
713
|
- 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).
|
720
|
-
- 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
|
714
|
+
- 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 an [`area_draw_params`](#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.
|
715
|
+
|
716
|
+
Note that when nesting an `area` directly underneath `window` (without a layout control like `vertical_box`), it is automatically reparented with `vertical_box` in between the `window` and `area` since it would not show up on Linux otherwise.
|
721
717
|
|
722
718
|
Here is an example of a declarative `area` with a stable path (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
723
719
|
|
@@ -741,9 +737,11 @@ window('Basic Area', 400, 400) {
|
|
741
737
|
}.show
|
742
738
|
```
|
743
739
|
|
744
|
-
|
740
|
+
Mac | Windows | Linux
|
741
|
+
----|---------|------
|
742
|
+
![glimmer-dsl-libui-mac-basic-area.png](images/glimmer-dsl-libui-mac-basic-area.png) | ![glimmer-dsl-libui-windows-basic-area.png](images/glimmer-dsl-libui-windows-basic-area.png) | ![glimmer-dsl-libui-linux-basic-area.png](images/glimmer-dsl-libui-linux-basic-area.png)
|
745
743
|
|
746
|
-
Here is the same example using a semi-declarative `area` with `on_draw` listener that receives a `area_draw_params` argument and a dynamic path (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
744
|
+
Here is the same example using a semi-declarative `area` with `on_draw` listener that receives a [`area_draw_params`](#area-draw-params) argument and a dynamic path (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
747
745
|
|
748
746
|
```ruby
|
749
747
|
require 'glimmer-dsl-libui'
|
@@ -769,151 +767,41 @@ window('Basic Area', 400, 400) {
|
|
769
767
|
|
770
768
|
Check [examples/dynamic_area.rb](#dynamic-area) for a more detailed semi-declarative example.
|
771
769
|
|
770
|
+
#### Scrolling Area
|
771
|
+
|
772
|
+
`scrolling_area(width as Numeric = main_window.width, height as Numeric = main_window.height)` is similar to `area`, but has the following additional methods:
|
773
|
+
- `scroll_to(x as Numeric, y as Numeric, width as Numeric = main_window.width, height as Numeric = main_window.height)`: scrolls to `x`/`y` location with `width` and `height` viewport size.
|
774
|
+
- `set_size(width as Numeric, height as Numeric)`: set size of scrolling area, which must must exceed that of visible viewport in order for scrolling to be enabled.
|
775
|
+
|
776
|
+
Mac |
|
777
|
+
----|
|
778
|
+
![glimmer-dsl-libui-mac-dynamic-area.png](images/glimmer-dsl-libui-mac-basic-scrolling-area.png) ![glimmer-dsl-libui-mac-dynamic-area-updated.png](images/glimmer-dsl-libui-mac-basic-scrolling-area-scrolled.png)
|
779
|
+
|
780
|
+
Check [examples/basic_scrolling_area.rb](#basic-scrolling-area) for a more detailed example.
|
781
|
+
|
782
|
+
#### Area Path Shapes
|
783
|
+
|
772
784
|
`path` can receive a `draw_fill_mode` argument that can accept values `:winding` or `:alternate` and defaults to `:winding`.
|
773
785
|
|
774
786
|
Available nested `path` shapes:
|
775
787
|
- `rectangle(x as Numeric, y as Numeric, width as Numeric, height as Numeric)`
|
776
788
|
- `square(x as Numeric, y as Numeric, length as Numeric)`
|
777
789
|
- `arc(x_center as Numeric, y_center as Numeric, radius as Numeric, start_angle as Numeric, sweep as Numeric, is_negative as Boolean)`
|
778
|
-
- `
|
779
|
-
- `
|
780
|
-
- `
|
781
|
-
- `
|
782
|
-
- `
|
790
|
+
- `circle(x_center as Numeric, y_center as Numeric, radius as Numeric)`
|
791
|
+
- `line(x as Numeric, y as Numeric)`: must be placed in a figure (check `polyline`/`polygon` alternatives that do not require a `figure`)
|
792
|
+
- `bezier(c1_x as Numeric, c1_y as Numeric, c2_x as Numeric, c2_y as Numeric, end_x as Numeric, end_y as Numeric)`: must be placed in a figure (check `polybezier` alternative that does not require a `figure`)
|
793
|
+
- `polygon(point_array as Array of Arrays of Numeric or Array of Numeric)`: shortcut for a closed figure of lines; can receive points as [[x1, y1], [x2, y2], ...] or [x1, y1, x2, y2, ...]
|
794
|
+
- `polyline(point_array as Array of Arrays of Numeric or Array of Numeric)`: shortcut for an open figure of lines; can receive points as [[x1, y1], [x2, y2], ...] or [x1, y1, x2, y2, ...]
|
795
|
+
- `polybezier(point_array as Array of Arrays of Numeric or Array of Numeric)`: shortcut for an open figure of beziers; can receive points as [[start_x1, start_y1], [c1_x2, c1_y2, c2_x2, c2_y2, end_x2, end_y2], [c1_x3, c1_y3, c2_x3, c2_y3, end_x3, end_y3], ...] or [start_x1, start_y1, c1_x2, c1_y2, c2_x2, c2_y2, end_x2, end_y2, c1_x3, c1_y3, c2_x3, c2_y3, end_x3, end_y3, ...]
|
783
796
|
- `figure(x=nil as Numeric, y=nil as Numeric)` (composite that can contain other shapes) (can set `closed true` to connect last point to first point automatically)
|
784
797
|
|
785
798
|
Check [examples/area_gallery.rb](#area-gallery) for an overiew of all `path` shapes.
|
786
799
|
|
787
|
-
|
788
|
-
|
789
|
-
-
|
790
|
-
- `:area_height`: area height
|
791
|
-
- `:clip_x`: clip region top-left x coordinate
|
792
|
-
- `:clip_y`: clip region top-left y coordinate
|
793
|
-
- `:clip_width`: clip region width
|
794
|
-
- `:clip_height`: clip region height
|
795
|
-
|
796
|
-
In general, it is recommended to use declarative stable paths whenever feasible since they require less code and simpler maintenance. But, in more advanced cases, semi-declarative dynamic paths could be used instead, especially if there are thousands of dynamic paths that need maximum performance and low memory footprint.
|
797
|
-
|
798
|
-
`area` supported mouse listeners are:
|
799
|
-
- `on_key_event {|area_key_event| ...}`: general catch-all key event (recommend using fine-grained key events below instead)
|
800
|
-
- `on_key_down {|area_key_event| ...}`
|
801
|
-
- `on_key_up {|area_key_event| ...}`
|
802
|
-
- `on_mouse_event {|area_mouse_event| ...}`: general catch-all mouse event (recommend using fine-grained mouse events below instead)
|
803
|
-
- `on_mouse_down {|area_mouse_event| ...}`
|
804
|
-
- `on_mouse_up {|area_mouse_event| ...}`
|
805
|
-
- `on_mouse_drag_started {|area_mouse_event| ...}`
|
806
|
-
- `on_mouse_dragged {|area_mouse_event| ...}`
|
807
|
-
- `on_mouse_dropped {|area_mouse_event| ...}`
|
808
|
-
- `on_mouse_entered {...}`
|
809
|
-
- `on_mouse_exited {...}`
|
810
|
-
- `on_mouse_crossed {|left| ...}` (NOT RECOMMENDED; it does what `on_mouse_entered` and `on_mouse_exited` do by returning a `left` argument indicating if mouse left `area`)
|
811
|
-
- `on_drag_broken {...}` (NOT RECOMMENDED; varies per platforms; use `on_mouse_dropped` instead)
|
812
|
-
|
813
|
-
The `area_mouse_event` `Hash` argument for mouse events that receive it (e.g. `on_mouse_up`, `on_mouse_dragged`) consist of the following hash keys:
|
814
|
-
- `:x`: mouse x location in relation to area's top-left-corner
|
815
|
-
- `:y`: mouse y location in relation to area's top-left-corner
|
816
|
-
- `:area_width`: area current width
|
817
|
-
- `:area_height`: area current height
|
818
|
-
- `:down`: mouse pressed button (e.g. `1` is left button, `3` is right button)
|
819
|
-
- `:up`: mouse depressed button (e.g. `1` is left button, `3` is right button)
|
820
|
-
- `:count`: count of mouse clicks (e.g. `2` for double-click, `1` for single-click)
|
821
|
-
- `:modifers`: `Array` of `Symbol`s from one of the following: `[:command, :shift, :alt, :control]`
|
822
|
-
- `:held`: mouse held button during dragging (e.g. `1` is left button, `4` is right button)
|
823
|
-
|
824
|
-
The `area_key_event` `Hash` argument for keyboard events that receive it (e.g. `on_key_up`, `on_key_down`) consist of the following hash keys:
|
825
|
-
- `:key`: key character (`String`)
|
826
|
-
- `:key_value`: key value (`Integer`). Useful in rare cases for numeric processing of keys instead of dealing with as `:key` character `String`
|
827
|
-
- `:ext_key`: non-character extra key (`Symbol`) from `Glimmer::LibUI.enum_symbols(:ext_key)` such as `:left`, `:right`, `:escape`, `:insert`
|
828
|
-
- `:ext_key_value`: non-character extra key value (`Integer`). Useful in rare cases for numeric processing of extra keys instead of dealing with as `:ext_key` `Symbol`
|
829
|
-
- `:modifier`: modifier key pressed alone (e.g. `:shift` or `:control`)
|
830
|
-
- `:modifiers`: modifier keys pressed simultaneously with `:key`, `:ext_key`, or `:modifier`
|
831
|
-
- `:up`: indicates if key has been released or not (Boolean)
|
832
|
-
|
833
|
-
Note that when nesting an `area` directly underneath `window` (without a layout control like `vertical_box`), it is automatically reparented with `vertical_box` in between the `window` and `area` since it would not show up on Linux otherwise.
|
834
|
-
|
835
|
-
To redraw an `area`, you may call the `#queue_redraw_all` method, or simply `#redraw`.
|
836
|
-
|
837
|
-
`area` has the following Glimmer-added API methods/attributes:
|
838
|
-
- `request_auto_redraw`: requests auto redraw upon changes to nested stable `path` or shapes
|
839
|
-
- `pause_auto_redraw`: pause auto redraw upon changes to nested stable `path` or shapes (useful to avoid too many micro-change redraws, to group all redraws as one after many micro-changes)
|
840
|
-
- `resume_auto_redraw`: resume auto redraw upon changes to nested stable `path` or shapes
|
841
|
-
- `auto_redraw_enabled`/`auto_redraw_enabled?`/`auto_redraw_enabled=`: an attribute to disable/enable auto redraw on an `area` upon changes to nested stable `path` or shapes
|
842
|
-
|
843
|
-
A transform `matrix` can be set on a path by building a `matrix(m11 = nil, m12 = nil, m21 = nil, m22 = nil, m31 = nil, m32 = nil) {operations}` proxy object and then setting via `transform` property, or alternatively by building and setting the matrix in one call to `transform(m11 = nil, m12 = nil, m21 = nil, m22 = nil, m31 = nil, m32 = nil) {operations}` passing it the matrix arguments and/or content operations.
|
844
|
-
|
845
|
-
When instantiating a `matrix` object, it always starts with identity matrix.
|
846
|
-
|
847
|
-
Here are the following operations that can be performed in a `matrix` body:
|
848
|
-
- `identity` [alias: `set_identity`]: resets matrix to identity matrix
|
849
|
-
- `translate(x as Numeric, y as Numeric)`
|
850
|
-
- `scale(x_center = 0 as Numeric, y_center = 0 as Numeric, x as Numeric, y as Numeric)`
|
851
|
-
- `skew(x = 0 as Numeric, y = 0 as Numeric, x_amount as Numeric, y_amount as Numeric)`
|
852
|
-
- `rotate(x = 0 as Numeric, y = 0 as Numeric, degrees as Numeric)`
|
853
|
-
|
854
|
-
Example of using transform matrix (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
855
|
-
|
856
|
-
```ruby
|
857
|
-
require 'glimmer-dsl-libui'
|
858
|
-
|
859
|
-
include Glimmer
|
860
|
-
|
861
|
-
window('Basic Transform', 350, 350) {
|
862
|
-
area {
|
863
|
-
path {
|
864
|
-
square(0, 0, 350)
|
865
|
-
|
866
|
-
fill r: 255, g: 255, b: 0
|
867
|
-
}
|
868
|
-
40.times do |n|
|
869
|
-
path {
|
870
|
-
square(0, 0, 100)
|
871
|
-
|
872
|
-
fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
|
873
|
-
stroke :black, thickness: 2
|
874
|
-
transform {
|
875
|
-
skew 0.15, 0.15
|
876
|
-
translate 50, 50
|
877
|
-
rotate 100, 100, -9 * n
|
878
|
-
scale 1.1, 1.1
|
879
|
-
}
|
880
|
-
}
|
881
|
-
end
|
882
|
-
}
|
883
|
-
}.show
|
884
|
-
```
|
885
|
-
|
886
|
-
Keep in mind that this part could be written differently when there is a need to reuse the matrix:
|
887
|
-
|
888
|
-
```ruby
|
889
|
-
transform {
|
890
|
-
translate 100, 100
|
891
|
-
rotate 100, 100, -9 * n
|
892
|
-
}
|
893
|
-
```
|
894
|
-
|
895
|
-
Alternatively:
|
896
|
-
|
897
|
-
```ruby
|
898
|
-
m1 = matrix {
|
899
|
-
translate 100, 100
|
900
|
-
rotate 100, 100, -9 * n
|
901
|
-
}
|
902
|
-
transform m1
|
903
|
-
# and then reuse m1 elsewhere too
|
904
|
-
```
|
905
|
-
|
906
|
-
You can set a `matrix`/`transform` on `area` directly to conveniently apply to all nested `path`s too.
|
907
|
-
|
908
|
-
Note that `area`, `path`, and nested shapes are all truly declarative, meaning they do not care about the ordering of calls to `fill`, `stroke`, and `transform`. Furthermore, any transform that is applied is reversed at the end of the block, so you never have to worry about the ordering of `transform` calls among different paths. You simply set a transform on the `path`s that need it and it is guaranteed to be called before all its content is drawn, and then undone afterwards to avoid affecting later paths. Matrix `transform` can be set on an entire `area` too, applying to all nested `path`s.
|
909
|
-
|
910
|
-
`fill` and `stroke` accept [X11](https://en.wikipedia.org/wiki/X11_color_names) color `Symbol`s/`String`s like `:skyblue` and `'sandybrown'` or 6-char hex or 3-char hex-shorthand (as `Integer` or `String` with or without `0x` prefix)
|
911
|
-
|
912
|
-
Available [X11 colors](https://en.wikipedia.org/wiki/X11_color_names) can be obtained through `Glimmer::LibUI.x11_colors` method.
|
913
|
-
|
914
|
-
Check [Basic Transform](#basic-transform) example for use of [X11](https://en.wikipedia.org/wiki/X11_color_names) colors.
|
800
|
+
Mac | Windows | Linux
|
801
|
+
----|---------|------
|
802
|
+
![glimmer-dsl-libui-mac-area-gallery.png](images/glimmer-dsl-libui-mac-area-gallery.png) | ![glimmer-dsl-libui-windows-area-gallery.png](images/glimmer-dsl-libui-windows-area-gallery.png) | ![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
915
803
|
|
916
|
-
|
804
|
+
#### Area Text
|
917
805
|
|
918
806
|
To draw `text` in an `area`, you simply nest a `text(x, y, width)` control directly under `area` or inside a `on_draw` listener, and then nest attributed `string {[attributes]; string_value}` controls underneath it returning an actual `String` (think of them as the `<span>` or `<p>` element in html, which contains a string of text). Alternatively, you can nest attributed `string(string_value) {[attributes]}` if `string_value` is a short single-line string. An attributed `string` value can be changed dynamically via its `string` property.
|
919
807
|
|
@@ -964,25 +852,34 @@ window('area text drawing') {
|
|
964
852
|
}.show
|
965
853
|
```
|
966
854
|
|
967
|
-
|
855
|
+
You may checkout [examples/basic_draw_text.rb](#basic-draw-text) and [examples/custom_draw_text.rb](#custom-draw-text) for examples of using `text` inside `area`.
|
856
|
+
|
857
|
+
Mac | Windows | Linux
|
858
|
+
----|---------|------
|
859
|
+
![glimmer-dsl-libui-mac-custom-draw-text-changed.png](images/glimmer-dsl-libui-mac-custom-draw-text-changed.png) | ![glimmer-dsl-libui-windows-custom-draw-text-changed.png](images/glimmer-dsl-libui-windows-custom-draw-text-changed.png) | ![glimmer-dsl-libui-linux-custom-draw-text-changed.png](images/glimmer-dsl-libui-linux-custom-draw-text-changed.png)
|
860
|
+
|
861
|
+
#### Area Image
|
968
862
|
|
969
863
|
**(ALPHA FEATURE)**
|
970
864
|
|
971
865
|
[libui](https://github.com/andlabs/libui) does not support `image` rendering outside of `table` yet.
|
972
|
-
However, [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) adds a special `image` custom control that renders an image unto an `area` pixel by pixel (and when possible to optimize, line by line).
|
866
|
+
However, [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) adds a special `image(file as String path or web URL, width as Numeric, height as Numeric)` custom control that renders an image unto an `area` pixel by pixel (and when possible to optimize, line by line).
|
973
867
|
|
974
|
-
Given that it is not a [libui](https://github.com/andlabs/libui)-native control, please keep these notes in mind:
|
975
|
-
-
|
868
|
+
Given that it is very new and is not a [libui](https://github.com/andlabs/libui)-native control, please keep these notes in mind:
|
869
|
+
- It only supports the `.png` file format.
|
870
|
+
- [libui](https://github.com/andlabs/libui) pixel-by-pixel rendering performance is slow.
|
976
871
|
- Including an `image` inside an `area` `on_draw` listener improves performance due to not retaining pixel/line data in memory.
|
977
|
-
- Supplying `width` and `height` (2nd and 3rd arguments) greatly improves performance when shrinking image
|
872
|
+
- Supplying `width` and `height` (2nd and 3rd arguments) greatly improves performance when shrinking image.
|
978
873
|
|
979
874
|
Currently, it is recommended to use `image` with very small `width` and `height` values only.
|
980
875
|
|
981
|
-
Setting a `transform` `matrix` is supported under `image` just like it is under `path` and `text` inside `area`.
|
876
|
+
Setting a [`transform` `matrix`](#area-transform-matrix) is supported under `image` just like it is under `path` and `text` inside `area`.
|
982
877
|
|
983
878
|
Example of using `image` declaratively (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
984
879
|
|
985
|
-
|
880
|
+
Mac | Windows | Linux
|
881
|
+
----|---------|------
|
882
|
+
![glimmer-dsl-libui-mac-basic-image.png](images/glimmer-dsl-libui-mac-basic-image.png) | ![glimmer-dsl-libui-windows-basic-image.png](images/glimmer-dsl-libui-windows-basic-image.png) | ![glimmer-dsl-libui-linux-basic-image.png](images/glimmer-dsl-libui-linux-basic-image.png)
|
986
883
|
|
987
884
|
```ruby
|
988
885
|
require 'glimmer-dsl-libui'
|
@@ -1128,76 +1025,219 @@ window('Basic Image', 96, 96) {
|
|
1128
1025
|
}.show
|
1129
1026
|
```
|
1130
1027
|
|
1131
|
-
|
1028
|
+
One final note is that in Linux, table images grow and shrink with the image size unlike on the Mac where table row heights are constant regardless of image sizes. As such, you may be able to repurpose a table with a single image column and a single row as an image control with more native libui rendering if you are only targeting Linux with your app.
|
1132
1029
|
|
1133
|
-
|
1030
|
+
Check out [examples/basic_image.rb](#basic-image) (all versions) for examples of using `image` Glimmer custom control.
|
1134
1031
|
|
1135
|
-
|
1136
|
-
- `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
|
1137
|
-
- All controls nested under a `horizontal_box`, `vertical_box`, and `form` have `stretchy` property (fill maximum space) as `true` by default (passed to `box_append`/`form_append` method)
|
1138
|
-
- `window` instatiation args can be left off, having the following defaults when unspecified: `title` as `''`, `width` as `190`, `height` as `150`, and `has_menubar` as `true`)
|
1139
|
-
- `window` has an `on_closing` listener by default that quits application upon hitting the close button (can be overridden with a manual `on_closing` implementation that returns integer `0` for success)
|
1140
|
-
- `group` has `title` property default to `''` if not specified in instantiation args, so it can be instantiated without args with `title` property specified in nested block (e.g. `group {title 'Address'; ...}`)
|
1141
|
-
- `button`, `checkbox`, and `label` have `text` default to `''` if not specified in instantiation args, so they can be instantiated without args with `text` property specified in nested block (e.g. `button {text 'Greet'; on_clicked {puts 'Hello'}}`)
|
1142
|
-
- `quit_menu_item` has an `on_clicked` listener by default that quits application upon selecting the quit menu item (can be overridden with a manual `on_clicked` implementation that returns integer `0` for success)
|
1143
|
-
- If an `on_closing` listener was defined on `window` and it does not return an integer, default exit behavior is assumed (`window.destroy` is called followed by `LibUI.quit`, returning `0`).
|
1144
|
-
- If an `on_clicked` listener was defined on `quit_menu_item` and it does not return an integer, default exit behavior is assumed (`main_window.destroy` is called followed by `LibUI.quit`, returning `0`).
|
1145
|
-
- All boolean property readers return `true` or `false` in Ruby instead of the [libui](https://github.com/andlabs/libui) original `0` or `1` in C.
|
1146
|
-
- All boolean property writers accept `true`/`false` in addition to `1`/`0` in Ruby
|
1147
|
-
- All string property readers return a `String` object in Ruby instead of the [libui](https://github.com/andlabs/libui) Fiddle pointer object.
|
1148
|
-
- Automatically allocate font descriptors upon instantiating `font_button` controls and free them when destorying `font_button` controls
|
1149
|
-
- Automatically allocate color value pointers upon instantiating `color_button` controls and free them when destorying `color_button` controls
|
1150
|
-
- On the Mac, if no `menu` items were added, an automatic `quit_menu_item` is added to enable quitting with CTRL+Q
|
1151
|
-
- When destroying a control nested under a `horizontal_box` or `vertical_box`, it is automatically deleted from the box's children
|
1152
|
-
- When destroying a control nested under a `form`, it is automatically deleted from the form's children
|
1153
|
-
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
1154
|
-
- For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui](https://github.com/andlabs/libui) original 0-based values, and return `dst` as Boolean instead of `isdst` as `1`/`0`
|
1155
|
-
- Smart defaults for `grid` child properties are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`:fill`), `vexpand` (`false`), and `valign` (`:fill`)
|
1156
|
-
- The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows` and `editable` properties (e.g. `NumRows`) as well as nested columns (e.g. `text_column`)
|
1157
|
-
- Table model instances are automatically freed from memory after `window` is destroyed.
|
1158
|
-
- 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.
|
1159
|
-
- `image` instances are automatically freed from memory after `window` is destroyed.
|
1160
|
-
- `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`
|
1161
|
-
- Automatically provide shifted `:key` characters in `area_key_event` provided in `area` key listeners `on_key_event`, `on_key_down`, and `on_key_up`
|
1162
|
-
- `area` paths are specified declaratively with figures underneath (e.g. `rectangle`) and `area` draw listener is automatically generated
|
1163
|
-
- Observe figure properties (e.g. `rectangle` `width`) for changes and automatically redraw containing area accordingly
|
1164
|
-
- Observe `path` `fill` and `stroke` hashes for changes and automatically redraw containing area accordingly
|
1165
|
-
- Observe `text` and `string` properties for changes and automatically redraw containing area accordingly
|
1166
|
-
- All controls are protected from garbage collection until no longer needed (explicitly destroyed), so there is no need to worry about surprises.
|
1167
|
-
- All resources are freed automatically once no longer needed or left to garbage collection.
|
1168
|
-
- When nesting an `area` directly underneath `window` (without a layout control like `vertical_box`), it is automatically reparented with `vertical_box` in between the `window` and `area` since it would not show up on Linux otherwise.
|
1169
|
-
- Colors may be passed in as a hash of `:r`, `:g`, `:b`, `:a`, or `:red`, `:green`, `:blue`, `:alpha`, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color like `:skyblue`, or 6-char hex or 3-char hex (as `Integer` or `String` with or without `0x` prefix)
|
1170
|
-
- Color alpha value defaults to `1.0` when not specified.
|
1032
|
+
#### Colors
|
1171
1033
|
|
1172
|
-
|
1034
|
+
`fill` and `stroke` accept [X11](https://en.wikipedia.org/wiki/X11_color_names) color `Symbol`s/`String`s like `:skyblue` and `'sandybrown'` or 6-char hex or 3-char hex-shorthand (as `Integer` or `String` with or without `0x` prefix)
|
1173
1035
|
|
1174
|
-
|
1036
|
+
Available [X11 colors](https://en.wikipedia.org/wiki/X11_color_names) can be obtained through `Glimmer::LibUI.x11_colors` method.
|
1175
1037
|
|
1176
|
-
|
1038
|
+
Check [Basic Transform](#basic-transform) example for use of [X11](https://en.wikipedia.org/wiki/X11_color_names) colors.
|
1177
1039
|
|
1178
|
-
|
1179
|
-
require 'glimmer-dsl-libui'
|
1180
|
-
require 'facets'
|
1040
|
+
Check [Histogram](#histogram) example for use of hex colors.
|
1181
1041
|
|
1182
|
-
|
1042
|
+
#### Area Draw Params
|
1183
1043
|
|
1184
|
-
|
1044
|
+
The `area_draw_params` `Hash` argument for `on_draw` block is a hash consisting of the following keys:
|
1045
|
+
- `:context`: the drawing context object
|
1046
|
+
- `:area_width`: area width
|
1047
|
+
- `:area_height`: area height
|
1048
|
+
- `:clip_x`: clip region top-left x coordinate
|
1049
|
+
- `:clip_y`: clip region top-left y coordinate
|
1050
|
+
- `:clip_width`: clip region width
|
1051
|
+
- `:clip_height`: clip region height
|
1185
1052
|
|
1186
|
-
|
1187
|
-
property = property.to_s
|
1188
|
-
entry { |e|
|
1189
|
-
label property.underscore.split('_').map(&:capitalize).join(' ')
|
1190
|
-
text model.send(property).to_s
|
1053
|
+
In general, it is recommended to use declarative stable paths whenever feasible since they require less code and simpler maintenance. But, in more advanced cases, semi-declarative dynamic paths could be used instead, especially if there are thousands of dynamic paths that need maximum performance and low memory footprint.
|
1191
1054
|
|
1192
|
-
|
1193
|
-
model.send("#{property}=", e.text)
|
1194
|
-
end
|
1195
|
-
}
|
1196
|
-
end
|
1055
|
+
#### Area Listeners
|
1197
1056
|
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1057
|
+
`area` supported listeners are:
|
1058
|
+
- `on_key_event {|area_key_event| ...}`: general catch-all key event (recommend using fine-grained key events below instead)
|
1059
|
+
- `on_key_down {|area_key_event| ...}`
|
1060
|
+
- `on_key_up {|area_key_event| ...}`
|
1061
|
+
- `on_mouse_event {|area_mouse_event| ...}`: general catch-all mouse event (recommend using fine-grained mouse events below instead)
|
1062
|
+
- `on_mouse_down {|area_mouse_event| ...}`
|
1063
|
+
- `on_mouse_up {|area_mouse_event| ...}`
|
1064
|
+
- `on_mouse_drag_started {|area_mouse_event| ...}`
|
1065
|
+
- `on_mouse_dragged {|area_mouse_event| ...}`
|
1066
|
+
- `on_mouse_dropped {|area_mouse_event| ...}`
|
1067
|
+
- `on_mouse_entered {...}`
|
1068
|
+
- `on_mouse_exited {...}`
|
1069
|
+
- `on_mouse_crossed {|left| ...}` (NOT RECOMMENDED; it does what `on_mouse_entered` and `on_mouse_exited` do by returning a `left` argument indicating if mouse left `area`)
|
1070
|
+
- `on_drag_broken {...}` (NOT RECOMMENDED; varies per platforms; use `on_mouse_dropped` instead)
|
1071
|
+
|
1072
|
+
The `area_mouse_event` `Hash` argument for mouse events that receive it (e.g. `on_mouse_up`, `on_mouse_dragged`) consist of the following hash keys:
|
1073
|
+
- `:x`: mouse x location in relation to area's top-left-corner
|
1074
|
+
- `:y`: mouse y location in relation to area's top-left-corner
|
1075
|
+
- `:area_width`: area current width
|
1076
|
+
- `:area_height`: area current height
|
1077
|
+
- `:down`: mouse pressed button (e.g. `1` is left button, `3` is right button)
|
1078
|
+
- `:up`: mouse depressed button (e.g. `1` is left button, `3` is right button)
|
1079
|
+
- `:count`: count of mouse clicks (e.g. `2` for double-click, `1` for single-click)
|
1080
|
+
- `:modifers`: `Array` of `Symbol`s from one of the following: `[:command, :shift, :alt, :control]`
|
1081
|
+
- `:held`: mouse held button during dragging (e.g. `1` is left button, `4` is right button)
|
1082
|
+
|
1083
|
+
The `area_key_event` `Hash` argument for keyboard events that receive it (e.g. `on_key_up`, `on_key_down`) consist of the following hash keys:
|
1084
|
+
- `:key`: key character (`String`)
|
1085
|
+
- `:key_value` (alias: `:key_code`): key code value (`Integer`). Useful in rare cases for numeric processing of keys instead of dealing with as `:key` character `String`
|
1086
|
+
- `:ext_key`: non-character extra key (`Symbol`) from `Glimmer::LibUI.enum_symbols(:ext_key)` such as `:left`, `:right`, `:escape`, `:insert`
|
1087
|
+
- `:ext_key_value`: non-character extra key value (`Integer`). Useful in rare cases for numeric processing of extra keys instead of dealing with as `:ext_key` `Symbol`
|
1088
|
+
- `:modifier`: modifier key pressed alone (e.g. `:shift` or `:control`)
|
1089
|
+
- `:modifiers`: modifier keys pressed simultaneously with `:key`, `:ext_key`, or `:modifier`
|
1090
|
+
- `:up`: indicates if key has been released or not (Boolean)
|
1091
|
+
|
1092
|
+
#### Area Methods/Attributes
|
1093
|
+
|
1094
|
+
To redraw an `area`, you may call the `#queue_redraw_all` method, or simply `#redraw`.
|
1095
|
+
|
1096
|
+
`area` has the following Glimmer-added API methods/attributes:
|
1097
|
+
- `request_auto_redraw`: requests auto redraw upon changes to nested stable `path` or shapes
|
1098
|
+
- `pause_auto_redraw`: pause auto redraw upon changes to nested stable `path` or shapes (useful to avoid too many micro-change redraws, to group all redraws as one after many micro-changes)
|
1099
|
+
- `resume_auto_redraw`: resume auto redraw upon changes to nested stable `path` or shapes
|
1100
|
+
- `auto_redraw_enabled`/`auto_redraw_enabled?`/`auto_redraw_enabled=`: an attribute to disable/enable auto redraw on an `area` upon changes to nested stable `path` or shapes
|
1101
|
+
|
1102
|
+
#### Area Transform Matrix
|
1103
|
+
|
1104
|
+
A transform `matrix` can be set on a path by building a `matrix(m11 = nil, m12 = nil, m21 = nil, m22 = nil, m31 = nil, m32 = nil) {operations}` proxy object and then setting via `transform` property, or alternatively by building and setting the matrix in one call to `transform(m11 = nil, m12 = nil, m21 = nil, m22 = nil, m31 = nil, m32 = nil) {operations}` passing it the matrix arguments and/or content operations.
|
1105
|
+
|
1106
|
+
When instantiating a `matrix` object, it always starts with identity matrix.
|
1107
|
+
|
1108
|
+
Here are the following operations that can be performed in a `matrix` body:
|
1109
|
+
- `identity` [alias: `set_identity`]: resets matrix to identity matrix
|
1110
|
+
- `translate(x as Numeric, y as Numeric)`
|
1111
|
+
- `scale(x_center = 0 as Numeric, y_center = 0 as Numeric, x as Numeric, y as Numeric)`
|
1112
|
+
- `skew(x = 0 as Numeric, y = 0 as Numeric, x_amount as Numeric, y_amount as Numeric)`
|
1113
|
+
- `rotate(x = 0 as Numeric, y = 0 as Numeric, degrees as Numeric)`
|
1114
|
+
|
1115
|
+
Example of using transform matrix (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
1116
|
+
|
1117
|
+
```ruby
|
1118
|
+
require 'glimmer-dsl-libui'
|
1119
|
+
|
1120
|
+
include Glimmer
|
1121
|
+
|
1122
|
+
window('Basic Transform', 350, 350) {
|
1123
|
+
area {
|
1124
|
+
path {
|
1125
|
+
square(0, 0, 350)
|
1126
|
+
|
1127
|
+
fill r: 255, g: 255, b: 0
|
1128
|
+
}
|
1129
|
+
40.times do |n|
|
1130
|
+
path {
|
1131
|
+
square(0, 0, 100)
|
1132
|
+
|
1133
|
+
fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
|
1134
|
+
stroke :black, thickness: 2
|
1135
|
+
transform {
|
1136
|
+
skew 0.15, 0.15
|
1137
|
+
translate 50, 50
|
1138
|
+
rotate 100, 100, -9 * n
|
1139
|
+
scale 1.1, 1.1
|
1140
|
+
}
|
1141
|
+
}
|
1142
|
+
end
|
1143
|
+
}
|
1144
|
+
}.show
|
1145
|
+
```
|
1146
|
+
|
1147
|
+
Keep in mind that this part could be written differently when there is a need to reuse the matrix:
|
1148
|
+
|
1149
|
+
```ruby
|
1150
|
+
transform {
|
1151
|
+
translate 100, 100
|
1152
|
+
rotate 100, 100, -9 * n
|
1153
|
+
}
|
1154
|
+
```
|
1155
|
+
|
1156
|
+
Alternatively:
|
1157
|
+
|
1158
|
+
```ruby
|
1159
|
+
m1 = matrix {
|
1160
|
+
translate 100, 100
|
1161
|
+
rotate 100, 100, -9 * n
|
1162
|
+
}
|
1163
|
+
transform m1
|
1164
|
+
# and then reuse m1 elsewhere too
|
1165
|
+
```
|
1166
|
+
|
1167
|
+
You can set a `matrix`/`transform` on `area` directly to conveniently apply to all nested `path`s too.
|
1168
|
+
|
1169
|
+
Note that `area`, `path`, and nested shapes are all truly declarative, meaning they do not care about the ordering of calls to `fill`, `stroke`, and `transform`. Furthermore, any transform that is applied is reversed at the end of the block, so you never have to worry about the ordering of `transform` calls among different paths. You simply set a transform on the `path`s that need it and it is guaranteed to be called before all its content is drawn, and then undone afterwards to avoid affecting later paths. Matrix `transform` can be set on an entire `area` too, applying to all nested `path`s.
|
1170
|
+
|
1171
|
+
### Smart Defaults and Conventions
|
1172
|
+
|
1173
|
+
- `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
|
1174
|
+
- `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
|
1175
|
+
- All controls nested under a `horizontal_box`, `vertical_box`, and `form` have `stretchy` property (fill maximum space) as `true` by default (passed to `box_append`/`form_append` method)
|
1176
|
+
- `window` instatiation args can be left off, having the following defaults when unspecified: `title` as `''`, `width` as `190`, `height` as `150`, and `has_menubar` as `true`)
|
1177
|
+
- `window` has an `on_closing` listener by default that quits application upon hitting the close button (can be overridden with a manual `on_closing` implementation that returns integer `0` for success)
|
1178
|
+
- `group` has `title` property default to `''` if not specified in instantiation args, so it can be instantiated without args with `title` property specified in nested block (e.g. `group {title 'Address'; ...}`)
|
1179
|
+
- `button`, `checkbox`, and `label` have `text` default to `''` if not specified in instantiation args, so they can be instantiated without args with `text` property specified in nested block (e.g. `button {text 'Greet'; on_clicked {puts 'Hello'}}`)
|
1180
|
+
- `quit_menu_item` has an `on_clicked` listener by default that quits application upon selecting the quit menu item (can be overridden with a manual `on_clicked` implementation that returns integer `0` for success)
|
1181
|
+
- If an `on_closing` listener was defined on `window` and it does not return an integer, default exit behavior is assumed (`window.destroy` is called followed by `LibUI.quit`, returning `0`).
|
1182
|
+
- If an `on_clicked` listener was defined on `quit_menu_item` and it does not return an integer, default exit behavior is assumed (`main_window.destroy` is called followed by `LibUI.quit`, returning `0`).
|
1183
|
+
- All boolean property readers return `true` or `false` in Ruby instead of the [libui](https://github.com/andlabs/libui) original `0` or `1` in C.
|
1184
|
+
- All boolean property writers accept `true`/`false` in addition to `1`/`0` in Ruby
|
1185
|
+
- All string property readers return a `String` object in Ruby instead of the [libui](https://github.com/andlabs/libui) Fiddle pointer object.
|
1186
|
+
- Automatically allocate font descriptors upon instantiating `font_button` controls and free them when destorying `font_button` controls
|
1187
|
+
- Automatically allocate color value pointers upon instantiating `color_button` controls and free them when destorying `color_button` controls
|
1188
|
+
- On the Mac, if no `menu` items were added, an automatic `quit_menu_item` is added to enable quitting with CTRL+Q
|
1189
|
+
- When destroying a control nested under a `horizontal_box` or `vertical_box`, it is automatically deleted from the box's children
|
1190
|
+
- When destroying a control nested under a `form`, it is automatically deleted from the form's children
|
1191
|
+
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
1192
|
+
- For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui](https://github.com/andlabs/libui) original 0-based values, and return `dst` as Boolean instead of `isdst` as `1`/`0`
|
1193
|
+
- Smart defaults for `grid` child properties are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`:fill`), `vexpand` (`false`), and `valign` (`:fill`)
|
1194
|
+
- The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows` and `editable` properties (e.g. `NumRows`) as well as nested columns (e.g. `text_column`)
|
1195
|
+
- Table model instances are automatically freed from memory after `window` is destroyed.
|
1196
|
+
- 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.
|
1197
|
+
- `image` instances are automatically freed from memory after `window` is destroyed.
|
1198
|
+
- `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`
|
1199
|
+
- Automatically provide shifted `:key` characters in `area_key_event` provided in `area` key listeners `on_key_event`, `on_key_down`, and `on_key_up`
|
1200
|
+
- `scrolling_area` `width` and `height` default to main window width and height if not specified.
|
1201
|
+
- `scrolling_area` `#scroll_to` 3rd and 4th arguments (`width` and `height`) default to main window width and height if not specified.
|
1202
|
+
- `area` paths are specified declaratively with figures underneath (e.g. `rectangle`) and `area` draw listener is automatically generated
|
1203
|
+
- Observe figure properties (e.g. `rectangle` `width`) for changes and automatically redraw containing area accordingly
|
1204
|
+
- Observe `path` `fill` and `stroke` hashes for changes and automatically redraw containing area accordingly
|
1205
|
+
- Observe `text` and `string` properties for changes and automatically redraw containing area accordingly
|
1206
|
+
- All controls are protected from garbage collection until no longer needed (explicitly destroyed), so there is no need to worry about surprises.
|
1207
|
+
- All resources are freed automatically once no longer needed or left to garbage collection.
|
1208
|
+
- When nesting an `area` directly underneath `window` (without a layout control like `vertical_box`), it is automatically reparented with `vertical_box` in between the `window` and `area` since it would not show up on Linux otherwise.
|
1209
|
+
- Colors may be passed in as a hash of `:r`, `:g`, `:b`, `:a`, or `:red`, `:green`, `:blue`, `:alpha`, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color like `:skyblue`, or 6-char hex or 3-char hex (as `Integer` or `String` with or without `0x` prefix)
|
1210
|
+
- Color alpha value defaults to `1.0` when not specified.
|
1211
|
+
|
1212
|
+
### Custom Keywords
|
1213
|
+
|
1214
|
+
To define custom keywords, simply define a method representing the custom control you want. To make reusable, you can define in modules and simply include the modules in the view classes that need them.
|
1215
|
+
|
1216
|
+
Example that defines `form_field`, `address_form`, `label_pair`, and `address` keywords (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
1217
|
+
|
1218
|
+
```ruby
|
1219
|
+
require 'glimmer-dsl-libui'
|
1220
|
+
require 'facets'
|
1221
|
+
|
1222
|
+
include Glimmer
|
1223
|
+
|
1224
|
+
Address = Struct.new(:street, :p_o_box, :city, :state, :zip_code)
|
1225
|
+
|
1226
|
+
def form_field(model, property)
|
1227
|
+
property = property.to_s
|
1228
|
+
entry { |e|
|
1229
|
+
label property.underscore.split('_').map(&:capitalize).join(' ')
|
1230
|
+
text model.send(property).to_s
|
1231
|
+
|
1232
|
+
on_changed do
|
1233
|
+
model.send("#{property}=", e.text)
|
1234
|
+
end
|
1235
|
+
}
|
1236
|
+
end
|
1237
|
+
|
1238
|
+
def address_form(address)
|
1239
|
+
form {
|
1240
|
+
form_field(address, :street)
|
1201
1241
|
form_field(address, :p_o_box)
|
1202
1242
|
form_field(address, :city)
|
1203
1243
|
form_field(address, :state)
|
@@ -1280,7 +1320,8 @@ window('Method-Based Custom Keyword') {
|
|
1280
1320
|
### API Gotchas
|
1281
1321
|
|
1282
1322
|
- 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`).
|
1283
|
-
- `table` `checkbox_column`
|
1323
|
+
- `table` `checkbox_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).
|
1324
|
+
- `table` `checkbox_text_column` checkbox editing only works on Linux (not Mac or Windows) due to a current limitation in [libui](https://github.com/andlabs/ui/issues/357).
|
1284
1325
|
- `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)
|
1285
1326
|
- `text` `string` `background` does not work on Windows due to an [issue in libui](https://github.com/andlabs/libui/issues/347).
|
1286
1327
|
- `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.
|
@@ -1307,12 +1348,122 @@ For Linux, simply package your app as a [Ruby Gem](https://guides.rubygems.org/w
|
|
1307
1348
|
|
1308
1349
|
## Glimmer Style Guide
|
1309
1350
|
|
1310
|
-
- Control arguments are always wrapped by parentheses
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1351
|
+
**1 - Control arguments are always wrapped by parentheses.**
|
1352
|
+
|
1353
|
+
Example:
|
1354
|
+
|
1355
|
+
```ruby
|
1356
|
+
label('Name')
|
1357
|
+
```
|
1358
|
+
|
1359
|
+
**2 - Control blocks are always declared with curly braces to clearly visualize hierarchical view code and separate from logic code.**
|
1360
|
+
|
1361
|
+
Example:
|
1362
|
+
|
1363
|
+
```ruby
|
1364
|
+
group('Basic Controls') {
|
1365
|
+
vertical_box {
|
1366
|
+
button('Button') {
|
1367
|
+
}
|
1368
|
+
}
|
1369
|
+
}
|
1370
|
+
```
|
1371
|
+
|
1372
|
+
**3 - Control property declarations always have arguments that are not wrapped inside parentheses and typically do not take a block.**
|
1373
|
+
|
1374
|
+
Example:
|
1375
|
+
|
1376
|
+
```ruby
|
1377
|
+
stretchy false
|
1378
|
+
value 42
|
1379
|
+
```
|
1380
|
+
|
1381
|
+
**4 - Control listeners are always declared starting with on_ prefix and affixing listener event method name afterwards in underscored lowercase form. Their multi-line blocks have a `do; end` style.**
|
1382
|
+
|
1383
|
+
Example:
|
1384
|
+
|
1385
|
+
```ruby
|
1386
|
+
button('Click') {
|
1387
|
+
on_clicked do
|
1388
|
+
msg_box('Information', 'You clicked the button')
|
1389
|
+
end
|
1390
|
+
}
|
1391
|
+
```
|
1392
|
+
|
1393
|
+
**5 - Iterator multi-line blocks always have `do; end` style to clearly separate logic code from view code.**
|
1394
|
+
|
1395
|
+
Example:
|
1396
|
+
|
1397
|
+
```ruby
|
1398
|
+
@field_hash.keys.each do |field|
|
1399
|
+
label(field) {
|
1400
|
+
stretchy false
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
entry {
|
1404
|
+
on_changed do |control|
|
1405
|
+
@field_hash[field] = control.text
|
1406
|
+
end
|
1407
|
+
}
|
1408
|
+
end
|
1409
|
+
```
|
1410
|
+
|
1411
|
+
**6 - In a widget's content block, attributes are declared first, with layout management attributes on top (e.g. `stretchy false`); an empty line separates attributes from nested widgets and listeners following afterwards.**
|
1412
|
+
|
1413
|
+
Example:
|
1414
|
+
|
1415
|
+
```ruby
|
1416
|
+
group('Numbers') {
|
1417
|
+
stretchy false
|
1418
|
+
|
1419
|
+
vertical_box {
|
1420
|
+
spinbox(0, 100) {
|
1421
|
+
stretchy false
|
1422
|
+
value 42
|
1423
|
+
|
1424
|
+
on_changed do |s|
|
1425
|
+
puts "New Spinbox value: #{s.value}"
|
1426
|
+
$stdout.flush # for Windows
|
1427
|
+
end
|
1428
|
+
}
|
1429
|
+
}
|
1430
|
+
}
|
1431
|
+
```
|
1432
|
+
|
1433
|
+
**7 - Unlike attributes, nested widgets with a content block and listeners are always separated from each other by an empty line to make readability easier except where it helps to group two widgets together (e.g. label and described entry).**
|
1434
|
+
|
1435
|
+
Example:
|
1436
|
+
|
1437
|
+
```ruby
|
1438
|
+
area {
|
1439
|
+
path { # needs an empty line afterwards
|
1440
|
+
square(0, 0, 100) # does not have a content block, so no empty line is needed
|
1441
|
+
square(100, 100, 400) # does not have a content block, so no empty line is needed
|
1442
|
+
|
1443
|
+
fill r: 102, g: 102, b: 204
|
1444
|
+
}
|
1445
|
+
|
1446
|
+
path { # needs an empty line afterwards
|
1447
|
+
rectangle(0, 100, 100, 400) # does not have a content block, so no empty line is needed
|
1448
|
+
rectangle(100, 0, 400, 100) # does not have a content block, so no empty line is needed
|
1449
|
+
|
1450
|
+
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
1451
|
+
}
|
1452
|
+
|
1453
|
+
polygon(100, 100, 100, 400, 400, 100, 400, 400) { # needs an empty line afterwards
|
1454
|
+
fill r: 202, g: 102, b: 104, a: 0.5 # attributes do not need an empty line separator
|
1455
|
+
stroke r: 0, g: 0, b: 0 # attributes do not need an empty line separator
|
1456
|
+
}
|
1457
|
+
|
1458
|
+
on_mouse_up do |area_mouse_event| # needs an empty line afterwards
|
1459
|
+
puts 'mouse up'
|
1460
|
+
end
|
1461
|
+
|
1462
|
+
on_key_up do |area_key_event| # needs an empty line afterwards
|
1463
|
+
puts 'key up'
|
1464
|
+
end
|
1465
|
+
}
|
1466
|
+
```
|
1316
1467
|
|
1317
1468
|
## Examples
|
1318
1469
|
|
@@ -1334,17 +1485,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
1334
1485
|
ruby -r glimmer-dsl-libui -e "require 'examples/meta_example'"
|
1335
1486
|
```
|
1336
1487
|
|
1337
|
-
Mac
|
1338
|
-
|
1339
|
-
![glimmer-dsl-libui-mac-meta-example.png](images/glimmer-dsl-libui-mac-meta-example.png)
|
1340
|
-
|
1341
|
-
Windows
|
1342
|
-
|
1343
|
-
![glimmer-dsl-libui-windows-meta-example.png](images/glimmer-dsl-libui-windows-meta-example.png)
|
1344
|
-
|
1345
|
-
Linux
|
1346
|
-
|
1347
|
-
![glimmer-dsl-libui-linux-meta-example.png](images/glimmer-dsl-libui-linux-meta-example.png)
|
1488
|
+
Mac | Windows | Linux
|
1489
|
+
----|---------|------
|
1490
|
+
![glimmer-dsl-libui-mac-meta-example.png](images/glimmer-dsl-libui-mac-meta-example.png) | ![glimmer-dsl-libui-windows-meta-example.png](images/glimmer-dsl-libui-windows-meta-example.png) | ![glimmer-dsl-libui-linux-meta-example.png](images/glimmer-dsl-libui-linux-meta-example.png)
|
1348
1491
|
|
1349
1492
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1350
1493
|
|
@@ -1502,17 +1645,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
1502
1645
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_window'"
|
1503
1646
|
```
|
1504
1647
|
|
1505
|
-
Mac
|
1506
|
-
|
1507
|
-
![glimmer-dsl-libui-mac-basic-window.png](images/glimmer-dsl-libui-mac-basic-window.png)
|
1508
|
-
|
1509
|
-
Windows
|
1510
|
-
|
1511
|
-
![glimmer-dsl-libui-windows-basic-window.png](images/glimmer-dsl-libui-windows-basic-window.png)
|
1512
|
-
|
1513
|
-
Linux
|
1514
|
-
|
1515
|
-
![glimmer-dsl-libui-linux-basic-window.png](images/glimmer-dsl-libui-linux-basic-window.png)
|
1648
|
+
Mac | Windows | Linux
|
1649
|
+
----|---------|------
|
1650
|
+
![glimmer-dsl-libui-mac-basic-window.png](images/glimmer-dsl-libui-mac-basic-window.png) | ![glimmer-dsl-libui-windows-basic-window.png](images/glimmer-dsl-libui-windows-basic-window.png) | ![glimmer-dsl-libui-linux-basic-window.png](images/glimmer-dsl-libui-linux-basic-window.png)
|
1516
1651
|
|
1517
1652
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
1518
1653
|
|
@@ -1585,20 +1720,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
1585
1720
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_button'"
|
1586
1721
|
```
|
1587
1722
|
|
1588
|
-
Mac
|
1589
|
-
|
1590
|
-
![glimmer-dsl-libui-mac-basic-button.png](images/glimmer-dsl-libui-mac-basic-button.png)
|
1591
|
-
![glimmer-dsl-libui-mac-basic-button-msg-box.png](images/glimmer-dsl-libui-mac-basic-button-msg-box.png)
|
1592
|
-
|
1593
|
-
Windows
|
1594
|
-
|
1595
|
-
![glimmer-dsl-libui-windows-basic-button.png](images/glimmer-dsl-libui-windows-basic-button.png)
|
1596
|
-
![glimmer-dsl-libui-windows-basic-button-msg-box.png](images/glimmer-dsl-libui-windows-basic-button-msg-box.png)
|
1597
|
-
|
1598
|
-
Linux
|
1599
|
-
|
1600
|
-
![glimmer-dsl-libui-linux-basic-button.png](images/glimmer-dsl-libui-linux-basic-button.png)
|
1601
|
-
![glimmer-dsl-libui-linux-basic-button-msg-box.png](images/glimmer-dsl-libui-linux-basic-button-msg-box.png)
|
1723
|
+
Mac | Windows | Linux
|
1724
|
+
----|---------|------
|
1725
|
+
![glimmer-dsl-libui-mac-basic-button.png](images/glimmer-dsl-libui-mac-basic-button.png) ![glimmer-dsl-libui-mac-basic-button-msg-box.png](images/glimmer-dsl-libui-mac-basic-button-msg-box.png) | ![glimmer-dsl-libui-windows-basic-button.png](images/glimmer-dsl-libui-windows-basic-button.png) ![glimmer-dsl-libui-windows-basic-button-msg-box.png](images/glimmer-dsl-libui-windows-basic-button-msg-box.png) | ![glimmer-dsl-libui-linux-basic-button.png](images/glimmer-dsl-libui-linux-basic-button.png) ![glimmer-dsl-libui-linux-basic-button-msg-box.png](images/glimmer-dsl-libui-linux-basic-button-msg-box.png)
|
1602
1726
|
|
1603
1727
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
1604
1728
|
|
@@ -1667,20 +1791,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
1667
1791
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_entry'"
|
1668
1792
|
```
|
1669
1793
|
|
1670
|
-
Mac
|
1671
|
-
|
1672
|
-
![glimmer-dsl-libui-mac-basic-entry.png](images/glimmer-dsl-libui-mac-basic-entry.png)
|
1673
|
-
![glimmer-dsl-libui-mac-basic-entry-msg-box.png](images/glimmer-dsl-libui-mac-basic-entry-msg-box.png)
|
1674
|
-
|
1675
|
-
Windows
|
1676
|
-
|
1677
|
-
![glimmer-dsl-libui-windows-basic-entry.png](images/glimmer-dsl-libui-windows-basic-entry.png)
|
1678
|
-
![glimmer-dsl-libui-windows-basic-entry-msg-box.png](images/glimmer-dsl-libui-windows-basic-entry-msg-box.png)
|
1679
|
-
|
1680
|
-
Linux
|
1681
|
-
|
1682
|
-
![glimmer-dsl-libui-linux-basic-entry.png](images/glimmer-dsl-libui-linux-basic-entry.png)
|
1683
|
-
![glimmer-dsl-libui-linux-basic-entry-msg-box.png](images/glimmer-dsl-libui-linux-basic-entry-msg-box.png)
|
1794
|
+
Mac | Windows | Linux
|
1795
|
+
----|---------|------
|
1796
|
+
![glimmer-dsl-libui-mac-basic-entry.png](images/glimmer-dsl-libui-mac-basic-entry.png) ![glimmer-dsl-libui-mac-basic-entry-msg-box.png](images/glimmer-dsl-libui-mac-basic-entry-msg-box.png) | ![glimmer-dsl-libui-windows-basic-entry.png](images/glimmer-dsl-libui-windows-basic-entry.png) ![glimmer-dsl-libui-windows-basic-entry-msg-box.png](images/glimmer-dsl-libui-windows-basic-entry-msg-box.png) | ![glimmer-dsl-libui-linux-basic-entry.png](images/glimmer-dsl-libui-linux-basic-entry.png) ![glimmer-dsl-libui-linux-basic-entry-msg-box.png](images/glimmer-dsl-libui-linux-basic-entry-msg-box.png)
|
1684
1797
|
|
1685
1798
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
1686
1799
|
|
@@ -1773,17 +1886,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
1773
1886
|
ruby -r glimmer-dsl-libui -e "require 'examples/simple_notepad'"
|
1774
1887
|
```
|
1775
1888
|
|
1776
|
-
Mac
|
1777
|
-
|
1778
|
-
![glimmer-dsl-libui-mac-simple-notepad.png](images/glimmer-dsl-libui-mac-simple-notepad.png)
|
1779
|
-
|
1780
|
-
Windows
|
1781
|
-
|
1782
|
-
![glimmer-dsl-libui-windows-simple-notepad.png](images/glimmer-dsl-libui-windows-simple-notepad.png)
|
1783
|
-
|
1784
|
-
Linux
|
1785
|
-
|
1786
|
-
![glimmer-dsl-libui-linux-simple-notepad.png](images/glimmer-dsl-libui-linux-simple-notepad.png)
|
1889
|
+
Mac | Windows | Linux
|
1890
|
+
----|---------|------
|
1891
|
+
![glimmer-dsl-libui-mac-simple-notepad.png](images/glimmer-dsl-libui-mac-simple-notepad.png) | ![glimmer-dsl-libui-windows-simple-notepad.png](images/glimmer-dsl-libui-windows-simple-notepad.png) | ![glimmer-dsl-libui-linux-simple-notepad.png](images/glimmer-dsl-libui-linux-simple-notepad.png)
|
1787
1892
|
|
1788
1893
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
1789
1894
|
|
@@ -1849,20 +1954,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
1849
1954
|
ruby -r glimmer-dsl-libui -e "require 'examples/midi_player'"
|
1850
1955
|
```
|
1851
1956
|
|
1852
|
-
Mac
|
1853
|
-
|
1854
|
-
![glimmer-dsl-libui-mac-midi-player.png](images/glimmer-dsl-libui-mac-midi-player.png)
|
1855
|
-
![glimmer-dsl-libui-mac-midi-player-msg-box.png](images/glimmer-dsl-libui-mac-midi-player-msg-box.png)
|
1856
|
-
|
1857
|
-
Windows
|
1858
|
-
|
1859
|
-
![glimmer-dsl-libui-windows-midi-player.png](images/glimmer-dsl-libui-windows-midi-player.png)
|
1860
|
-
![glimmer-dsl-libui-windows-midi-player-msg-box.png](images/glimmer-dsl-libui-windows-midi-player-msg-box.png)
|
1861
|
-
|
1862
|
-
Linux
|
1863
|
-
|
1864
|
-
![glimmer-dsl-libui-linux-midi-player.png](images/glimmer-dsl-libui-linux-midi-player.png)
|
1865
|
-
![glimmer-dsl-libui-linux-midi-player-msg-box.png](images/glimmer-dsl-libui-linux-midi-player-msg-box.png)
|
1957
|
+
Mac | Windows | Linux
|
1958
|
+
----|---------|------
|
1959
|
+
![glimmer-dsl-libui-mac-midi-player.png](images/glimmer-dsl-libui-mac-midi-player.png) ![glimmer-dsl-libui-mac-midi-player-msg-box.png](images/glimmer-dsl-libui-mac-midi-player-msg-box.png) | ![glimmer-dsl-libui-windows-midi-player.png](images/glimmer-dsl-libui-windows-midi-player.png) ![glimmer-dsl-libui-windows-midi-player-msg-box.png](images/glimmer-dsl-libui-windows-midi-player-msg-box.png) | ![glimmer-dsl-libui-linux-midi-player.png](images/glimmer-dsl-libui-linux-midi-player.png) ![glimmer-dsl-libui-linux-midi-player-msg-box.png](images/glimmer-dsl-libui-linux-midi-player-msg-box.png)
|
1866
1960
|
|
1867
1961
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
1868
1962
|
|
@@ -1885,12 +1979,8 @@ class TinyMidiPlayer
|
|
1885
1979
|
|
1886
1980
|
def stop_midi
|
1887
1981
|
if @pid
|
1888
|
-
if @th.alive?
|
1889
|
-
|
1890
|
-
@pid = nil
|
1891
|
-
else
|
1892
|
-
@pid = nil
|
1893
|
-
end
|
1982
|
+
Process.kill(:SIGKILL, @pid) if @th.alive?
|
1983
|
+
@pid = nil
|
1894
1984
|
end
|
1895
1985
|
end
|
1896
1986
|
|
@@ -1916,6 +2006,20 @@ class TinyMidiPlayer
|
|
1916
2006
|
end
|
1917
2007
|
|
1918
2008
|
def create_gui
|
2009
|
+
# loop_menu = UI.new_menu('Repeat')
|
2010
|
+
# items = %w[Off One].map do |item_name|
|
2011
|
+
# item = UI.menu_append_check_item(loop_menu, item_name)
|
2012
|
+
# end
|
2013
|
+
# items.each_with_index do |item, idx|
|
2014
|
+
# UI.menu_item_on_clicked(item) do
|
2015
|
+
# @repeat = idx
|
2016
|
+
# (items - [item]).each do |i|
|
2017
|
+
# UI.menu_item_set_checked(i, 0)
|
2018
|
+
# end
|
2019
|
+
# 0
|
2020
|
+
# end
|
2021
|
+
# end
|
2022
|
+
|
1919
2023
|
help_menu = UI.new_menu('Help')
|
1920
2024
|
version_item = UI.menu_append_item(help_menu, 'Version')
|
1921
2025
|
|
@@ -1930,11 +2034,11 @@ class TinyMidiPlayer
|
|
1930
2034
|
|
1931
2035
|
UI.new_horizontal_box.tap do |hbox|
|
1932
2036
|
UI.new_vertical_box.tap do |vbox|
|
1933
|
-
UI.new_button('
|
2037
|
+
UI.new_button('▶').tap do |button1|
|
1934
2038
|
UI.button_on_clicked(button1) { play_midi }
|
1935
2039
|
UI.box_append(vbox, button1, 1)
|
1936
2040
|
end
|
1937
|
-
UI.new_button('
|
2041
|
+
UI.new_button('■').tap do |button2|
|
1938
2042
|
UI.button_on_clicked(button2) { stop_midi }
|
1939
2043
|
UI.box_append(vbox, button2, 1)
|
1940
2044
|
end
|
@@ -2028,12 +2132,12 @@ class TinyMidiPlayer
|
|
2028
2132
|
vertical_box {
|
2029
2133
|
stretchy false
|
2030
2134
|
|
2031
|
-
button('
|
2135
|
+
button('▶') {
|
2032
2136
|
on_clicked do
|
2033
2137
|
play_midi
|
2034
2138
|
end
|
2035
2139
|
}
|
2036
|
-
button('
|
2140
|
+
button('■') {
|
2037
2141
|
on_clicked do
|
2038
2142
|
stop_midi
|
2039
2143
|
end
|
@@ -2072,17 +2176,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
2072
2176
|
ruby -r glimmer-dsl-libui -e "require 'examples/control_gallery'"
|
2073
2177
|
```
|
2074
2178
|
|
2075
|
-
Mac
|
2076
|
-
|
2077
|
-
![glimmer-dsl-libui-mac-control-gallery.png](images/glimmer-dsl-libui-mac-control-gallery.png)
|
2078
|
-
|
2079
|
-
Windows
|
2080
|
-
|
2081
|
-
![glimmer-dsl-libui-windows-control-gallery.png](images/glimmer-dsl-libui-windows-control-gallery.png)
|
2082
|
-
|
2083
|
-
Linux
|
2084
|
-
|
2085
|
-
![glimmer-dsl-libui-linux-control-gallery.png](images/glimmer-dsl-libui-linux-control-gallery.png)
|
2179
|
+
Mac | Windows | Linux
|
2180
|
+
----|---------|------
|
2181
|
+
![glimmer-dsl-libui-mac-control-gallery.png](images/glimmer-dsl-libui-mac-control-gallery.png) | ![glimmer-dsl-libui-windows-control-gallery.png](images/glimmer-dsl-libui-windows-control-gallery.png) | ![glimmer-dsl-libui-linux-control-gallery.png](images/glimmer-dsl-libui-linux-control-gallery.png)
|
2086
2182
|
|
2087
2183
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
2088
2184
|
|
@@ -2466,20 +2562,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
2466
2562
|
ruby -r glimmer-dsl-libui -e "require 'examples/font_button'"
|
2467
2563
|
```
|
2468
2564
|
|
2469
|
-
Mac
|
2470
|
-
|
2471
|
-
![glimmer-dsl-libui-mac-font-button.png](images/glimmer-dsl-libui-mac-font-button.png)
|
2472
|
-
![glimmer-dsl-libui-mac-font-button-selection.png](images/glimmer-dsl-libui-mac-font-button-selection.png)
|
2473
|
-
|
2474
|
-
Windows
|
2475
|
-
|
2476
|
-
![glimmer-dsl-libui-windows-font-button.png](images/glimmer-dsl-libui-windows-font-button.png)
|
2477
|
-
![glimmer-dsl-libui-windows-font-button-selection.png](images/glimmer-dsl-libui-windows-font-button-selection.png)
|
2478
|
-
|
2479
|
-
Linux
|
2480
|
-
|
2481
|
-
![glimmer-dsl-libui-linux-font-button.png](images/glimmer-dsl-libui-linux-font-button.png)
|
2482
|
-
![glimmer-dsl-libui-linux-font-button-selection.png](images/glimmer-dsl-libui-linux-font-button-selection.png)
|
2565
|
+
Mac | Windows | Linux
|
2566
|
+
----|---------|------
|
2567
|
+
![glimmer-dsl-libui-mac-font-button.png](images/glimmer-dsl-libui-mac-font-button.png) ![glimmer-dsl-libui-mac-font-button-selection.png](images/glimmer-dsl-libui-mac-font-button-selection.png) | ![glimmer-dsl-libui-windows-font-button.png](images/glimmer-dsl-libui-windows-font-button.png) ![glimmer-dsl-libui-windows-font-button-selection.png](images/glimmer-dsl-libui-windows-font-button-selection.png) | ![glimmer-dsl-libui-linux-font-button.png](images/glimmer-dsl-libui-linux-font-button.png) ![glimmer-dsl-libui-linux-font-button-selection.png](images/glimmer-dsl-libui-linux-font-button-selection.png)
|
2483
2568
|
|
2484
2569
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
2485
2570
|
|
@@ -2555,20 +2640,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
2555
2640
|
ruby -r glimmer-dsl-libui -e "require 'examples/color_button'"
|
2556
2641
|
```
|
2557
2642
|
|
2558
|
-
Mac
|
2559
|
-
|
2560
|
-
![glimmer-dsl-libui-mac-color-button.png](images/glimmer-dsl-libui-mac-color-button.png)
|
2561
|
-
![glimmer-dsl-libui-mac-color-button-selection.png](images/glimmer-dsl-libui-mac-color-button-selection.png)
|
2562
|
-
|
2563
|
-
Windows
|
2564
|
-
|
2565
|
-
![glimmer-dsl-libui-windows-color-button.png](images/glimmer-dsl-libui-windows-color-button.png)
|
2566
|
-
![glimmer-dsl-libui-windows-color-button-selection.png](images/glimmer-dsl-libui-windows-color-button-selection.png)
|
2567
|
-
|
2568
|
-
Linux
|
2569
|
-
|
2570
|
-
![glimmer-dsl-libui-linux-color-button.png](images/glimmer-dsl-libui-linux-color-button.png)
|
2571
|
-
![glimmer-dsl-libui-linux-color-button-selection.png](images/glimmer-dsl-libui-linux-color-button-selection.png)
|
2643
|
+
Mac | Windows | Linux
|
2644
|
+
----|---------|------
|
2645
|
+
![glimmer-dsl-libui-mac-color-button.png](images/glimmer-dsl-libui-mac-color-button.png) ![glimmer-dsl-libui-mac-color-button-selection.png](images/glimmer-dsl-libui-mac-color-button-selection.png) | ![glimmer-dsl-libui-windows-color-button.png](images/glimmer-dsl-libui-windows-color-button.png) ![glimmer-dsl-libui-windows-color-button-selection.png](images/glimmer-dsl-libui-windows-color-button-selection.png) | ![glimmer-dsl-libui-linux-color-button.png](images/glimmer-dsl-libui-linux-color-button.png) ![glimmer-dsl-libui-linux-color-button-selection.png](images/glimmer-dsl-libui-linux-color-button-selection.png)
|
2572
2646
|
|
2573
2647
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2574
2648
|
|
@@ -2605,17 +2679,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
2605
2679
|
ruby -r glimmer-dsl-libui -e "require 'examples/date_time_picker'"
|
2606
2680
|
```
|
2607
2681
|
|
2608
|
-
Mac
|
2609
|
-
|
2610
|
-
![glimmer-dsl-libui-mac-date-time-picker.png](images/glimmer-dsl-libui-mac-date-time-picker.png)
|
2611
|
-
|
2612
|
-
Windows
|
2613
|
-
|
2614
|
-
![glimmer-dsl-libui-windows-date-time-picker.png](images/glimmer-dsl-libui-windows-date-time-picker.png)
|
2615
|
-
|
2616
|
-
Linux
|
2617
|
-
|
2618
|
-
![glimmer-dsl-libui-linux-date-time-picker.png](images/glimmer-dsl-libui-linux-date-time-picker.png)
|
2682
|
+
Mac | Windows | Linux
|
2683
|
+
----|---------|------
|
2684
|
+
![glimmer-dsl-libui-mac-date-time-picker.png](images/glimmer-dsl-libui-mac-date-time-picker.png) | ![glimmer-dsl-libui-windows-date-time-picker.png](images/glimmer-dsl-libui-windows-date-time-picker.png) | ![glimmer-dsl-libui-linux-date-time-picker.png](images/glimmer-dsl-libui-linux-date-time-picker.png)
|
2619
2685
|
|
2620
2686
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
2621
2687
|
|
@@ -2699,23 +2765,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
2699
2765
|
ruby -r glimmer-dsl-libui -e "require 'examples/grid'"
|
2700
2766
|
```
|
2701
2767
|
|
2702
|
-
Mac
|
2703
|
-
|
2704
|
-
![glimmer-dsl-libui-mac-grid-span.png](images/glimmer-dsl-libui-mac-grid-span.png)
|
2705
|
-
![glimmer-dsl-libui-mac-grid-expand.png](images/glimmer-dsl-libui-mac-grid-expand.png)
|
2706
|
-
![glimmer-dsl-libui-mac-grid-align.png](images/glimmer-dsl-libui-mac-grid-align.png)
|
2707
|
-
|
2708
|
-
Windows
|
2709
|
-
|
2710
|
-
![glimmer-dsl-libui-windows-grid-span.png](images/glimmer-dsl-libui-windows-grid-span.png)
|
2711
|
-
![glimmer-dsl-libui-windows-grid-expand.png](images/glimmer-dsl-libui-windows-grid-expand.png)
|
2712
|
-
![glimmer-dsl-libui-windows-grid-align.png](images/glimmer-dsl-libui-windows-grid-align.png)
|
2713
|
-
|
2714
|
-
Linux
|
2715
|
-
|
2716
|
-
![glimmer-dsl-libui-linux-grid-span.png](images/glimmer-dsl-libui-linux-grid-span.png)
|
2717
|
-
![glimmer-dsl-libui-linux-grid-expand.png](images/glimmer-dsl-libui-linux-grid-expand.png)
|
2718
|
-
![glimmer-dsl-libui-linux-grid-align.png](images/glimmer-dsl-libui-linux-grid-align.png)
|
2768
|
+
Mac | Windows | Linux
|
2769
|
+
----|---------|------
|
2770
|
+
![glimmer-dsl-libui-mac-grid-span.png](images/glimmer-dsl-libui-mac-grid-span.png) ![glimmer-dsl-libui-mac-grid-expand.png](images/glimmer-dsl-libui-mac-grid-expand.png) ![glimmer-dsl-libui-mac-grid-align.png](images/glimmer-dsl-libui-mac-grid-align.png) | ![glimmer-dsl-libui-windows-grid-span.png](images/glimmer-dsl-libui-windows-grid-span.png) ![glimmer-dsl-libui-windows-grid-expand.png](images/glimmer-dsl-libui-windows-grid-expand.png) ![glimmer-dsl-libui-windows-grid-align.png](images/glimmer-dsl-libui-windows-grid-align.png) | ![glimmer-dsl-libui-linux-grid-span.png](images/glimmer-dsl-libui-linux-grid-span.png) ![glimmer-dsl-libui-linux-grid-expand.png](images/glimmer-dsl-libui-linux-grid-expand.png) ![glimmer-dsl-libui-linux-grid-align.png](images/glimmer-dsl-libui-linux-grid-align.png)
|
2719
2771
|
|
2720
2772
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2721
2773
|
|
@@ -2728,16 +2780,16 @@ window('Grid') {
|
|
2728
2780
|
tab {
|
2729
2781
|
tab_item('Span') {
|
2730
2782
|
grid {
|
2731
|
-
4.times
|
2732
|
-
4.times
|
2783
|
+
4.times do |top_value|
|
2784
|
+
4.times do |left_value|
|
2733
2785
|
label("(#{left_value}, #{top_value}) xspan1\nyspan1") {
|
2734
2786
|
left left_value
|
2735
2787
|
top top_value
|
2736
2788
|
hexpand true
|
2737
2789
|
vexpand true
|
2738
2790
|
}
|
2739
|
-
|
2740
|
-
|
2791
|
+
end
|
2792
|
+
end
|
2741
2793
|
label("(0, 4) xspan2\nyspan1 more text fits horizontally") {
|
2742
2794
|
left 0
|
2743
2795
|
top 4
|
@@ -2844,20 +2896,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
2844
2896
|
ruby -r glimmer-dsl-libui -e "require 'examples/form'"
|
2845
2897
|
```
|
2846
2898
|
|
2847
|
-
Mac
|
2848
|
-
|
2849
|
-
![glimmer-dsl-libui-mac-form.png](images/glimmer-dsl-libui-mac-form.png)
|
2850
|
-
![glimmer-dsl-libui-mac-form-msg-box.png](images/glimmer-dsl-libui-mac-form-msg-box.png)
|
2851
|
-
|
2852
|
-
Windows
|
2853
|
-
|
2854
|
-
![glimmer-dsl-libui-windows-form.png](images/glimmer-dsl-libui-windows-form.png)
|
2855
|
-
![glimmer-dsl-libui-windows-form-msg-box.png](images/glimmer-dsl-libui-windows-form-msg-box.png)
|
2856
|
-
|
2857
|
-
Linux
|
2858
|
-
|
2859
|
-
![glimmer-dsl-libui-linux-form.png](images/glimmer-dsl-libui-linux-form.png)
|
2860
|
-
![glimmer-dsl-libui-linux-form-msg-box.png](images/glimmer-dsl-libui-linux-form-msg-box.png)
|
2899
|
+
Mac | Windows | Linux
|
2900
|
+
----|---------|------
|
2901
|
+
![glimmer-dsl-libui-mac-form.png](images/glimmer-dsl-libui-mac-form.png) ![glimmer-dsl-libui-mac-form-msg-box.png](images/glimmer-dsl-libui-mac-form-msg-box.png) | ![glimmer-dsl-libui-windows-form.png](images/glimmer-dsl-libui-windows-form.png) ![glimmer-dsl-libui-windows-form-msg-box.png](images/glimmer-dsl-libui-windows-form-msg-box.png) | ![glimmer-dsl-libui-linux-form.png](images/glimmer-dsl-libui-linux-form.png) ![glimmer-dsl-libui-linux-form-msg-box.png](images/glimmer-dsl-libui-linux-form-msg-box.png)
|
2861
2902
|
|
2862
2903
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2863
2904
|
|
@@ -2915,17 +2956,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
2915
2956
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table'"
|
2916
2957
|
```
|
2917
2958
|
|
2918
|
-
Mac
|
2919
|
-
|
2920
|
-
![glimmer-dsl-libui-mac-basic-table.png](images/glimmer-dsl-libui-mac-basic-table.png)
|
2921
|
-
|
2922
|
-
Windows
|
2923
|
-
|
2924
|
-
![glimmer-dsl-libui-windows-basic-table.png](images/glimmer-dsl-libui-windows-basic-table.png)
|
2925
|
-
|
2926
|
-
Linux
|
2927
|
-
|
2928
|
-
![glimmer-dsl-libui-linux-basic-table.png](images/glimmer-dsl-libui-linux-basic-table.png)
|
2959
|
+
Mac | Windows | Linux
|
2960
|
+
----|---------|------
|
2961
|
+
![glimmer-dsl-libui-mac-basic-table.png](images/glimmer-dsl-libui-mac-basic-table.png) | ![glimmer-dsl-libui-windows-basic-table.png](images/glimmer-dsl-libui-windows-basic-table.png) | ![glimmer-dsl-libui-linux-basic-table.png](images/glimmer-dsl-libui-linux-basic-table.png)
|
2929
2962
|
|
2930
2963
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
2931
2964
|
|
@@ -3039,23 +3072,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3039
3072
|
ruby -r glimmer-dsl-libui -e "require 'examples/editable_table'"
|
3040
3073
|
```
|
3041
3074
|
|
3042
|
-
Mac
|
3043
|
-
|
3044
|
-
![glimmer-dsl-libui-mac-editable-table.png](images/glimmer-dsl-libui-mac-editable-table.png)
|
3045
|
-
![glimmer-dsl-libui-mac-editable-table-editing.png](images/glimmer-dsl-libui-mac-editable-table-editing.png)
|
3046
|
-
![glimmer-dsl-libui-mac-editable-table-edited.png](images/glimmer-dsl-libui-mac-editable-table-edited.png)
|
3047
|
-
|
3048
|
-
Windows
|
3049
|
-
|
3050
|
-
![glimmer-dsl-libui-windows-editable-table.png](images/glimmer-dsl-libui-windows-editable-table.png)
|
3051
|
-
![glimmer-dsl-libui-windows-editable-table-editing.png](images/glimmer-dsl-libui-windows-editable-table-editing.png)
|
3052
|
-
![glimmer-dsl-libui-windows-editable-table-edited.png](images/glimmer-dsl-libui-windows-editable-table-edited.png)
|
3053
|
-
|
3054
|
-
Linux
|
3055
|
-
|
3056
|
-
![glimmer-dsl-libui-linux-editable-table.png](images/glimmer-dsl-libui-linux-editable-table.png)
|
3057
|
-
![glimmer-dsl-libui-linux-editable-table-editing.png](images/glimmer-dsl-libui-linux-editable-table-editing.png)
|
3058
|
-
![glimmer-dsl-libui-linux-editable-table-edited.png](images/glimmer-dsl-libui-linux-editable-table-edited.png)
|
3075
|
+
Mac | Windows | Linux
|
3076
|
+
----|---------|------
|
3077
|
+
![glimmer-dsl-libui-mac-editable-table.png](images/glimmer-dsl-libui-mac-editable-table.png) ![glimmer-dsl-libui-mac-editable-table-editing.png](images/glimmer-dsl-libui-mac-editable-table-editing.png) ![glimmer-dsl-libui-mac-editable-table-edited.png](images/glimmer-dsl-libui-mac-editable-table-edited.png) | ![glimmer-dsl-libui-windows-editable-table.png](images/glimmer-dsl-libui-windows-editable-table.png) ![glimmer-dsl-libui-windows-editable-table-editing.png](images/glimmer-dsl-libui-windows-editable-table-editing.png) ![glimmer-dsl-libui-windows-editable-table-edited.png](images/glimmer-dsl-libui-windows-editable-table-edited.png) | ![glimmer-dsl-libui-linux-editable-table.png](images/glimmer-dsl-libui-linux-editable-table.png) ![glimmer-dsl-libui-linux-editable-table-editing.png](images/glimmer-dsl-libui-linux-editable-table-editing.png) ![glimmer-dsl-libui-linux-editable-table-edited.png](images/glimmer-dsl-libui-linux-editable-table-edited.png)
|
3059
3078
|
|
3060
3079
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3061
3080
|
|
@@ -3113,20 +3132,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3113
3132
|
ruby -r glimmer-dsl-libui -e "require 'examples/editable_column_table'"
|
3114
3133
|
```
|
3115
3134
|
|
3116
|
-
Mac
|
3117
|
-
|
3118
|
-
![glimmer-dsl-libui-mac-editable-column-table-editing.png](images/glimmer-dsl-libui-mac-editable-column-table-editing.png)
|
3119
|
-
![glimmer-dsl-libui-mac-editable-column-table-edited.png](images/glimmer-dsl-libui-mac-editable-column-table-edited.png)
|
3120
|
-
|
3121
|
-
Windows
|
3122
|
-
|
3123
|
-
![glimmer-dsl-libui-windows-editable-column-table-editing.png](images/glimmer-dsl-libui-windows-editable-column-table-editing.png)
|
3124
|
-
![glimmer-dsl-libui-windows-editable-column-table-edited.png](images/glimmer-dsl-libui-windows-editable-column-table-edited.png)
|
3125
|
-
|
3126
|
-
Linux
|
3127
|
-
|
3128
|
-
![glimmer-dsl-libui-linux-editable-column-table-editing.png](images/glimmer-dsl-libui-linux-editable-column-table-editing.png)
|
3129
|
-
![glimmer-dsl-libui-linux-editable-column-table-edited.png](images/glimmer-dsl-libui-linux-editable-column-table-edited.png)
|
3135
|
+
Mac | Windows | Linux
|
3136
|
+
----|---------|------
|
3137
|
+
![glimmer-dsl-libui-mac-editable-column-table-editing.png](images/glimmer-dsl-libui-mac-editable-column-table-editing.png) ![glimmer-dsl-libui-mac-editable-column-table-edited.png](images/glimmer-dsl-libui-mac-editable-column-table-edited.png) | ![glimmer-dsl-libui-windows-editable-column-table-editing.png](images/glimmer-dsl-libui-windows-editable-column-table-editing.png) ![glimmer-dsl-libui-windows-editable-column-table-edited.png](images/glimmer-dsl-libui-windows-editable-column-table-edited.png) | ![glimmer-dsl-libui-linux-editable-column-table-editing.png](images/glimmer-dsl-libui-linux-editable-column-table-editing.png) ![glimmer-dsl-libui-linux-editable-column-table-edited.png](images/glimmer-dsl-libui-linux-editable-column-table-edited.png)
|
3130
3138
|
|
3131
3139
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3132
3140
|
|
@@ -3180,17 +3188,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3180
3188
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_image'"
|
3181
3189
|
```
|
3182
3190
|
|
3183
|
-
Mac
|
3184
|
-
|
3185
|
-
![glimmer-dsl-libui-mac-basic-table-image.png](images/glimmer-dsl-libui-mac-basic-table-image.png)
|
3186
|
-
|
3187
|
-
Windows
|
3188
|
-
|
3189
|
-
![glimmer-dsl-libui-windows-basic-table-image.png](images/glimmer-dsl-libui-windows-basic-table-image.png)
|
3190
|
-
|
3191
|
-
Linux
|
3192
|
-
|
3193
|
-
![glimmer-dsl-libui-linux-basic-table-image.png](images/glimmer-dsl-libui-linux-basic-table-image.png)
|
3191
|
+
Mac | Windows | Linux
|
3192
|
+
----|---------|------
|
3193
|
+
![glimmer-dsl-libui-mac-basic-table-image.png](images/glimmer-dsl-libui-mac-basic-table-image.png) | ![glimmer-dsl-libui-windows-basic-table-image.png](images/glimmer-dsl-libui-windows-basic-table-image.png) | ![glimmer-dsl-libui-linux-basic-table-image.png](images/glimmer-dsl-libui-linux-basic-table-image.png)
|
3194
3194
|
|
3195
3195
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
3196
3196
|
|
@@ -3278,6 +3278,41 @@ UI.quit
|
|
3278
3278
|
# NOTE:
|
3279
3279
|
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
3280
3280
|
|
3281
|
+
require 'glimmer-dsl-libui'
|
3282
|
+
|
3283
|
+
include Glimmer
|
3284
|
+
|
3285
|
+
IMAGE_ROWS = []
|
3286
|
+
|
3287
|
+
50.times do |i|
|
3288
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
3289
|
+
puts "Processing Image: #{url}"; $stdout.flush # for Windows
|
3290
|
+
IMAGE_ROWS << [image(url)] # array of one column cell
|
3291
|
+
rescue StandardError => e
|
3292
|
+
warn url, e.message
|
3293
|
+
end
|
3294
|
+
|
3295
|
+
window('The Red Turtle', 310, 350, false) {
|
3296
|
+
horizontal_box {
|
3297
|
+
table {
|
3298
|
+
image_column('www.ghibli.jp/works/red-turtle')
|
3299
|
+
|
3300
|
+
cell_rows IMAGE_ROWS
|
3301
|
+
}
|
3302
|
+
}
|
3303
|
+
|
3304
|
+
on_closing do
|
3305
|
+
puts 'Bye Bye'
|
3306
|
+
end
|
3307
|
+
}.show
|
3308
|
+
```
|
3309
|
+
|
3310
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (manual construction of `image` from `image_part`):
|
3311
|
+
|
3312
|
+
```ruby
|
3313
|
+
# NOTE:
|
3314
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
3315
|
+
|
3281
3316
|
require 'glimmer-dsl-libui'
|
3282
3317
|
require 'chunky_png'
|
3283
3318
|
require 'open-uri'
|
@@ -3336,19 +3371,47 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3336
3371
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_image_text'"
|
3337
3372
|
```
|
3338
3373
|
|
3339
|
-
Mac
|
3374
|
+
Mac | Windows | Linux
|
3375
|
+
----|---------|------
|
3376
|
+
![glimmer-dsl-libui-mac-basic-table-image-text.png](images/glimmer-dsl-libui-mac-basic-table-image-text.png) | ![glimmer-dsl-libui-windows-basic-table-image-text.png](images/glimmer-dsl-libui-windows-basic-table-image-text.png) | ![glimmer-dsl-libui-linux-basic-table-image-text.png](images/glimmer-dsl-libui-linux-basic-table-image-text.png)
|
3340
3377
|
|
3341
|
-
|
3378
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3379
|
+
|
3380
|
+
```ruby
|
3381
|
+
# NOTE:
|
3382
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
3342
3383
|
|
3343
|
-
|
3384
|
+
require 'glimmer-dsl-libui'
|
3344
3385
|
|
3345
|
-
|
3386
|
+
include Glimmer
|
3346
3387
|
|
3347
|
-
|
3388
|
+
IMAGE_ROWS = []
|
3348
3389
|
|
3349
|
-
|
3390
|
+
5.times do |i|
|
3391
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
3392
|
+
puts "Processing Image: #{url}"; $stdout.flush # for Windows
|
3393
|
+
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
3394
|
+
img = image(url)
|
3395
|
+
IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
|
3396
|
+
rescue StandardError => e
|
3397
|
+
warn url, e.message
|
3398
|
+
end
|
3350
3399
|
|
3351
|
-
|
3400
|
+
window('The Red Turtle', 670, 350) {
|
3401
|
+
horizontal_box {
|
3402
|
+
table {
|
3403
|
+
image_text_column('image/number')
|
3404
|
+
image_text_column('image/number (editable)') {
|
3405
|
+
editable true
|
3406
|
+
}
|
3407
|
+
|
3408
|
+
cell_rows IMAGE_ROWS
|
3409
|
+
}
|
3410
|
+
}
|
3411
|
+
}.show
|
3412
|
+
```
|
3413
|
+
|
3414
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (manual construction of `image` from `image_part`):
|
3352
3415
|
|
3353
3416
|
```ruby
|
3354
3417
|
# NOTE:
|
@@ -3410,20 +3473,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3410
3473
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_button'"
|
3411
3474
|
```
|
3412
3475
|
|
3413
|
-
Mac
|
3414
|
-
|
3415
|
-
![glimmer-dsl-libui-mac-basic-table-button.png](images/glimmer-dsl-libui-mac-basic-table-button.png)
|
3416
|
-
![glimmer-dsl-libui-mac-basic-table-button-deleted.png](images/glimmer-dsl-libui-mac-basic-table-button-deleted.png)
|
3417
|
-
|
3418
|
-
Windows
|
3419
|
-
|
3420
|
-
![glimmer-dsl-libui-windows-basic-table-button.png](images/glimmer-dsl-libui-windows-basic-table-button.png)
|
3421
|
-
![glimmer-dsl-libui-windows-basic-table-button-deleted.png](images/glimmer-dsl-libui-windows-basic-table-button-deleted.png)
|
3422
|
-
|
3423
|
-
Linux
|
3424
|
-
|
3425
|
-
![glimmer-dsl-libui-linux-basic-table-button.png](images/glimmer-dsl-libui-linux-basic-table-button.png)
|
3426
|
-
![glimmer-dsl-libui-linux-basic-table-button-deleted.png](images/glimmer-dsl-libui-linux-basic-table-button-deleted.png)
|
3476
|
+
Mac | Windows | Linux
|
3477
|
+
----|---------|------
|
3478
|
+
![glimmer-dsl-libui-mac-basic-table-button.png](images/glimmer-dsl-libui-mac-basic-table-button.png) ![glimmer-dsl-libui-mac-basic-table-button-deleted.png](images/glimmer-dsl-libui-mac-basic-table-button-deleted.png) | ![glimmer-dsl-libui-windows-basic-table-button.png](images/glimmer-dsl-libui-windows-basic-table-button.png) ![glimmer-dsl-libui-windows-basic-table-button-deleted.png](images/glimmer-dsl-libui-windows-basic-table-button-deleted.png) | ![glimmer-dsl-libui-linux-basic-table-button.png](images/glimmer-dsl-libui-linux-basic-table-button.png) ![glimmer-dsl-libui-linux-basic-table-button-deleted.png](images/glimmer-dsl-libui-linux-basic-table-button-deleted.png)
|
3427
3479
|
|
3428
3480
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3429
3481
|
|
@@ -3477,17 +3529,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3477
3529
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox'"
|
3478
3530
|
```
|
3479
3531
|
|
3480
|
-
Mac
|
3481
|
-
|
3482
|
-
![glimmer-dsl-libui-mac-basic-table-checkbox.png](images/glimmer-dsl-libui-mac-basic-table-checkbox.png)
|
3483
|
-
|
3484
|
-
Windows
|
3485
|
-
|
3486
|
-
![glimmer-dsl-libui-windows-basic-table-checkbox.png](images/glimmer-dsl-libui-windows-basic-table-checkbox.png)
|
3487
|
-
|
3488
|
-
Linux
|
3489
|
-
|
3490
|
-
![glimmer-dsl-libui-linux-basic-table-checkbox.png](images/glimmer-dsl-libui-linux-basic-table-checkbox.png)
|
3532
|
+
Mac | Windows | Linux
|
3533
|
+
----|---------|------
|
3534
|
+
![glimmer-dsl-libui-mac-basic-table-checkbox.png](images/glimmer-dsl-libui-mac-basic-table-checkbox.png) | ![glimmer-dsl-libui-windows-basic-table-checkbox.png](images/glimmer-dsl-libui-windows-basic-table-checkbox.png) | ![glimmer-dsl-libui-linux-basic-table-checkbox.png](images/glimmer-dsl-libui-linux-basic-table-checkbox.png)
|
3491
3535
|
|
3492
3536
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3493
3537
|
|
@@ -3533,17 +3577,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3533
3577
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox_text'"
|
3534
3578
|
```
|
3535
3579
|
|
3536
|
-
Mac
|
3537
|
-
|
3538
|
-
![glimmer-dsl-libui-mac-basic-table-checkbox-text.png](images/glimmer-dsl-libui-mac-basic-table-checkbox-text.png)
|
3539
|
-
|
3540
|
-
Windows
|
3541
|
-
|
3542
|
-
![glimmer-dsl-libui-windows-basic-table-checkbox-text.png](images/glimmer-dsl-libui-windows-basic-table-checkbox-text.png)
|
3543
|
-
|
3544
|
-
Linux
|
3545
|
-
|
3546
|
-
![glimmer-dsl-libui-linux-basic-table-checkbox-text.png](images/glimmer-dsl-libui-linux-basic-table-checkbox-text.png)
|
3580
|
+
Mac | Windows | Linux
|
3581
|
+
----|---------|------
|
3582
|
+
![glimmer-dsl-libui-mac-basic-table-checkbox-text.png](images/glimmer-dsl-libui-mac-basic-table-checkbox-text.png) | ![glimmer-dsl-libui-windows-basic-table-checkbox-text.png](images/glimmer-dsl-libui-windows-basic-table-checkbox-text.png) | ![glimmer-dsl-libui-linux-basic-table-checkbox-text.png](images/glimmer-dsl-libui-linux-basic-table-checkbox-text.png)
|
3547
3583
|
|
3548
3584
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3549
3585
|
|
@@ -3589,17 +3625,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3589
3625
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_progress_bar'"
|
3590
3626
|
```
|
3591
3627
|
|
3592
|
-
Mac
|
3593
|
-
|
3594
|
-
![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png)
|
3595
|
-
|
3596
|
-
Windows
|
3597
|
-
|
3598
|
-
![glimmer-dsl-libui-windows-basic-table-progress-bar.png](images/glimmer-dsl-libui-windows-basic-table-progress-bar.png)
|
3599
|
-
|
3600
|
-
Linux
|
3601
|
-
|
3602
|
-
![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
|
3628
|
+
Mac | Windows | Linux
|
3629
|
+
----|---------|------
|
3630
|
+
![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png) | ![glimmer-dsl-libui-windows-basic-table-progress-bar.png](images/glimmer-dsl-libui-windows-basic-table-progress-bar.png) | ![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
|
3603
3631
|
|
3604
3632
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3605
3633
|
|
@@ -3654,19 +3682,45 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3654
3682
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_color'"
|
3655
3683
|
```
|
3656
3684
|
|
3657
|
-
Mac
|
3685
|
+
Mac | Windows | Linux
|
3686
|
+
----|---------|------
|
3687
|
+
![glimmer-dsl-libui-mac-basic-table-color.png](images/glimmer-dsl-libui-mac-basic-table-color.png) | ![glimmer-dsl-libui-windows-basic-table-color.png](images/glimmer-dsl-libui-windows-basic-table-color.png) | ![glimmer-dsl-libui-linux-basic-table-color.png](images/glimmer-dsl-libui-linux-basic-table-color.png)
|
3688
|
+
|
3689
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3690
|
+
|
3691
|
+
```ruby
|
3692
|
+
# frozen_string_literal: true
|
3658
3693
|
|
3659
|
-
|
3694
|
+
require 'glimmer-dsl-libui'
|
3660
3695
|
|
3661
|
-
|
3696
|
+
include Glimmer
|
3697
|
+
|
3698
|
+
img = image(File.expand_path('../icons/glimmer.png', __dir__), 24, 24)
|
3662
3699
|
|
3663
|
-
|
3700
|
+
data = [
|
3701
|
+
[['cat', :red] , ['meow', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], {r: 255, g: 120, b: 0, a: 0.5}],
|
3702
|
+
[['dog', :yellow] , ['woof', {r: 240, g: 32, b: 32}] , [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], :skyblue],
|
3703
|
+
[['chicken', :beige], ['cock-a-doodle-doo', :blue] , [false, 'mammal', :red] , [img, 'Glimmer', :beige], {r: 5, g: 120, b: 110}],
|
3704
|
+
[['horse', :purple] , ['neigh', {r: 240, g: 32, b: 32}], [true, 'mammal', :green], [img, 'Glimmer', :dark_blue], '13a1fb'],
|
3705
|
+
[['cow', :gray] , ['moo', :blue] , [true, 'mammal', :green], [img, 'Glimmer', :brown], 0x12ff02]
|
3706
|
+
]
|
3664
3707
|
|
3665
|
-
|
3708
|
+
window('Animals', 500, 200) {
|
3709
|
+
horizontal_box {
|
3710
|
+
table {
|
3711
|
+
text_color_column('Animal')
|
3712
|
+
text_color_column('Sound')
|
3713
|
+
checkbox_text_color_column('Description')
|
3714
|
+
image_text_color_column('GUI')
|
3715
|
+
background_color_column('Mammal')
|
3666
3716
|
|
3667
|
-
|
3717
|
+
cell_rows data
|
3718
|
+
}
|
3719
|
+
}
|
3720
|
+
}.show
|
3721
|
+
```
|
3668
3722
|
|
3669
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3723
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (manual construction of [libui](https://github.com/andlabs/libui) `image` from `image_part`):
|
3670
3724
|
|
3671
3725
|
```ruby
|
3672
3726
|
require 'glimmer-dsl-libui'
|
@@ -3724,23 +3778,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3724
3778
|
ruby -r glimmer-dsl-libui -e "require 'examples/form_table'"
|
3725
3779
|
```
|
3726
3780
|
|
3727
|
-
Mac
|
3728
|
-
|
3729
|
-
![glimmer-dsl-libui-mac-form-table.png](images/glimmer-dsl-libui-mac-form-table.png)
|
3730
|
-
![glimmer-dsl-libui-mac-form-table-contact-entered.png](images/glimmer-dsl-libui-mac-form-table-contact-entered.png)
|
3731
|
-
![glimmer-dsl-libui-mac-form-table-filtered.png](images/glimmer-dsl-libui-mac-form-table-filtered.png)
|
3732
|
-
|
3733
|
-
Windows
|
3734
|
-
|
3735
|
-
![glimmer-dsl-libui-windows-form-table.png](images/glimmer-dsl-libui-windows-form-table.png)
|
3736
|
-
![glimmer-dsl-libui-windows-form-table-contact-entered.png](images/glimmer-dsl-libui-windows-form-table-contact-entered.png)
|
3737
|
-
![glimmer-dsl-libui-windows-form-table-filtered.png](images/glimmer-dsl-libui-windows-form-table-filtered.png)
|
3738
|
-
|
3739
|
-
Linux
|
3740
|
-
|
3741
|
-
![glimmer-dsl-libui-linux-form-table.png](images/glimmer-dsl-libui-linux-form-table.png)
|
3742
|
-
![glimmer-dsl-libui-linux-form-table-contact-entered.png](images/glimmer-dsl-libui-linux-form-table-contact-entered.png)
|
3743
|
-
![glimmer-dsl-libui-linux-form-table-filtered.png](images/glimmer-dsl-libui-linux-form-table-filtered.png)
|
3781
|
+
Mac | Windows | Linux
|
3782
|
+
----|---------|------
|
3783
|
+
![glimmer-dsl-libui-mac-form-table.png](images/glimmer-dsl-libui-mac-form-table.png) ![glimmer-dsl-libui-mac-form-table-contact-entered.png](images/glimmer-dsl-libui-mac-form-table-contact-entered.png) ![glimmer-dsl-libui-mac-form-table-filtered.png](images/glimmer-dsl-libui-mac-form-table-filtered.png) | ![glimmer-dsl-libui-windows-form-table.png](images/glimmer-dsl-libui-windows-form-table.png) ![glimmer-dsl-libui-windows-form-table-contact-entered.png](images/glimmer-dsl-libui-windows-form-table-contact-entered.png) ![glimmer-dsl-libui-windows-form-table-filtered.png](images/glimmer-dsl-libui-windows-form-table-filtered.png) | ![glimmer-dsl-libui-linux-form-table.png](images/glimmer-dsl-libui-linux-form-table.png) ![glimmer-dsl-libui-linux-form-table-contact-entered.png](images/glimmer-dsl-libui-linux-form-table-contact-entered.png) ![glimmer-dsl-libui-linux-form-table-filtered.png](images/glimmer-dsl-libui-linux-form-table-filtered.png)
|
3744
3784
|
|
3745
3785
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3746
3786
|
|
@@ -3767,15 +3807,19 @@ window('Contacts', 600, 600) { |w|
|
|
3767
3807
|
@name_entry = entry {
|
3768
3808
|
label 'Name'
|
3769
3809
|
}
|
3810
|
+
|
3770
3811
|
@email_entry = entry {
|
3771
3812
|
label 'Email'
|
3772
3813
|
}
|
3814
|
+
|
3773
3815
|
@phone_entry = entry {
|
3774
3816
|
label 'Phone'
|
3775
3817
|
}
|
3818
|
+
|
3776
3819
|
@city_entry = entry {
|
3777
3820
|
label 'City'
|
3778
3821
|
}
|
3822
|
+
|
3779
3823
|
@state_entry = entry {
|
3780
3824
|
label 'State'
|
3781
3825
|
}
|
@@ -3852,17 +3896,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3852
3896
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_area'"
|
3853
3897
|
```
|
3854
3898
|
|
3855
|
-
Mac
|
3856
|
-
|
3857
|
-
![glimmer-dsl-libui-mac-basic-area.png](images/glimmer-dsl-libui-mac-basic-area.png)
|
3858
|
-
|
3859
|
-
Windows
|
3860
|
-
|
3861
|
-
![glimmer-dsl-libui-windows-basic-area.png](images/glimmer-dsl-libui-windows-basic-area.png)
|
3862
|
-
|
3863
|
-
Linux
|
3864
|
-
|
3865
|
-
![glimmer-dsl-libui-linux-basic-area.png](images/glimmer-dsl-libui-linux-basic-area.png)
|
3899
|
+
Mac | Windows | Linux
|
3900
|
+
----|---------|------
|
3901
|
+
![glimmer-dsl-libui-mac-basic-area.png](images/glimmer-dsl-libui-mac-basic-area.png) | ![glimmer-dsl-libui-windows-basic-area.png](images/glimmer-dsl-libui-windows-basic-area.png) | ![glimmer-dsl-libui-linux-basic-area.png](images/glimmer-dsl-libui-linux-basic-area.png)
|
3866
3902
|
|
3867
3903
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
3868
3904
|
|
@@ -3978,20 +4014,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
3978
4014
|
ruby -r glimmer-dsl-libui -e "require 'examples/dynamic_area'"
|
3979
4015
|
```
|
3980
4016
|
|
3981
|
-
Mac
|
3982
|
-
|
3983
|
-
![glimmer-dsl-libui-mac-dynamic-area.png](images/glimmer-dsl-libui-mac-dynamic-area.png)
|
3984
|
-
![glimmer-dsl-libui-mac-dynamic-area-updated.png](images/glimmer-dsl-libui-mac-dynamic-area-updated.png)
|
3985
|
-
|
3986
|
-
Windows
|
3987
|
-
|
3988
|
-
![glimmer-dsl-libui-windows-dynamic-area.png](images/glimmer-dsl-libui-windows-dynamic-area.png)
|
3989
|
-
![glimmer-dsl-libui-windows-dynamic-area-updated.png](images/glimmer-dsl-libui-windows-dynamic-area-updated.png)
|
3990
|
-
|
3991
|
-
Linux
|
3992
|
-
|
3993
|
-
![glimmer-dsl-libui-linux-dynamic-area.png](images/glimmer-dsl-libui-linux-dynamic-area.png)
|
3994
|
-
![glimmer-dsl-libui-linux-dynamic-area-updated.png](images/glimmer-dsl-libui-linux-dynamic-area-updated.png)
|
4017
|
+
Mac | Windows | Linux
|
4018
|
+
----|---------|------
|
4019
|
+
![glimmer-dsl-libui-mac-dynamic-area.png](images/glimmer-dsl-libui-mac-dynamic-area.png) ![glimmer-dsl-libui-mac-dynamic-area-updated.png](images/glimmer-dsl-libui-mac-dynamic-area-updated.png) | ![glimmer-dsl-libui-windows-dynamic-area.png](images/glimmer-dsl-libui-windows-dynamic-area.png) ![glimmer-dsl-libui-windows-dynamic-area-updated.png](images/glimmer-dsl-libui-windows-dynamic-area-updated.png) | ![glimmer-dsl-libui-linux-dynamic-area.png](images/glimmer-dsl-libui-linux-dynamic-area.png) ![glimmer-dsl-libui-linux-dynamic-area-updated.png](images/glimmer-dsl-libui-linux-dynamic-area-updated.png)
|
3995
4020
|
|
3996
4021
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
3997
4022
|
|
@@ -4000,7 +4025,7 @@ require 'glimmer-dsl-libui'
|
|
4000
4025
|
|
4001
4026
|
include Glimmer
|
4002
4027
|
|
4003
|
-
window('Dynamic Area', 240,
|
4028
|
+
window('Dynamic Area', 240, 600) {
|
4004
4029
|
margined true
|
4005
4030
|
|
4006
4031
|
vertical_box {
|
@@ -4086,9 +4111,7 @@ window('Dynamic Area', 240, 500) {
|
|
4086
4111
|
|
4087
4112
|
@area = area {
|
4088
4113
|
on_draw do |area_draw_params|
|
4089
|
-
|
4090
|
-
rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value)
|
4091
|
-
|
4114
|
+
rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value) { # a dynamic path is added semi-declaratively inside on_draw block
|
4092
4115
|
fill r: @red_spinbox.value, g: @green_spinbox.value, b: @blue_spinbox.value, a: @alpha_spinbox.value / 100.0
|
4093
4116
|
}
|
4094
4117
|
end
|
@@ -4156,7 +4179,7 @@ window('Dynamic Area', 240, 600) {
|
|
4156
4179
|
value 102
|
4157
4180
|
|
4158
4181
|
on_changed do
|
4159
|
-
@
|
4182
|
+
@rectangle.fill[:r] = @red_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
|
4160
4183
|
end
|
4161
4184
|
}
|
4162
4185
|
|
@@ -4165,7 +4188,7 @@ window('Dynamic Area', 240, 600) {
|
|
4165
4188
|
value 102
|
4166
4189
|
|
4167
4190
|
on_changed do
|
4168
|
-
@
|
4191
|
+
@rectangle.fill[:g] = @green_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
|
4169
4192
|
end
|
4170
4193
|
}
|
4171
4194
|
|
@@ -4174,7 +4197,7 @@ window('Dynamic Area', 240, 600) {
|
|
4174
4197
|
value 204
|
4175
4198
|
|
4176
4199
|
on_changed do
|
4177
|
-
@
|
4200
|
+
@rectangle.fill[:b] = @blue_spinbox.value # updating hash properties automatically triggers area.queue_redraw_all
|
4178
4201
|
end
|
4179
4202
|
}
|
4180
4203
|
|
@@ -4183,15 +4206,13 @@ window('Dynamic Area', 240, 600) {
|
|
4183
4206
|
value 100
|
4184
4207
|
|
4185
4208
|
on_changed do
|
4186
|
-
@
|
4209
|
+
@rectangle.fill[:a] = @alpha_spinbox.value / 100.0 # updating hash properties automatically triggers area.queue_redraw_all
|
4187
4210
|
end
|
4188
4211
|
}
|
4189
4212
|
}
|
4190
4213
|
|
4191
4214
|
area {
|
4192
|
-
@
|
4193
|
-
@rectangle = rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value)
|
4194
|
-
|
4215
|
+
@rectangle = rectangle(@x_spinbox.value, @y_spinbox.value, @width_spinbox.value, @height_spinbox.value) { # stable path
|
4195
4216
|
fill r: @red_spinbox.value, g: @green_spinbox.value, b: @blue_spinbox.value, a: @alpha_spinbox.value / 100.0
|
4196
4217
|
}
|
4197
4218
|
}
|
@@ -4199,33 +4220,128 @@ window('Dynamic Area', 240, 600) {
|
|
4199
4220
|
}.show
|
4200
4221
|
```
|
4201
4222
|
|
4202
|
-
### Area
|
4223
|
+
### Basic Scrolling Area
|
4203
4224
|
|
4204
|
-
[examples/
|
4225
|
+
[examples/basic_scrolling_area.rb](examples/basic_scrolling_area.rb)
|
4205
4226
|
|
4206
4227
|
Run with this command from the root of the project if you cloned the project:
|
4207
4228
|
|
4208
4229
|
```
|
4209
|
-
ruby -r './lib/glimmer-dsl-libui' examples/
|
4230
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_scrolling_area.rb
|
4210
4231
|
```
|
4211
4232
|
|
4212
4233
|
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
4213
4234
|
|
4214
4235
|
```
|
4215
|
-
ruby -r glimmer-dsl-libui -e "require 'examples/
|
4236
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_scrolling_area'"
|
4237
|
+
```
|
4238
|
+
|
4239
|
+
Mac |
|
4240
|
+
----|
|
4241
|
+
![glimmer-dsl-libui-mac-dynamic-area.png](images/glimmer-dsl-libui-mac-basic-scrolling-area.png) ![glimmer-dsl-libui-mac-dynamic-area-updated.png](images/glimmer-dsl-libui-mac-basic-scrolling-area-scrolled.png)
|
4242
|
+
|
4243
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
4244
|
+
|
4245
|
+
```ruby
|
4246
|
+
require 'glimmer-dsl-libui'
|
4247
|
+
|
4248
|
+
class BasicScrollingArea
|
4249
|
+
include Glimmer
|
4250
|
+
|
4251
|
+
SCROLLING_AREA_WIDTH = 800
|
4252
|
+
SCROLLING_AREA_HEIGHT = 400
|
4253
|
+
SCROLLING_AREA_PADDING_X = 20
|
4254
|
+
SCROLLING_AREA_PADDING_Y = 20
|
4255
|
+
|
4256
|
+
def initialize
|
4257
|
+
@x = SCROLLING_AREA_PADDING_X
|
4258
|
+
@y = SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y
|
4259
|
+
create_gui
|
4260
|
+
Glimmer::LibUI.timer(0.01) do
|
4261
|
+
@x += SCROLLING_AREA_PADDING_X
|
4262
|
+
@y = [[@y + rand(SCROLLING_AREA_PADDING_Y*4)*(rand(2) == 0 ? -1 : 1), SCROLLING_AREA_PADDING_Y].max, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y].min
|
4263
|
+
@graph.content { # re-open @graph's content and add a line
|
4264
|
+
line(@x, @y)
|
4265
|
+
}
|
4266
|
+
# if there is a need to enlarge scrolling area, call `@scrolling_area.set_size(new_width, new_height)`
|
4267
|
+
@scrolling_area.scroll_to(@x - (SCROLLING_AREA_WIDTH/2), @y) # 3rd and 4th arguments for width and height are assumed as those of main window by default if not supplied
|
4268
|
+
# return false to stop timer once @x exceeds scrolling area width - padding
|
4269
|
+
false if @x >= (SCROLLING_AREA_WIDTH - SCROLLING_AREA_PADDING_X*2)
|
4270
|
+
end
|
4271
|
+
end
|
4272
|
+
|
4273
|
+
def launch
|
4274
|
+
@main_window.show
|
4275
|
+
end
|
4276
|
+
|
4277
|
+
def x_axis
|
4278
|
+
polyline(SCROLLING_AREA_PADDING_X, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y, SCROLLING_AREA_WIDTH - SCROLLING_AREA_PADDING_X*2, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y) {
|
4279
|
+
stroke :black, thickness: 3
|
4280
|
+
}
|
4281
|
+
|
4282
|
+
((SCROLLING_AREA_WIDTH - SCROLLING_AREA_PADDING_X*4) / SCROLLING_AREA_PADDING_X).times do |x_multiplier|
|
4283
|
+
x = x_multiplier*SCROLLING_AREA_PADDING_X + SCROLLING_AREA_PADDING_X*2
|
4284
|
+
y = SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y
|
4285
|
+
|
4286
|
+
polyline(x, y, x, y + SCROLLING_AREA_PADDING_Y/2) {
|
4287
|
+
stroke :black, thickness: 2
|
4288
|
+
}
|
4289
|
+
end
|
4290
|
+
end
|
4291
|
+
|
4292
|
+
def y_axis
|
4293
|
+
polyline(SCROLLING_AREA_PADDING_X, SCROLLING_AREA_PADDING_Y, SCROLLING_AREA_PADDING_X, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y) {
|
4294
|
+
stroke :black, thickness: 3
|
4295
|
+
}
|
4296
|
+
|
4297
|
+
((SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y*3) / SCROLLING_AREA_PADDING_Y).times do |y_multiplier|
|
4298
|
+
x = SCROLLING_AREA_PADDING_X
|
4299
|
+
y = y_multiplier*SCROLLING_AREA_PADDING_Y + SCROLLING_AREA_PADDING_Y*2
|
4300
|
+
|
4301
|
+
polyline(x, y, x - SCROLLING_AREA_PADDING_X/2, y) {
|
4302
|
+
stroke :black, thickness: 2
|
4303
|
+
}
|
4304
|
+
end
|
4305
|
+
end
|
4306
|
+
|
4307
|
+
def create_gui
|
4308
|
+
@main_window = window('Basic Scrolling Area', SCROLLING_AREA_WIDTH / 2, SCROLLING_AREA_HEIGHT) {
|
4309
|
+
resizable false
|
4310
|
+
|
4311
|
+
@scrolling_area = scrolling_area(SCROLLING_AREA_WIDTH, SCROLLING_AREA_HEIGHT) {
|
4312
|
+
x_axis
|
4313
|
+
y_axis
|
4314
|
+
|
4315
|
+
@graph = figure(SCROLLING_AREA_PADDING_X, SCROLLING_AREA_HEIGHT - SCROLLING_AREA_PADDING_Y) {
|
4316
|
+
stroke :blue, thickness: 2
|
4317
|
+
}
|
4318
|
+
}
|
4319
|
+
}
|
4320
|
+
end
|
4321
|
+
end
|
4322
|
+
|
4323
|
+
BasicScrollingArea.new.launch
|
4216
4324
|
```
|
4217
4325
|
|
4218
|
-
|
4326
|
+
### Area Gallery
|
4327
|
+
|
4328
|
+
[examples/area_gallery.rb](examples/area_gallery.rb)
|
4219
4329
|
|
4220
|
-
|
4330
|
+
Run with this command from the root of the project if you cloned the project:
|
4221
4331
|
|
4222
|
-
|
4332
|
+
```
|
4333
|
+
ruby -r './lib/glimmer-dsl-libui' examples/area_gallery.rb
|
4334
|
+
```
|
4223
4335
|
|
4224
|
-
|
4336
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
4225
4337
|
|
4226
|
-
|
4338
|
+
```
|
4339
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/area_gallery'"
|
4340
|
+
```
|
4227
4341
|
|
4228
|
-
|
4342
|
+
Mac | Windows | Linux
|
4343
|
+
----|---------|------
|
4344
|
+
![glimmer-dsl-libui-mac-area-gallery.png](images/glimmer-dsl-libui-mac-area-gallery.png) | ![glimmer-dsl-libui-windows-area-gallery.png](images/glimmer-dsl-libui-windows-area-gallery.png) | ![glimmer-dsl-libui-linux-area-gallery.png](images/glimmer-dsl-libui-linux-area-gallery.png)
|
4229
4345
|
|
4230
4346
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
4231
4347
|
|
@@ -4236,53 +4352,268 @@ include Glimmer
|
|
4236
4352
|
|
4237
4353
|
window('Area Gallery', 400, 400) {
|
4238
4354
|
area {
|
4239
|
-
|
4355
|
+
polygon(100, 100, 100, 400, 400, 100, 400, 400) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
4356
|
+
fill r: 202, g: 102, b: 104, a: 0.5
|
4357
|
+
stroke r: 0, g: 0, b: 0
|
4358
|
+
}
|
4359
|
+
|
4360
|
+
polybezier(0, 0,
|
4361
|
+
200, 100, 100, 200, 400, 100,
|
4362
|
+
300, 100, 100, 300, 100, 400,
|
4363
|
+
100, 300, 300, 100, 400, 400) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
4364
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4365
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4366
|
+
}
|
4367
|
+
|
4368
|
+
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
4369
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4370
|
+
}
|
4371
|
+
|
4372
|
+
arc(404, 216, 190, 90, 90, false) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
4373
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4374
|
+
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}]
|
4375
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4376
|
+
}
|
4377
|
+
|
4378
|
+
circle(200, 200, 90) { # declarative stable path (implicit path syntax for a single shape nested directly under area)
|
4379
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4380
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4381
|
+
}
|
4382
|
+
|
4383
|
+
path { # declarative stable path (explicit path syntax for multiple shapes sharing attributes)
|
4240
4384
|
square(0, 0, 100)
|
4241
4385
|
square(100, 100, 400)
|
4242
|
-
|
4386
|
+
|
4243
4387
|
fill r: 102, g: 102, b: 204
|
4244
4388
|
}
|
4245
|
-
|
4389
|
+
|
4390
|
+
path { # declarative stable path (explicit path syntax for multiple shapes sharing attributes)
|
4246
4391
|
rectangle(0, 100, 100, 400)
|
4247
4392
|
rectangle(100, 0, 400, 100)
|
4248
|
-
|
4393
|
+
|
4249
4394
|
# linear gradient (has x0, y0, x1, y1, and stops)
|
4250
4395
|
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
4251
4396
|
}
|
4252
|
-
|
4253
|
-
|
4397
|
+
|
4398
|
+
text(161, 40, 100) { # declarative stable text
|
4399
|
+
string('Area Gallery') {
|
4400
|
+
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
4401
|
+
color :black
|
4402
|
+
}
|
4403
|
+
}
|
4404
|
+
|
4405
|
+
on_mouse_event do |area_mouse_event|
|
4406
|
+
p area_mouse_event
|
4407
|
+
end
|
4408
|
+
|
4409
|
+
on_mouse_moved do |area_mouse_event|
|
4410
|
+
puts 'moved'
|
4411
|
+
end
|
4412
|
+
|
4413
|
+
on_mouse_down do |area_mouse_event|
|
4414
|
+
puts 'mouse down'
|
4415
|
+
end
|
4416
|
+
|
4417
|
+
on_mouse_up do |area_mouse_event|
|
4418
|
+
puts 'mouse up'
|
4419
|
+
end
|
4420
|
+
|
4421
|
+
on_mouse_drag_started do |area_mouse_event|
|
4422
|
+
puts 'drag started'
|
4423
|
+
end
|
4424
|
+
|
4425
|
+
on_mouse_dragged do |area_mouse_event|
|
4426
|
+
puts 'dragged'
|
4427
|
+
end
|
4428
|
+
|
4429
|
+
on_mouse_dropped do |area_mouse_event|
|
4430
|
+
puts 'dropped'
|
4431
|
+
end
|
4432
|
+
|
4433
|
+
on_mouse_entered do
|
4434
|
+
puts 'entered'
|
4435
|
+
end
|
4436
|
+
|
4437
|
+
on_mouse_exited do
|
4438
|
+
puts 'exited'
|
4439
|
+
end
|
4440
|
+
|
4441
|
+
on_key_event do |area_key_event|
|
4442
|
+
p area_key_event
|
4443
|
+
end
|
4444
|
+
|
4445
|
+
on_key_up do |area_key_event|
|
4446
|
+
puts 'key up'
|
4447
|
+
end
|
4448
|
+
|
4449
|
+
on_key_down do |area_key_event|
|
4450
|
+
puts 'key down'
|
4451
|
+
end
|
4452
|
+
}
|
4453
|
+
}.show
|
4454
|
+
```
|
4455
|
+
|
4456
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2 (setting shape properties instead of arguments):
|
4457
|
+
|
4458
|
+
```ruby
|
4459
|
+
require 'glimmer-dsl-libui'
|
4460
|
+
|
4461
|
+
include Glimmer
|
4462
|
+
|
4463
|
+
window('Area Gallery', 400, 400) {
|
4464
|
+
area {
|
4465
|
+
|
4466
|
+
figure { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
|
4467
|
+
x 100
|
4468
|
+
y 100
|
4469
|
+
|
4470
|
+
line {
|
4471
|
+
x 100
|
4472
|
+
y 400
|
4473
|
+
}
|
4254
4474
|
|
4475
|
+
line {
|
4476
|
+
x 400
|
4477
|
+
y 100
|
4478
|
+
}
|
4479
|
+
|
4480
|
+
line {
|
4481
|
+
x 400
|
4482
|
+
y 400
|
4483
|
+
}
|
4484
|
+
|
4485
|
+
closed true # polygon figure is closed (last point forms a line with first point)
|
4255
4486
|
fill r: 202, g: 102, b: 104, a: 0.5
|
4256
4487
|
stroke r: 0, g: 0, b: 0
|
4257
4488
|
}
|
4258
|
-
|
4259
|
-
|
4260
|
-
|
4489
|
+
|
4490
|
+
figure { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
|
4491
|
+
x 0
|
4492
|
+
y 0
|
4493
|
+
|
4494
|
+
bezier {
|
4495
|
+
c1_x 200
|
4496
|
+
c1_y 100
|
4497
|
+
c2_x 100
|
4498
|
+
c2_y 200
|
4499
|
+
end_x 400
|
4500
|
+
end_y 100
|
4501
|
+
}
|
4502
|
+
|
4503
|
+
bezier {
|
4504
|
+
c1_x 300
|
4505
|
+
c1_y 100
|
4506
|
+
c2_x 100
|
4507
|
+
c2_y 300
|
4508
|
+
end_x 100
|
4509
|
+
end_y 400
|
4510
|
+
}
|
4511
|
+
|
4512
|
+
bezier {
|
4513
|
+
c1_x 100
|
4514
|
+
c1_y 300
|
4515
|
+
c2_x 300
|
4516
|
+
c2_y 100
|
4517
|
+
end_x 400
|
4518
|
+
end_y 400
|
4519
|
+
}
|
4520
|
+
|
4261
4521
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4262
4522
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4263
4523
|
}
|
4264
|
-
path { # declarative stable path
|
4265
|
-
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
4266
4524
|
|
4267
|
-
|
4268
|
-
|
4269
|
-
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4273
|
-
|
4274
|
-
|
4275
|
-
|
4276
|
-
|
4277
|
-
|
4278
|
-
|
4279
|
-
|
4280
|
-
|
4281
|
-
|
4282
|
-
|
4283
|
-
|
4525
|
+
figure { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
|
4526
|
+
x 100
|
4527
|
+
y 100
|
4528
|
+
|
4529
|
+
line {
|
4530
|
+
x 400
|
4531
|
+
y 100
|
4532
|
+
}
|
4533
|
+
|
4534
|
+
line {
|
4535
|
+
x 100
|
4536
|
+
y 400
|
4537
|
+
}
|
4538
|
+
|
4539
|
+
line {
|
4540
|
+
x 400
|
4541
|
+
y 400
|
4542
|
+
}
|
4543
|
+
|
4544
|
+
line {
|
4545
|
+
x 0
|
4546
|
+
y 0
|
4547
|
+
}
|
4548
|
+
|
4549
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4550
|
+
}
|
4551
|
+
|
4552
|
+
arc { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
|
4553
|
+
x_center 404
|
4554
|
+
y_center 216
|
4555
|
+
radius 190
|
4556
|
+
start_angle 90
|
4557
|
+
sweep 90
|
4558
|
+
is_negative false
|
4559
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4560
|
+
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}]
|
4561
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4562
|
+
}
|
4563
|
+
|
4564
|
+
circle { # declarative stable path with explicit attributes (implicit path syntax for a single shape nested directly under area)
|
4565
|
+
x_center 200
|
4566
|
+
y_center 200
|
4567
|
+
radius 90
|
4568
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4569
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4570
|
+
}
|
4571
|
+
|
4572
|
+
path { # declarative stable path with explicit attributes (explicit path syntax for multiple shapes sharing attributes)
|
4573
|
+
square {
|
4574
|
+
x 0
|
4575
|
+
y 0
|
4576
|
+
length 100
|
4577
|
+
}
|
4578
|
+
|
4579
|
+
square {
|
4580
|
+
x 100
|
4581
|
+
y 100
|
4582
|
+
length 400
|
4583
|
+
}
|
4584
|
+
|
4585
|
+
fill r: 102, g: 102, b: 204
|
4586
|
+
}
|
4587
|
+
|
4588
|
+
path { # declarative stable path with explicit attributes (explicit path syntax for multiple shapes sharing attributes)
|
4589
|
+
rectangle {
|
4590
|
+
x 0
|
4591
|
+
y 100
|
4592
|
+
width 100
|
4593
|
+
height 400
|
4594
|
+
}
|
4595
|
+
|
4596
|
+
rectangle {
|
4597
|
+
x 100
|
4598
|
+
y 0
|
4599
|
+
width 400
|
4600
|
+
height 100
|
4601
|
+
}
|
4602
|
+
|
4603
|
+
# linear gradient (has x0, y0, x1, y1, and stops)
|
4604
|
+
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
4605
|
+
}
|
4606
|
+
|
4607
|
+
text { # declarative stable text with explicit attributes
|
4608
|
+
x 161
|
4609
|
+
y 40
|
4610
|
+
width 100
|
4611
|
+
|
4612
|
+
string {
|
4284
4613
|
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
4285
4614
|
color :black
|
4615
|
+
|
4616
|
+
'Area Gallery'
|
4286
4617
|
}
|
4287
4618
|
}
|
4288
4619
|
|
@@ -4337,7 +4668,7 @@ window('Area Gallery', 400, 400) {
|
|
4337
4668
|
}.show
|
4338
4669
|
```
|
4339
4670
|
|
4340
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version
|
4671
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 3 (semi-declarative `on_draw` dynamic `path` approach):
|
4341
4672
|
|
4342
4673
|
```ruby
|
4343
4674
|
require 'glimmer-dsl-libui'
|
@@ -4346,157 +4677,57 @@ include Glimmer
|
|
4346
4677
|
|
4347
4678
|
window('Area Gallery', 400, 400) {
|
4348
4679
|
area {
|
4349
|
-
|
4350
|
-
|
4351
|
-
|
4352
|
-
|
4353
|
-
length 100
|
4680
|
+
on_draw do |area_draw_params|
|
4681
|
+
polygon(100, 100, 100, 400, 400, 100, 400, 400) { # dynamic path, added semi-declaratively inside on_draw block
|
4682
|
+
fill r: 202, g: 102, b: 104, a: 0.5
|
4683
|
+
stroke r: 0, g: 0, b: 0
|
4354
4684
|
}
|
4355
|
-
|
4356
|
-
|
4357
|
-
|
4358
|
-
|
4685
|
+
|
4686
|
+
polybezier(0, 0,
|
4687
|
+
200, 100, 100, 200, 400, 100,
|
4688
|
+
300, 100, 100, 300, 100, 400,
|
4689
|
+
100, 300, 300, 100, 400, 400) { # dynamic path, added semi-declaratively inside on_draw block
|
4690
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4691
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4359
4692
|
}
|
4360
4693
|
|
4361
|
-
|
4362
|
-
|
4363
|
-
path { # declarative stable path
|
4364
|
-
rectangle {
|
4365
|
-
x 0
|
4366
|
-
y 100
|
4367
|
-
width 100
|
4368
|
-
height 400
|
4694
|
+
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0) { # dynamic path, added semi-declaratively inside on_draw block
|
4695
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4369
4696
|
}
|
4370
|
-
|
4371
|
-
|
4372
|
-
|
4373
|
-
|
4374
|
-
|
4697
|
+
|
4698
|
+
arc(404, 216, 190, 90, 90, false) { # dynamic path, added semi-declaratively inside on_draw block
|
4699
|
+
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4700
|
+
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}]
|
4701
|
+
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4375
4702
|
}
|
4376
4703
|
|
4377
|
-
|
4378
|
-
|
4379
|
-
|
4380
|
-
path { # declarative stable path
|
4381
|
-
figure {
|
4382
|
-
x 100
|
4383
|
-
y 100
|
4384
|
-
|
4385
|
-
line {
|
4386
|
-
x 100
|
4387
|
-
y 400
|
4388
|
-
}
|
4389
|
-
line {
|
4390
|
-
x 400
|
4391
|
-
y 100
|
4392
|
-
}
|
4393
|
-
line {
|
4394
|
-
x 400
|
4395
|
-
y 400
|
4396
|
-
}
|
4397
|
-
|
4398
|
-
closed true
|
4704
|
+
circle(200, 200, 90) { # dynamic path, added semi-declaratively inside on_draw block
|
4705
|
+
fill r: 202, g: 102, b: 204, a: 0.5
|
4706
|
+
stroke r: 0, g: 0, b: 0, thickness: 2
|
4399
4707
|
}
|
4400
|
-
|
4401
|
-
|
4402
|
-
|
4403
|
-
|
4404
|
-
path { # declarative stable path
|
4405
|
-
figure {
|
4406
|
-
x 0
|
4407
|
-
y 0
|
4708
|
+
|
4709
|
+
path { # dynamic path, added semi-declaratively inside on_draw block
|
4710
|
+
square(0, 0, 100)
|
4711
|
+
square(100, 100, 400)
|
4408
4712
|
|
4409
|
-
|
4410
|
-
c1_x 200
|
4411
|
-
c1_y 100
|
4412
|
-
c2_x 100
|
4413
|
-
c2_y 200
|
4414
|
-
end_x 400
|
4415
|
-
end_y 100
|
4416
|
-
}
|
4417
|
-
bezier {
|
4418
|
-
c1_x 300
|
4419
|
-
c1_y 100
|
4420
|
-
c2_x 100
|
4421
|
-
c2_y 300
|
4422
|
-
end_x 100
|
4423
|
-
end_y 400
|
4424
|
-
}
|
4425
|
-
bezier {
|
4426
|
-
c1_x 100
|
4427
|
-
c1_y 300
|
4428
|
-
c2_x 300
|
4429
|
-
c2_y 100
|
4430
|
-
end_x 400
|
4431
|
-
end_y 400
|
4432
|
-
}
|
4713
|
+
fill r: 102, g: 102, b: 204
|
4433
4714
|
}
|
4434
|
-
|
4435
|
-
|
4436
|
-
|
4437
|
-
|
4438
|
-
path { # declarative stable path
|
4439
|
-
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
4440
|
-
figure {
|
4441
|
-
x 100
|
4442
|
-
y 100
|
4715
|
+
|
4716
|
+
path { # dynamic path, added semi-declaratively inside on_draw block
|
4717
|
+
rectangle(0, 100, 100, 400)
|
4718
|
+
rectangle(100, 0, 400, 100)
|
4443
4719
|
|
4444
|
-
|
4445
|
-
|
4446
|
-
y 100
|
4447
|
-
}
|
4448
|
-
line {
|
4449
|
-
x 100
|
4450
|
-
y 400
|
4451
|
-
}
|
4452
|
-
line {
|
4453
|
-
x 400
|
4454
|
-
y 400
|
4455
|
-
}
|
4456
|
-
line {
|
4457
|
-
x 0
|
4458
|
-
y 0
|
4459
|
-
}
|
4460
|
-
}
|
4461
|
-
|
4462
|
-
stroke r: 0, g: 0, b: 0, thickness: 2
|
4463
|
-
}
|
4464
|
-
path { # declarative stable path
|
4465
|
-
arc {
|
4466
|
-
x_center 404
|
4467
|
-
y_center 216
|
4468
|
-
radius 190
|
4469
|
-
start_angle 90
|
4470
|
-
sweep 90
|
4471
|
-
is_negative false
|
4472
|
-
}
|
4473
|
-
|
4474
|
-
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4475
|
-
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}]
|
4476
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4477
|
-
}
|
4478
|
-
path { # declarative stable path
|
4479
|
-
circle {
|
4480
|
-
x_center 200
|
4481
|
-
y_center 200
|
4482
|
-
radius 90
|
4720
|
+
# linear gradient (has x0, y0, x1, y1, and stops)
|
4721
|
+
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
4483
4722
|
}
|
4484
|
-
|
4485
|
-
fill r: 202, g: 102, b: 204, a: 0.5
|
4486
|
-
stroke r: 0, g: 0, b: 0, thickness: 2
|
4487
|
-
}
|
4488
|
-
text {
|
4489
|
-
x 161
|
4490
|
-
y 40
|
4491
|
-
width 100
|
4492
4723
|
|
4493
|
-
|
4494
|
-
|
4495
|
-
|
4496
|
-
|
4497
|
-
|
4724
|
+
text(161, 40, 100) { # dynamic text added semi-declaratively inside on_draw block
|
4725
|
+
string('Area Gallery') {
|
4726
|
+
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
4727
|
+
color :black
|
4728
|
+
}
|
4498
4729
|
}
|
4499
|
-
|
4730
|
+
end
|
4500
4731
|
|
4501
4732
|
on_mouse_event do |area_mouse_event|
|
4502
4733
|
p area_mouse_event
|
@@ -4549,7 +4780,7 @@ window('Area Gallery', 400, 400) {
|
|
4549
4780
|
}.show
|
4550
4781
|
```
|
4551
4782
|
|
4552
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version
|
4783
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 4 (setting shape properties instead of arguments with semi-declarative `on_draw` dynamic `path` approach):
|
4553
4784
|
|
4554
4785
|
```ruby
|
4555
4786
|
require 'glimmer-dsl-libui'
|
@@ -4559,124 +4790,119 @@ include Glimmer
|
|
4559
4790
|
window('Area Gallery', 400, 400) {
|
4560
4791
|
area {
|
4561
4792
|
on_draw do |area_draw_params|
|
4562
|
-
|
4563
|
-
|
4564
|
-
|
4565
|
-
|
4566
|
-
|
4567
|
-
|
4568
|
-
|
4569
|
-
|
4570
|
-
|
4571
|
-
|
4572
|
-
|
4573
|
-
|
4574
|
-
|
4575
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4576
|
-
polygon(100, 100, 100, 400, 400, 100, 400, 400)
|
4793
|
+
figure { # dynamic path, added semi-declaratively inside on_draw block
|
4794
|
+
x 100
|
4795
|
+
y 100
|
4796
|
+
|
4797
|
+
line {
|
4798
|
+
x 100
|
4799
|
+
y 400
|
4800
|
+
}
|
4801
|
+
|
4802
|
+
line {
|
4803
|
+
x 400
|
4804
|
+
y 100
|
4805
|
+
}
|
4577
4806
|
|
4807
|
+
line {
|
4808
|
+
x 400
|
4809
|
+
y 400
|
4810
|
+
}
|
4811
|
+
|
4812
|
+
closed true # polygon figure is closed (last point forms a line with first point)
|
4578
4813
|
fill r: 202, g: 102, b: 104, a: 0.5
|
4579
4814
|
stroke r: 0, g: 0, b: 0
|
4580
4815
|
}
|
4581
|
-
|
4582
|
-
|
4583
|
-
|
4816
|
+
|
4817
|
+
figure { # dynamic path, added semi-declaratively inside on_draw block
|
4818
|
+
x 0
|
4819
|
+
y 0
|
4820
|
+
|
4821
|
+
bezier {
|
4822
|
+
c1_x 200
|
4823
|
+
c1_y 100
|
4824
|
+
c2_x 100
|
4825
|
+
c2_y 200
|
4826
|
+
end_x 400
|
4827
|
+
end_y 100
|
4828
|
+
}
|
4829
|
+
|
4830
|
+
bezier {
|
4831
|
+
c1_x 300
|
4832
|
+
c1_y 100
|
4833
|
+
c2_x 100
|
4834
|
+
c2_y 300
|
4835
|
+
end_x 100
|
4836
|
+
end_y 400
|
4837
|
+
}
|
4838
|
+
|
4839
|
+
bezier {
|
4840
|
+
c1_x 100
|
4841
|
+
c1_y 300
|
4842
|
+
c2_x 300
|
4843
|
+
c2_y 100
|
4844
|
+
end_x 400
|
4845
|
+
end_y 400
|
4846
|
+
}
|
4847
|
+
|
4584
4848
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4585
4849
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4586
4850
|
}
|
4587
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4588
|
-
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
4589
4851
|
|
4852
|
+
figure { # dynamic path, added semi-declaratively inside on_draw block
|
4853
|
+
x 100
|
4854
|
+
y 100
|
4855
|
+
|
4856
|
+
line {
|
4857
|
+
x 400
|
4858
|
+
y 100
|
4859
|
+
}
|
4860
|
+
|
4861
|
+
line {
|
4862
|
+
x 100
|
4863
|
+
y 400
|
4864
|
+
}
|
4865
|
+
|
4866
|
+
line {
|
4867
|
+
x 400
|
4868
|
+
y 400
|
4869
|
+
}
|
4870
|
+
|
4871
|
+
line {
|
4872
|
+
x 0
|
4873
|
+
y 0
|
4874
|
+
}
|
4875
|
+
|
4590
4876
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
4591
4877
|
}
|
4592
|
-
|
4593
|
-
|
4594
|
-
|
4878
|
+
|
4879
|
+
arc { # dynamic path, added semi-declaratively inside on_draw block
|
4880
|
+
x_center 404
|
4881
|
+
y_center 216
|
4882
|
+
radius 190
|
4883
|
+
start_angle 90
|
4884
|
+
sweep 90
|
4885
|
+
is_negative false
|
4595
4886
|
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4596
4887
|
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}]
|
4597
4888
|
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4598
4889
|
}
|
4599
|
-
|
4600
|
-
|
4601
|
-
|
4890
|
+
|
4891
|
+
circle { # dynamic path, added semi-declaratively inside on_draw block
|
4892
|
+
x_center 200
|
4893
|
+
y_center 200
|
4894
|
+
radius 90
|
4602
4895
|
fill r: 202, g: 102, b: 204, a: 0.5
|
4603
4896
|
stroke r: 0, g: 0, b: 0, thickness: 2
|
4604
4897
|
}
|
4605
|
-
|
4606
|
-
|
4607
|
-
font family: 'Arial', size: (OS.mac? ? 14 : 11)
|
4608
|
-
color :black
|
4609
|
-
}
|
4610
|
-
}
|
4611
|
-
end
|
4612
|
-
|
4613
|
-
on_mouse_event do |area_mouse_event|
|
4614
|
-
p area_mouse_event
|
4615
|
-
end
|
4616
|
-
|
4617
|
-
on_mouse_moved do |area_mouse_event|
|
4618
|
-
puts 'moved'
|
4619
|
-
end
|
4620
|
-
|
4621
|
-
on_mouse_down do |area_mouse_event|
|
4622
|
-
puts 'mouse down'
|
4623
|
-
end
|
4624
|
-
|
4625
|
-
on_mouse_up do |area_mouse_event|
|
4626
|
-
puts 'mouse up'
|
4627
|
-
end
|
4628
|
-
|
4629
|
-
on_mouse_drag_started do |area_mouse_event|
|
4630
|
-
puts 'drag started'
|
4631
|
-
end
|
4632
|
-
|
4633
|
-
on_mouse_dragged do |area_mouse_event|
|
4634
|
-
puts 'dragged'
|
4635
|
-
end
|
4636
|
-
|
4637
|
-
on_mouse_dropped do |area_mouse_event|
|
4638
|
-
puts 'dropped'
|
4639
|
-
end
|
4640
|
-
|
4641
|
-
on_mouse_entered do
|
4642
|
-
puts 'entered'
|
4643
|
-
end
|
4644
|
-
|
4645
|
-
on_mouse_exited do
|
4646
|
-
puts 'exited'
|
4647
|
-
end
|
4648
|
-
|
4649
|
-
on_key_event do |area_key_event|
|
4650
|
-
p area_key_event
|
4651
|
-
end
|
4652
|
-
|
4653
|
-
on_key_up do |area_key_event|
|
4654
|
-
puts 'key up'
|
4655
|
-
end
|
4656
|
-
|
4657
|
-
on_key_down do |area_key_event|
|
4658
|
-
puts 'key down'
|
4659
|
-
end
|
4660
|
-
}
|
4661
|
-
}.show
|
4662
|
-
```
|
4663
|
-
|
4664
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 4 (setting shape properties instead of arguments with semi-declarative `on_draw` dynamic `path` approach):
|
4665
|
-
|
4666
|
-
```ruby
|
4667
|
-
require 'glimmer-dsl-libui'
|
4668
|
-
|
4669
|
-
include Glimmer
|
4670
|
-
|
4671
|
-
window('Area Gallery', 400, 400) {
|
4672
|
-
area {
|
4673
|
-
on_draw do |area_draw_params|
|
4674
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4898
|
+
|
4899
|
+
path { # dynamic path, added semi-declaratively inside on_draw block
|
4675
4900
|
square {
|
4676
4901
|
x 0
|
4677
4902
|
y 0
|
4678
4903
|
length 100
|
4679
4904
|
}
|
4905
|
+
|
4680
4906
|
square {
|
4681
4907
|
x 100
|
4682
4908
|
y 100
|
@@ -4685,13 +4911,15 @@ window('Area Gallery', 400, 400) {
|
|
4685
4911
|
|
4686
4912
|
fill r: 102, g: 102, b: 204
|
4687
4913
|
}
|
4688
|
-
|
4914
|
+
|
4915
|
+
path { # dynamic path, added semi-declaratively inside on_draw block
|
4689
4916
|
rectangle {
|
4690
4917
|
x 0
|
4691
4918
|
y 100
|
4692
4919
|
width 100
|
4693
4920
|
height 400
|
4694
4921
|
}
|
4922
|
+
|
4695
4923
|
rectangle {
|
4696
4924
|
x 100
|
4697
4925
|
y 0
|
@@ -4702,115 +4930,8 @@ window('Area Gallery', 400, 400) {
|
|
4702
4930
|
# linear gradient (has x0, y0, x1, y1, and stops)
|
4703
4931
|
fill x0: 10, y0: 10, x1: 350, y1: 350, stops: [{pos: 0.25, r: 204, g: 102, b: 204}, {pos: 0.75, r: 102, g: 102, b: 204}]
|
4704
4932
|
}
|
4705
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4706
|
-
figure {
|
4707
|
-
x 100
|
4708
|
-
y 100
|
4709
|
-
|
4710
|
-
line {
|
4711
|
-
x 100
|
4712
|
-
y 400
|
4713
|
-
}
|
4714
|
-
line {
|
4715
|
-
x 400
|
4716
|
-
y 100
|
4717
|
-
}
|
4718
|
-
line {
|
4719
|
-
x 400
|
4720
|
-
y 400
|
4721
|
-
}
|
4722
|
-
|
4723
|
-
closed true
|
4724
|
-
}
|
4725
|
-
|
4726
|
-
fill r: 202, g: 102, b: 104, a: 0.5
|
4727
|
-
stroke r: 0, g: 0, b: 0
|
4728
|
-
}
|
4729
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4730
|
-
figure {
|
4731
|
-
x 0
|
4732
|
-
y 0
|
4733
|
-
|
4734
|
-
bezier {
|
4735
|
-
c1_x 200
|
4736
|
-
c1_y 100
|
4737
|
-
c2_x 100
|
4738
|
-
c2_y 200
|
4739
|
-
end_x 400
|
4740
|
-
end_y 100
|
4741
|
-
}
|
4742
|
-
bezier {
|
4743
|
-
c1_x 300
|
4744
|
-
c1_y 100
|
4745
|
-
c2_x 100
|
4746
|
-
c2_y 300
|
4747
|
-
end_x 100
|
4748
|
-
end_y 400
|
4749
|
-
}
|
4750
|
-
bezier {
|
4751
|
-
c1_x 100
|
4752
|
-
c1_y 300
|
4753
|
-
c2_x 300
|
4754
|
-
c2_y 100
|
4755
|
-
end_x 400
|
4756
|
-
end_y 400
|
4757
|
-
}
|
4758
|
-
}
|
4759
|
-
|
4760
|
-
fill r: 202, g: 102, b: 204, a: 0.5
|
4761
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4762
|
-
}
|
4763
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4764
|
-
polyline(100, 100, 400, 100, 100, 400, 400, 400, 0, 0)
|
4765
|
-
figure {
|
4766
|
-
x 100
|
4767
|
-
y 100
|
4768
|
-
|
4769
|
-
line {
|
4770
|
-
x 400
|
4771
|
-
y 100
|
4772
|
-
}
|
4773
|
-
line {
|
4774
|
-
x 100
|
4775
|
-
y 400
|
4776
|
-
}
|
4777
|
-
line {
|
4778
|
-
x 400
|
4779
|
-
y 400
|
4780
|
-
}
|
4781
|
-
line {
|
4782
|
-
x 0
|
4783
|
-
y 0
|
4784
|
-
}
|
4785
|
-
}
|
4786
4933
|
|
4787
|
-
|
4788
|
-
}
|
4789
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4790
|
-
arc {
|
4791
|
-
x_center 404
|
4792
|
-
y_center 216
|
4793
|
-
radius 190
|
4794
|
-
start_angle 90
|
4795
|
-
sweep 90
|
4796
|
-
is_negative false
|
4797
|
-
}
|
4798
|
-
|
4799
|
-
# radial gradient (has an outer_radius in addition to x0, y0, x1, y1, and stops)
|
4800
|
-
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}]
|
4801
|
-
stroke r: 0, g: 0, b: 0, thickness: 2, dashes: [50, 10, 10, 10], dash_phase: -50.0
|
4802
|
-
}
|
4803
|
-
path { # a dynamic path is added semi-declaratively inside on_draw block
|
4804
|
-
circle {
|
4805
|
-
x_center 200
|
4806
|
-
y_center 200
|
4807
|
-
radius 90
|
4808
|
-
}
|
4809
|
-
|
4810
|
-
fill r: 202, g: 102, b: 204, a: 0.5
|
4811
|
-
stroke r: 0, g: 0, b: 0, thickness: 2
|
4812
|
-
}
|
4813
|
-
text {
|
4934
|
+
text { # dynamic path, added semi-declaratively inside on_draw block
|
4814
4935
|
x 161
|
4815
4936
|
y 40
|
4816
4937
|
width 100
|
@@ -4891,9 +5012,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
4891
5012
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_image'"
|
4892
5013
|
```
|
4893
5014
|
|
4894
|
-
Mac
|
4895
|
-
|
4896
|
-
![glimmer-dsl-libui-mac-basic-image.png](images/glimmer-dsl-libui-mac-basic-image.png)
|
5015
|
+
Mac | Windows | Linux
|
5016
|
+
----|---------|------
|
5017
|
+
![glimmer-dsl-libui-mac-basic-image.png](images/glimmer-dsl-libui-mac-basic-image.png) | ![glimmer-dsl-libui-windows-basic-image.png](images/glimmer-dsl-libui-windows-basic-image.png) | ![glimmer-dsl-libui-linux-basic-image.png](images/glimmer-dsl-libui-linux-basic-image.png)
|
4897
5018
|
|
4898
5019
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
4899
5020
|
|
@@ -5081,17 +5202,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
5081
5202
|
ruby -r glimmer-dsl-libui -e "require 'examples/histogram'"
|
5082
5203
|
```
|
5083
5204
|
|
5084
|
-
Mac
|
5085
|
-
|
5086
|
-
![glimmer-dsl-libui-mac-histogram.png](images/glimmer-dsl-libui-mac-histogram.png)
|
5087
|
-
|
5088
|
-
Windows
|
5089
|
-
|
5090
|
-
![glimmer-dsl-libui-windows-histogram.png](images/glimmer-dsl-libui-windows-histogram.png)
|
5091
|
-
|
5092
|
-
Linux
|
5093
|
-
|
5094
|
-
![glimmer-dsl-libui-linux-histogram.png](images/glimmer-dsl-libui-linux-histogram.png)
|
5205
|
+
Mac | Windows | Linux
|
5206
|
+
----|---------|------
|
5207
|
+
![glimmer-dsl-libui-mac-histogram.png](images/glimmer-dsl-libui-mac-histogram.png) | ![glimmer-dsl-libui-windows-histogram.png](images/glimmer-dsl-libui-windows-histogram.png) | ![glimmer-dsl-libui-linux-histogram.png](images/glimmer-dsl-libui-linux-histogram.png)
|
5095
5208
|
|
5096
5209
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
5097
5210
|
|
@@ -5419,19 +5532,46 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
5419
5532
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_transform'"
|
5420
5533
|
```
|
5421
5534
|
|
5422
|
-
Mac
|
5535
|
+
Mac | Windows | Linux
|
5536
|
+
----|---------|------
|
5537
|
+
![glimmer-dsl-libui-mac-basic-transform.png](images/glimmer-dsl-libui-mac-basic-transform.png) | ![glimmer-dsl-libui-windows-basic-transform.png](images/glimmer-dsl-libui-windows-basic-transform.png) | ![glimmer-dsl-libui-linux-basic-transform.png](images/glimmer-dsl-libui-linux-basic-transform.png)
|
5423
5538
|
|
5424
|
-
|
5425
|
-
|
5426
|
-
Windows
|
5539
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
5427
5540
|
|
5428
|
-
|
5541
|
+
```ruby
|
5542
|
+
require 'glimmer-dsl-libui'
|
5429
5543
|
|
5430
|
-
|
5544
|
+
include Glimmer
|
5431
5545
|
|
5432
|
-
|
5546
|
+
window('Basic Transform', 350, 350) {
|
5547
|
+
area {
|
5548
|
+
square(0, 0, 350) {
|
5549
|
+
fill r: 255, g: 255, b: 0
|
5550
|
+
}
|
5551
|
+
40.times do |n|
|
5552
|
+
square(0, 0, 100) {
|
5553
|
+
fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
|
5554
|
+
stroke :black, thickness: 2
|
5555
|
+
|
5556
|
+
transform {
|
5557
|
+
unless OS.windows?
|
5558
|
+
skew 0.15, 0.15
|
5559
|
+
translate 50, 50
|
5560
|
+
end
|
5561
|
+
rotate 100, 100, -9 * n
|
5562
|
+
scale 1.1, 1.1
|
5563
|
+
if OS.windows?
|
5564
|
+
skew 0.15, 0.15
|
5565
|
+
translate 50, 50
|
5566
|
+
end
|
5567
|
+
}
|
5568
|
+
}
|
5569
|
+
end
|
5570
|
+
}
|
5571
|
+
}.show
|
5572
|
+
```
|
5433
5573
|
|
5434
|
-
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
5574
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version 2:
|
5435
5575
|
|
5436
5576
|
```ruby
|
5437
5577
|
require 'glimmer-dsl-libui'
|
@@ -5451,11 +5591,18 @@ window('Basic Transform', 350, 350) {
|
|
5451
5591
|
|
5452
5592
|
fill r: [255 - n*5, 0].max, g: [n*5, 255].min, b: 0, a: 0.5
|
5453
5593
|
stroke :black, thickness: 2
|
5594
|
+
|
5454
5595
|
transform {
|
5455
|
-
|
5456
|
-
|
5596
|
+
unless OS.windows?
|
5597
|
+
skew 0.15, 0.15
|
5598
|
+
translate 50, 50
|
5599
|
+
end
|
5457
5600
|
rotate 100, 100, -9 * n
|
5458
5601
|
scale 1.1, 1.1
|
5602
|
+
if OS.windows?
|
5603
|
+
skew 0.15, 0.15
|
5604
|
+
translate 50, 50
|
5605
|
+
end
|
5459
5606
|
}
|
5460
5607
|
}
|
5461
5608
|
end
|
@@ -5479,20 +5626,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
5479
5626
|
ruby -r glimmer-dsl-libui -e "require 'examples/login'"
|
5480
5627
|
```
|
5481
5628
|
|
5482
|
-
Mac
|
5483
|
-
|
5484
|
-
![glimmer-dsl-libui-mac-login.png](images/glimmer-dsl-libui-mac-login.png)
|
5485
|
-
![glimmer-dsl-libui-mac-login-logged-in.png](images/glimmer-dsl-libui-mac-login-logged-in.png)
|
5486
|
-
|
5487
|
-
Windows
|
5488
|
-
|
5489
|
-
![glimmer-dsl-libui-windows-login.png](images/glimmer-dsl-libui-windows-login.png)
|
5490
|
-
![glimmer-dsl-libui-windows-login-logged-in.png](images/glimmer-dsl-libui-windows-login-logged-in.png)
|
5491
|
-
|
5492
|
-
Linux
|
5493
|
-
|
5494
|
-
![glimmer-dsl-libui-linux-login.png](images/glimmer-dsl-libui-linux-login.png)
|
5495
|
-
![glimmer-dsl-libui-linux-login-logged-in.png](images/glimmer-dsl-libui-linux-login-logged-in.png)
|
5629
|
+
Mac | Windows | Linux
|
5630
|
+
----|---------|------
|
5631
|
+
![glimmer-dsl-libui-mac-login.png](images/glimmer-dsl-libui-mac-login.png) ![glimmer-dsl-libui-mac-login-logged-in.png](images/glimmer-dsl-libui-mac-login-logged-in.png) | ![glimmer-dsl-libui-windows-login.png](images/glimmer-dsl-libui-windows-login.png) ![glimmer-dsl-libui-windows-login-logged-in.png](images/glimmer-dsl-libui-windows-login-logged-in.png) | ![glimmer-dsl-libui-linux-login.png](images/glimmer-dsl-libui-linux-login.png) ![glimmer-dsl-libui-linux-login-logged-in.png](images/glimmer-dsl-libui-linux-login-logged-in.png)
|
5496
5632
|
|
5497
5633
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
5498
5634
|
|
@@ -5560,20 +5696,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
5560
5696
|
ruby -r glimmer-dsl-libui -e "require 'examples/timer'"
|
5561
5697
|
```
|
5562
5698
|
|
5563
|
-
Mac
|
5564
|
-
|
5565
|
-
![glimmer-dsl-libui-mac-timer.png](images/glimmer-dsl-libui-mac-timer.png)
|
5566
|
-
![glimmer-dsl-libui-mac-timer-in-progress.png](images/glimmer-dsl-libui-mac-timer-in-progress.png)
|
5567
|
-
|
5568
|
-
Windows
|
5569
|
-
|
5570
|
-
![glimmer-dsl-libui-windows-timer.png](images/glimmer-dsl-libui-windows-timer.png)
|
5571
|
-
![glimmer-dsl-libui-windows-timer-in-progress.png](images/glimmer-dsl-libui-windows-timer-in-progress.png)
|
5572
|
-
|
5573
|
-
Linux
|
5574
|
-
|
5575
|
-
![glimmer-dsl-libui-linux-timer.png](images/glimmer-dsl-libui-linux-timer.png)
|
5576
|
-
![glimmer-dsl-libui-linux-timer-in-progress.png](images/glimmer-dsl-libui-linux-timer-in-progress.png)
|
5699
|
+
Mac | Windows | Linux
|
5700
|
+
----|---------|------
|
5701
|
+
![glimmer-dsl-libui-mac-timer.png](images/glimmer-dsl-libui-mac-timer.png) ![glimmer-dsl-libui-mac-timer-in-progress.png](images/glimmer-dsl-libui-mac-timer-in-progress.png) | ![glimmer-dsl-libui-windows-timer.png](images/glimmer-dsl-libui-windows-timer.png) ![glimmer-dsl-libui-windows-timer-in-progress.png](images/glimmer-dsl-libui-windows-timer-in-progress.png) | ![glimmer-dsl-libui-linux-timer.png](images/glimmer-dsl-libui-linux-timer.png) ![glimmer-dsl-libui-linux-timer-in-progress.png](images/glimmer-dsl-libui-linux-timer-in-progress.png)
|
5577
5702
|
|
5578
5703
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
5579
5704
|
|
@@ -5729,23 +5854,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
5729
5854
|
ruby -r glimmer-dsl-libui -e "require 'examples/color_the_circles'"
|
5730
5855
|
```
|
5731
5856
|
|
5732
|
-
Mac
|
5733
|
-
|
5734
|
-
![glimmer-dsl-libui-mac-color-the-circles.png](images/glimmer-dsl-libui-mac-color-the-circles.png)
|
5735
|
-
![glimmer-dsl-libui-mac-color-the-circles-lost.png](images/glimmer-dsl-libui-mac-color-the-circles-lost.png)
|
5736
|
-
![glimmer-dsl-libui-mac-color-the-circles-won.png](images/glimmer-dsl-libui-mac-color-the-circles-won.png)
|
5737
|
-
|
5738
|
-
Windows
|
5739
|
-
|
5740
|
-
![glimmer-dsl-libui-windows-color-the-circles.png](images/glimmer-dsl-libui-windows-color-the-circles.png)
|
5741
|
-
![glimmer-dsl-libui-windows-color-the-circles-lost.png](images/glimmer-dsl-libui-windows-color-the-circles-lost.png)
|
5742
|
-
![glimmer-dsl-libui-windows-color-the-circles-won.png](images/glimmer-dsl-libui-windows-color-the-circles-won.png)
|
5743
|
-
|
5744
|
-
Linux
|
5745
|
-
|
5746
|
-
![glimmer-dsl-libui-linux-color-the-circles.png](images/glimmer-dsl-libui-linux-color-the-circles.png)
|
5747
|
-
![glimmer-dsl-libui-linux-color-the-circles-lost.png](images/glimmer-dsl-libui-linux-color-the-circles-lost.png)
|
5748
|
-
![glimmer-dsl-libui-linux-color-the-circles-won.png](images/glimmer-dsl-libui-linux-color-the-circles-won.png)
|
5857
|
+
Mac | Windows | Linux
|
5858
|
+
----|---------|------
|
5859
|
+
![glimmer-dsl-libui-mac-color-the-circles.png](images/glimmer-dsl-libui-mac-color-the-circles.png) ![glimmer-dsl-libui-mac-color-the-circles-lost.png](images/glimmer-dsl-libui-mac-color-the-circles-lost.png) ![glimmer-dsl-libui-mac-color-the-circles-won.png](images/glimmer-dsl-libui-mac-color-the-circles-won.png) | ![glimmer-dsl-libui-windows-color-the-circles.png](images/glimmer-dsl-libui-windows-color-the-circles.png) ![glimmer-dsl-libui-windows-color-the-circles-lost.png](images/glimmer-dsl-libui-windows-color-the-circles-lost.png) ![glimmer-dsl-libui-windows-color-the-circles-won.png](images/glimmer-dsl-libui-windows-color-the-circles-won.png) | ![glimmer-dsl-libui-linux-color-the-circles.png](images/glimmer-dsl-libui-linux-color-the-circles.png) ![glimmer-dsl-libui-linux-color-the-circles-lost.png](images/glimmer-dsl-libui-linux-color-the-circles-lost.png) ![glimmer-dsl-libui-linux-color-the-circles-won.png](images/glimmer-dsl-libui-linux-color-the-circles-won.png)
|
5749
5860
|
|
5750
5861
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
5751
5862
|
|
@@ -5779,15 +5890,17 @@ class ColorTheCircles
|
|
5779
5890
|
|
5780
5891
|
def register_observers
|
5781
5892
|
observer = Glimmer::DataBinding::Observer.proc do |new_score|
|
5782
|
-
|
5783
|
-
|
5784
|
-
|
5785
|
-
|
5786
|
-
|
5787
|
-
|
5788
|
-
|
5789
|
-
|
5790
|
-
|
5893
|
+
Glimmer::LibUI.queue_main do
|
5894
|
+
@score_label.text = new_score.to_s
|
5895
|
+
if new_score == -20
|
5896
|
+
@game_over = true
|
5897
|
+
msg_box('You Lost!', 'Sorry! Your score reached -20')
|
5898
|
+
restart_game
|
5899
|
+
elsif new_score == 0
|
5900
|
+
@game_over = true
|
5901
|
+
msg_box('You Won!', 'Congratulations! Your score reached 0')
|
5902
|
+
restart_game
|
5903
|
+
end
|
5791
5904
|
end
|
5792
5905
|
end
|
5793
5906
|
observer.observe(self, :score) # automatically enhances self to become Glimmer::DataBinding::ObservableModel and notify observer on score attribute changes
|
@@ -5951,9 +6064,7 @@ class ColorTheCircles
|
|
5951
6064
|
}
|
5952
6065
|
|
5953
6066
|
@circles_data.each do |circle_data|
|
5954
|
-
|
5955
|
-
circle_data[:circle] = circle(*circle_data[:args])
|
5956
|
-
|
6067
|
+
circle_data[:circle] = circle(*circle_data[:args]) {
|
5957
6068
|
fill circle_data[:fill]
|
5958
6069
|
stroke circle_data[:stroke]
|
5959
6070
|
}
|
@@ -5988,17 +6099,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
5988
6099
|
ruby -r glimmer-dsl-libui -e "require 'examples/basic_draw_text'"
|
5989
6100
|
```
|
5990
6101
|
|
5991
|
-
Mac
|
5992
|
-
|
5993
|
-
![glimmer-dsl-libui-mac-basic-draw-text.png](images/glimmer-dsl-libui-mac-basic-draw-text.png)
|
5994
|
-
|
5995
|
-
Windows
|
5996
|
-
|
5997
|
-
![glimmer-dsl-libui-windows-basic-draw-text.png](images/glimmer-dsl-libui-windows-basic-draw-text.png)
|
5998
|
-
|
5999
|
-
Linux
|
6000
|
-
|
6001
|
-
![glimmer-dsl-libui-linux-basic-draw-text.png](images/glimmer-dsl-libui-linux-basic-draw-text.png)
|
6102
|
+
Mac | Windows | Linux
|
6103
|
+
----|---------|------
|
6104
|
+
![glimmer-dsl-libui-mac-basic-draw-text.png](images/glimmer-dsl-libui-mac-basic-draw-text.png) | ![glimmer-dsl-libui-windows-basic-draw-text.png](images/glimmer-dsl-libui-windows-basic-draw-text.png) | ![glimmer-dsl-libui-linux-basic-draw-text.png](images/glimmer-dsl-libui-linux-basic-draw-text.png)
|
6002
6105
|
|
6003
6106
|
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
6004
6107
|
|
@@ -6274,20 +6377,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
6274
6377
|
ruby -r glimmer-dsl-libui -e "require 'examples/custom_draw_text'"
|
6275
6378
|
```
|
6276
6379
|
|
6277
|
-
Mac
|
6278
|
-
|
6279
|
-
![glimmer-dsl-libui-mac-custom-draw-text.png](images/glimmer-dsl-libui-mac-custom-draw-text.png)
|
6280
|
-
![glimmer-dsl-libui-mac-custom-draw-text-changed.png](images/glimmer-dsl-libui-mac-custom-draw-text-changed.png)
|
6281
|
-
|
6282
|
-
Windows
|
6283
|
-
|
6284
|
-
![glimmer-dsl-libui-windows-custom-draw-text.png](images/glimmer-dsl-libui-windows-custom-draw-text.png)
|
6285
|
-
![glimmer-dsl-libui-windows-custom-draw-text-changed.png](images/glimmer-dsl-libui-windows-custom-draw-text-changed.png)
|
6286
|
-
|
6287
|
-
Linux
|
6288
|
-
|
6289
|
-
![glimmer-dsl-libui-linux-custom-draw-text.png](images/glimmer-dsl-libui-linux-custom-draw-text.png)
|
6290
|
-
![glimmer-dsl-libui-linux-custom-draw-text-changed.png](images/glimmer-dsl-libui-linux-custom-draw-text-changed.png)
|
6380
|
+
Mac | Windows | Linux
|
6381
|
+
----|---------|------
|
6382
|
+
![glimmer-dsl-libui-mac-custom-draw-text.png](images/glimmer-dsl-libui-mac-custom-draw-text.png) ![glimmer-dsl-libui-mac-custom-draw-text-changed.png](images/glimmer-dsl-libui-mac-custom-draw-text-changed.png) | ![glimmer-dsl-libui-windows-custom-draw-text.png](images/glimmer-dsl-libui-windows-custom-draw-text.png) ![glimmer-dsl-libui-windows-custom-draw-text-changed.png](images/glimmer-dsl-libui-windows-custom-draw-text-changed.png) | ![glimmer-dsl-libui-linux-custom-draw-text.png](images/glimmer-dsl-libui-linux-custom-draw-text.png) ![glimmer-dsl-libui-linux-custom-draw-text-changed.png](images/glimmer-dsl-libui-linux-custom-draw-text-changed.png)
|
6291
6383
|
|
6292
6384
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
6293
6385
|
|
@@ -6494,17 +6586,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
6494
6586
|
ruby -r glimmer-dsl-libui -e "require 'examples/method_based_custom_keyword'"
|
6495
6587
|
```
|
6496
6588
|
|
6497
|
-
Mac
|
6498
|
-
|
6499
|
-
![glimmer-dsl-libui-mac-method-based-custom-keyword.png](images/glimmer-dsl-libui-mac-method-based-custom-keyword.png)
|
6500
|
-
|
6501
|
-
Windows
|
6502
|
-
|
6503
|
-
![glimmer-dsl-libui-windows-method-based-custom-keyword.png](images/glimmer-dsl-libui-windows-method-based-custom-keyword.png)
|
6504
|
-
|
6505
|
-
Linux
|
6506
|
-
|
6507
|
-
![glimmer-dsl-libui-linux-method-based-custom-keyword.png](images/glimmer-dsl-libui-linux-method-based-custom-keyword.png)
|
6589
|
+
Mac | Windows | Linux
|
6590
|
+
----|---------|------
|
6591
|
+
![glimmer-dsl-libui-mac-method-based-custom-keyword.png](images/glimmer-dsl-libui-mac-method-based-custom-keyword.png) | ![glimmer-dsl-libui-windows-method-based-custom-keyword.png](images/glimmer-dsl-libui-windows-method-based-custom-keyword.png) | ![glimmer-dsl-libui-linux-method-based-custom-keyword.png](images/glimmer-dsl-libui-linux-method-based-custom-keyword.png)
|
6508
6592
|
|
6509
6593
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
6510
6594
|
|
@@ -6626,29 +6710,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
6626
6710
|
ruby -r glimmer-dsl-libui -e "require 'examples/tetris'"
|
6627
6711
|
```
|
6628
6712
|
|
6629
|
-
Mac
|
6630
|
-
|
6631
|
-
![glimmer-dsl-libui-mac-tetris.png](images/glimmer-dsl-libui-mac-tetris.png)
|
6632
|
-
|
6633
|
-
![glimmer-dsl-libui-mac-tetris-game-over.png](images/glimmer-dsl-libui-mac-tetris-game-over.png)
|
6634
|
-
|
6635
|
-
![glimmer-dsl-libui-mac-tetris-high-scores.png](images/glimmer-dsl-libui-mac-tetris-high-scores.png)
|
6636
|
-
|
6637
|
-
Windows
|
6638
|
-
|
6639
|
-
![glimmer-dsl-libui-windows-tetris.png](images/glimmer-dsl-libui-windows-tetris.png)
|
6640
|
-
|
6641
|
-
![glimmer-dsl-libui-windows-tetris-game-over.png](images/glimmer-dsl-libui-windows-tetris-game-over.png)
|
6642
|
-
|
6643
|
-
![glimmer-dsl-libui-windows-tetris-high-scores.png](images/glimmer-dsl-libui-windows-tetris-high-scores.png)
|
6644
|
-
|
6645
|
-
Linux
|
6646
|
-
|
6647
|
-
![glimmer-dsl-libui-linux-tetris.png](images/glimmer-dsl-libui-linux-tetris.png)
|
6648
|
-
|
6649
|
-
![glimmer-dsl-libui-linux-tetris-game-over.png](images/glimmer-dsl-libui-linux-tetris-game-over.png)
|
6650
|
-
|
6651
|
-
![glimmer-dsl-libui-linux-tetris-high-scores.png](images/glimmer-dsl-libui-linux-tetris-high-scores.png)
|
6713
|
+
Mac | Windows | Linux
|
6714
|
+
----|---------|------
|
6715
|
+
![glimmer-dsl-libui-mac-tetris.png](images/glimmer-dsl-libui-mac-tetris.png) ![glimmer-dsl-libui-mac-tetris-game-over.png](images/glimmer-dsl-libui-mac-tetris-game-over.png) ![glimmer-dsl-libui-mac-tetris-high-scores.png](images/glimmer-dsl-libui-mac-tetris-high-scores.png) | ![glimmer-dsl-libui-windows-tetris.png](images/glimmer-dsl-libui-windows-tetris.png) ![glimmer-dsl-libui-windows-tetris-game-over.png](images/glimmer-dsl-libui-windows-tetris-game-over.png) ![glimmer-dsl-libui-windows-tetris-high-scores.png](images/glimmer-dsl-libui-windows-tetris-high-scores.png) | ![glimmer-dsl-libui-linux-tetris.png](images/glimmer-dsl-libui-linux-tetris.png) ![glimmer-dsl-libui-linux-tetris-game-over.png](images/glimmer-dsl-libui-linux-tetris-game-over.png) ![glimmer-dsl-libui-linux-tetris-high-scores.png](images/glimmer-dsl-libui-linux-tetris-high-scores.png)
|
6652
6716
|
|
6653
6717
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
6654
6718
|
|
@@ -6808,6 +6872,8 @@ class Tetris
|
|
6808
6872
|
end
|
6809
6873
|
}
|
6810
6874
|
radio_menu_item('Rotate Left on Up Arrow') {
|
6875
|
+
checked true
|
6876
|
+
|
6811
6877
|
on_clicked do
|
6812
6878
|
@game.rotate_left_on_up = true
|
6813
6879
|
end
|
@@ -6856,34 +6922,31 @@ class Tetris
|
|
6856
6922
|
bevel_pixel_size = 0.16 * block_size.to_f
|
6857
6923
|
color = Glimmer::LibUI.interpret_color(Model::Block::COLOR_CLEAR)
|
6858
6924
|
area {
|
6859
|
-
block[:background_square] =
|
6860
|
-
square(0, 0, block_size)
|
6861
|
-
|
6925
|
+
block[:background_square] = square(0, 0, block_size) {
|
6862
6926
|
fill color
|
6863
6927
|
}
|
6864
|
-
|
6865
|
-
|
6866
|
-
|
6928
|
+
|
6929
|
+
block[:top_bevel_edge] = polygon {
|
6930
|
+
point_array 0, 0, block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size, bevel_pixel_size
|
6867
6931
|
fill r: color[:r] + 4*BEVEL_CONSTANT, g: color[:g] + 4*BEVEL_CONSTANT, b: color[:b] + 4*BEVEL_CONSTANT
|
6868
6932
|
}
|
6869
|
-
|
6870
|
-
|
6871
|
-
|
6933
|
+
|
6934
|
+
block[:right_bevel_edge] = polygon {
|
6935
|
+
point_array block_size, 0, block_size - bevel_pixel_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size, block_size
|
6872
6936
|
fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
|
6873
6937
|
}
|
6874
|
-
|
6875
|
-
|
6876
|
-
|
6938
|
+
|
6939
|
+
block[:bottom_bevel_edge] = polygon {
|
6940
|
+
point_array block_size, block_size, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size, block_size - bevel_pixel_size
|
6877
6941
|
fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
|
6878
6942
|
}
|
6879
|
-
|
6880
|
-
|
6881
|
-
|
6943
|
+
|
6944
|
+
block[:left_bevel_edge] = polygon {
|
6945
|
+
point_array 0, 0, 0, block_size, bevel_pixel_size, block_size - bevel_pixel_size, bevel_pixel_size, bevel_pixel_size
|
6882
6946
|
fill r: color[:r] - BEVEL_CONSTANT, g: color[:g] - BEVEL_CONSTANT, b: color[:b] - BEVEL_CONSTANT
|
6883
6947
|
}
|
6884
|
-
|
6885
|
-
|
6886
|
-
|
6948
|
+
|
6949
|
+
block[:border_square] = square(0, 0, block_size) {
|
6887
6950
|
stroke COLOR_GRAY
|
6888
6951
|
}
|
6889
6952
|
|
@@ -7043,35 +7106,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
7043
7106
|
ruby -r glimmer-dsl-libui -e "require 'examples/tic_tac_toe'"
|
7044
7107
|
```
|
7045
7108
|
|
7046
|
-
Mac
|
7047
|
-
|
7048
|
-
![glimmer-dsl-libui-mac-tic-tac-toe.png](images/glimmer-dsl-libui-mac-tic-tac-toe.png)
|
7049
|
-
|
7050
|
-
![glimmer-dsl-libui-mac-tic-tac-toe-player-o-wins.png](images/glimmer-dsl-libui-mac-tic-tac-toe-player-o-wins.png)
|
7051
|
-
|
7052
|
-
![glimmer-dsl-libui-mac-tic-tac-toe-player-x-wins.png](images/glimmer-dsl-libui-mac-tic-tac-toe-player-x-wins.png)
|
7053
|
-
|
7054
|
-
![glimmer-dsl-libui-mac-tic-tac-toe-draw.png](images/glimmer-dsl-libui-mac-tic-tac-toe-draw.png)
|
7055
|
-
|
7056
|
-
Windows
|
7057
|
-
|
7058
|
-
![glimmer-dsl-libui-windows-tic-tac-toe.png](images/glimmer-dsl-libui-windows-tic-tac-toe.png)
|
7059
|
-
|
7060
|
-
![glimmer-dsl-libui-windows-tic-tac-toe-player-o-wins.png](images/glimmer-dsl-libui-windows-tic-tac-toe-player-o-wins.png)
|
7061
|
-
|
7062
|
-
![glimmer-dsl-libui-windows-tic-tac-toe-player-x-wins.png](images/glimmer-dsl-libui-windows-tic-tac-toe-player-x-wins.png)
|
7063
|
-
|
7064
|
-
![glimmer-dsl-libui-windows-tic-tac-toe-draw.png](images/glimmer-dsl-libui-windows-tic-tac-toe-draw.png)
|
7065
|
-
|
7066
|
-
Linux
|
7067
|
-
|
7068
|
-
![glimmer-dsl-libui-linux-tic-tac-toe.png](images/glimmer-dsl-libui-linux-tic-tac-toe.png)
|
7069
|
-
|
7070
|
-
![glimmer-dsl-libui-linux-tic-tac-toe-player-o-wins.png](images/glimmer-dsl-libui-linux-tic-tac-toe-player-o-wins.png)
|
7071
|
-
|
7072
|
-
![glimmer-dsl-libui-linux-tic-tac-toe-player-x-wins.png](images/glimmer-dsl-libui-linux-tic-tac-toe-player-x-wins.png)
|
7073
|
-
|
7074
|
-
![glimmer-dsl-libui-linux-tic-tac-toe-draw.png](images/glimmer-dsl-libui-linux-tic-tac-toe-draw.png)
|
7109
|
+
Mac | Windows | Linux
|
7110
|
+
----|---------|------
|
7111
|
+
![glimmer-dsl-libui-mac-tic-tac-toe.png](images/glimmer-dsl-libui-mac-tic-tac-toe.png) ![glimmer-dsl-libui-mac-tic-tac-toe-player-o-wins.png](images/glimmer-dsl-libui-mac-tic-tac-toe-player-o-wins.png) ![glimmer-dsl-libui-mac-tic-tac-toe-player-x-wins.png](images/glimmer-dsl-libui-mac-tic-tac-toe-player-x-wins.png) ![glimmer-dsl-libui-mac-tic-tac-toe-draw.png](images/glimmer-dsl-libui-mac-tic-tac-toe-draw.png) | ![glimmer-dsl-libui-windows-tic-tac-toe.png](images/glimmer-dsl-libui-windows-tic-tac-toe.png) ![glimmer-dsl-libui-windows-tic-tac-toe-player-o-wins.png](images/glimmer-dsl-libui-windows-tic-tac-toe-player-o-wins.png) ![glimmer-dsl-libui-windows-tic-tac-toe-player-x-wins.png](images/glimmer-dsl-libui-windows-tic-tac-toe-player-x-wins.png) ![glimmer-dsl-libui-windows-tic-tac-toe-draw.png](images/glimmer-dsl-libui-windows-tic-tac-toe-draw.png) | ![glimmer-dsl-libui-linux-tic-tac-toe.png](images/glimmer-dsl-libui-linux-tic-tac-toe.png) ![glimmer-dsl-libui-linux-tic-tac-toe-player-o-wins.png](images/glimmer-dsl-libui-linux-tic-tac-toe-player-o-wins.png) ![glimmer-dsl-libui-linux-tic-tac-toe-player-x-wins.png](images/glimmer-dsl-libui-linux-tic-tac-toe-player-x-wins.png) ![glimmer-dsl-libui-linux-tic-tac-toe-draw.png](images/glimmer-dsl-libui-linux-tic-tac-toe-draw.png)
|
7075
7112
|
|
7076
7113
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
7077
7114
|
|
@@ -7123,14 +7160,12 @@ class TicTacToe
|
|
7123
7160
|
|
7124
7161
|
3.times.map do |column|
|
7125
7162
|
area {
|
7126
|
-
|
7127
|
-
square(0, 0, 60)
|
7128
|
-
|
7163
|
+
square(0, 0, 60) {
|
7129
7164
|
stroke :black, thickness: 2
|
7130
7165
|
}
|
7131
7166
|
text(23, 19) {
|
7132
7167
|
@cells[row] << string('') {
|
7133
|
-
font family: 'Arial', size: 20
|
7168
|
+
font family: 'Arial', size: OS.mac? ? 20 : 16
|
7134
7169
|
}
|
7135
7170
|
}
|
7136
7171
|
on_mouse_up do
|
@@ -7181,23 +7216,9 @@ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/
|
|
7181
7216
|
ruby -r glimmer-dsl-libui -e "require 'examples/snake'"
|
7182
7217
|
```
|
7183
7218
|
|
7184
|
-
Mac
|
7185
|
-
|
7186
|
-
![glimmer-dsl-libui-mac-snake.png](images/glimmer-dsl-libui-mac-snake.png)
|
7187
|
-
|
7188
|
-
![glimmer-dsl-libui-mac-snake-game-over.png](images/glimmer-dsl-libui-mac-snake-game-over.png)
|
7189
|
-
|
7190
|
-
Windows
|
7191
|
-
|
7192
|
-
![glimmer-dsl-libui-windows-snake.png](images/glimmer-dsl-libui-windows-snake.png)
|
7193
|
-
|
7194
|
-
![glimmer-dsl-libui-windows-snake-game-over.png](images/glimmer-dsl-libui-windows-snake-game-over.png)
|
7195
|
-
|
7196
|
-
Linux
|
7197
|
-
|
7198
|
-
![glimmer-dsl-libui-linux-snake.png](images/glimmer-dsl-libui-linux-snake.png)
|
7199
|
-
|
7200
|
-
![glimmer-dsl-libui-linux-snake-game-over.png](images/glimmer-dsl-libui-linux-snake-game-over.png)
|
7219
|
+
Mac | Windows | Linux
|
7220
|
+
----|---------|------
|
7221
|
+
![glimmer-dsl-libui-mac-snake.png](images/glimmer-dsl-libui-mac-snake.png) ![glimmer-dsl-libui-mac-snake-game-over.png](images/glimmer-dsl-libui-mac-snake-game-over.png) | ![glimmer-dsl-libui-windows-snake.png](images/glimmer-dsl-libui-windows-snake.png) ![glimmer-dsl-libui-windows-snake-game-over.png](images/glimmer-dsl-libui-windows-snake-game-over.png) | ![glimmer-dsl-libui-linux-snake.png](images/glimmer-dsl-libui-linux-snake.png) ![glimmer-dsl-libui-linux-snake-game-over.png](images/glimmer-dsl-libui-linux-snake-game-over.png)
|
7201
7222
|
|
7202
7223
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
7203
7224
|
|
@@ -7236,7 +7257,7 @@ class Snake
|
|
7236
7257
|
Glimmer::DataBinding::Observer.proc do |game_over|
|
7237
7258
|
Glimmer::LibUI.queue_main do
|
7238
7259
|
if game_over
|
7239
|
-
msg_box('Game Over!', "Score: #{@game.score}")
|
7260
|
+
msg_box('Game Over!', "Score: #{@game.score} | High Score: #{@game.high_score}")
|
7240
7261
|
@game.start
|
7241
7262
|
end
|
7242
7263
|
end
|
@@ -7245,7 +7266,7 @@ class Snake
|
|
7245
7266
|
Glimmer::LibUI.timer(SNAKE_MOVE_DELAY) do
|
7246
7267
|
unless @game.over?
|
7247
7268
|
@game.snake.move
|
7248
|
-
@main_window.title = "Glimmer Snake (Score: #{@game.score})"
|
7269
|
+
@main_window.title = "Glimmer Snake (Score: #{@game.score} | High Score: #{@game.high_score})"
|
7249
7270
|
end
|
7250
7271
|
end
|
7251
7272
|
end
|
@@ -7265,9 +7286,7 @@ class Snake
|
|
7265
7286
|
|
7266
7287
|
@game.width.times do |column|
|
7267
7288
|
area {
|
7268
|
-
@cell_grid.last <<
|
7269
|
-
square(0, 0, CELL_SIZE)
|
7270
|
-
|
7289
|
+
@cell_grid.last << square(0, 0, CELL_SIZE) {
|
7271
7290
|
fill Presenter::Cell::COLOR_CLEAR
|
7272
7291
|
}
|
7273
7292
|
|