glimmer-dsl-libui 0.0.22 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +177 -17
- data/VERSION +1 -1
- data/examples/basic_table.rb +1 -1
- data/examples/basic_table_button.rb +1 -5
- data/examples/basic_table_checkbox.rb +25 -0
- data/examples/basic_table_checkbox_text.rb +27 -0
- data/examples/basic_table_image.rb +1 -1
- data/examples/basic_table_image_text.rb +3 -7
- data/examples/basic_table_progress_bar.rb +24 -0
- data/examples/editable_column_table.rb +1 -1
- data/examples/editable_table.rb +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/checkbox_column_proxy.rb +42 -0
- data/lib/glimmer/libui/checkbox_text_column_proxy.rb +44 -0
- data/lib/glimmer/libui/image_part_proxy.rb +10 -0
- data/lib/glimmer/libui/image_proxy.rb +63 -0
- data/lib/glimmer/libui/progress_bar_column_proxy.rb +40 -0
- data/lib/glimmer/libui/table_proxy.rb +13 -10
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a22a20e6928aba5a45b52a05d55c4b6fc8fe33ff4e39c71701e4f3675c8c118
|
4
|
+
data.tar.gz: 13549e3b443fcc717a8ebee91694568a868bb7f3a6a6028f063b063d79af2e79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce691f8f98fcae7063245d9a8cd14b61ed64f6207236a7b111de8a35c6e84225634faaf1968218567827b06cd2f4b1b20a664c013c85b1b761bcecd6fd87e095
|
7
|
+
data.tar.gz: 662d181cac9f3d86996b85d0aa8b725e99c154502867cdb8e1814dfc452956864772e31e6cac1127acf5966c29fd5aa017aea1cb4a3ad11c8331b7e42b49d756
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,26 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.26
|
4
|
+
|
5
|
+
- New examples/basic_table_progress_bar.rb
|
6
|
+
- Support table `progress_bar_column`
|
7
|
+
|
8
|
+
## 0.0.25
|
9
|
+
|
10
|
+
- New examples/basic_table_checkbox_text.rb
|
11
|
+
- Support table `checkbox_text_column`
|
12
|
+
|
13
|
+
## 0.0.24
|
14
|
+
|
15
|
+
- New examples/basic_table_checkbox.rb
|
16
|
+
- Support table `checkbox_column`
|
17
|
+
- Improve support for table row deletion upon actual `cell_rows` deletion by handling multiple-row deletion not just single-row deletion
|
18
|
+
|
19
|
+
## 0.0.23
|
20
|
+
|
21
|
+
- Have `image` not require `width` and `height` if it only has one `image_part` (defaults to `image_part` `width` and `height`)
|
22
|
+
- Upgrade to LibUI version 0.0.10
|
23
|
+
|
3
24
|
## 0.0.22
|
4
25
|
|
5
26
|
- New examples/basic_table_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.26
|
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.26](#-glimmer-dsl-for-libui-0026)
|
47
47
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
48
48
|
- [Usage](#usage)
|
49
49
|
- [API](#api)
|
@@ -75,6 +75,9 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
75
75
|
- [Basic Table Image](#basic-table-image)
|
76
76
|
- [Basic Table Image Text](#basic-table-image-text)
|
77
77
|
- [Basic Table Button](#basic-table-button)
|
78
|
+
- [Basic Table Checkbox](#basic-table-checkbox)
|
79
|
+
- [Basic Table Checkbox Text](#basic-table-checkbox-text)
|
80
|
+
- [Basic Table Progress Bar](#basic-table-progress-bar)
|
78
81
|
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
79
82
|
- [Help](#help)
|
80
83
|
- [Issues](#issues)
|
@@ -162,7 +165,7 @@ gem install glimmer-dsl-libui
|
|
162
165
|
Or install via Bundler `Gemfile`:
|
163
166
|
|
164
167
|
```ruby
|
165
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
168
|
+
gem 'glimmer-dsl-libui', '~> 0.0.26'
|
166
169
|
```
|
167
170
|
|
168
171
|
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.
|
@@ -219,7 +222,10 @@ Control(Args) | Properties | Listeners
|
|
219
222
|
------------- | ---------- | ---------
|
220
223
|
`about_menu_item` | None | `on_clicked`
|
221
224
|
`button(text as String)` | `text` (`String`) | `on_clicked`
|
225
|
+
`button_column(name as String)` | `enabled` (Boolean) | None
|
222
226
|
`checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
|
227
|
+
`checkbox_column(name as String)` | None | None
|
228
|
+
`checkbox_text_column(name as String)` | `editable` (Boolean) | None
|
223
229
|
`combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
|
224
230
|
`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`
|
225
231
|
`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`
|
@@ -245,6 +251,7 @@ Control(Args) | Properties | Listeners
|
|
245
251
|
`non_wrapping_multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
|
246
252
|
`preferences_menu_item` | None | `on_clicked`
|
247
253
|
`progress_bar` | `value` (`Numeric`) | None
|
254
|
+
`progress_bar_column(name as String)` | None | None
|
248
255
|
`quit_menu_item` | None | `on_clicked`
|
249
256
|
`radio_buttons` | `selected` (`Integer`) | `on_selected`
|
250
257
|
`slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
@@ -252,7 +259,7 @@ Control(Args) | Properties | Listeners
|
|
252
259
|
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
253
260
|
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
|
254
261
|
`table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values for `text_column` cells or `Array` of `image`/`String` for `image_text_column`)), `editable` as Boolean | None
|
255
|
-
`text_column(name as String)` | `editable`
|
262
|
+
`text_column(name as String)` | `editable` (Boolean) | None
|
256
263
|
`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`
|
257
264
|
`vertical_box` | `padded` (Boolean) | None
|
258
265
|
`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`
|
@@ -319,7 +326,9 @@ Control(Args) | Properties | Listeners
|
|
319
326
|
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
320
327
|
- The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows` and `editable` properties (e.g. `NumRows`) as well as nested columns (e.g. `text_column`)
|
321
328
|
- Table model instances are automatically freed from memory after `window` is destroyed.
|
329
|
+
- Table `cell_rows` data has implicit data-binding to table cell values. When deleting data from `cell_rows` array, then actual rows from the `table` are automatically deleted.
|
322
330
|
- `image` instances are automatically freed from memory after `window` is destroyed.
|
331
|
+
- `image` `width` and `height` can be left off if it has one `image_part` only as they default to the same `width` and `height` of the `image_part`
|
323
332
|
|
324
333
|
### API Gotchas
|
325
334
|
|
@@ -1808,7 +1817,7 @@ data = [
|
|
1808
1817
|
%w[cat meow],
|
1809
1818
|
%w[dog woof],
|
1810
1819
|
%w[checken cock-a-doodle-doo],
|
1811
|
-
%w[
|
1820
|
+
%w[horse neigh],
|
1812
1821
|
%w[cow moo]
|
1813
1822
|
]
|
1814
1823
|
|
@@ -1866,7 +1875,7 @@ data = [
|
|
1866
1875
|
%w[cat meow],
|
1867
1876
|
%w[dog woof],
|
1868
1877
|
%w[chicken cock-a-doodle-doo],
|
1869
|
-
%w[
|
1878
|
+
%w[horse neigh],
|
1870
1879
|
%w[cow moo]
|
1871
1880
|
]
|
1872
1881
|
|
@@ -1925,7 +1934,7 @@ data = [
|
|
1925
1934
|
%w[cat meow],
|
1926
1935
|
%w[dog woof],
|
1927
1936
|
%w[chicken cock-a-doodle-doo],
|
1928
|
-
%w[
|
1937
|
+
%w[horse neigh],
|
1929
1938
|
%w[cow moo]
|
1930
1939
|
]
|
1931
1940
|
|
@@ -1983,7 +1992,7 @@ data = [
|
|
1983
1992
|
%w[cat calm meow],
|
1984
1993
|
%w[dog loyal woof],
|
1985
1994
|
%w[chicken bird cock-a-doodle-doo],
|
1986
|
-
%w[
|
1995
|
+
%w[horse fast neigh],
|
1987
1996
|
%w[cow slow moo]
|
1988
1997
|
]
|
1989
1998
|
|
@@ -2141,7 +2150,7 @@ IMAGE_ROWS = []
|
|
2141
2150
|
data = canvas.to_rgba_stream
|
2142
2151
|
width = canvas.width
|
2143
2152
|
height = canvas.height
|
2144
|
-
img = image
|
2153
|
+
img = image {
|
2145
2154
|
image_part(data, width, height, width * 4)
|
2146
2155
|
}
|
2147
2156
|
IMAGE_ROWS << [img] # array of one column cell
|
@@ -2219,23 +2228,19 @@ IMAGE_ROWS = []
|
|
2219
2228
|
data = canvas.to_rgba_stream
|
2220
2229
|
width = canvas.width
|
2221
2230
|
height = canvas.height
|
2222
|
-
img = image
|
2231
|
+
img = image {
|
2223
2232
|
image_part(data, width, height, width * 4)
|
2224
2233
|
}
|
2225
2234
|
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
2226
|
-
IMAGE_ROWS << [[img, text],
|
2235
|
+
IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
|
2227
2236
|
rescue StandardError => e
|
2228
2237
|
warn url, e.message
|
2229
2238
|
end
|
2230
2239
|
|
2231
|
-
window('The Red Turtle',
|
2240
|
+
window('The Red Turtle', 670, 350) {
|
2232
2241
|
horizontal_box {
|
2233
2242
|
table {
|
2234
2243
|
image_text_column('image/number')
|
2235
|
-
text_column('number')
|
2236
|
-
text_column('number (editable)') {
|
2237
|
-
editable true
|
2238
|
-
}
|
2239
2244
|
image_text_column('image/number (editable)') {
|
2240
2245
|
editable true
|
2241
2246
|
}
|
@@ -2283,7 +2288,7 @@ data = [
|
|
2283
2288
|
%w[cat meow delete],
|
2284
2289
|
%w[dog woof delete],
|
2285
2290
|
%w[chicken cock-a-doodle-doo delete],
|
2286
|
-
%w[
|
2291
|
+
%w[horse neigh delete],
|
2287
2292
|
%w[cow moo delete]
|
2288
2293
|
]
|
2289
2294
|
|
@@ -2304,6 +2309,161 @@ window('Animal sounds', 300, 200) {
|
|
2304
2309
|
}.show
|
2305
2310
|
```
|
2306
2311
|
|
2312
|
+
### Basic Table Checkbox
|
2313
|
+
|
2314
|
+
[examples/basic_table_checkbox.rb](examples/basic_table_checkbox.rb)
|
2315
|
+
|
2316
|
+
Run with this command from the root of the project if you cloned the project:
|
2317
|
+
|
2318
|
+
```
|
2319
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox.rb
|
2320
|
+
```
|
2321
|
+
|
2322
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
2323
|
+
|
2324
|
+
```
|
2325
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox'"
|
2326
|
+
```
|
2327
|
+
|
2328
|
+
Mac
|
2329
|
+
|
2330
|
+
![glimmer-dsl-libui-mac-basic-table-checkbox.png](images/glimmer-dsl-libui-mac-basic-table-checkbox.png)
|
2331
|
+
|
2332
|
+
Linux
|
2333
|
+
|
2334
|
+
![glimmer-dsl-libui-linux-basic-table-checkbox.png](images/glimmer-dsl-libui-linux-basic-table-checkbox.png)
|
2335
|
+
|
2336
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2337
|
+
|
2338
|
+
```ruby
|
2339
|
+
require 'glimmer-dsl-libui'
|
2340
|
+
|
2341
|
+
include Glimmer
|
2342
|
+
|
2343
|
+
data = [
|
2344
|
+
['cat', 'meow', true],
|
2345
|
+
['dog', 'woof', true],
|
2346
|
+
['chicken', 'cock-a-doodle-doo', false],
|
2347
|
+
['horse', 'neigh', true],
|
2348
|
+
['cow', 'moo', true]
|
2349
|
+
]
|
2350
|
+
|
2351
|
+
window('Animal sounds', 300, 200) {
|
2352
|
+
horizontal_box {
|
2353
|
+
table {
|
2354
|
+
text_column('Animal')
|
2355
|
+
text_column('Description')
|
2356
|
+
checkbox_column('Mammal')
|
2357
|
+
|
2358
|
+
cell_rows data
|
2359
|
+
}
|
2360
|
+
}
|
2361
|
+
}.show
|
2362
|
+
```
|
2363
|
+
|
2364
|
+
### Basic Table Checkbox Text
|
2365
|
+
|
2366
|
+
[examples/basic_table_checkbox_text.rb](examples/basic_table_checkbox_text.rb)
|
2367
|
+
|
2368
|
+
Run with this command from the root of the project if you cloned the project:
|
2369
|
+
|
2370
|
+
```
|
2371
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox_text.rb
|
2372
|
+
```
|
2373
|
+
|
2374
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
2375
|
+
|
2376
|
+
```
|
2377
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox_text'"
|
2378
|
+
```
|
2379
|
+
|
2380
|
+
Mac
|
2381
|
+
|
2382
|
+
![glimmer-dsl-libui-mac-basic-table-checkbox-text.png](images/glimmer-dsl-libui-mac-basic-table-checkbox-text.png)
|
2383
|
+
|
2384
|
+
Linux
|
2385
|
+
|
2386
|
+
![glimmer-dsl-libui-linux-basic-table-checkbox-text.png](images/glimmer-dsl-libui-linux-basic-table-checkbox-text.png)
|
2387
|
+
|
2388
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2389
|
+
|
2390
|
+
```ruby
|
2391
|
+
require 'glimmer-dsl-libui'
|
2392
|
+
|
2393
|
+
include Glimmer
|
2394
|
+
|
2395
|
+
data = [
|
2396
|
+
['cat', 'meow', [true, 'mammal']],
|
2397
|
+
['dog', 'woof', [true, 'mammal']],
|
2398
|
+
['chicken', 'cock-a-doodle-doo', [false, 'mammal']],
|
2399
|
+
['horse', 'neigh', [true, 'mammal']],
|
2400
|
+
['cow', 'moo', [true, 'mammal']]
|
2401
|
+
]
|
2402
|
+
|
2403
|
+
window('Animal sounds', 400, 200) {
|
2404
|
+
horizontal_box {
|
2405
|
+
table {
|
2406
|
+
text_column('Animal')
|
2407
|
+
text_column('Sound')
|
2408
|
+
checkbox_text_column('Description')
|
2409
|
+
|
2410
|
+
cell_rows data
|
2411
|
+
}
|
2412
|
+
}
|
2413
|
+
}.show
|
2414
|
+
```
|
2415
|
+
|
2416
|
+
### Basic Table Progress Bar
|
2417
|
+
|
2418
|
+
[examples/basic_table_progress_bar.rb](examples/basic_table_progress_bar.rb)
|
2419
|
+
|
2420
|
+
Run with this command from the root of the project if you cloned the project:
|
2421
|
+
|
2422
|
+
```
|
2423
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_progress_bar.rb
|
2424
|
+
```
|
2425
|
+
|
2426
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
2427
|
+
|
2428
|
+
```
|
2429
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_progress_bar'"
|
2430
|
+
```
|
2431
|
+
|
2432
|
+
Mac
|
2433
|
+
|
2434
|
+
![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png)
|
2435
|
+
|
2436
|
+
Linux
|
2437
|
+
|
2438
|
+
![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
|
2439
|
+
|
2440
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2441
|
+
|
2442
|
+
```ruby
|
2443
|
+
require 'glimmer-dsl-libui'
|
2444
|
+
|
2445
|
+
include Glimmer
|
2446
|
+
|
2447
|
+
data = [
|
2448
|
+
['task 1', 0],
|
2449
|
+
['task 2', 15],
|
2450
|
+
['task 3', 100],
|
2451
|
+
['task 4', 75],
|
2452
|
+
['task 5', -1],
|
2453
|
+
]
|
2454
|
+
|
2455
|
+
window('Task progress', 300, 200) {
|
2456
|
+
horizontal_box {
|
2457
|
+
table {
|
2458
|
+
text_column('Task')
|
2459
|
+
progress_bar_column('Progress')
|
2460
|
+
|
2461
|
+
cell_rows data
|
2462
|
+
}
|
2463
|
+
}
|
2464
|
+
}.show
|
2465
|
+
```
|
2466
|
+
|
2307
2467
|
## Contributing to glimmer-dsl-libui
|
2308
2468
|
|
2309
2469
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.26
|
data/examples/basic_table.rb
CHANGED
@@ -8,7 +8,7 @@ data = [
|
|
8
8
|
%w[cat meow delete],
|
9
9
|
%w[dog woof delete],
|
10
10
|
%w[chicken cock-a-doodle-doo delete],
|
11
|
-
%w[
|
11
|
+
%w[horse neigh delete],
|
12
12
|
%w[cow moo delete]
|
13
13
|
]
|
14
14
|
|
@@ -26,8 +26,4 @@ window('Animal sounds', 300, 200) {
|
|
26
26
|
cell_rows data # implicit data-binding
|
27
27
|
}
|
28
28
|
}
|
29
|
-
|
30
|
-
on_closing do
|
31
|
-
puts 'Bye Bye'
|
32
|
-
end
|
33
29
|
}.show
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
data = [
|
8
|
+
['cat', 'meow', true],
|
9
|
+
['dog', 'woof', true],
|
10
|
+
['chicken', 'cock-a-doodle-doo', false],
|
11
|
+
['horse', 'neigh', true],
|
12
|
+
['cow', 'moo', true]
|
13
|
+
]
|
14
|
+
|
15
|
+
window('Animal sounds', 300, 200) {
|
16
|
+
horizontal_box {
|
17
|
+
table {
|
18
|
+
text_column('Animal')
|
19
|
+
text_column('Description')
|
20
|
+
checkbox_column('Mammal')
|
21
|
+
|
22
|
+
cell_rows data
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}.show
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
data = [
|
8
|
+
['cat', 'meow', [true, 'mammal']],
|
9
|
+
['dog', 'woof', [true, 'mammal']],
|
10
|
+
['chicken', 'cock-a-doodle-doo', [false, 'mammal']],
|
11
|
+
['horse', 'neigh', [true, 'mammal']],
|
12
|
+
['cow', 'moo', [true, 'mammal']]
|
13
|
+
]
|
14
|
+
|
15
|
+
window('Animal sounds', 400, 200) {
|
16
|
+
horizontal_box {
|
17
|
+
table {
|
18
|
+
text_column('Animal')
|
19
|
+
text_column('Sound')
|
20
|
+
checkbox_text_column('Description') {
|
21
|
+
editable true
|
22
|
+
}
|
23
|
+
|
24
|
+
cell_rows data
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}.show
|
@@ -20,23 +20,19 @@ IMAGE_ROWS = []
|
|
20
20
|
data = canvas.to_rgba_stream
|
21
21
|
width = canvas.width
|
22
22
|
height = canvas.height
|
23
|
-
img = image
|
23
|
+
img = image {
|
24
24
|
image_part(data, width, height, width * 4)
|
25
25
|
}
|
26
26
|
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
27
|
-
IMAGE_ROWS << [[img, text],
|
27
|
+
IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
|
28
28
|
rescue StandardError => e
|
29
29
|
warn url, e.message
|
30
30
|
end
|
31
31
|
|
32
|
-
window('The Red Turtle',
|
32
|
+
window('The Red Turtle', 670, 350) {
|
33
33
|
horizontal_box {
|
34
34
|
table {
|
35
35
|
image_text_column('image/number')
|
36
|
-
text_column('number')
|
37
|
-
text_column('number (editable)') {
|
38
|
-
editable true
|
39
|
-
}
|
40
36
|
image_text_column('image/number (editable)') {
|
41
37
|
editable true
|
42
38
|
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
data = [
|
8
|
+
['task 1', 0],
|
9
|
+
['task 2', 15],
|
10
|
+
['task 3', 100],
|
11
|
+
['task 4', 75],
|
12
|
+
['task 5', -1],
|
13
|
+
]
|
14
|
+
|
15
|
+
window('Task progress', 300, 200) {
|
16
|
+
horizontal_box {
|
17
|
+
table {
|
18
|
+
text_column('Task')
|
19
|
+
progress_bar_column('Progress')
|
20
|
+
|
21
|
+
cell_rows data
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}.show
|
data/examples/editable_table.rb
CHANGED
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -0,0 +1,42 @@
|
|
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
|
+
require 'glimmer/libui/column'
|
24
|
+
require 'glimmer/libui/editable_column'
|
25
|
+
|
26
|
+
module Glimmer
|
27
|
+
module LibUI
|
28
|
+
# Proxy for LibUI checkbox column objects
|
29
|
+
#
|
30
|
+
# Follows the Proxy Design Pattern
|
31
|
+
class CheckboxColumnProxy < ControlProxy
|
32
|
+
include Column
|
33
|
+
# include EditableColumn # TODO enable this once checkbox column becomes editable on macosx in C libui (currently has a bug)
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def build_control
|
38
|
+
@parent_proxy.append_checkbox_column(name, column_index, -1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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
|
+
require 'glimmer/libui/column'
|
24
|
+
require 'glimmer/libui/dual_column'
|
25
|
+
require 'glimmer/libui/editable_column'
|
26
|
+
|
27
|
+
module Glimmer
|
28
|
+
module LibUI
|
29
|
+
# Proxy for LibUI checkbox text column objects
|
30
|
+
#
|
31
|
+
# Follows the Proxy Design Pattern
|
32
|
+
class CheckboxTextColumnProxy < ControlProxy
|
33
|
+
include Column
|
34
|
+
include DualColumn
|
35
|
+
include EditableColumn # TODO split into editable_checkbox and editable_text properties in the future given that checkbox and text can be edited separately
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def build_control
|
40
|
+
@parent_proxy.append_checkbox_text_column(name, column_index, -1, second_column_index, editable_value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -27,6 +27,16 @@ module Glimmer
|
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class ImagePartProxy < ControlProxy
|
30
|
+
def initialize(keyword, parent, args, &block)
|
31
|
+
@keyword = keyword
|
32
|
+
@parent_proxy = parent
|
33
|
+
@args = args
|
34
|
+
@block = block
|
35
|
+
@enabled = true
|
36
|
+
@children = []
|
37
|
+
post_add_content if @block.nil?
|
38
|
+
end
|
39
|
+
|
30
40
|
private
|
31
41
|
|
32
42
|
def build_control
|
@@ -0,0 +1,63 @@
|
|
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
|
+
require 'glimmer/data_binding/observer'
|
24
|
+
|
25
|
+
using ArrayIncludeMethods
|
26
|
+
|
27
|
+
module Glimmer
|
28
|
+
module LibUI
|
29
|
+
# Proxy for LibUI image objects
|
30
|
+
#
|
31
|
+
# Follows the Proxy Design Pattern
|
32
|
+
class ImageProxy < ControlProxy
|
33
|
+
def initialize(keyword, parent, args, &block)
|
34
|
+
@keyword = keyword
|
35
|
+
@parent_proxy = parent
|
36
|
+
@args = args
|
37
|
+
@block = block
|
38
|
+
@enabled = true
|
39
|
+
@children = []
|
40
|
+
post_add_content if @block.nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
def post_add_content
|
44
|
+
build_control
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
def post_initialize_child(child)
|
49
|
+
@children << child
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def build_control
|
55
|
+
@args = [@children.first.args[1], @children.first.args[2]] if @children.size == 1 && (@args[0].nil? || @args[1].nil?)
|
56
|
+
super
|
57
|
+
@libui.tap do
|
58
|
+
@children.each {|child| child&.send(:build_control) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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
|
+
require 'glimmer/libui/column'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module LibUI
|
27
|
+
# Proxy for LibUI progress bar column objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class ProgressBarColumnProxy < ControlProxy
|
31
|
+
include Column
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def build_control
|
36
|
+
@parent_proxy.append_progress_bar_column(name, column_index)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -70,11 +70,10 @@ module Glimmer
|
|
70
70
|
@cell_rows.tap do
|
71
71
|
@last_cell_rows = @cell_rows.clone
|
72
72
|
Glimmer::DataBinding::Observer.proc do
|
73
|
-
if
|
74
|
-
|
75
|
-
|
73
|
+
if @cell_rows.size < @last_cell_rows.size && @last_cell_rows.include_all?(*@cell_rows)
|
74
|
+
@last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |index|
|
75
|
+
::LibUI.table_model_row_deleted(model, index)
|
76
76
|
end
|
77
|
-
::LibUI.table_model_row_deleted(model, row)
|
78
77
|
end
|
79
78
|
@last_cell_rows = @cell_rows.clone
|
80
79
|
end.observe(self, :cell_rows)
|
@@ -112,12 +111,8 @@ module Glimmer
|
|
112
111
|
0
|
113
112
|
when ImageColumnProxy, ImageTextColumnProxy
|
114
113
|
1
|
115
|
-
|
116
|
-
|
117
|
-
# when CheckboxTextColumnProxy
|
118
|
-
# 2
|
119
|
-
# when ProgressBarColumnProxy
|
120
|
-
# 2
|
114
|
+
when CheckboxColumnProxy, CheckboxTextColumnProxy, ProgressBarColumnProxy
|
115
|
+
2
|
121
116
|
end
|
122
117
|
end
|
123
118
|
@model_handler.NumRows = rbcallback(4) { cell_rows.count }
|
@@ -128,6 +123,10 @@ module Glimmer
|
|
128
123
|
::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
|
129
124
|
when ImageColumnProxy, ImageTextColumnProxy
|
130
125
|
::LibUI.new_table_value_image((expanded_cell_rows[row] && (expanded_cell_rows[row][column].respond_to?(:libui) ? expanded_cell_rows[row][column].libui : expanded_cell_rows[row][column])))
|
126
|
+
when CheckboxColumnProxy, CheckboxTextColumnProxy
|
127
|
+
::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column] == 1 || expanded_cell_rows[row][column].to_s.strip.downcase == 'true' ? 1 : 0)))
|
128
|
+
when ProgressBarColumnProxy
|
129
|
+
::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column].to_i)))
|
131
130
|
end
|
132
131
|
end
|
133
132
|
@model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
|
@@ -141,6 +140,10 @@ module Glimmer
|
|
141
140
|
@cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
|
142
141
|
when ButtonColumnProxy
|
143
142
|
@columns[column].notify_listeners(:on_clicked, row)
|
143
|
+
when CheckboxColumnProxy, CheckboxTextColumnProxy
|
144
|
+
column = @columns[column].index
|
145
|
+
@cell_rows[row] ||= []
|
146
|
+
@cell_rows[row][column] = ::LibUI.table_value_int(val).to_i == 1
|
144
147
|
end
|
145
148
|
end
|
146
149
|
|
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.26
|
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-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.1.
|
19
|
+
version: 2.1.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.1.
|
26
|
+
version: 2.1.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: os
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.0.
|
53
|
+
version: 0.0.10
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.0.
|
60
|
+
version: 0.0.10
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: juwelier
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,8 +198,11 @@ files:
|
|
198
198
|
- examples/basic_entry.rb
|
199
199
|
- examples/basic_table.rb
|
200
200
|
- examples/basic_table_button.rb
|
201
|
+
- examples/basic_table_checkbox.rb
|
202
|
+
- examples/basic_table_checkbox_text.rb
|
201
203
|
- examples/basic_table_image.rb
|
202
204
|
- examples/basic_table_image_text.rb
|
205
|
+
- examples/basic_table_progress_bar.rb
|
203
206
|
- examples/basic_window.rb
|
204
207
|
- examples/basic_window2.rb
|
205
208
|
- examples/color_button.rb
|
@@ -228,7 +231,9 @@ files:
|
|
228
231
|
- lib/glimmer/libui/button_column_proxy.rb
|
229
232
|
- lib/glimmer/libui/button_proxy.rb
|
230
233
|
- lib/glimmer/libui/check_menu_item_proxy.rb
|
234
|
+
- lib/glimmer/libui/checkbox_column_proxy.rb
|
231
235
|
- lib/glimmer/libui/checkbox_proxy.rb
|
236
|
+
- lib/glimmer/libui/checkbox_text_column_proxy.rb
|
232
237
|
- lib/glimmer/libui/color_button_proxy.rb
|
233
238
|
- lib/glimmer/libui/column.rb
|
234
239
|
- lib/glimmer/libui/combobox_proxy.rb
|
@@ -246,6 +251,7 @@ files:
|
|
246
251
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
247
252
|
- lib/glimmer/libui/image_column_proxy.rb
|
248
253
|
- lib/glimmer/libui/image_part_proxy.rb
|
254
|
+
- lib/glimmer/libui/image_proxy.rb
|
249
255
|
- lib/glimmer/libui/image_text_column_proxy.rb
|
250
256
|
- lib/glimmer/libui/label_proxy.rb
|
251
257
|
- lib/glimmer/libui/menu_item_proxy.rb
|
@@ -253,6 +259,7 @@ files:
|
|
253
259
|
- lib/glimmer/libui/multiline_entry_proxy.rb
|
254
260
|
- lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb
|
255
261
|
- lib/glimmer/libui/preferences_menu_item_proxy.rb
|
262
|
+
- lib/glimmer/libui/progress_bar_column_proxy.rb
|
256
263
|
- lib/glimmer/libui/quit_menu_item_proxy.rb
|
257
264
|
- lib/glimmer/libui/radio_buttons_proxy.rb
|
258
265
|
- lib/glimmer/libui/separator_menu_item_proxy.rb
|