glimmer-dsl-libui 0.0.10 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +287 -24
- data/VERSION +1 -1
- data/examples/color_button.rb +14 -0
- data/examples/date_time_picker.rb +20 -0
- data/examples/grid.rb +72 -0
- data/examples/meta_example.rb +13 -6
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/box.rb +10 -0
- data/lib/glimmer/libui/color_button_proxy.rb +64 -0
- data/lib/glimmer/libui/control_proxy.rb +23 -7
- data/lib/glimmer/libui/date_picker_proxy.rb +7 -0
- data/lib/glimmer/libui/date_time_picker_proxy.rb +33 -0
- data/lib/glimmer/libui/font_button_proxy.rb +20 -0
- data/lib/glimmer/libui/grid_proxy.rb +52 -0
- data/lib/glimmer/libui/group_proxy.rb +5 -0
- data/lib/glimmer/libui/time_picker_proxy.rb +7 -0
- data/lib/glimmer/libui/window_proxy.rb +10 -1
- data/lib/glimmer-dsl-libui.rb +1 -0
- metadata +27 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daf22d736dce460dde98ce6cb9d10d50433cce189b648b7b9f4fccd1a4e6cefc
|
4
|
+
data.tar.gz: 36f38bc99b47ae56d321986e9e27e3dfce18dacb3cc3f4722966c36ab329a896
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fcd083428bfdb29db1428012a8dab67516ea5525e37aa5bdb0c7aa0b9679b78e3a01090b8ec20ca4d799b1ea48c41b0983d2570fd12a470246bb2b7fb7eae4c
|
7
|
+
data.tar.gz: b5824e2efefc6ccc319a029d4f5eadd976658c3c85bac6fe993ff6da4a9eb2cd5484ccea877b8557c49e2454ac8bb77599eb12219e1eff9fffddeda2489c67ee
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.14
|
4
|
+
|
5
|
+
- New examples/grid.rb
|
6
|
+
- Support `grid` control and child attributes of `left`, `top`, `xspan`, `yspan`, `hexpand`, `halign`, `vexpand`, and `valign`
|
7
|
+
- Smart defaults for `grid` child attributes `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
8
|
+
|
9
|
+
## 0.0.13
|
10
|
+
|
11
|
+
- Support examples/date_time_picker.rb
|
12
|
+
- Support `date_time_picker`, `date_picker`, and `time_picker` controls having `time`/`time=`/`set_time` property
|
13
|
+
|
14
|
+
## 0.0.12
|
15
|
+
|
16
|
+
- Have examples/meta_example.rb allow code editing to enable experimentation and learning
|
17
|
+
- Fix issue with examples/meta_example using puts_debuggerer (a development gem)
|
18
|
+
|
19
|
+
## 0.0.11
|
20
|
+
|
21
|
+
- New examples/basic_color.rb
|
22
|
+
- Support `color_button` `color` property
|
23
|
+
- Proper destroy of controls (deleting from parent `box`, `window`, or `group` first)
|
24
|
+
- On the Mac only, if no menu is specified, add a Quit menu item automatically to allow quitting with CMD+Q
|
25
|
+
|
3
26
|
## 0.0.10
|
4
27
|
|
5
28
|
- Support examples/font_button.rb
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for LibUI 0.0.
|
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.0.14
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
|
@@ -43,7 +43,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
43
43
|
|
44
44
|
## Table of Contents
|
45
45
|
|
46
|
-
- [Glimmer DSL for LibUI 0.0.
|
46
|
+
- [Glimmer DSL for LibUI 0.0.14](#-glimmer-dsl-for-libui-0014)
|
47
47
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
48
48
|
- [Usage](#usage)
|
49
49
|
- [API](#api)
|
@@ -53,6 +53,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
53
53
|
- [Extra Dialogs](#extra-dialogs)
|
54
54
|
- [Extra Operations](#extra-operations)
|
55
55
|
- [Smart Defaults and Conventions](#smart-defaults-and-conventions)
|
56
|
+
- [API Gotchas](#api-gotchas)
|
56
57
|
- [Original API](#original-api)
|
57
58
|
- [Glimmer Style Guide](#glimmer-style-guide)
|
58
59
|
- [Girb (Glimmer IRB)](#girb-glimmer-irb)
|
@@ -64,6 +65,9 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
64
65
|
- [Midi Player](#midi-player)
|
65
66
|
- [Control Gallery](#control-gallery)
|
66
67
|
- [Font Button](#font-button)
|
68
|
+
- [Color Button](#color-button)
|
69
|
+
- [Date Time Picker](#date-time-picker)
|
70
|
+
- [Grid](#grid)
|
67
71
|
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
68
72
|
- [Help](#help)
|
69
73
|
- [Issues](#issues)
|
@@ -151,7 +155,7 @@ gem install glimmer-dsl-libui
|
|
151
155
|
Or install via Bundler `Gemfile`:
|
152
156
|
|
153
157
|
```ruby
|
154
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
158
|
+
gem 'glimmer-dsl-libui', '~> 0.0.14'
|
155
159
|
```
|
156
160
|
|
157
161
|
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.
|
@@ -185,7 +189,7 @@ Any control returned by a [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) keyword d
|
|
185
189
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
186
190
|
|
187
191
|
```ruby
|
188
|
-
w = window('hello world'
|
192
|
+
w = window('hello world')
|
189
193
|
puts w.title # => hello world
|
190
194
|
w.title = 'howdy'
|
191
195
|
puts w.title # => howdy
|
@@ -198,7 +202,7 @@ Controls are wrapped as Ruby proxy objects, having a `#libui` method to obtain t
|
|
198
202
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
199
203
|
|
200
204
|
```ruby
|
201
|
-
w = window('hello world'
|
205
|
+
w = window('hello world') # => #<Glimmer::LibUI::WindowProxy:0x00007fde4ea39fb0
|
202
206
|
w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0 free=0x0000000000000000>
|
203
207
|
```
|
204
208
|
|
@@ -210,12 +214,13 @@ Control(Args) | Properties | Listeners
|
|
210
214
|
`button(text as String)` | `text` (`String`) | `on_clicked`
|
211
215
|
`checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
|
212
216
|
`combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
|
213
|
-
`color_button` | `color` (
|
214
|
-
`date_picker` | `time` (`
|
215
|
-
`date_time_picker` | `time` (`
|
217
|
+
`color_button` | `color` (Array of `red` as `Float`, `green` as `Float`, `blue` as `Float`, `alpha` as `Float`), `red` as `Float`, `green` as `Float`, `blue` as `Float`, `alpha` as `Float` | `on_changed`
|
218
|
+
`date_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`, `mday` as `Integer`, `mon` as `Integer`, `year` as `Integer`, `wday` as `Integer`, `yday` as `Integer`, `dst` as Boolean) | `on_changed`
|
219
|
+
`date_time_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`, `mday` as `Integer`, `mon` as `Integer`, `year` as `Integer`, `wday` as `Integer`, `yday` as `Integer`, `dst` as Boolean) | `on_changed`
|
216
220
|
`editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
|
217
221
|
`entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
218
|
-
`font_button` | `font` [read-only] (`Hash` of keys: `:family`, `:size`, `:weight`, `:italic`, `:stretch`) | `on_changed`
|
222
|
+
`font_button` | `font` [read-only] (`Hash` of keys: `:family`, `:size`, `:weight`, `:italic`, `:stretch`), `family` as `String`, `size` as `Float`, `weight` as `Integer`, `italic` as `Integer`, `stretch` as `Integer` | `on_changed`
|
223
|
+
`grid` | `padded` (Boolean) | None
|
219
224
|
`group(text as String)` | `margined` (Boolean), `title` (`String`) | None
|
220
225
|
`horizontal_box` | `padded` (Boolean) | None
|
221
226
|
`horizontal_separator` | None | None
|
@@ -234,7 +239,7 @@ Control(Args) | Properties | Listeners
|
|
234
239
|
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
235
240
|
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
236
241
|
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
|
237
|
-
`time_picker` | `time` (`
|
242
|
+
`time_picker` | `time` (`Hash` of keys: `sec` as `Integer`, `min` as `Integer`, `hour` as `Integer`, `mday` as `Integer`, `mon` as `Integer`, `year` as `Integer`, `wday` as `Integer`, `yday` as `Integer`, `dst` as Boolean) | `on_changed`
|
238
243
|
`vertical_box` | `padded` (Boolean) | None
|
239
244
|
`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`) | `on_closing`, `on_content_size_changed`
|
240
245
|
|
@@ -245,7 +250,15 @@ Control(Args) | Properties | Listeners
|
|
245
250
|
- `parent` (`Fiddle::Pointer`)
|
246
251
|
- `toplevel` [read-only] (Boolean)
|
247
252
|
- `visible` (Boolean)
|
248
|
-
- `stretchy` [dsl-only] (Boolean): available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `vertical_box`
|
253
|
+
- `stretchy` [dsl-only] (Boolean) [default=`true`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `vertical_box`
|
254
|
+
- `left` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
255
|
+
- `top` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
256
|
+
- `xspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
257
|
+
- `yspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
258
|
+
- `hexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
259
|
+
- `halign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
260
|
+
- `vexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
261
|
+
- `valign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
249
262
|
|
250
263
|
### Common Control Operations
|
251
264
|
- `destroy`
|
@@ -267,7 +280,7 @@ Control(Args) | Properties | Listeners
|
|
267
280
|
|
268
281
|
### Smart Defaults and Conventions
|
269
282
|
|
270
|
-
- `horizontal_box` and `
|
283
|
+
- `horizontal_box`, `vertical_box`, and `grid` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
|
271
284
|
- `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
|
272
285
|
- All controls nested under a `horizontal_box` or `vertical_box` have `stretchy` property (passed to `box_append` method) as `true` by default (filling maximum space)
|
273
286
|
- `window` constructor args can be left off and have the following defaults when unspecified: `title` as `'Glimmer'`, `width` as `150`, `height` as `150`, and `has_menubar` as `true`)
|
@@ -278,7 +291,17 @@ Control(Args) | Properties | Listeners
|
|
278
291
|
- 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.
|
279
292
|
- All boolean property writers accept `true`/`false` in addition to `1`/`0` in Ruby
|
280
293
|
- All string property readers return a `String` object in Ruby instead of the [libui](https://github.com/andlabs/libui) Fiddle pointer object.
|
281
|
-
- Automatically allocate font descriptors upon instantiating `font_button` controls and free
|
294
|
+
- Automatically allocate font descriptors upon instantiating `font_button` controls and free them when destorying `font_button` controls
|
295
|
+
- Automatically allocate color value pointers upon instantiating `color_button` controls and free them when destorying `color_button` controls
|
296
|
+
- On the Mac, if no `menu` items were added, an automatic `quit_menu_item` is added to enable quitting with CTRL+Q
|
297
|
+
- When destroying a control nested under a `horizontal_box` or `vertical_box`, it is automatically deleted from the box's children
|
298
|
+
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
299
|
+
- 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`
|
300
|
+
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
301
|
+
|
302
|
+
### API Gotchas
|
303
|
+
|
304
|
+
There is no proper was 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`)
|
282
305
|
|
283
306
|
### Original API
|
284
307
|
|
@@ -287,7 +310,7 @@ check out the [libui C headers](https://github.com/andlabs/libui/blob/master/ui.
|
|
287
310
|
|
288
311
|
## Glimmer Style Guide
|
289
312
|
|
290
|
-
- Control arguments are always wrapped
|
313
|
+
- Control arguments are always wrapped by parentheses
|
291
314
|
- Control blocks are always declared with curly braces to clearly visualize hierarchical view code and separate from logic code
|
292
315
|
- Control property declarations always have arguments and never take a block
|
293
316
|
- Control property arguments are never wrapped inside parentheses
|
@@ -308,9 +331,9 @@ Gotcha: On the Mac, when you close a window opened in `girb`, it remains open un
|
|
308
331
|
|
309
332
|
## Examples
|
310
333
|
|
311
|
-
These examples include reimplementions of the examples in the [LibUI](https://github.com/kojix2/LibUI) project utilizing the [Glimmer GUI DSL](#glimmer-gui-dsl-concepts).
|
334
|
+
These examples include reimplementions of the examples in the [LibUI](https://github.com/kojix2/LibUI) project utilizing the [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) as well as brand new examples.
|
312
335
|
|
313
|
-
To browse all examples, simply launch the [Meta-Example](examples/meta_example.rb), which lists all examples and displays each example's code when selected.
|
336
|
+
To browse all examples, simply launch the [Meta-Example](examples/meta_example.rb), which lists all examples and displays each example's code when selected. It also enables code editing to facilitate experimentation and learning.
|
314
337
|
|
315
338
|
[examples/meta_example.rb](examples/meta_example.rb)
|
316
339
|
|
@@ -334,7 +357,7 @@ Linux
|
|
334
357
|
|
335
358
|

|
336
359
|
|
337
|
-
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
360
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
338
361
|
|
339
362
|
```ruby
|
340
363
|
require 'glimmer-dsl-libui'
|
@@ -357,11 +380,11 @@ class MetaExample
|
|
357
380
|
File.join(File.expand_path('.', __dir__), "#{example.underscore}.rb")
|
358
381
|
end
|
359
382
|
|
383
|
+
def glimmer_dsl_libui_file
|
384
|
+
File.expand_path('../lib/glimmer-dsl-libui', __dir__)
|
385
|
+
end
|
386
|
+
|
360
387
|
def launch
|
361
|
-
menu('File') {
|
362
|
-
quit_menu_item
|
363
|
-
}
|
364
|
-
|
365
388
|
window('Meta-Example', 700, 500) { |w|
|
366
389
|
margined true
|
367
390
|
|
@@ -380,13 +403,20 @@ class MetaExample
|
|
380
403
|
stretchy false
|
381
404
|
|
382
405
|
on_clicked do
|
383
|
-
|
406
|
+
begin
|
407
|
+
meta_example_file = File.join(Dir.home, '.meta_example.rb')
|
408
|
+
File.write(meta_example_file, @nwme.text)
|
409
|
+
result = `ruby -r #{glimmer_dsl_libui_file} #{meta_example_file} 2>&1`
|
410
|
+
msg_box(w, 'Error Running Example', result) if result.include?('error')
|
411
|
+
rescue => e
|
412
|
+
puts 'Unable to write code changes! Running original example...'
|
413
|
+
system "ruby -r #{glimmer_dsl_libui_file} #{file_path_for(@examples[@rbs.selected])}"
|
414
|
+
end
|
384
415
|
end
|
385
416
|
}
|
386
417
|
}
|
387
418
|
vertical_box {
|
388
419
|
@nwme = non_wrapping_multiline_entry {
|
389
|
-
read_only true
|
390
420
|
text File.read(file_path_for(@examples[@rbs.selected]))
|
391
421
|
}
|
392
422
|
}
|
@@ -480,7 +510,7 @@ ruby -r glimmer-dsl-libui -e "require 'examples/basic_button'"
|
|
480
510
|
Mac
|
481
511
|
|
482
512
|

|
483
|
-

|
513
|
+

|
484
514
|
|
485
515
|
Linux
|
486
516
|
|
@@ -1422,7 +1452,240 @@ window('hello world', 300, 200) {
|
|
1422
1452
|
puts 'Bye Bye'
|
1423
1453
|
end
|
1424
1454
|
}.show
|
1455
|
+
```
|
1456
|
+
|
1457
|
+
### Color Button
|
1458
|
+
|
1459
|
+
[examples/color_button.rb](examples/color_button.rb)
|
1460
|
+
|
1461
|
+
Run with this command from the root of the project if you cloned the project:
|
1462
|
+
|
1463
|
+
```
|
1464
|
+
ruby -r './lib/glimmer-dsl-libui' examples/color_button.rb
|
1465
|
+
```
|
1466
|
+
|
1467
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1468
|
+
|
1469
|
+
```
|
1470
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/color_button'"
|
1471
|
+
```
|
1472
|
+
|
1473
|
+
Mac
|
1474
|
+
|
1475
|
+

|
1476
|
+

|
1477
|
+
|
1478
|
+
Linux
|
1479
|
+
|
1480
|
+

|
1481
|
+

|
1482
|
+
|
1483
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1484
|
+
|
1485
|
+
```ruby
|
1486
|
+
require 'glimmer-dsl-libui'
|
1487
|
+
|
1488
|
+
include Glimmer
|
1489
|
+
|
1490
|
+
window('color button', 230) {
|
1491
|
+
color_button { |cb|
|
1492
|
+
on_changed do
|
1493
|
+
rgba = cb.color
|
1494
|
+
p rgba
|
1495
|
+
end
|
1496
|
+
}
|
1497
|
+
}.show
|
1498
|
+
```
|
1499
|
+
|
1500
|
+
### Date Time Picker
|
1501
|
+
|
1502
|
+
[examples/date_time_picker.rb](examples/date_time_picker.rb)
|
1503
|
+
|
1504
|
+
Run with this command from the root of the project if you cloned the project:
|
1505
|
+
|
1506
|
+
```
|
1507
|
+
ruby -r './lib/glimmer-dsl-libui' examples/date_time_picker.rb
|
1508
|
+
```
|
1509
|
+
|
1510
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1511
|
+
|
1512
|
+
```
|
1513
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/date_time_picker'"
|
1514
|
+
```
|
1515
|
+
|
1516
|
+
Mac
|
1517
|
+
|
1518
|
+

|
1519
|
+
|
1520
|
+
Linux
|
1521
|
+
|
1522
|
+

|
1523
|
+
|
1524
|
+
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
1525
|
+
|
1526
|
+
```ruby
|
1527
|
+
require 'libui'
|
1528
|
+
|
1529
|
+
UI = LibUI
|
1530
|
+
|
1531
|
+
UI.init
|
1532
|
+
|
1533
|
+
vbox = UI.new_vertical_box
|
1534
|
+
|
1535
|
+
date_time_picker = UI.new_date_time_picker
|
1536
|
+
|
1537
|
+
time = UI::FFI::TM.malloc
|
1538
|
+
|
1539
|
+
UI.date_time_picker_on_changed(date_time_picker) do
|
1540
|
+
UI.date_time_picker_time(date_time_picker, time)
|
1541
|
+
p sec: time.tm_sec,
|
1542
|
+
min: time.tm_min,
|
1543
|
+
hour: time.tm_hour,
|
1544
|
+
mday: time.tm_mday,
|
1545
|
+
mon: time.tm_mon,
|
1546
|
+
year: time.tm_year,
|
1547
|
+
wday: time.tm_wday,
|
1548
|
+
yday: time.tm_yday,
|
1549
|
+
isdst: time.tm_isdst
|
1550
|
+
end
|
1551
|
+
UI.box_append(vbox, date_time_picker, 1)
|
1552
|
+
|
1553
|
+
main_window = UI.new_window('Date Time Pickers', 300, 200, 1)
|
1554
|
+
UI.window_on_closing(main_window) do
|
1555
|
+
puts 'Bye Bye'
|
1556
|
+
UI.control_destroy(main_window)
|
1557
|
+
UI.quit
|
1558
|
+
0
|
1559
|
+
end
|
1560
|
+
UI.window_set_child(main_window, vbox)
|
1561
|
+
UI.control_show(main_window)
|
1562
|
+
|
1563
|
+
UI.main
|
1564
|
+
UI.quit
|
1565
|
+
```
|
1566
|
+
|
1567
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1568
|
+
|
1569
|
+
```ruby
|
1570
|
+
require 'glimmer-dsl-libui'
|
1571
|
+
|
1572
|
+
include Glimmer
|
1573
|
+
|
1574
|
+
window('Date Time Pickers', 300, 200) {
|
1575
|
+
vertical_box {
|
1576
|
+
date_time_picker { |dtp|
|
1577
|
+
on_changed do
|
1578
|
+
time = dtp.time
|
1579
|
+
p time
|
1580
|
+
end
|
1581
|
+
}
|
1582
|
+
}
|
1583
|
+
|
1584
|
+
on_closing do
|
1585
|
+
puts 'Bye Bye'
|
1586
|
+
end
|
1587
|
+
}.show
|
1588
|
+
```
|
1589
|
+
|
1590
|
+
### Grid
|
1591
|
+
|
1592
|
+
[examples/grid.rb](examples/grid.rb)
|
1593
|
+
|
1594
|
+
Run with this command from the root of the project if you cloned the project:
|
1595
|
+
|
1596
|
+
```
|
1597
|
+
ruby -r './lib/glimmer-dsl-libui' examples/grid.rb
|
1598
|
+
```
|
1599
|
+
|
1600
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1601
|
+
|
1602
|
+
```
|
1603
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/grid'"
|
1604
|
+
```
|
1605
|
+
|
1606
|
+
Mac
|
1607
|
+
|
1608
|
+

|
1609
|
+

|
1610
|
+
|
1611
|
+
Linux
|
1612
|
+
|
1613
|
+

|
1614
|
+

|
1615
|
+
|
1616
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1617
|
+
|
1618
|
+
```ruby
|
1619
|
+
require 'glimmer-dsl-libui'
|
1620
|
+
|
1621
|
+
include Glimmer
|
1425
1622
|
|
1623
|
+
window('Grid') {
|
1624
|
+
tab {
|
1625
|
+
tab_item('Spanning') {
|
1626
|
+
grid {
|
1627
|
+
4.times { |left_value|
|
1628
|
+
4.times { |top_value|
|
1629
|
+
label("(#{left_value}, #{top_value}) xspan1\nyspan1") {
|
1630
|
+
left left_value
|
1631
|
+
top top_value
|
1632
|
+
hexpand true
|
1633
|
+
vexpand true
|
1634
|
+
}
|
1635
|
+
}
|
1636
|
+
}
|
1637
|
+
label("(0, 4) xspan2\nyspan1 more text fits horizontally") {
|
1638
|
+
left 0
|
1639
|
+
top 4
|
1640
|
+
xspan 2
|
1641
|
+
}
|
1642
|
+
label("(2, 4) xspan2\nyspan1 more text fits horizontally") {
|
1643
|
+
left 2
|
1644
|
+
top 4
|
1645
|
+
xspan 2
|
1646
|
+
}
|
1647
|
+
label("(0, 5) xspan1\nyspan2\nmore text\nfits vertically") {
|
1648
|
+
left 0
|
1649
|
+
top 5
|
1650
|
+
yspan 2
|
1651
|
+
}
|
1652
|
+
label("(0, 7) xspan1\nyspan2\nmore text\nfits vertically") {
|
1653
|
+
left 0
|
1654
|
+
top 7
|
1655
|
+
yspan 2
|
1656
|
+
}
|
1657
|
+
label("(1, 5) xspan3\nyspan4 a lot more text fits horizontally than before\nand\neven\na lot\nmore text\nfits vertically\nthan\nbefore") {
|
1658
|
+
left 1
|
1659
|
+
top 5
|
1660
|
+
xspan 3
|
1661
|
+
yspan 4
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
}
|
1665
|
+
tab_item('Expanding') {
|
1666
|
+
grid {
|
1667
|
+
label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
1668
|
+
left 0
|
1669
|
+
top 0
|
1670
|
+
hexpand true
|
1671
|
+
vexpand true
|
1672
|
+
}
|
1673
|
+
label("(1, 0)") {
|
1674
|
+
left 1
|
1675
|
+
top 0
|
1676
|
+
}
|
1677
|
+
label("(0, 1)") {
|
1678
|
+
left 0
|
1679
|
+
top 1
|
1680
|
+
}
|
1681
|
+
label("(1, 1)") {
|
1682
|
+
left 1
|
1683
|
+
top 1
|
1684
|
+
}
|
1685
|
+
}
|
1686
|
+
}
|
1687
|
+
}
|
1688
|
+
}.show
|
1426
1689
|
```
|
1427
1690
|
|
1428
1691
|
## Contributing to glimmer-dsl-libui
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.14
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window('Date Time Pickers', 300, 200) {
|
8
|
+
vertical_box {
|
9
|
+
date_time_picker { |dtp|
|
10
|
+
on_changed do
|
11
|
+
time = dtp.time
|
12
|
+
p time
|
13
|
+
end
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
on_closing do
|
18
|
+
puts 'Bye Bye'
|
19
|
+
end
|
20
|
+
}.show
|
data/examples/grid.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window('Grid') {
|
8
|
+
tab {
|
9
|
+
tab_item('Spanning') {
|
10
|
+
grid {
|
11
|
+
4.times { |left_value|
|
12
|
+
4.times { |top_value|
|
13
|
+
label("(#{left_value}, #{top_value}) xspan1\nyspan1") {
|
14
|
+
left left_value
|
15
|
+
top top_value
|
16
|
+
hexpand true
|
17
|
+
vexpand true
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
label("(0, 4) xspan2\nyspan1 more text fits horizontally") {
|
22
|
+
left 0
|
23
|
+
top 4
|
24
|
+
xspan 2
|
25
|
+
}
|
26
|
+
label("(2, 4) xspan2\nyspan1 more text fits horizontally") {
|
27
|
+
left 2
|
28
|
+
top 4
|
29
|
+
xspan 2
|
30
|
+
}
|
31
|
+
label("(0, 5) xspan1\nyspan2\nmore text\nfits vertically") {
|
32
|
+
left 0
|
33
|
+
top 5
|
34
|
+
yspan 2
|
35
|
+
}
|
36
|
+
label("(0, 7) xspan1\nyspan2\nmore text\nfits vertically") {
|
37
|
+
left 0
|
38
|
+
top 7
|
39
|
+
yspan 2
|
40
|
+
}
|
41
|
+
label("(1, 5) xspan3\nyspan4 a lot more text fits horizontally than before\nand\neven\na lot\nmore text\nfits vertically\nthan\nbefore") {
|
42
|
+
left 1
|
43
|
+
top 5
|
44
|
+
xspan 3
|
45
|
+
yspan 4
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
tab_item('Expanding') {
|
50
|
+
grid {
|
51
|
+
label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
52
|
+
left 0
|
53
|
+
top 0
|
54
|
+
hexpand true
|
55
|
+
vexpand true
|
56
|
+
}
|
57
|
+
label("(1, 0)") {
|
58
|
+
left 1
|
59
|
+
top 0
|
60
|
+
}
|
61
|
+
label("(0, 1)") {
|
62
|
+
left 0
|
63
|
+
top 1
|
64
|
+
}
|
65
|
+
label("(1, 1)") {
|
66
|
+
left 1
|
67
|
+
top 1
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}.show
|
data/examples/meta_example.rb
CHANGED
@@ -20,11 +20,11 @@ class MetaExample
|
|
20
20
|
File.join(File.expand_path('.', __dir__), "#{example.underscore}.rb")
|
21
21
|
end
|
22
22
|
|
23
|
+
def glimmer_dsl_libui_file
|
24
|
+
File.expand_path('../lib/glimmer-dsl-libui', __dir__)
|
25
|
+
end
|
26
|
+
|
23
27
|
def launch
|
24
|
-
menu('File') {
|
25
|
-
quit_menu_item
|
26
|
-
}
|
27
|
-
|
28
28
|
window('Meta-Example', 700, 500) { |w|
|
29
29
|
margined true
|
30
30
|
|
@@ -43,13 +43,20 @@ class MetaExample
|
|
43
43
|
stretchy false
|
44
44
|
|
45
45
|
on_clicked do
|
46
|
-
|
46
|
+
begin
|
47
|
+
meta_example_file = File.join(Dir.home, '.meta_example.rb')
|
48
|
+
File.write(meta_example_file, @nwme.text)
|
49
|
+
result = `ruby -r #{glimmer_dsl_libui_file} #{meta_example_file} 2>&1`
|
50
|
+
msg_box(w, 'Error Running Example', result) if result.include?('error')
|
51
|
+
rescue => e
|
52
|
+
puts 'Unable to write code changes! Running original example...'
|
53
|
+
system "ruby -r #{glimmer_dsl_libui_file} #{file_path_for(@examples[@rbs.selected])}"
|
54
|
+
end
|
47
55
|
end
|
48
56
|
}
|
49
57
|
}
|
50
58
|
vertical_box {
|
51
59
|
@nwme = non_wrapping_multiline_entry {
|
52
|
-
read_only true
|
53
60
|
text File.read(file_path_for(@examples[@rbs.selected]))
|
54
61
|
}
|
55
62
|
}
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/lib/glimmer/libui/box.rb
CHANGED
@@ -29,12 +29,22 @@ module Glimmer
|
|
29
29
|
def post_initialize_child(child)
|
30
30
|
child.stretchy = true if child.stretchy.nil?
|
31
31
|
::LibUI.box_append(@libui, child.libui, ControlProxy.boolean_to_integer(child.stretchy))
|
32
|
+
children << child
|
32
33
|
end
|
33
34
|
|
34
35
|
def libui_api_keyword
|
35
36
|
'box'
|
36
37
|
end
|
37
38
|
|
39
|
+
def children
|
40
|
+
@children ||= []
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy_child(child)
|
44
|
+
::LibUI.send("box_delete", @libui, children.index(child))
|
45
|
+
ControlProxy.all_control_proxies.delete(child)
|
46
|
+
end
|
47
|
+
|
38
48
|
private
|
39
49
|
|
40
50
|
def build_control
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
# Proxy for LibUI color button objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class ColorButtonProxy < ControlProxy
|
30
|
+
def color
|
31
|
+
@red ||= Fiddle::Pointer.malloc(8) # double
|
32
|
+
@green ||= Fiddle::Pointer.malloc(8) # double
|
33
|
+
@blue ||= Fiddle::Pointer.malloc(8) # double
|
34
|
+
@alpha ||= Fiddle::Pointer.malloc(8) # double
|
35
|
+
::LibUI.color_button_color(@libui, @red, @green, @blue, @alpha)
|
36
|
+
[@red[0, 8].unpack1('d') * 255.0, @green[0, 8].unpack1('d') * 255.0, @blue[0, 8].unpack1('d') * 255.0, @alpha[0, 8].unpack1('d')]
|
37
|
+
end
|
38
|
+
|
39
|
+
def red
|
40
|
+
color[0]
|
41
|
+
end
|
42
|
+
|
43
|
+
def green
|
44
|
+
color[1]
|
45
|
+
end
|
46
|
+
|
47
|
+
def blue
|
48
|
+
color[2]
|
49
|
+
end
|
50
|
+
|
51
|
+
def alpha
|
52
|
+
color[3]
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy
|
56
|
+
Fiddle.free @red unless @red.nil?
|
57
|
+
Fiddle.free @green unless @green.nil?
|
58
|
+
Fiddle.free @blue unless @blue.nil?
|
59
|
+
Fiddle.free @alpha unless @alpha.nil?
|
60
|
+
super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -52,7 +52,7 @@ module Glimmer
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def main_window_proxy
|
55
|
-
all_control_proxies.find {|c| c.is_a?(WindowProxy)}
|
55
|
+
all_control_proxies.find {|c| c.is_a?(Glimmer::LibUI::WindowProxy)}
|
56
56
|
end
|
57
57
|
|
58
58
|
def integer_to_boolean(int)
|
@@ -62,6 +62,10 @@ module Glimmer
|
|
62
62
|
def boolean_to_integer(bool)
|
63
63
|
bool.nil? ? nil : (bool ? 1 : 0)
|
64
64
|
end
|
65
|
+
|
66
|
+
def menu_proxies
|
67
|
+
all_control_proxies.select {|c| c.keyword == 'menu' }
|
68
|
+
end
|
65
69
|
end
|
66
70
|
|
67
71
|
BOOLEAN_PROPERTIES = %w[
|
@@ -167,7 +171,7 @@ module Glimmer
|
|
167
171
|
::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
|
168
172
|
elsif ::LibUI.respond_to?("control_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
|
169
173
|
property = method_name.to_s.sub(/\?$/, '')
|
170
|
-
value = ::LibUI.send("control_#{
|
174
|
+
value = ::LibUI.send("control_#{property}", @libui, *args)
|
171
175
|
handle_string_property(property, handle_boolean_property(property, value))
|
172
176
|
elsif ::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}")
|
173
177
|
property = method_name.to_s.sub(/=$/, '')
|
@@ -198,6 +202,23 @@ module Glimmer
|
|
198
202
|
@keyword
|
199
203
|
end
|
200
204
|
|
205
|
+
def destroy
|
206
|
+
if parent_proxy.nil?
|
207
|
+
default_destroy
|
208
|
+
else
|
209
|
+
parent_proxy.destroy_child(self)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def destroy_child(child)
|
214
|
+
child.default_destroy
|
215
|
+
end
|
216
|
+
|
217
|
+
def default_destroy
|
218
|
+
send_to_libui('destroy')
|
219
|
+
ControlProxy.all_control_proxies.delete(self)
|
220
|
+
end
|
221
|
+
|
201
222
|
def enabled(value = nil)
|
202
223
|
if value.nil?
|
203
224
|
@enabled
|
@@ -229,11 +250,6 @@ module Glimmer
|
|
229
250
|
alias set_visible visible
|
230
251
|
alias visible= visible
|
231
252
|
|
232
|
-
def destroy
|
233
|
-
send_to_libui('destroy')
|
234
|
-
self.class.all_control_proxies.delete(self)
|
235
|
-
end
|
236
|
-
|
237
253
|
private
|
238
254
|
|
239
255
|
def build_control
|
@@ -30,6 +30,39 @@ module Glimmer
|
|
30
30
|
def libui_api_keyword
|
31
31
|
'date_time_picker'
|
32
32
|
end
|
33
|
+
|
34
|
+
def time(value = nil)
|
35
|
+
@time ||= ::LibUI::FFI::TM.malloc
|
36
|
+
::LibUI.date_time_picker_time(@libui, @time)
|
37
|
+
if value.nil?
|
38
|
+
{
|
39
|
+
sec: @time.tm_sec,
|
40
|
+
min: @time.tm_min,
|
41
|
+
hour: @time.tm_hour,
|
42
|
+
mday: @time.tm_mday,
|
43
|
+
mon: @time.tm_mon + 1,
|
44
|
+
year: @time.tm_year + 1900,
|
45
|
+
wday: @time.tm_wday + 1,
|
46
|
+
yday: @time.tm_yday + 1,
|
47
|
+
dst: @time.tm_isdst == 1
|
48
|
+
}
|
49
|
+
else
|
50
|
+
@time.tm_sec = value[:sec] unless value[:sec].nil?
|
51
|
+
@time.tm_min = value[:min] unless value[:min].nil?
|
52
|
+
@time.tm_hour = value[:hour] unless value[:hour].nil?
|
53
|
+
@time.tm_mday = value[:mday] unless value[:mday].nil?
|
54
|
+
@time.tm_mon = value[:mon] - 1 unless value[:mon].nil?
|
55
|
+
@time.tm_year = value[:year] - 1900 unless value[:year].nil?
|
56
|
+
::LibUI.date_time_picker_set_time(@libui, @time)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
alias set_time time
|
60
|
+
alias time= time
|
61
|
+
|
62
|
+
def destroy
|
63
|
+
Fiddle.free @time unless @time.nil?
|
64
|
+
super
|
65
|
+
end
|
33
66
|
end
|
34
67
|
end
|
35
68
|
end
|
@@ -39,6 +39,26 @@ module Glimmer
|
|
39
39
|
}
|
40
40
|
end
|
41
41
|
|
42
|
+
def family
|
43
|
+
font[:family]
|
44
|
+
end
|
45
|
+
|
46
|
+
def size
|
47
|
+
font[:size]
|
48
|
+
end
|
49
|
+
|
50
|
+
def weight
|
51
|
+
font[:weight]
|
52
|
+
end
|
53
|
+
|
54
|
+
def italic
|
55
|
+
font[:italic]
|
56
|
+
end
|
57
|
+
|
58
|
+
def stretch
|
59
|
+
font[:stretch]
|
60
|
+
end
|
61
|
+
|
42
62
|
def destroy
|
43
63
|
::LibUI.free_font_button_font(@font_descriptor) unless @font_descriptor.nil?
|
44
64
|
super
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
class GridProxy < ControlProxy
|
27
|
+
APPEND_PROPERTIES = %w[left top xspan yspan hexpand halign vexpand valign]
|
28
|
+
|
29
|
+
def post_initialize_child(child)
|
30
|
+
child.left = 0 if child.left.nil?
|
31
|
+
child.top = 0 if child.top.nil?
|
32
|
+
child.xspan = 1 if child.xspan.nil?
|
33
|
+
child.yspan = 1 if child.yspan.nil?
|
34
|
+
child.hexpand = false if child.hexpand.nil?
|
35
|
+
child.halign = 0 if child.halign.nil?
|
36
|
+
child.vexpand = false if child.vexpand.nil?
|
37
|
+
child.valign = 0 if child.valign.nil?
|
38
|
+
::LibUI.grid_append(@libui, child.libui, child.left, child.top, child.xspan, child.yspan, ControlProxy.boolean_to_integer(child.hexpand), child.halign, ControlProxy.boolean_to_integer(child.vexpand), child.valign)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Note that there is no proper destroy_child(child) method for GridProxy due to libui not offering any API for it (no grid_delete)
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def build_control
|
46
|
+
super.tap do
|
47
|
+
self.padded = true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -35,9 +35,14 @@ module Glimmer
|
|
35
35
|
def post_initialize_child(child)
|
36
36
|
::LibUI.window_set_child(@libui, child.libui)
|
37
37
|
end
|
38
|
+
|
39
|
+
def destroy_child(child)
|
40
|
+
::LibUI.send("window_set_child", @libui, nil)
|
41
|
+
super
|
42
|
+
end
|
38
43
|
|
39
44
|
def show
|
40
|
-
|
45
|
+
super
|
41
46
|
unless @shown_at_least_once
|
42
47
|
@shown_at_least_once = true
|
43
48
|
::LibUI.main
|
@@ -64,6 +69,10 @@ module Glimmer
|
|
64
69
|
private
|
65
70
|
|
66
71
|
def build_control
|
72
|
+
if OS.mac? && ControlProxy.menu_proxies.empty?
|
73
|
+
menu_proxy = ControlProxy.create('menu', nil, [''])
|
74
|
+
quit_menu_item_proxy = ControlProxy.create('quit_menu_item', menu_proxy, [])
|
75
|
+
end
|
67
76
|
construction_args = @args.dup
|
68
77
|
construction_args[0] = DEFAULT_TITLE if construction_args.size == 0
|
69
78
|
construction_args[1] = DEFAULT_WIDTH if construction_args.size == 1
|
data/lib/glimmer-dsl-libui.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -24,6 +24,26 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.1.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: os
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.0.0
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.0.0
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.0
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: libui
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,8 +184,11 @@ files:
|
|
164
184
|
- examples/basic_entry.rb
|
165
185
|
- examples/basic_window.rb
|
166
186
|
- examples/basic_window2.rb
|
187
|
+
- examples/color_button.rb
|
167
188
|
- examples/control_gallery.rb
|
189
|
+
- examples/date_time_picker.rb
|
168
190
|
- examples/font_button.rb
|
191
|
+
- examples/grid.rb
|
169
192
|
- examples/meta_example.rb
|
170
193
|
- examples/midi_player.rb
|
171
194
|
- examples/simple_notepad.rb
|
@@ -182,12 +205,14 @@ files:
|
|
182
205
|
- lib/glimmer/libui/about_menu_item_proxy.rb
|
183
206
|
- lib/glimmer/libui/box.rb
|
184
207
|
- lib/glimmer/libui/check_menu_item_proxy.rb
|
208
|
+
- lib/glimmer/libui/color_button_proxy.rb
|
185
209
|
- lib/glimmer/libui/combobox_proxy.rb
|
186
210
|
- lib/glimmer/libui/control_proxy.rb
|
187
211
|
- lib/glimmer/libui/date_picker_proxy.rb
|
188
212
|
- lib/glimmer/libui/date_time_picker_proxy.rb
|
189
213
|
- lib/glimmer/libui/editable_combobox_proxy.rb
|
190
214
|
- lib/glimmer/libui/font_button_proxy.rb
|
215
|
+
- lib/glimmer/libui/grid_proxy.rb
|
191
216
|
- lib/glimmer/libui/group_proxy.rb
|
192
217
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
193
218
|
- lib/glimmer/libui/menu_item_proxy.rb
|