glimmer-dsl-libui 0.0.13 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +312 -10
- data/VERSION +1 -1
- data/examples/basic_entry.rb +1 -1
- data/examples/basic_table.rb +28 -0
- data/examples/form.rb +27 -0
- data/examples/grid.rb +72 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/button_proxy.rb +41 -0
- data/lib/glimmer/libui/checkbox_proxy.rb +41 -0
- data/lib/glimmer/libui/control_proxy.rb +5 -1
- data/lib/glimmer/libui/form_proxy.rb +54 -0
- data/lib/glimmer/libui/grid_proxy.rb +57 -0
- data/lib/glimmer/libui/group_proxy.rb +6 -1
- data/lib/glimmer/libui/label_proxy.rb +41 -0
- data/lib/glimmer/libui/menu_proxy.rb +41 -0
- data/lib/glimmer/libui/table_proxy.rb +105 -0
- data/lib/glimmer/libui/text_column_proxy.rb +51 -0
- data/lib/glimmer/libui/window_proxy.rb +12 -2
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9821169ec1b82253239d5169165c94c76e8b4efa407c27ccf4e73eae25cd68f
|
4
|
+
data.tar.gz: 47b312e49da5f6acf1011d1e45283d1b6d9cb2f8a03d37e218fba794e07990d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 326d75305142c5773a9dfd487fb595e7271c26a003ff1db10771a5e805e8c77eb567f6f56b54ac7ab721e2ed532f70ccdd9fa42437f6fd12c616f98d28c91f0e
|
7
|
+
data.tar.gz: a60432231078bf85d00e8882657eae577eeb99cf0b71a57f12c485c933577f8f4f7d98ec1cb6337f4ab4f1d02bf0c0061a618b9f998c16dc05641ad6efc8352f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.17
|
4
|
+
|
5
|
+
- Support examples/basic_table.rb
|
6
|
+
- Support non-editable `table` control
|
7
|
+
- Support table `text_column`
|
8
|
+
- Support table `cell_rows` property as an `Array` (rows) of `Array`s (row columns) of cell values
|
9
|
+
|
10
|
+
## 0.0.16
|
11
|
+
|
12
|
+
- Support ability to instantiate without args and set args as properties afterwards inside block (e.g. `window { title 'Greeter'; content_size 300, 400; button {text 'Greet'; on_clicked {puts 'Hi'}} }`)
|
13
|
+
- window (was supported before, but changed default title to empty string)
|
14
|
+
- button
|
15
|
+
- checkbox
|
16
|
+
- group
|
17
|
+
- label
|
18
|
+
|
19
|
+
## 0.0.15
|
20
|
+
|
21
|
+
- New examples/form.rb
|
22
|
+
- Support `form` control and child attributes of `stretchy` and `label`
|
23
|
+
- Smart defaults for `form` child attributes `stretchy` (`true`) and `label` (`''`)
|
24
|
+
|
25
|
+
## 0.0.14
|
26
|
+
|
27
|
+
- New examples/grid.rb
|
28
|
+
- Support `grid` control and child attributes of `left`, `top`, `xspan`, `yspan`, `hexpand`, `halign`, `vexpand`, and `valign`
|
29
|
+
- Smart defaults for `grid` child attributes `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
30
|
+
|
3
31
|
## 0.0.13
|
4
32
|
|
5
33
|
- Support examples/date_time_picker.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.17
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[![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.17](#-glimmer-dsl-for-libui-0017)
|
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)
|
@@ -66,6 +67,9 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
66
67
|
- [Font Button](#font-button)
|
67
68
|
- [Color Button](#color-button)
|
68
69
|
- [Date Time Picker](#date-time-picker)
|
70
|
+
- [Grid](#grid)
|
71
|
+
- [Form](#form)
|
72
|
+
- [Basic Table](#basic-table)
|
69
73
|
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
70
74
|
- [Help](#help)
|
71
75
|
- [Issues](#issues)
|
@@ -153,7 +157,7 @@ gem install glimmer-dsl-libui
|
|
153
157
|
Or install via Bundler `Gemfile`:
|
154
158
|
|
155
159
|
```ruby
|
156
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
160
|
+
gem 'glimmer-dsl-libui', '~> 0.0.17'
|
157
161
|
```
|
158
162
|
|
159
163
|
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.
|
@@ -218,6 +222,8 @@ Control(Args) | Properties | Listeners
|
|
218
222
|
`editable_combobox` | `items` (`Array` of `String`), `text` (`String`) | `on_changed`
|
219
223
|
`entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
220
224
|
`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`
|
225
|
+
`form` | `padded` (Boolean) | None
|
226
|
+
`grid` | `padded` (Boolean) | None
|
221
227
|
`group(text as String)` | `margined` (Boolean), `title` (`String`) | None
|
222
228
|
`horizontal_box` | `padded` (Boolean) | None
|
223
229
|
`horizontal_separator` | None | None
|
@@ -236,9 +242,11 @@ Control(Args) | Properties | Listeners
|
|
236
242
|
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
237
243
|
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
238
244
|
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
|
245
|
+
`table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values)) | None
|
246
|
+
`text_column(name as String)` | None | None
|
239
247
|
`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`
|
240
248
|
`vertical_box` | `padded` (Boolean) | None
|
241
|
-
`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`
|
249
|
+
`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`, `on_destroy`
|
242
250
|
|
243
251
|
### Common Control Properties
|
244
252
|
- `enabled` (Boolean)
|
@@ -247,7 +255,15 @@ Control(Args) | Properties | Listeners
|
|
247
255
|
- `parent` (`Fiddle::Pointer`)
|
248
256
|
- `toplevel` [read-only] (Boolean)
|
249
257
|
- `visible` (Boolean)
|
250
|
-
- `stretchy` [dsl-only] (Boolean): available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box` or `
|
258
|
+
- `stretchy` [dsl-only] (Boolean) [default=`true`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `horizontal_box`, `vertical_box`, or `form`
|
259
|
+
- `left` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
260
|
+
- `top` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
261
|
+
- `xspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
262
|
+
- `yspan` [dsl-only] (`Integer`) [default=`1`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
263
|
+
- `hexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
264
|
+
- `halign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
265
|
+
- `vexpand` [dsl-only] (Boolean) [default=`false`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
266
|
+
- `valign` [dsl-only] (`Integer`) [default=`0`]: available in [Glimmer GUI DSL](#glimmer-gui-dsl-concepts) when nested under `grid`
|
251
267
|
|
252
268
|
### Common Control Operations
|
253
269
|
- `destroy`
|
@@ -269,11 +285,13 @@ Control(Args) | Properties | Listeners
|
|
269
285
|
|
270
286
|
### Smart Defaults and Conventions
|
271
287
|
|
272
|
-
- `horizontal_box` and `
|
288
|
+
- `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
|
273
289
|
- `group` controls have `margined` as `true` upon instantiation to ensure more user-friendly GUI by default
|
274
|
-
- All controls nested under a `horizontal_box`
|
275
|
-
- `window`
|
290
|
+
- 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)
|
291
|
+
- `window` instatiation args can be left off, having the following defaults when unspecified: `title` as `''`, `width` as `150`, `height` as `150`, and `has_menubar` as `true`)
|
276
292
|
- `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)
|
293
|
+
- `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'; ...}`)
|
294
|
+
- `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'}}`)
|
277
295
|
- `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)
|
278
296
|
- 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`).
|
279
297
|
- 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`).
|
@@ -284,8 +302,15 @@ Control(Args) | Properties | Listeners
|
|
284
302
|
- Automatically allocate color value pointers upon instantiating `color_button` controls and free them when destorying `color_button` controls
|
285
303
|
- On the Mac, if no `menu` items were added, an automatic `quit_menu_item` is added to enable quitting with CTRL+Q
|
286
304
|
- When destroying a control nested under a `horizontal_box` or `vertical_box`, it is automatically deleted from the box's children
|
305
|
+
- When destroying a control nested under a `form`, it is automatically deleted from the form's children
|
287
306
|
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
288
307
|
- 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`
|
308
|
+
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
309
|
+
- The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows` property (e.g. `NumRows`)
|
310
|
+
|
311
|
+
### API Gotchas
|
312
|
+
|
313
|
+
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`)
|
289
314
|
|
290
315
|
### Original API
|
291
316
|
|
@@ -655,7 +680,7 @@ window('Basic Entry', 300, 50) { |w|
|
|
655
680
|
}
|
656
681
|
|
657
682
|
button('Button') {
|
658
|
-
stretchy false
|
683
|
+
stretchy false # stretchy property is available when control is nested under horizontal_box
|
659
684
|
|
660
685
|
on_clicked do
|
661
686
|
text = e.text
|
@@ -1548,7 +1573,7 @@ UI.main
|
|
1548
1573
|
UI.quit
|
1549
1574
|
```
|
1550
1575
|
|
1551
|
-
|
1576
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1552
1577
|
|
1553
1578
|
```ruby
|
1554
1579
|
require 'glimmer-dsl-libui'
|
@@ -1571,6 +1596,283 @@ window('Date Time Pickers', 300, 200) {
|
|
1571
1596
|
}.show
|
1572
1597
|
```
|
1573
1598
|
|
1599
|
+
### Grid
|
1600
|
+
|
1601
|
+
[examples/grid.rb](examples/grid.rb)
|
1602
|
+
|
1603
|
+
Run with this command from the root of the project if you cloned the project:
|
1604
|
+
|
1605
|
+
```
|
1606
|
+
ruby -r './lib/glimmer-dsl-libui' examples/grid.rb
|
1607
|
+
```
|
1608
|
+
|
1609
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1610
|
+
|
1611
|
+
```
|
1612
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/grid'"
|
1613
|
+
```
|
1614
|
+
|
1615
|
+
Mac
|
1616
|
+
|
1617
|
+
![glimmer-dsl-libui-mac-grid-spanning.png](images/glimmer-dsl-libui-mac-grid-spanning.png)
|
1618
|
+
![glimmer-dsl-libui-mac-grid-expanding.png](images/glimmer-dsl-libui-mac-grid-expanding.png)
|
1619
|
+
|
1620
|
+
Linux
|
1621
|
+
|
1622
|
+
![glimmer-dsl-libui-linux-grid-spanning.png](images/glimmer-dsl-libui-linux-grid-spanning.png)
|
1623
|
+
![glimmer-dsl-libui-linux-grid-expanding.png](images/glimmer-dsl-libui-linux-grid-expanding.png)
|
1624
|
+
|
1625
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1626
|
+
|
1627
|
+
```ruby
|
1628
|
+
require 'glimmer-dsl-libui'
|
1629
|
+
|
1630
|
+
include Glimmer
|
1631
|
+
|
1632
|
+
window('Grid') {
|
1633
|
+
tab {
|
1634
|
+
tab_item('Spanning') {
|
1635
|
+
grid {
|
1636
|
+
4.times { |top_value|
|
1637
|
+
4.times { |left_value|
|
1638
|
+
label("(#{left_value}, #{top_value}) xspan1\nyspan1") {
|
1639
|
+
left left_value
|
1640
|
+
top top_value
|
1641
|
+
hexpand true
|
1642
|
+
vexpand true
|
1643
|
+
}
|
1644
|
+
}
|
1645
|
+
}
|
1646
|
+
label("(0, 4) xspan2\nyspan1 more text fits horizontally") {
|
1647
|
+
left 0
|
1648
|
+
top 4
|
1649
|
+
xspan 2
|
1650
|
+
}
|
1651
|
+
label("(2, 4) xspan2\nyspan1 more text fits horizontally") {
|
1652
|
+
left 2
|
1653
|
+
top 4
|
1654
|
+
xspan 2
|
1655
|
+
}
|
1656
|
+
label("(0, 5) xspan1\nyspan2\nmore text\nfits vertically") {
|
1657
|
+
left 0
|
1658
|
+
top 5
|
1659
|
+
yspan 2
|
1660
|
+
}
|
1661
|
+
label("(0, 7) xspan1\nyspan2\nmore text\nfits vertically") {
|
1662
|
+
left 0
|
1663
|
+
top 7
|
1664
|
+
yspan 2
|
1665
|
+
}
|
1666
|
+
label("(1, 5) xspan3\nyspan4 a lot more text fits horizontally than before\nand\neven\na lot\nmore text\nfits vertically\nthan\nbefore") {
|
1667
|
+
left 1
|
1668
|
+
top 5
|
1669
|
+
xspan 3
|
1670
|
+
yspan 4
|
1671
|
+
}
|
1672
|
+
}
|
1673
|
+
}
|
1674
|
+
tab_item('Expanding') {
|
1675
|
+
grid {
|
1676
|
+
label("(0, 0) hexpand/vexpand\nall available horizontal space is taken\nand\nall\navailable\nvertical\nspace\nis\ntaken") {
|
1677
|
+
left 0
|
1678
|
+
top 0
|
1679
|
+
hexpand true
|
1680
|
+
vexpand true
|
1681
|
+
}
|
1682
|
+
label("(1, 0)") {
|
1683
|
+
left 1
|
1684
|
+
top 0
|
1685
|
+
}
|
1686
|
+
label("(0, 1)") {
|
1687
|
+
left 0
|
1688
|
+
top 1
|
1689
|
+
}
|
1690
|
+
label("(1, 1)") {
|
1691
|
+
left 1
|
1692
|
+
top 1
|
1693
|
+
}
|
1694
|
+
}
|
1695
|
+
}
|
1696
|
+
}
|
1697
|
+
}.show
|
1698
|
+
```
|
1699
|
+
|
1700
|
+
### Form
|
1701
|
+
|
1702
|
+
[examples/form.rb](examples/form.rb)
|
1703
|
+
|
1704
|
+
Run with this command from the root of the project if you cloned the project:
|
1705
|
+
|
1706
|
+
```
|
1707
|
+
ruby -r './lib/glimmer-dsl-libui' examples/form.rb
|
1708
|
+
```
|
1709
|
+
|
1710
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1711
|
+
|
1712
|
+
```
|
1713
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/form'"
|
1714
|
+
```
|
1715
|
+
|
1716
|
+
Mac
|
1717
|
+
|
1718
|
+
![glimmer-dsl-libui-mac-form.png](images/glimmer-dsl-libui-mac-form.png)
|
1719
|
+
![glimmer-dsl-libui-mac-form-msg-box.png](images/glimmer-dsl-libui-mac-form-msg-box.png)
|
1720
|
+
|
1721
|
+
Linux
|
1722
|
+
|
1723
|
+
![glimmer-dsl-libui-linux-form.png](images/glimmer-dsl-libui-linux-form.png)
|
1724
|
+
![glimmer-dsl-libui-linux-form-msg-box.png](images/glimmer-dsl-libui-linux-form-msg-box.png)
|
1725
|
+
|
1726
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1727
|
+
|
1728
|
+
```ruby
|
1729
|
+
require 'glimmer-dsl-libui'
|
1730
|
+
|
1731
|
+
include Glimmer
|
1732
|
+
|
1733
|
+
window('Form') { |w|
|
1734
|
+
margined true
|
1735
|
+
|
1736
|
+
vertical_box {
|
1737
|
+
form {
|
1738
|
+
@first_name_entry = entry {
|
1739
|
+
label 'First Name' # label property is available when control is nested under form
|
1740
|
+
}
|
1741
|
+
|
1742
|
+
@last_name_entry = entry {
|
1743
|
+
label 'Last Name' # label property is available when control is nested under form
|
1744
|
+
}
|
1745
|
+
}
|
1746
|
+
|
1747
|
+
button('Display Name') {
|
1748
|
+
on_clicked do
|
1749
|
+
msg_box(w, 'Name', "#{@first_name_entry.text} #{@last_name_entry.text}")
|
1750
|
+
end
|
1751
|
+
}
|
1752
|
+
}
|
1753
|
+
}.show
|
1754
|
+
```
|
1755
|
+
|
1756
|
+
### Basic Table
|
1757
|
+
|
1758
|
+
[examples/basic_table.rb](examples/basic_table.rb)
|
1759
|
+
|
1760
|
+
Run with this command from the root of the project if you cloned the project:
|
1761
|
+
|
1762
|
+
```
|
1763
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table.rb
|
1764
|
+
```
|
1765
|
+
|
1766
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1767
|
+
|
1768
|
+
```
|
1769
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table'"
|
1770
|
+
```
|
1771
|
+
|
1772
|
+
Mac
|
1773
|
+
|
1774
|
+
![glimmer-dsl-libui-mac-basic-table.png](images/glimmer-dsl-libui-mac-basic-table.png)
|
1775
|
+
|
1776
|
+
Linux
|
1777
|
+
|
1778
|
+
![glimmer-dsl-libui-linux-basic-table.png](images/glimmer-dsl-libui-linux-basic-table.png)
|
1779
|
+
|
1780
|
+
[LibUI](https://github.com/kojix2/LibUI) Original Version:
|
1781
|
+
|
1782
|
+
```ruby
|
1783
|
+
require 'libui'
|
1784
|
+
|
1785
|
+
UI = LibUI
|
1786
|
+
|
1787
|
+
UI.init
|
1788
|
+
|
1789
|
+
main_window = UI.new_window('Animal sounds', 300, 200, 1)
|
1790
|
+
|
1791
|
+
hbox = UI.new_horizontal_box
|
1792
|
+
UI.window_set_child(main_window, hbox)
|
1793
|
+
|
1794
|
+
data = [
|
1795
|
+
%w[cat meow],
|
1796
|
+
%w[dog woof],
|
1797
|
+
%w[checken cock-a-doodle-doo],
|
1798
|
+
%w[hourse neigh],
|
1799
|
+
%w[cow moo]
|
1800
|
+
]
|
1801
|
+
|
1802
|
+
# Protects BlockCaller objects from garbage collection.
|
1803
|
+
@blockcaller = []
|
1804
|
+
def rbcallback(*args, &block)
|
1805
|
+
args << [0] if args.size == 1 # Argument types are ommited
|
1806
|
+
blockcaller = Fiddle::Closure::BlockCaller.new(*args, &block)
|
1807
|
+
@blockcaller << blockcaller
|
1808
|
+
blockcaller
|
1809
|
+
end
|
1810
|
+
|
1811
|
+
model_handler = UI::FFI::TableModelHandler.malloc
|
1812
|
+
model_handler.NumColumns = rbcallback(4) { 2 }
|
1813
|
+
model_handler.ColumnType = rbcallback(4) { 0 }
|
1814
|
+
model_handler.NumRows = rbcallback(4) { 5 }
|
1815
|
+
model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
|
1816
|
+
UI.new_table_value_string(data[row][column])
|
1817
|
+
end
|
1818
|
+
model_handler.SetCellValue = rbcallback(0, [0]) {}
|
1819
|
+
|
1820
|
+
model = UI.new_table_model(model_handler)
|
1821
|
+
|
1822
|
+
table_params = UI::FFI::TableParams.malloc
|
1823
|
+
table_params.Model = model
|
1824
|
+
table_params.RowBackgroundColorModelColumn = -1
|
1825
|
+
|
1826
|
+
table = UI.new_table(table_params)
|
1827
|
+
UI.table_append_text_column(table, 'Animal', 0, -1)
|
1828
|
+
UI.table_append_text_column(table, 'Description', 1, -1)
|
1829
|
+
|
1830
|
+
UI.box_append(hbox, table, 1)
|
1831
|
+
UI.control_show(main_window)
|
1832
|
+
|
1833
|
+
UI.window_on_closing(main_window) do
|
1834
|
+
puts 'Bye Bye'
|
1835
|
+
UI.control_destroy(main_window)
|
1836
|
+
UI.free_table_model(model)
|
1837
|
+
UI.quit
|
1838
|
+
0
|
1839
|
+
end
|
1840
|
+
|
1841
|
+
UI.main
|
1842
|
+
UI.quit
|
1843
|
+
```
|
1844
|
+
|
1845
|
+
[Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1846
|
+
|
1847
|
+
```ruby
|
1848
|
+
require 'glimmer-dsl-libui'
|
1849
|
+
|
1850
|
+
include Glimmer
|
1851
|
+
|
1852
|
+
data = [
|
1853
|
+
%w[cat meow],
|
1854
|
+
%w[dog woof],
|
1855
|
+
%w[chicken cock-a-doodle-doo],
|
1856
|
+
%w[hourse neigh],
|
1857
|
+
%w[cow moo]
|
1858
|
+
]
|
1859
|
+
|
1860
|
+
window('Animal sounds', 300, 200) {
|
1861
|
+
horizontal_box {
|
1862
|
+
table {
|
1863
|
+
text_column('Animal')
|
1864
|
+
text_column('Description')
|
1865
|
+
|
1866
|
+
cell_rows data
|
1867
|
+
}
|
1868
|
+
}
|
1869
|
+
|
1870
|
+
on_closing do
|
1871
|
+
puts 'Bye Bye'
|
1872
|
+
end
|
1873
|
+
}.show
|
1874
|
+
```
|
1875
|
+
|
1574
1876
|
## Contributing to glimmer-dsl-libui
|
1575
1877
|
|
1576
1878
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.17
|
data/examples/basic_entry.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
data = [
|
8
|
+
%w[cat meow],
|
9
|
+
%w[dog woof],
|
10
|
+
%w[chicken cock-a-doodle-doo],
|
11
|
+
%w[hourse neigh],
|
12
|
+
%w[cow moo]
|
13
|
+
]
|
14
|
+
|
15
|
+
window('Animal sounds', 300, 200) {
|
16
|
+
horizontal_box {
|
17
|
+
table {
|
18
|
+
text_column('Animal')
|
19
|
+
text_column('Description')
|
20
|
+
|
21
|
+
cell_rows data
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
on_closing do
|
26
|
+
puts 'Bye Bye'
|
27
|
+
end
|
28
|
+
}.show
|
data/examples/form.rb
ADDED
@@ -0,0 +1,27 @@
|
|
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
|
+
label 'First Name' # label property is available when control is nested under form
|
14
|
+
}
|
15
|
+
|
16
|
+
@last_name_entry = entry {
|
17
|
+
label 'Last Name' # label property is available when control is nested under form
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
button('Display Name') {
|
22
|
+
on_clicked do
|
23
|
+
msg_box(w, 'Name', "#{@first_name_entry.text} #{@last_name_entry.text}")
|
24
|
+
end
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}.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 { |top_value|
|
12
|
+
4.times { |left_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/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -0,0 +1,41 @@
|
|
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 button objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class ButtonProxy < ControlProxy
|
30
|
+
DEFAULT_TEXT = ''
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build_control
|
35
|
+
construction_args = @args.dup
|
36
|
+
construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
|
37
|
+
@libui = ControlProxy.new_control(@keyword, construction_args)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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 checkbox objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class CheckboxProxy < ControlProxy
|
30
|
+
DEFAULT_TEXT = ''
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build_control
|
35
|
+
construction_args = @args.dup
|
36
|
+
construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
|
37
|
+
@libui = ControlProxy.new_control(@keyword, construction_args)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -66,6 +66,10 @@ module Glimmer
|
|
66
66
|
def menu_proxies
|
67
67
|
all_control_proxies.select {|c| c.keyword == 'menu' }
|
68
68
|
end
|
69
|
+
|
70
|
+
def new_control(keyword, args)
|
71
|
+
::LibUI.send("new_#{keyword}", *args)
|
72
|
+
end
|
69
73
|
end
|
70
74
|
|
71
75
|
BOOLEAN_PROPERTIES = %w[
|
@@ -254,7 +258,7 @@ module Glimmer
|
|
254
258
|
|
255
259
|
def build_control
|
256
260
|
@libui = if ::LibUI.respond_to?("new_#{keyword}")
|
257
|
-
|
261
|
+
ControlProxy.new_control(@keyword, @args)
|
258
262
|
elsif ::LibUI.respond_to?(keyword)
|
259
263
|
@args[0] = @args.first.libui if @args.first.is_a?(ControlProxy)
|
260
264
|
::LibUI.send(@keyword, *@args)
|
@@ -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
|
@@ -27,6 +27,8 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class GroupProxy < ControlProxy
|
30
|
+
DEFAULT_TITLE = ''
|
31
|
+
|
30
32
|
def post_initialize_child(child)
|
31
33
|
::LibUI.group_set_child(@libui, child.libui)
|
32
34
|
end
|
@@ -39,7 +41,10 @@ module Glimmer
|
|
39
41
|
private
|
40
42
|
|
41
43
|
def build_control
|
42
|
-
|
44
|
+
construction_args = @args.dup
|
45
|
+
construction_args[0] = DEFAULT_TITLE if construction_args.size == 0
|
46
|
+
@libui = ControlProxy.new_control(@keyword, construction_args)
|
47
|
+
@libui.tap do
|
43
48
|
self.margined = true
|
44
49
|
end
|
45
50
|
end
|
@@ -0,0 +1,41 @@
|
|
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 label objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class LabelProxy < ControlProxy
|
30
|
+
DEFAULT_TEXT = ''
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build_control
|
35
|
+
construction_args = @args.dup
|
36
|
+
construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
|
37
|
+
@libui = ControlProxy.new_control(@keyword, construction_args)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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 menu objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class MenuProxy < ControlProxy
|
30
|
+
DEFAULT_TEXT = ''
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build_control
|
35
|
+
construction_args = @args.dup
|
36
|
+
construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
|
37
|
+
@libui = ControlProxy.new_control(@keyword, construction_args)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,105 @@
|
|
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 table objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class TableProxy < ControlProxy
|
30
|
+
attr_reader :model_handler, :model, :table_params, :columns
|
31
|
+
|
32
|
+
def initialize(keyword, parent, args, &block)
|
33
|
+
@keyword = keyword
|
34
|
+
@parent_proxy = parent
|
35
|
+
@args = args
|
36
|
+
@block = block
|
37
|
+
@enabled = true
|
38
|
+
@columns = []
|
39
|
+
@cell_rows = []
|
40
|
+
window_proxy.on_destroy do
|
41
|
+
# the following unless condition is an exceptional condition stumbled upon that fails freeing the table model
|
42
|
+
::LibUI.free_table_model(@model) unless @destroyed && parent_proxy.is_a?(Glimmer::LibUI::Box)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def post_add_content
|
47
|
+
build_control
|
48
|
+
super
|
49
|
+
end
|
50
|
+
|
51
|
+
def post_initialize_child(child)
|
52
|
+
@columns << child
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy
|
56
|
+
super
|
57
|
+
@destroyed = true
|
58
|
+
end
|
59
|
+
|
60
|
+
def cell_rows(rows = nil)
|
61
|
+
if rows.nil?
|
62
|
+
@cell_rows
|
63
|
+
else
|
64
|
+
@cell_rows = rows
|
65
|
+
end
|
66
|
+
end
|
67
|
+
alias cell_rows= cell_rows
|
68
|
+
alias set_cell_rows cell_rows
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def build_control
|
73
|
+
@model_handler = ::LibUI::FFI::TableModelHandler.malloc
|
74
|
+
@model_handler.NumColumns = rbcallback(4) { @columns.count }
|
75
|
+
@model_handler.ColumnType = rbcallback(4) { 0 } # TODO derive from @columns when supporting multiple column types in the future
|
76
|
+
@model_handler.NumRows = rbcallback(4) { cell_rows.count }
|
77
|
+
@model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
|
78
|
+
::LibUI.new_table_value_string((@cell_rows[row] && @cell_rows[row][column]).to_s)
|
79
|
+
end
|
80
|
+
|
81
|
+
@model = ::LibUI.new_table_model(@model_handler)
|
82
|
+
|
83
|
+
@table_params = ::LibUI::FFI::TableParams.malloc
|
84
|
+
@table_params.Model = @model
|
85
|
+
@table_params.RowBackgroundColorModelColumn = -1
|
86
|
+
|
87
|
+
@libui = ControlProxy.new_control(@keyword, [@table_params])
|
88
|
+
@libui.tap do
|
89
|
+
@columns.each {|column| column.send(:build_control) }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def rbcallback(*args, &block)
|
94
|
+
# TODO consider moving to a more general reusable location in the future (e.g. when used with `AreaProxy`)
|
95
|
+
# Protects BlockCaller objects from garbage collection.
|
96
|
+
@blockcaller ||= []
|
97
|
+
args << [0] if args.size == 1 # Argument types are ommited
|
98
|
+
blockcaller = Fiddle::Closure::BlockCaller.new(*args, &block)
|
99
|
+
@blockcaller << blockcaller
|
100
|
+
blockcaller
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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 text column objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class TextColumnProxy < ControlProxy
|
30
|
+
def initialize(keyword, parent, args, &block)
|
31
|
+
# TODO eventually move this to a supermodule ColumnProxy
|
32
|
+
@keyword = keyword
|
33
|
+
@parent_proxy = parent
|
34
|
+
@args = args
|
35
|
+
@block = block
|
36
|
+
@enabled = true
|
37
|
+
post_add_content if @block.nil?
|
38
|
+
end
|
39
|
+
|
40
|
+
def name
|
41
|
+
@args.first
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def build_control
|
47
|
+
@libui = @parent_proxy.append_text_column(name, @parent_proxy.columns.map(&:libui).compact.count, -1) # -1 for non-editable for now until editing is supported
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -27,7 +27,7 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class WindowProxy < ControlProxy
|
30
|
-
DEFAULT_TITLE = '
|
30
|
+
DEFAULT_TITLE = ''
|
31
31
|
DEFAULT_WIDTH = 150
|
32
32
|
DEFAULT_HEIGHT = 150
|
33
33
|
DEFAULT_HAS_MENUBAR = 1
|
@@ -40,6 +40,16 @@ module Glimmer
|
|
40
40
|
::LibUI.send("window_set_child", @libui, nil)
|
41
41
|
super
|
42
42
|
end
|
43
|
+
|
44
|
+
def destroy
|
45
|
+
super
|
46
|
+
@on_destroy_procs&.each { |on_destroy_proc| on_destroy_proc.call(self)}
|
47
|
+
end
|
48
|
+
|
49
|
+
def on_destroy(&block)
|
50
|
+
@on_destroy_procs ||= []
|
51
|
+
@on_destroy_procs << block
|
52
|
+
end
|
43
53
|
|
44
54
|
def show
|
45
55
|
super
|
@@ -79,7 +89,7 @@ module Glimmer
|
|
79
89
|
construction_args[2] = DEFAULT_HEIGHT if construction_args.size == 2
|
80
90
|
construction_args[3] = DEFAULT_HAS_MENUBAR if construction_args.size == 3
|
81
91
|
construction_args[3] = ControlProxy.boolean_to_integer(construction_args[3]) if construction_args.size == 4 && (construction_args[3].is_a?(TrueClass) || construction_args[3].is_a?(FalseClass))
|
82
|
-
@libui =
|
92
|
+
@libui = ControlProxy.new_control(@keyword, construction_args)
|
83
93
|
@libui.tap do
|
84
94
|
handle_listener('on_closing') do
|
85
95
|
destroy
|
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.17
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -182,12 +182,15 @@ files:
|
|
182
182
|
- bin/girb_runner.rb
|
183
183
|
- examples/basic_button.rb
|
184
184
|
- examples/basic_entry.rb
|
185
|
+
- examples/basic_table.rb
|
185
186
|
- examples/basic_window.rb
|
186
187
|
- examples/basic_window2.rb
|
187
188
|
- examples/color_button.rb
|
188
189
|
- examples/control_gallery.rb
|
189
190
|
- examples/date_time_picker.rb
|
190
191
|
- examples/font_button.rb
|
192
|
+
- examples/form.rb
|
193
|
+
- examples/grid.rb
|
191
194
|
- examples/meta_example.rb
|
192
195
|
- examples/midi_player.rb
|
193
196
|
- examples/simple_notepad.rb
|
@@ -203,7 +206,9 @@ files:
|
|
203
206
|
- lib/glimmer/dsl/libui/tab_item_expression.rb
|
204
207
|
- lib/glimmer/libui/about_menu_item_proxy.rb
|
205
208
|
- lib/glimmer/libui/box.rb
|
209
|
+
- lib/glimmer/libui/button_proxy.rb
|
206
210
|
- lib/glimmer/libui/check_menu_item_proxy.rb
|
211
|
+
- lib/glimmer/libui/checkbox_proxy.rb
|
207
212
|
- lib/glimmer/libui/color_button_proxy.rb
|
208
213
|
- lib/glimmer/libui/combobox_proxy.rb
|
209
214
|
- lib/glimmer/libui/control_proxy.rb
|
@@ -211,9 +216,13 @@ files:
|
|
211
216
|
- lib/glimmer/libui/date_time_picker_proxy.rb
|
212
217
|
- lib/glimmer/libui/editable_combobox_proxy.rb
|
213
218
|
- lib/glimmer/libui/font_button_proxy.rb
|
219
|
+
- lib/glimmer/libui/form_proxy.rb
|
220
|
+
- lib/glimmer/libui/grid_proxy.rb
|
214
221
|
- lib/glimmer/libui/group_proxy.rb
|
215
222
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
223
|
+
- lib/glimmer/libui/label_proxy.rb
|
216
224
|
- lib/glimmer/libui/menu_item_proxy.rb
|
225
|
+
- lib/glimmer/libui/menu_proxy.rb
|
217
226
|
- lib/glimmer/libui/multiline_entry_proxy.rb
|
218
227
|
- lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb
|
219
228
|
- lib/glimmer/libui/preferences_menu_item_proxy.rb
|
@@ -221,6 +230,8 @@ files:
|
|
221
230
|
- lib/glimmer/libui/radio_buttons_proxy.rb
|
222
231
|
- lib/glimmer/libui/separator_menu_item_proxy.rb
|
223
232
|
- lib/glimmer/libui/tab_item_proxy.rb
|
233
|
+
- lib/glimmer/libui/table_proxy.rb
|
234
|
+
- lib/glimmer/libui/text_column_proxy.rb
|
224
235
|
- lib/glimmer/libui/time_picker_proxy.rb
|
225
236
|
- lib/glimmer/libui/vertical_box_proxy.rb
|
226
237
|
- lib/glimmer/libui/window_proxy.rb
|