glimmer-dsl-libui 0.0.23 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e29a14b4e8c65eaaa7ffa9d1ef5a7e1d13a592cf5d1090e850525b8d9188450
4
- data.tar.gz: 37f077425a3627fddd8047a052fa55c43b8b907160ddb406a821757b544c5d97
3
+ metadata.gz: 1014e0c2243936dc61a783c96c3f5760faf93692f8d60535667b29f5a0378cf9
4
+ data.tar.gz: 4176b09e4f89d5cdf2d182f1dceb9ae67aab71b3b28696d1a77e191708b931d8
5
5
  SHA512:
6
- metadata.gz: 2447933bbdce2b03660b8d9c4eb13736b4989eb2632288951ad836b3bd25f0e8fa7075d976b42da1df8a2495540302dd18c02c162abb08ab5a9cd5fad4c1378d
7
- data.tar.gz: f5018929934e70c3364f29ac124626ac1d9502e748e4b98ec1f44cdc5dae63e3baf7d856aa56dc50bb044e2909d040fff1c812ca66706bba4fa53fd92efdc97c
6
+ metadata.gz: 7080a17729c2059e0b7459a6087466d38a7fda9aa91be1964109418ec2bb8c55187d45fa75f6b2c83fa9c30d886c8efb84ca1c1714cf73e5e02b6a6a51741559
7
+ data.tar.gz: 9f21040ea200f827efcb235541fe28565361819aae0005653778d480b80b6e9d43e6ec7008e5512199abeb2e5832f2776beacda806cf260b73795bf5bfa7e9e5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.27
4
+
5
+ - New examples/form_table.rb
6
+ - Support automatic table row insertion upon inserting data rows into `cell_rows`
7
+
8
+ ## 0.0.26
9
+
10
+ - New examples/basic_table_progress_bar.rb
11
+ - Support table `progress_bar_column`
12
+
13
+ ## 0.0.25
14
+
15
+ - New examples/basic_table_checkbox_text.rb
16
+ - Support table `checkbox_text_column`
17
+
18
+ ## 0.0.24
19
+
20
+ - New examples/basic_table_checkbox.rb
21
+ - Support table `checkbox_column`
22
+ - Improve support for table row deletion upon actual `cell_rows` deletion by handling multiple-row deletion not just single-row deletion
23
+
3
24
  ## 0.0.23
4
25
 
5
26
  - Have `image` not require `width` and `height` if it only has one `image_part` (defaults to `image_part` `width` and `height`)
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.23
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.27
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.23](#-glimmer-dsl-for-libui-0023)
46
+ - [Glimmer DSL for LibUI 0.0.27](#-glimmer-dsl-for-libui-0027)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
@@ -75,6 +75,10 @@ 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)
81
+ - [Form Table](#form-table)
78
82
  - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
79
83
  - [Help](#help)
80
84
  - [Issues](#issues)
@@ -162,7 +166,7 @@ gem install glimmer-dsl-libui
162
166
  Or install via Bundler `Gemfile`:
163
167
 
164
168
  ```ruby
165
- gem 'glimmer-dsl-libui', '~> 0.0.23'
169
+ gem 'glimmer-dsl-libui', '~> 0.0.27'
166
170
  ```
167
171
 
168
172
  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 +223,10 @@ Control(Args) | Properties | Listeners
219
223
  ------------- | ---------- | ---------
220
224
  `about_menu_item` | None | `on_clicked`
221
225
  `button(text as String)` | `text` (`String`) | `on_clicked`
226
+ `button_column(name as String)` | `enabled` (Boolean) | None
222
227
  `checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
228
+ `checkbox_column(name as String)` | None | None
229
+ `checkbox_text_column(name as String)` | `editable` (Boolean) | None
223
230
  `combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
224
231
  `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
232
  `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 +252,7 @@ Control(Args) | Properties | Listeners
245
252
  `non_wrapping_multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
246
253
  `preferences_menu_item` | None | `on_clicked`
247
254
  `progress_bar` | `value` (`Numeric`) | None
255
+ `progress_bar_column(name as String)` | None | None
248
256
  `quit_menu_item` | None | `on_clicked`
249
257
  `radio_buttons` | `selected` (`Integer`) | `on_selected`
250
258
  `slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
@@ -252,7 +260,7 @@ Control(Args) | Properties | Listeners
252
260
  `tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
253
261
  `tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
254
262
  `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` as Boolean | None
263
+ `text_column(name as String)` | `editable` (Boolean) | None
256
264
  `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
265
  `vertical_box` | `padded` (Boolean) | None
258
266
  `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 +327,7 @@ Control(Args) | Properties | Listeners
319
327
  - 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
328
  - 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
329
  - Table model instances are automatically freed from memory after `window` is destroyed.
322
- - 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.
330
+ - Table `cell_rows` data has implicit data-binding to table cell values for deletion and insertion (done by diffing `cell_rows` value before and after change and auto-informing `table` of deletions [`::LibUI.table_model_row_deleted`] and insertions [`::LibUI.table_model_row_deleted`]). When deleting data rows from `cell_rows` array, then actual rows from the `table` are automatically deleted. When inserting data rows into `cell_rows` array, then actual `table` rows are automatically inserted.
323
331
  - `image` instances are automatically freed from memory after `window` is destroyed.
324
332
  - `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`
325
333
 
@@ -1810,7 +1818,7 @@ data = [
1810
1818
  %w[cat meow],
1811
1819
  %w[dog woof],
1812
1820
  %w[checken cock-a-doodle-doo],
1813
- %w[hourse neigh],
1821
+ %w[horse neigh],
1814
1822
  %w[cow moo]
1815
1823
  ]
1816
1824
 
@@ -1868,7 +1876,7 @@ data = [
1868
1876
  %w[cat meow],
1869
1877
  %w[dog woof],
1870
1878
  %w[chicken cock-a-doodle-doo],
1871
- %w[hourse neigh],
1879
+ %w[horse neigh],
1872
1880
  %w[cow moo]
1873
1881
  ]
1874
1882
 
@@ -1927,7 +1935,7 @@ data = [
1927
1935
  %w[cat meow],
1928
1936
  %w[dog woof],
1929
1937
  %w[chicken cock-a-doodle-doo],
1930
- %w[hourse neigh],
1938
+ %w[horse neigh],
1931
1939
  %w[cow moo]
1932
1940
  ]
1933
1941
 
@@ -1985,7 +1993,7 @@ data = [
1985
1993
  %w[cat calm meow],
1986
1994
  %w[dog loyal woof],
1987
1995
  %w[chicken bird cock-a-doodle-doo],
1988
- %w[hourse fast neigh],
1996
+ %w[horse fast neigh],
1989
1997
  %w[cow slow moo]
1990
1998
  ]
1991
1999
 
@@ -2281,7 +2289,7 @@ data = [
2281
2289
  %w[cat meow delete],
2282
2290
  %w[dog woof delete],
2283
2291
  %w[chicken cock-a-doodle-doo delete],
2284
- %w[hourse neigh delete],
2292
+ %w[horse neigh delete],
2285
2293
  %w[cow moo delete]
2286
2294
  ]
2287
2295
 
@@ -2302,6 +2310,257 @@ window('Animal sounds', 300, 200) {
2302
2310
  }.show
2303
2311
  ```
2304
2312
 
2313
+ ### Basic Table Checkbox
2314
+
2315
+ [examples/basic_table_checkbox.rb](examples/basic_table_checkbox.rb)
2316
+
2317
+ Run with this command from the root of the project if you cloned the project:
2318
+
2319
+ ```
2320
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox.rb
2321
+ ```
2322
+
2323
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2324
+
2325
+ ```
2326
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox'"
2327
+ ```
2328
+
2329
+ Mac
2330
+
2331
+ ![glimmer-dsl-libui-mac-basic-table-checkbox.png](images/glimmer-dsl-libui-mac-basic-table-checkbox.png)
2332
+
2333
+ Linux
2334
+
2335
+ ![glimmer-dsl-libui-linux-basic-table-checkbox.png](images/glimmer-dsl-libui-linux-basic-table-checkbox.png)
2336
+
2337
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2338
+
2339
+ ```ruby
2340
+ require 'glimmer-dsl-libui'
2341
+
2342
+ include Glimmer
2343
+
2344
+ data = [
2345
+ ['cat', 'meow', true],
2346
+ ['dog', 'woof', true],
2347
+ ['chicken', 'cock-a-doodle-doo', false],
2348
+ ['horse', 'neigh', true],
2349
+ ['cow', 'moo', true]
2350
+ ]
2351
+
2352
+ window('Animal sounds', 300, 200) {
2353
+ horizontal_box {
2354
+ table {
2355
+ text_column('Animal')
2356
+ text_column('Description')
2357
+ checkbox_column('Mammal')
2358
+
2359
+ cell_rows data
2360
+ }
2361
+ }
2362
+ }.show
2363
+ ```
2364
+
2365
+ ### Basic Table Checkbox Text
2366
+
2367
+ [examples/basic_table_checkbox_text.rb](examples/basic_table_checkbox_text.rb)
2368
+
2369
+ Run with this command from the root of the project if you cloned the project:
2370
+
2371
+ ```
2372
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox_text.rb
2373
+ ```
2374
+
2375
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2376
+
2377
+ ```
2378
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox_text'"
2379
+ ```
2380
+
2381
+ Mac
2382
+
2383
+ ![glimmer-dsl-libui-mac-basic-table-checkbox-text.png](images/glimmer-dsl-libui-mac-basic-table-checkbox-text.png)
2384
+
2385
+ Linux
2386
+
2387
+ ![glimmer-dsl-libui-linux-basic-table-checkbox-text.png](images/glimmer-dsl-libui-linux-basic-table-checkbox-text.png)
2388
+
2389
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2390
+
2391
+ ```ruby
2392
+ require 'glimmer-dsl-libui'
2393
+
2394
+ include Glimmer
2395
+
2396
+ data = [
2397
+ ['cat', 'meow', [true, 'mammal']],
2398
+ ['dog', 'woof', [true, 'mammal']],
2399
+ ['chicken', 'cock-a-doodle-doo', [false, 'mammal']],
2400
+ ['horse', 'neigh', [true, 'mammal']],
2401
+ ['cow', 'moo', [true, 'mammal']]
2402
+ ]
2403
+
2404
+ window('Animal sounds', 400, 200) {
2405
+ horizontal_box {
2406
+ table {
2407
+ text_column('Animal')
2408
+ text_column('Sound')
2409
+ checkbox_text_column('Description')
2410
+
2411
+ cell_rows data
2412
+ }
2413
+ }
2414
+ }.show
2415
+ ```
2416
+
2417
+ ### Basic Table Progress Bar
2418
+
2419
+ [examples/basic_table_progress_bar.rb](examples/basic_table_progress_bar.rb)
2420
+
2421
+ Run with this command from the root of the project if you cloned the project:
2422
+
2423
+ ```
2424
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_progress_bar.rb
2425
+ ```
2426
+
2427
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2428
+
2429
+ ```
2430
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_progress_bar'"
2431
+ ```
2432
+
2433
+ Mac
2434
+
2435
+ ![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png)
2436
+
2437
+ Linux
2438
+
2439
+ ![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
2440
+
2441
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2442
+
2443
+ ```ruby
2444
+ require 'glimmer-dsl-libui'
2445
+
2446
+ include Glimmer
2447
+
2448
+ data = [
2449
+ ['task 1', 0],
2450
+ ['task 2', 15],
2451
+ ['task 3', 100],
2452
+ ['task 4', 75],
2453
+ ['task 5', -1],
2454
+ ]
2455
+
2456
+ window('Task progress', 300, 200) {
2457
+ horizontal_box {
2458
+ table {
2459
+ text_column('Task')
2460
+ progress_bar_column('Progress')
2461
+
2462
+ cell_rows data
2463
+ }
2464
+ }
2465
+ }.show
2466
+ ```
2467
+
2468
+ ### Form Table
2469
+
2470
+ [examples/form_table.rb](examples/form_table.rb)
2471
+
2472
+ Run with this command from the root of the project if you cloned the project:
2473
+
2474
+ ```
2475
+ ruby -r './lib/glimmer-dsl-libui' examples/form_table.rb
2476
+ ```
2477
+
2478
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2479
+
2480
+ ```
2481
+ ruby -r glimmer-dsl-libui -e "require 'examples/form_table'"
2482
+ ```
2483
+
2484
+ Mac
2485
+
2486
+ ![glimmer-dsl-libui-mac-form-table.png](images/glimmer-dsl-libui-mac-form-table.png)
2487
+ ![glimmer-dsl-libui-mac-form-table-contact-entered.png](images/glimmer-dsl-libui-mac-form-table-contact-entered.png)
2488
+
2489
+ Linux
2490
+
2491
+ ![glimmer-dsl-libui-linux-form-table.png](images/glimmer-dsl-libui-linux-form-table.png)
2492
+ ![glimmer-dsl-libui-linux-form-table-contact-entered.png](images/glimmer-dsl-libui-linux-form-table-contact-entered.png)
2493
+
2494
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2495
+
2496
+ ```ruby
2497
+ require 'glimmer-dsl-libui'
2498
+
2499
+ include Glimmer
2500
+
2501
+ data = [
2502
+ ['Lisa Sky', 'lisa@sky.com', '720-523-4329', 'Denver', 'CO', '80014'],
2503
+ ['Jordan Biggins', 'jordan@biggins.com', '617-528-5399', 'Boston', 'MA', '02101'],
2504
+ ['Mary Glass', 'mary@glass.com', '847-589-8788', 'Elk Grove Village', 'IL', '60007'],
2505
+ ['Darren McGrath', 'darren@mcgrath.com', '206-539-9283', 'Seattle', 'WA', '98101'],
2506
+ ['Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA', '90001'],
2507
+ ]
2508
+
2509
+ window('Contacts', 600, 600) { |w|
2510
+ margined true
2511
+
2512
+ vertical_box {
2513
+ form {
2514
+ stretchy false
2515
+
2516
+ @name_entry = entry {
2517
+ label 'Name'
2518
+ }
2519
+ @email_entry = entry {
2520
+ label 'Email'
2521
+ }
2522
+ @phone_entry = entry {
2523
+ label 'Phone'
2524
+ }
2525
+ @city_entry = entry {
2526
+ label 'City'
2527
+ }
2528
+ @state_entry = entry {
2529
+ label 'State'
2530
+ }
2531
+ }
2532
+
2533
+ button('Save Contact') {
2534
+ stretchy false
2535
+
2536
+ on_clicked do
2537
+ new_row = [@name_entry.text, @email_entry.text, @phone_entry.text, @city_entry.text, @state_entry.text]
2538
+ if new_row.include?('')
2539
+ msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
2540
+ else
2541
+ data << new_row # automatically inserts a row into the table due to implicit data-binding
2542
+ @name_entry.text = ''
2543
+ @email_entry.text = ''
2544
+ @phone_entry.text = ''
2545
+ @city_entry.text = ''
2546
+ @state_entry.text = ''
2547
+ end
2548
+ end
2549
+ }
2550
+
2551
+ table {
2552
+ text_column('Name')
2553
+ text_column('Email')
2554
+ text_column('Phone')
2555
+ text_column('City')
2556
+ text_column('State')
2557
+
2558
+ cell_rows data # implicit data-binding
2559
+ }
2560
+ }
2561
+ }.show
2562
+ ```
2563
+
2305
2564
  ## Contributing to glimmer-dsl-libui
2306
2565
 
2307
2566
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.23
1
+ 0.0.27
@@ -8,7 +8,7 @@ data = [
8
8
  %w[cat meow],
9
9
  %w[dog woof],
10
10
  %w[chicken cock-a-doodle-doo],
11
- %w[hourse neigh],
11
+ %w[horse neigh],
12
12
  %w[cow moo]
13
13
  ]
14
14
 
@@ -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[hourse neigh delete],
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
@@ -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
@@ -8,7 +8,7 @@ data = [
8
8
  %w[cat calm meow],
9
9
  %w[dog loyal woof],
10
10
  %w[chicken bird cock-a-doodle-doo],
11
- %w[hourse fast neigh],
11
+ %w[horse fast neigh],
12
12
  %w[cow slow moo]
13
13
  ]
14
14
 
@@ -8,7 +8,7 @@ data = [
8
8
  %w[cat meow],
9
9
  %w[dog woof],
10
10
  %w[chicken cock-a-doodle-doo],
11
- %w[hourse neigh],
11
+ %w[horse neigh],
12
12
  %w[cow moo]
13
13
  ]
14
14
 
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+
5
+ include Glimmer
6
+
7
+ data = [
8
+ ['Lisa Sky', 'lisa@sky.com', '720-523-4329', 'Denver', 'CO', '80014'],
9
+ ['Jordan Biggins', 'jordan@biggins.com', '617-528-5399', 'Boston', 'MA', '02101'],
10
+ ['Mary Glass', 'mary@glass.com', '847-589-8788', 'Elk Grove Village', 'IL', '60007'],
11
+ ['Darren McGrath', 'darren@mcgrath.com', '206-539-9283', 'Seattle', 'WA', '98101'],
12
+ ['Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA', '90001'],
13
+ ]
14
+
15
+ window('Contacts', 600, 600) { |w|
16
+ margined true
17
+
18
+ vertical_box {
19
+ form {
20
+ stretchy false
21
+
22
+ @name_entry = entry {
23
+ label 'Name'
24
+ }
25
+ @email_entry = entry {
26
+ label 'Email'
27
+ }
28
+ @phone_entry = entry {
29
+ label 'Phone'
30
+ }
31
+ @city_entry = entry {
32
+ label 'City'
33
+ }
34
+ @state_entry = entry {
35
+ label 'State'
36
+ }
37
+ }
38
+
39
+ button('Save Contact') {
40
+ stretchy false
41
+
42
+ on_clicked do
43
+ new_row = [@name_entry.text, @email_entry.text, @phone_entry.text, @city_entry.text, @state_entry.text]
44
+ if new_row.include?('')
45
+ msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
46
+ else
47
+ data << new_row # automatically inserts a row into the table due to implicit data-binding
48
+ @name_entry.text = ''
49
+ @email_entry.text = ''
50
+ @phone_entry.text = ''
51
+ @city_entry.text = ''
52
+ @state_entry.text = ''
53
+ end
54
+ end
55
+ }
56
+
57
+ table {
58
+ text_column('Name')
59
+ text_column('Email')
60
+ text_column('Phone')
61
+ text_column('City')
62
+ text_column('State')
63
+
64
+ cell_rows data # implicit data-binding
65
+ }
66
+ }
67
+ }.show
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
@@ -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,14 @@ 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 (@cell_rows.size == @last_cell_rows.size - 1) && @last_cell_rows & @cell_rows == @cell_rows
74
- _, row = @last_cell_rows.each_with_index.find do |row_data, row|
75
- !@cell_rows.include?(row_data)
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
+ end
77
+ elsif @cell_rows.size > @last_cell_rows.size && @cell_rows.include_all?(*@last_cell_rows)
78
+ @cell_rows.array_diff_indexes(@last_cell_rows).each do |index|
79
+ ::LibUI.table_model_row_inserted(model, index)
76
80
  end
77
- ::LibUI.table_model_row_deleted(model, row)
78
81
  end
79
82
  @last_cell_rows = @cell_rows.clone
80
83
  end.observe(self, :cell_rows)
@@ -112,12 +115,8 @@ module Glimmer
112
115
  0
113
116
  when ImageColumnProxy, ImageTextColumnProxy
114
117
  1
115
- # when CheckboxColumnProxy
116
- # 2
117
- # when CheckboxTextColumnProxy
118
- # 2
119
- # when ProgressBarColumnProxy
120
- # 2
118
+ when CheckboxColumnProxy, CheckboxTextColumnProxy, ProgressBarColumnProxy
119
+ 2
121
120
  end
122
121
  end
123
122
  @model_handler.NumRows = rbcallback(4) { cell_rows.count }
@@ -128,6 +127,10 @@ module Glimmer
128
127
  ::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
129
128
  when ImageColumnProxy, ImageTextColumnProxy
130
129
  ::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])))
130
+ when CheckboxColumnProxy, CheckboxTextColumnProxy
131
+ ::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)))
132
+ when ProgressBarColumnProxy
133
+ ::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column].to_i)))
131
134
  end
132
135
  end
133
136
  @model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
@@ -141,6 +144,10 @@ module Glimmer
141
144
  @cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
142
145
  when ButtonColumnProxy
143
146
  @columns[column].notify_listeners(:on_clicked, row)
147
+ when CheckboxColumnProxy, CheckboxTextColumnProxy
148
+ column = @columns[column].index
149
+ @cell_rows[row] ||= []
150
+ @cell_rows[row][column] = ::LibUI.table_value_int(val).to_i == 1
144
151
  end
145
152
  end
146
153
 
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.23
4
+ version: 0.0.27
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-26 00:00:00.000000000 Z
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.4
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.4
26
+ version: 2.1.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: os
29
29
  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
@@ -209,6 +212,7 @@ files:
209
212
  - examples/editable_table.rb
210
213
  - examples/font_button.rb
211
214
  - examples/form.rb
215
+ - examples/form_table.rb
212
216
  - examples/grid.rb
213
217
  - examples/meta_example.rb
214
218
  - examples/midi_player.rb
@@ -228,7 +232,9 @@ files:
228
232
  - lib/glimmer/libui/button_column_proxy.rb
229
233
  - lib/glimmer/libui/button_proxy.rb
230
234
  - lib/glimmer/libui/check_menu_item_proxy.rb
235
+ - lib/glimmer/libui/checkbox_column_proxy.rb
231
236
  - lib/glimmer/libui/checkbox_proxy.rb
237
+ - lib/glimmer/libui/checkbox_text_column_proxy.rb
232
238
  - lib/glimmer/libui/color_button_proxy.rb
233
239
  - lib/glimmer/libui/column.rb
234
240
  - lib/glimmer/libui/combobox_proxy.rb
@@ -254,6 +260,7 @@ files:
254
260
  - lib/glimmer/libui/multiline_entry_proxy.rb
255
261
  - lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb
256
262
  - lib/glimmer/libui/preferences_menu_item_proxy.rb
263
+ - lib/glimmer/libui/progress_bar_column_proxy.rb
257
264
  - lib/glimmer/libui/quit_menu_item_proxy.rb
258
265
  - lib/glimmer/libui/radio_buttons_proxy.rb
259
266
  - lib/glimmer/libui/separator_menu_item_proxy.rb