glimmer-dsl-libui 0.0.11 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +294 -19
- data/VERSION +1 -1
- data/examples/date_time_picker.rb +20 -0
- data/examples/form.rb +29 -0
- data/examples/grid.rb +72 -0
- data/examples/meta_example.rb +13 -2
- data/glimmer-dsl-libui.gemspec +0 -0
- 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/form_proxy.rb +54 -0
- data/lib/glimmer/libui/grid_proxy.rb +57 -0
- data/lib/glimmer/libui/time_picker_proxy.rb +7 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45785cccb2a89070b2230fdae1c7418b48c6b8ac4682bf6ee0c2eb832f35bc1c
|
4
|
+
data.tar.gz: 0a5544bef68a214ddb4ed55eb4ff71efa5916ce8c7e2d0b1c6d8f36d5b5fbd6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08005e8f56a310c7b534bfafde7e958617ee483985f30facf02a62a015d860a6378e4f7d5399b37fa5a247ef899a7092c313f120d5599a72d288bd3781a43820'
|
7
|
+
data.tar.gz: befd92a20a6bc56c19049cfc385970bd8e113ae191c45ac3c3fffb513dd9140838229b79859392aed2e452d6e235d95059fe5d7847b3ac48cc5b4261aae50b26
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.15
|
4
|
+
|
5
|
+
- New examples/form.rb
|
6
|
+
- Support `form` control and child attributes of `stretchy` and `label`
|
7
|
+
- Smart defaults for `form` child attributes `stretchy` (`true`) and `label` (`''`)
|
8
|
+
|
9
|
+
## 0.0.14
|
10
|
+
|
11
|
+
- New examples/grid.rb
|
12
|
+
- Support `grid` control and child attributes of `left`, `top`, `xspan`, `yspan`, `hexpand`, `halign`, `vexpand`, and `valign`
|
13
|
+
- Smart defaults for `grid` child attributes `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
14
|
+
|
15
|
+
## 0.0.13
|
16
|
+
|
17
|
+
- Support examples/date_time_picker.rb
|
18
|
+
- Support `date_time_picker`, `date_picker`, and `time_picker` controls having `time`/`time=`/`set_time` property
|
19
|
+
|
20
|
+
## 0.0.12
|
21
|
+
|
22
|
+
- Have examples/meta_example.rb allow code editing to enable experimentation and learning
|
23
|
+
- Fix issue with examples/meta_example using puts_debuggerer (a development gem)
|
24
|
+
|
3
25
|
## 0.0.11
|
4
26
|
|
5
27
|
- New examples/basic_color.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.15
|
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
|
[![Maintainability](https://api.codeclimate.com/v1/badges/ce2853efdbecf6ebdc73/maintainability)](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.15](#-glimmer-dsl-for-libui-0015)
|
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)
|
@@ -65,6 +66,9 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
65
66
|
- [Control Gallery](#control-gallery)
|
66
67
|
- [Font Button](#font-button)
|
67
68
|
- [Color Button](#color-button)
|
69
|
+
- [Date Time Picker](#date-time-picker)
|
70
|
+
- [Grid](#grid)
|
71
|
+
- [Form](#form)
|
68
72
|
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
69
73
|
- [Help](#help)
|
70
74
|
- [Issues](#issues)
|
@@ -152,7 +156,7 @@ gem install glimmer-dsl-libui
|
|
152
156
|
Or install via Bundler `Gemfile`:
|
153
157
|
|
154
158
|
```ruby
|
155
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
159
|
+
gem 'glimmer-dsl-libui', '~> 0.0.15'
|
156
160
|
```
|
157
161
|
|
158
162
|
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.
|
@@ -186,7 +190,7 @@ Any control returned by a [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) keyword d
|
|
186
190
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
187
191
|
|
188
192
|
```ruby
|
189
|
-
w = window('hello world'
|
193
|
+
w = window('hello world')
|
190
194
|
puts w.title # => hello world
|
191
195
|
w.title = 'howdy'
|
192
196
|
puts w.title # => howdy
|
@@ -199,7 +203,7 @@ Controls are wrapped as Ruby proxy objects, having a `#libui` method to obtain t
|
|
199
203
|
Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
|
200
204
|
|
201
205
|
```ruby
|
202
|
-
w = window('hello world'
|
206
|
+
w = window('hello world') # => #<Glimmer::LibUI::WindowProxy:0x00007fde4ea39fb0
|
203
207
|
w.libui # => #<Fiddle::Pointer:0x00007fde53997980 ptr=0x00007fde51352a60 size=0 free=0x0000000000000000>
|
204
208
|
```
|
205
209
|
|
@@ -212,11 +216,13 @@ Control(Args) | Properties | Listeners
|
|
212
216
|
`checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
|
213
217
|
`combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
|
214
218
|
`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`
|
215
|
-
`date_picker` | `time` (`
|
216
|
-
`date_time_picker` | `time` (`
|
219
|
+
`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`
|
220
|
+
`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`
|
217
221
|
`editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
|
218
222
|
`entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
219
223
|
`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`
|
224
|
+
`form` | `padded` (Boolean) | None
|
225
|
+
`grid` | `padded` (Boolean) | None
|
220
226
|
`group(text as String)` | `margined` (Boolean), `title` (`String`) | None
|
221
227
|
`horizontal_box` | `padded` (Boolean) | None
|
222
228
|
`horizontal_separator` | None | None
|
@@ -235,7 +241,7 @@ Control(Args) | Properties | Listeners
|
|
235
241
|
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
236
242
|
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
237
243
|
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
|
238
|
-
`time_picker` | `time` (`
|
244
|
+
`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`
|
239
245
|
`vertical_box` | `padded` (Boolean) | None
|
240
246
|
`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`
|
241
247
|
|
@@ -246,7 +252,15 @@ Control(Args) | Properties | Listeners
|
|
246
252
|
- `parent` (`Fiddle::Pointer`)
|
247
253
|
- `toplevel` [read-only] (Boolean)
|
248
254
|
- `visible` (Boolean)
|
249
|
-
- `stretchy` [dsl-only] (Boolean): available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `
|
255
|
+
- `stretchy` [dsl-only] (Boolean) [default=`true`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box`, `vertical_box`, or `form`
|
256
|
+
- `left` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
257
|
+
- `top` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
258
|
+
- `xspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
259
|
+
- `yspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
260
|
+
- `hexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
261
|
+
- `halign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
262
|
+
- `vexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
263
|
+
- `valign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
250
264
|
|
251
265
|
### Common Control Operations
|
252
266
|
- `destroy`
|
@@ -268,7 +282,7 @@ Control(Args) | Properties | Listeners
|
|
268
282
|
|
269
283
|
### Smart Defaults and Conventions
|
270
284
|
|
271
|
-
- `horizontal_box` and `
|
285
|
+
- `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
|
272
286
|
- `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
|
273
287
|
- 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)
|
274
288
|
- `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`)
|
@@ -283,7 +297,14 @@ Control(Args) | Properties | Listeners
|
|
283
297
|
- Automatically allocate color value pointers upon instantiating `color_button` controls and free them when destorying `color_button` controls
|
284
298
|
- On the Mac, if no `menu` items were added, an automatic `quit_menu_item` is added to enable quitting with CTRL+Q
|
285
299
|
- When destroying a control nested under a `horizontal_box` or `vertical_box`, it is automatically deleted from the box's children
|
300
|
+
- When destroying a control nested under a `form`, it is automatically deleted from the form's children
|
286
301
|
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
302
|
+
- 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`
|
303
|
+
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
304
|
+
|
305
|
+
### API Gotchas
|
306
|
+
|
307
|
+
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`)
|
287
308
|
|
288
309
|
### Original API
|
289
310
|
|
@@ -315,7 +336,7 @@ Gotcha: On the Mac, when you close a window opened in `girb`, it remains open un
|
|
315
336
|
|
316
337
|
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.
|
317
338
|
|
318
|
-
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.
|
339
|
+
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.
|
319
340
|
|
320
341
|
[examples/meta_example.rb](examples/meta_example.rb)
|
321
342
|
|
@@ -362,11 +383,11 @@ class MetaExample
|
|
362
383
|
File.join(File.expand_path('.', __dir__), "#{example.underscore}.rb")
|
363
384
|
end
|
364
385
|
|
386
|
+
def glimmer_dsl_libui_file
|
387
|
+
File.expand_path('../lib/glimmer-dsl-libui', __dir__)
|
388
|
+
end
|
389
|
+
|
365
390
|
def launch
|
366
|
-
menu('File') {
|
367
|
-
quit_menu_item
|
368
|
-
}
|
369
|
-
|
370
391
|
window('Meta-Example', 700, 500) { |w|
|
371
392
|
margined true
|
372
393
|
|
@@ -385,13 +406,20 @@ class MetaExample
|
|
385
406
|
stretchy false
|
386
407
|
|
387
408
|
on_clicked do
|
388
|
-
|
409
|
+
begin
|
410
|
+
meta_example_file = File.join(Dir.home, '.meta_example.rb')
|
411
|
+
File.write(meta_example_file, @nwme.text)
|
412
|
+
result = `ruby -r #{glimmer_dsl_libui_file} #{meta_example_file} 2>&1`
|
413
|
+
msg_box(w, 'Error Running Example', result) if result.include?('error')
|
414
|
+
rescue => e
|
415
|
+
puts 'Unable to write code changes! Running original example...'
|
416
|
+
system "ruby -r #{glimmer_dsl_libui_file} #{file_path_for(@examples[@rbs.selected])}"
|
417
|
+
end
|
389
418
|
end
|
390
419
|
}
|
391
420
|
}
|
392
421
|
vertical_box {
|
393
422
|
@nwme = non_wrapping_multiline_entry {
|
394
|
-
read_only true
|
395
423
|
text File.read(file_path_for(@examples[@rbs.selected]))
|
396
424
|
}
|
397
425
|
}
|
@@ -1458,8 +1486,6 @@ Linux
|
|
1458
1486
|
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1459
1487
|
|
1460
1488
|
```ruby
|
1461
|
-
# frozen_string_literal: true
|
1462
|
-
|
1463
1489
|
require 'glimmer-dsl-libui'
|
1464
1490
|
|
1465
1491
|
include Glimmer
|
@@ -1474,6 +1500,255 @@ window('color button', 230) {
|
|
1474
1500
|
}.show
|
1475
1501
|
```
|
1476
1502
|
|
1503
|
+
### Date Time Picker
|
1504
|
+
|
1505
|
+
[examples/date_time_picker.rb](examples/date_time_picker.rb)
|
1506
|
+
|
1507
|
+
Run with this command from the root of the project if you cloned the project:
|
1508
|
+
|
1509
|
+
```
|
1510
|
+
ruby -r './lib/glimmer-dsl-libui' examples/date_time_picker.rb
|
1511
|
+
```
|
1512
|
+
|
1513
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1514
|
+
|
1515
|
+
```
|
1516
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/date_time_picker'"
|
1517
|
+
```
|
1518
|
+
|
1519
|
+
Mac
|
1520
|
+
|
1521
|
+
![glimmer-dsl-libui-mac-date-time-picker.png](images/glimmer-dsl-libui-mac-date-time-picker.png)
|
1522
|
+
|
1523
|
+
Linux
|
1524
|
+
|
1525
|
+
![glimmer-dsl-libui-linux-date-time-picker.png](images/glimmer-dsl-libui-linux-date-time-picker.png)
|
1526
|
+
|
1527
|
+
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
1528
|
+
|
1529
|
+
```ruby
|
1530
|
+
require 'libui'
|
1531
|
+
|
1532
|
+
UI = LibUI
|
1533
|
+
|
1534
|
+
UI.init
|
1535
|
+
|
1536
|
+
vbox = UI.new_vertical_box
|
1537
|
+
|
1538
|
+
date_time_picker = UI.new_date_time_picker
|
1539
|
+
|
1540
|
+
time = UI::FFI::TM.malloc
|
1541
|
+
|
1542
|
+
UI.date_time_picker_on_changed(date_time_picker) do
|
1543
|
+
UI.date_time_picker_time(date_time_picker, time)
|
1544
|
+
p sec: time.tm_sec,
|
1545
|
+
min: time.tm_min,
|
1546
|
+
hour: time.tm_hour,
|
1547
|
+
mday: time.tm_mday,
|
1548
|
+
mon: time.tm_mon,
|
1549
|
+
year: time.tm_year,
|
1550
|
+
wday: time.tm_wday,
|
1551
|
+
yday: time.tm_yday,
|
1552
|
+
isdst: time.tm_isdst
|
1553
|
+
end
|
1554
|
+
UI.box_append(vbox, date_time_picker, 1)
|
1555
|
+
|
1556
|
+
main_window = UI.new_window('Date Time Pickers', 300, 200, 1)
|
1557
|
+
UI.window_on_closing(main_window) do
|
1558
|
+
puts 'Bye Bye'
|
1559
|
+
UI.control_destroy(main_window)
|
1560
|
+
UI.quit
|
1561
|
+
0
|
1562
|
+
end
|
1563
|
+
UI.window_set_child(main_window, vbox)
|
1564
|
+
UI.control_show(main_window)
|
1565
|
+
|
1566
|
+
UI.main
|
1567
|
+
UI.quit
|
1568
|
+
```
|
1569
|
+
|
1570
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1571
|
+
|
1572
|
+
```ruby
|
1573
|
+
require 'glimmer-dsl-libui'
|
1574
|
+
|
1575
|
+
include Glimmer
|
1576
|
+
|
1577
|
+
window('Date Time Pickers', 300, 200) {
|
1578
|
+
vertical_box {
|
1579
|
+
date_time_picker { |dtp|
|
1580
|
+
on_changed do
|
1581
|
+
time = dtp.time
|
1582
|
+
p time
|
1583
|
+
end
|
1584
|
+
}
|
1585
|
+
}
|
1586
|
+
|
1587
|
+
on_closing do
|
1588
|
+
puts 'Bye Bye'
|
1589
|
+
end
|
1590
|
+
}.show
|
1591
|
+
```
|
1592
|
+
|
1593
|
+
### Grid
|
1594
|
+
|
1595
|
+
[examples/grid.rb](examples/grid.rb)
|
1596
|
+
|
1597
|
+
Run with this command from the root of the project if you cloned the project:
|
1598
|
+
|
1599
|
+
```
|
1600
|
+
ruby -r './lib/glimmer-dsl-libui' examples/grid.rb
|
1601
|
+
```
|
1602
|
+
|
1603
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1604
|
+
|
1605
|
+
```
|
1606
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/grid'"
|
1607
|
+
```
|
1608
|
+
|
1609
|
+
Mac
|
1610
|
+
|
1611
|
+
![glimmer-dsl-libui-mac-grid-spanning.png](images/glimmer-dsl-libui-mac-grid-spanning.png)
|
1612
|
+
![glimmer-dsl-libui-mac-grid-expanding.png](images/glimmer-dsl-libui-mac-grid-expanding.png)
|
1613
|
+
|
1614
|
+
Linux
|
1615
|
+
|
1616
|
+
![glimmer-dsl-libui-linux-grid-spanning.png](images/glimmer-dsl-libui-linux-grid-spanning.png)
|
1617
|
+
![glimmer-dsl-libui-linux-grid-expanding.png](images/glimmer-dsl-libui-linux-grid-expanding.png)
|
1618
|
+
|
1619
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1620
|
+
|
1621
|
+
```ruby
|
1622
|
+
require 'glimmer-dsl-libui'
|
1623
|
+
|
1624
|
+
include Glimmer
|
1625
|
+
|
1626
|
+
window('Grid') {
|
1627
|
+
tab {
|
1628
|
+
tab_item('Spanning') {
|
1629
|
+
grid {
|
1630
|
+
4.times { |left_value|
|
1631
|
+
4.times { |top_value|
|
1632
|
+
label("(#{left_value}, #{top_value}) xspan1\nyspan1") {
|
1633
|
+
left left_value
|
1634
|
+
top top_value
|
1635
|
+
hexpand true
|
1636
|
+
vexpand true
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
}
|
1640
|
+
label("(0, 4) xspan2\nyspan1 more text fits horizontally") {
|
1641
|
+
left 0
|
1642
|
+
top 4
|
1643
|
+
xspan 2
|
1644
|
+
}
|
1645
|
+
label("(2, 4) xspan2\nyspan1 more text fits horizontally") {
|
1646
|
+
left 2
|
1647
|
+
top 4
|
1648
|
+
xspan 2
|
1649
|
+
}
|
1650
|
+
label("(0, 5) xspan1\nyspan2\nmore text\nfits vertically") {
|
1651
|
+
left 0
|
1652
|
+
top 5
|
1653
|
+
yspan 2
|
1654
|
+
}
|
1655
|
+
label("(0, 7) xspan1\nyspan2\nmore text\nfits vertically") {
|
1656
|
+
left 0
|
1657
|
+
top 7
|
1658
|
+
yspan 2
|
1659
|
+
}
|
1660
|
+
label("(1, 5) xspan3\nyspan4 a lot more text fits horizontally than before\nand\neven\na lot\nmore text\nfits vertically\nthan\nbefore") {
|
1661
|
+
left 1
|
1662
|
+
top 5
|
1663
|
+
xspan 3
|
1664
|
+
yspan 4
|
1665
|
+
}
|
1666
|
+
}
|
1667
|
+
}
|
1668
|
+
tab_item('Expanding') {
|
1669
|
+
grid {
|
1670
|
+
label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
1671
|
+
left 0
|
1672
|
+
top 0
|
1673
|
+
hexpand true
|
1674
|
+
vexpand true
|
1675
|
+
}
|
1676
|
+
label("(1, 0)") {
|
1677
|
+
left 1
|
1678
|
+
top 0
|
1679
|
+
}
|
1680
|
+
label("(0, 1)") {
|
1681
|
+
left 0
|
1682
|
+
top 1
|
1683
|
+
}
|
1684
|
+
label("(1, 1)") {
|
1685
|
+
left 1
|
1686
|
+
top 1
|
1687
|
+
}
|
1688
|
+
}
|
1689
|
+
}
|
1690
|
+
}
|
1691
|
+
}.show
|
1692
|
+
```
|
1693
|
+
|
1694
|
+
### Form
|
1695
|
+
|
1696
|
+
[examples/form.rb](examples/form.rb)
|
1697
|
+
|
1698
|
+
Run with this command from the root of the project if you cloned the project:
|
1699
|
+
|
1700
|
+
```
|
1701
|
+
ruby -r './lib/glimmer-dsl-libui' examples/form.rb
|
1702
|
+
```
|
1703
|
+
|
1704
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1705
|
+
|
1706
|
+
```
|
1707
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/form'"
|
1708
|
+
```
|
1709
|
+
|
1710
|
+
Mac
|
1711
|
+
|
1712
|
+
![glimmer-dsl-libui-mac-form.png](images/glimmer-dsl-libui-mac-form.png)
|
1713
|
+
![glimmer-dsl-libui-mac-form-msg-box.png](images/glimmer-dsl-libui-mac-form-msg-box.png)
|
1714
|
+
|
1715
|
+
Linux
|
1716
|
+
|
1717
|
+
![glimmer-dsl-libui-linux-form.png](images/glimmer-dsl-libui-linux-form.png)
|
1718
|
+
![glimmer-dsl-libui-linux-form-msg-box.png](images/glimmer-dsl-libui-linux-form-msg-box.png)
|
1719
|
+
|
1720
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1721
|
+
|
1722
|
+
```ruby
|
1723
|
+
require 'glimmer-dsl-libui'
|
1724
|
+
|
1725
|
+
include Glimmer
|
1726
|
+
|
1727
|
+
window('Form') { |w|
|
1728
|
+
margined true
|
1729
|
+
|
1730
|
+
vertical_box {
|
1731
|
+
form {
|
1732
|
+
@first_name_entry = entry {
|
1733
|
+
# stretchy true # Smart default option for appending to form
|
1734
|
+
label 'First Name'
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
@last_name_entry = entry {
|
1738
|
+
# stretchy true # Smart default option for appending to form
|
1739
|
+
label 'Last Name'
|
1740
|
+
}
|
1741
|
+
}
|
1742
|
+
|
1743
|
+
button('Display Name') {
|
1744
|
+
on_clicked do
|
1745
|
+
msg_box(w, 'Name', "#{@first_name_entry.text} #{@last_name_entry.text}")
|
1746
|
+
end
|
1747
|
+
}
|
1748
|
+
}
|
1749
|
+
}.show
|
1750
|
+
```
|
1751
|
+
|
1477
1752
|
## Contributing to glimmer-dsl-libui
|
1478
1753
|
|
1479
1754
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
@@ -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/form.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window('Form') { |w|
|
8
|
+
margined true
|
9
|
+
|
10
|
+
vertical_box {
|
11
|
+
form {
|
12
|
+
@first_name_entry = entry {
|
13
|
+
# stretchy true # Smart default option for appending to form
|
14
|
+
label 'First Name'
|
15
|
+
}
|
16
|
+
|
17
|
+
@last_name_entry = entry {
|
18
|
+
# stretchy true # Smart default option for appending to form
|
19
|
+
label 'Last Name'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
button('Display Name') {
|
24
|
+
on_clicked do
|
25
|
+
msg_box(w, 'Name', "#{@first_name_entry.text} #{@last_name_entry.text}")
|
26
|
+
end
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}.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,6 +20,10 @@ 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
28
|
window('Meta-Example', 700, 500) { |w|
|
25
29
|
margined true
|
@@ -39,13 +43,20 @@ class MetaExample
|
|
39
43
|
stretchy false
|
40
44
|
|
41
45
|
on_clicked do
|
42
|
-
|
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
|
43
55
|
end
|
44
56
|
}
|
45
57
|
}
|
46
58
|
vertical_box {
|
47
59
|
@nwme = non_wrapping_multiline_entry {
|
48
|
-
read_only true
|
49
60
|
text File.read(file_path_for(@examples[@rbs.selected]))
|
50
61
|
}
|
51
62
|
}
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -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
|
@@ -0,0 +1,54 @@
|
|
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 FormProxy < ControlProxy
|
27
|
+
APPEND_PROPERTIES = %w[label stretchy]
|
28
|
+
|
29
|
+
def post_initialize_child(child)
|
30
|
+
child.label = '' if child.label.nil?
|
31
|
+
child.stretchy = true if child.stretchy.nil?
|
32
|
+
::LibUI.form_append(@libui, child.label, child.libui, ControlProxy.boolean_to_integer(child.stretchy))
|
33
|
+
children << child
|
34
|
+
end
|
35
|
+
|
36
|
+
def children
|
37
|
+
@children ||= []
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy_child(child)
|
41
|
+
::LibUI.send("form_delete", @libui, children.index(child))
|
42
|
+
ControlProxy.all_control_proxies.delete(child)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def build_control
|
48
|
+
super.tap do
|
49
|
+
self.padded = true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,57 @@
|
|
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
|
+
children << child
|
40
|
+
end
|
41
|
+
|
42
|
+
def children
|
43
|
+
@children ||= []
|
44
|
+
end
|
45
|
+
|
46
|
+
# Note that there is no proper destroy_child(child) method for GridProxy due to libui not offering any API for it (no grid_delete)
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def build_control
|
51
|
+
super.tap do
|
52
|
+
self.padded = true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
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.15
|
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
|
@@ -186,7 +186,10 @@ files:
|
|
186
186
|
- examples/basic_window2.rb
|
187
187
|
- examples/color_button.rb
|
188
188
|
- examples/control_gallery.rb
|
189
|
+
- examples/date_time_picker.rb
|
189
190
|
- examples/font_button.rb
|
191
|
+
- examples/form.rb
|
192
|
+
- examples/grid.rb
|
190
193
|
- examples/meta_example.rb
|
191
194
|
- examples/midi_player.rb
|
192
195
|
- examples/simple_notepad.rb
|
@@ -210,6 +213,8 @@ files:
|
|
210
213
|
- lib/glimmer/libui/date_time_picker_proxy.rb
|
211
214
|
- lib/glimmer/libui/editable_combobox_proxy.rb
|
212
215
|
- lib/glimmer/libui/font_button_proxy.rb
|
216
|
+
- lib/glimmer/libui/form_proxy.rb
|
217
|
+
- lib/glimmer/libui/grid_proxy.rb
|
213
218
|
- lib/glimmer/libui/group_proxy.rb
|
214
219
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
215
220
|
- lib/glimmer/libui/menu_item_proxy.rb
|