glimmer-dsl-libui 0.0.24 → 0.0.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48620214d8ee4d8658822fd623fbc35cacca3a65fdb9b50b9c0e594f37bce0ad
4
- data.tar.gz: 595c65cc0ec5c8f94eea6b2aa542cd3f55870d537d3de4fa230b237e58a13835
3
+ metadata.gz: 54faaec785d114536e8b747aa55f7d7bd043339e99f041722d60d70623a9b648
4
+ data.tar.gz: 9391f99834f34e2b878b2dbf41b7a8ff3f1ab58daf003acdf33a4f93a2e0777c
5
5
  SHA512:
6
- metadata.gz: 52bfdf8599bc77a418a96a3ed4e3e072c06c328a9597325d66b21419cfde80ade7475f3744870ad0413383d72154db9caea0158e5a2f82e2e7446f231b1eb800
7
- data.tar.gz: b8f10cae326f757cf6fdbff6085db5d9302696109158046c19cca0d57aaad63f9d28e30509155e69fa3d26bcc48541e3276e04d21c27969425663177da32a3a5
6
+ metadata.gz: 8f2d65ebb19e77c5fab1e037c751af43635a03b07671c8e03ac507bf4e01c04e37c083ffe91a4b18796505801e0d77d84770d0aa13951785422db6ae3c11830f
7
+ data.tar.gz: 34965b3e01a55733b767dccb4356b4902627a55fd6843295c76fc473a4b049456c7ee59df12bfc9f61541668b763a394d1fb43955f057f6cc8f6a4f72a2ae6b3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.28
4
+
5
+ - Support automatic table row change when updating a row in `cell_rows` (e.g. `data[3] = ['new', 'row', 'cell', 'values']`)
6
+ - Support `editable` property for `checkbox_column` (checkbox editing only works in Windows due to a [libui](https://github.com/andlabs/libui) limitation)
7
+ - Support `editable`, `editable_checkbox`, and `editable_text` properties for `checkbox_text_column` (checkbox editing only works in Windows due to a [libui](https://github.com/andlabs/libui) limitation)
8
+ - Fix examples/basic_table_checkbox_text.rb by removing `editable` property
9
+
10
+ ## 0.0.27
11
+
12
+ - New examples/form_table.rb
13
+ - Support automatic table row insertion upon inserting data rows into `cell_rows`
14
+
15
+ ## 0.0.26
16
+
17
+ - New examples/basic_table_progress_bar.rb
18
+ - Support table `progress_bar_column`
19
+
20
+ ## 0.0.25
21
+
22
+ - New examples/basic_table_checkbox_text.rb
23
+ - Support table `checkbox_text_column`
24
+
3
25
  ## 0.0.24
4
26
 
5
27
  - New examples/basic_table_checkbox.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.24
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.28
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.24](#-glimmer-dsl-for-libui-0024)
46
+ - [Glimmer DSL for LibUI 0.0.28](#-glimmer-dsl-for-libui-0028)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
@@ -52,6 +52,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
52
52
  - [Common Control Operations](#common-control-operations)
53
53
  - [Extra Dialogs](#extra-dialogs)
54
54
  - [Extra Operations](#extra-operations)
55
+ - [Table API](#table-api)
55
56
  - [Smart Defaults and Conventions](#smart-defaults-and-conventions)
56
57
  - [API Gotchas](#api-gotchas)
57
58
  - [Original API](#original-api)
@@ -76,6 +77,9 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
76
77
  - [Basic Table Image Text](#basic-table-image-text)
77
78
  - [Basic Table Button](#basic-table-button)
78
79
  - [Basic Table Checkbox](#basic-table-checkbox)
80
+ - [Basic Table Checkbox Text](#basic-table-checkbox-text)
81
+ - [Basic Table Progress Bar](#basic-table-progress-bar)
82
+ - [Form Table](#form-table)
79
83
  - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
80
84
  - [Help](#help)
81
85
  - [Issues](#issues)
@@ -163,7 +167,7 @@ gem install glimmer-dsl-libui
163
167
  Or install via Bundler `Gemfile`:
164
168
 
165
169
  ```ruby
166
- gem 'glimmer-dsl-libui', '~> 0.0.24'
170
+ gem 'glimmer-dsl-libui', '~> 0.0.28'
167
171
  ```
168
172
 
169
173
  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.
@@ -222,7 +226,8 @@ Control(Args) | Properties | Listeners
222
226
  `button(text as String)` | `text` (`String`) | `on_clicked`
223
227
  `button_column(name as String)` | `enabled` (Boolean) | None
224
228
  `checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
225
- `checkbox_column(name as String)` | None | None
229
+ `checkbox_column(name as String)` | `editable` (Boolean) [Windows-only due to a current libui limitation] | None
230
+ `checkbox_text_column(name as String)` | `editable` (Boolean) [Windows-only due to a current libui limitation], `editable_checkbox` (Boolean) [Windows-only due to a current libui limitation], `editable_text` (Boolean) | None
226
231
  `combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
227
232
  `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`
228
233
  `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`
@@ -248,6 +253,7 @@ Control(Args) | Properties | Listeners
248
253
  `non_wrapping_multiline_entry` | `read_only` (Boolean), `text` (`String`) | `on_changed`
249
254
  `preferences_menu_item` | None | `on_clicked`
250
255
  `progress_bar` | `value` (`Numeric`) | None
256
+ `progress_bar_column(name as String)` | None | None
251
257
  `quit_menu_item` | None | `on_clicked`
252
258
  `radio_buttons` | `selected` (`Integer`) | `on_selected`
253
259
  `slider(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
@@ -255,7 +261,7 @@ Control(Args) | Properties | Listeners
255
261
  `tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
256
262
  `tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
257
263
  `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
258
- `text_column(name as String)` | `editable` as Boolean | None
264
+ `text_column(name as String)` | `editable` (Boolean) | None
259
265
  `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`
260
266
  `vertical_box` | `padded` (Boolean) | None
261
267
  `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`
@@ -297,6 +303,24 @@ Control(Args) | Properties | Listeners
297
303
  - `ControlProxy::main_window_proxy`: returns the first window proxy instantiated in the application
298
304
  - `ControlProxy#window_proxy`: returns the window proxy parent for a control
299
305
 
306
+ ### Table API
307
+
308
+ The `table` control must first declare its columns via one of these column keywords (mentioned in [Supported Controls](#supported-controls)):
309
+ - `button_column`: expects `String` cell values
310
+ - `checkbox_column`: expects Boolean cell values
311
+ - `checkbox_text_column`: expects dual-element `Array` of Boolean and `String` cell values
312
+ - `image_column`: expects `image` cell values (produced by `image` and `image_part` keywords as per [Supported Controls](#supported-controls))
313
+ - `image_text_column`: expects dual-element `Array` of `image` and `String` cell values
314
+ - `text_column`: expects `String` cell values
315
+ - `progress_bar_column`: expects `Integer` cell values
316
+
317
+ Afterwards, it must declare its `cell_rows` array (`Array` of `Array`s of column cell values) and whether it is `editable` (Boolean) for all its columns.
318
+
319
+ Note that the `cell_rows` property declaration results in "implicit data-binding" between the `table` control and `Array` of `Arrays` (a new innovation) to provide convenience automatic support for:
320
+ - Deleting cell rows: Calling `Array#delete`, `Array#delete_at`, `Array#delete_if`, or any filtering/deletion `Array` method automatically deletes rows in actual `table` control
321
+ - Inserting cell rows: Calling `Array#<<`, `Array#push`, `Array#prepend`, or any insertion/addition `Array` method automatically inserts rows in actual `table` control
322
+ - Changing cell rows: Calling `Array#[]=`, `Array#map!`, or any update `Array` method automatically updates rows in actual `table` control
323
+
300
324
  ### Smart Defaults and Conventions
301
325
 
302
326
  - `horizontal_box`, `vertical_box`, `grid`, and `form` controls have `padded` as `true` upon instantiation to ensure more user-friendly GUI by default
@@ -322,13 +346,14 @@ Control(Args) | Properties | Listeners
322
346
  - Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
323
347
  - 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`)
324
348
  - Table model instances are automatically freed from memory after `window` is destroyed.
325
- - 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.
349
+ - Table `cell_rows` data has implicit data-binding to table cell values for deletion, insertion, and change (done by diffing `cell_rows` value before and after change and auto-informing `table` of deletions [`LibUI.table_model_row_deleted`], insertions [`LibUI.table_model_row_deleted`], and changes [`LibUI.table_model_row_changed`]). 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. When updating data rows in `cell_rows` array, then actual `table` rows are automatically updated.
326
350
  - `image` instances are automatically freed from memory after `window` is destroyed.
327
351
  - `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`
328
352
 
329
353
  ### API Gotchas
330
354
 
331
- 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`)
355
+ - 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`).
356
+ - `table` `checkbox_column` and `checkbox_text_column` checkbox editing currently only works in Windows due to a current limitation in [libui](https://github.com/andlabs/libui).
332
357
 
333
358
  ### Original API
334
359
 
@@ -2357,6 +2382,205 @@ window('Animal sounds', 300, 200) {
2357
2382
  }.show
2358
2383
  ```
2359
2384
 
2385
+ ### Basic Table Checkbox Text
2386
+
2387
+ [examples/basic_table_checkbox_text.rb](examples/basic_table_checkbox_text.rb)
2388
+
2389
+ Run with this command from the root of the project if you cloned the project:
2390
+
2391
+ ```
2392
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox_text.rb
2393
+ ```
2394
+
2395
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2396
+
2397
+ ```
2398
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox_text'"
2399
+ ```
2400
+
2401
+ Mac
2402
+
2403
+ ![glimmer-dsl-libui-mac-basic-table-checkbox-text.png](images/glimmer-dsl-libui-mac-basic-table-checkbox-text.png)
2404
+
2405
+ Linux
2406
+
2407
+ ![glimmer-dsl-libui-linux-basic-table-checkbox-text.png](images/glimmer-dsl-libui-linux-basic-table-checkbox-text.png)
2408
+
2409
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2410
+
2411
+ ```ruby
2412
+ require 'glimmer-dsl-libui'
2413
+
2414
+ include Glimmer
2415
+
2416
+ data = [
2417
+ ['cat', 'meow', [true, 'mammal']],
2418
+ ['dog', 'woof', [true, 'mammal']],
2419
+ ['chicken', 'cock-a-doodle-doo', [false, 'mammal']],
2420
+ ['horse', 'neigh', [true, 'mammal']],
2421
+ ['cow', 'moo', [true, 'mammal']]
2422
+ ]
2423
+
2424
+ window('Animal sounds', 400, 200) {
2425
+ horizontal_box {
2426
+ table {
2427
+ text_column('Animal')
2428
+ text_column('Sound')
2429
+ checkbox_text_column('Description')
2430
+
2431
+ cell_rows data
2432
+ }
2433
+ }
2434
+ }.show
2435
+ ```
2436
+
2437
+ ### Basic Table Progress Bar
2438
+
2439
+ [examples/basic_table_progress_bar.rb](examples/basic_table_progress_bar.rb)
2440
+
2441
+ Run with this command from the root of the project if you cloned the project:
2442
+
2443
+ ```
2444
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_progress_bar.rb
2445
+ ```
2446
+
2447
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2448
+
2449
+ ```
2450
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_progress_bar'"
2451
+ ```
2452
+
2453
+ Mac
2454
+
2455
+ ![glimmer-dsl-libui-mac-basic-table-progress-bar.png](images/glimmer-dsl-libui-mac-basic-table-progress-bar.png)
2456
+
2457
+ Linux
2458
+
2459
+ ![glimmer-dsl-libui-linux-basic-table-progress-bar.png](images/glimmer-dsl-libui-linux-basic-table-progress-bar.png)
2460
+
2461
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2462
+
2463
+ ```ruby
2464
+ require 'glimmer-dsl-libui'
2465
+
2466
+ include Glimmer
2467
+
2468
+ data = [
2469
+ ['task 1', 0],
2470
+ ['task 2', 15],
2471
+ ['task 3', 100],
2472
+ ['task 4', 75],
2473
+ ['task 5', -1],
2474
+ ]
2475
+
2476
+ window('Task progress', 300, 200) {
2477
+ horizontal_box {
2478
+ table {
2479
+ text_column('Task')
2480
+ progress_bar_column('Progress')
2481
+
2482
+ cell_rows data
2483
+ }
2484
+ }
2485
+ }.show
2486
+ ```
2487
+
2488
+ ### Form Table
2489
+
2490
+ [examples/form_table.rb](examples/form_table.rb)
2491
+
2492
+ Run with this command from the root of the project if you cloned the project:
2493
+
2494
+ ```
2495
+ ruby -r './lib/glimmer-dsl-libui' examples/form_table.rb
2496
+ ```
2497
+
2498
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2499
+
2500
+ ```
2501
+ ruby -r glimmer-dsl-libui -e "require 'examples/form_table'"
2502
+ ```
2503
+
2504
+ Mac
2505
+
2506
+ ![glimmer-dsl-libui-mac-form-table.png](images/glimmer-dsl-libui-mac-form-table.png)
2507
+ ![glimmer-dsl-libui-mac-form-table-contact-entered.png](images/glimmer-dsl-libui-mac-form-table-contact-entered.png)
2508
+
2509
+ Linux
2510
+
2511
+ ![glimmer-dsl-libui-linux-form-table.png](images/glimmer-dsl-libui-linux-form-table.png)
2512
+ ![glimmer-dsl-libui-linux-form-table-contact-entered.png](images/glimmer-dsl-libui-linux-form-table-contact-entered.png)
2513
+
2514
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2515
+
2516
+ ```ruby
2517
+ require 'glimmer-dsl-libui'
2518
+
2519
+ include Glimmer
2520
+
2521
+ data = [
2522
+ ['Lisa Sky', 'lisa@sky.com', '720-523-4329', 'Denver', 'CO', '80014'],
2523
+ ['Jordan Biggins', 'jordan@biggins.com', '617-528-5399', 'Boston', 'MA', '02101'],
2524
+ ['Mary Glass', 'mary@glass.com', '847-589-8788', 'Elk Grove Village', 'IL', '60007'],
2525
+ ['Darren McGrath', 'darren@mcgrath.com', '206-539-9283', 'Seattle', 'WA', '98101'],
2526
+ ['Melody Hanheimer', 'melody@hanheimer.com', '213-493-8274', 'Los Angeles', 'CA', '90001'],
2527
+ ]
2528
+
2529
+ window('Contacts', 600, 600) { |w|
2530
+ margined true
2531
+
2532
+ vertical_box {
2533
+ form {
2534
+ stretchy false
2535
+
2536
+ @name_entry = entry {
2537
+ label 'Name'
2538
+ }
2539
+ @email_entry = entry {
2540
+ label 'Email'
2541
+ }
2542
+ @phone_entry = entry {
2543
+ label 'Phone'
2544
+ }
2545
+ @city_entry = entry {
2546
+ label 'City'
2547
+ }
2548
+ @state_entry = entry {
2549
+ label 'State'
2550
+ }
2551
+ }
2552
+
2553
+ button('Save Contact') {
2554
+ stretchy false
2555
+
2556
+ on_clicked do
2557
+ new_row = [@name_entry.text, @email_entry.text, @phone_entry.text, @city_entry.text, @state_entry.text]
2558
+ if new_row.include?('')
2559
+ msg_box_error(w, 'Validation Error!', 'All fields are required! Please make sure to enter a value for all fields.')
2560
+ else
2561
+ data << new_row # automatically inserts a row into the table due to implicit data-binding
2562
+ @name_entry.text = ''
2563
+ @email_entry.text = ''
2564
+ @phone_entry.text = ''
2565
+ @city_entry.text = ''
2566
+ @state_entry.text = ''
2567
+ end
2568
+ end
2569
+ }
2570
+
2571
+ table {
2572
+ text_column('Name')
2573
+ text_column('Email')
2574
+ text_column('Phone')
2575
+ text_column('City')
2576
+ text_column('State')
2577
+
2578
+ cell_rows data # implicit data-binding
2579
+ }
2580
+ }
2581
+ }.show
2582
+ ```
2583
+
2360
2584
  ## Contributing to glimmer-dsl-libui
2361
2585
 
2362
2586
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.24
1
+ 0.0.28
@@ -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, '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
+
22
+ cell_rows data
23
+ }
24
+ }
25
+ }.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
@@ -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
@@ -30,12 +30,12 @@ module Glimmer
30
30
  # Follows the Proxy Design Pattern
31
31
  class CheckboxColumnProxy < ControlProxy
32
32
  include Column
33
- # include EditableColumn # TODO enable this once checkbox column becomes editable on macosx in C libui (currently has a bug)
33
+ include EditableColumn
34
34
 
35
35
  private
36
36
 
37
37
  def build_control
38
- @parent_proxy.append_checkbox_column(name, column_index, -1)
38
+ @parent_proxy.append_checkbox_column(name, column_index, editable_value)
39
39
  end
40
40
  end
41
41
  end
@@ -0,0 +1,76 @@
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
36
+
37
+ def editable_checkbox(value = nil)
38
+ if value.nil?
39
+ @editable_checkbox = false if @editable_checkbox.nil?
40
+ @editable_checkbox
41
+ else
42
+ @editable_checkbox = !!value
43
+ end
44
+ end
45
+ alias editable_checkbox= editable_checkbox
46
+ alias set_editable_checkbox editable_checkbox
47
+ alias editable_checkbox? editable_checkbox
48
+
49
+ def editable_text(value = nil)
50
+ if value.nil?
51
+ @editable_text = false if @editable_text.nil?
52
+ @editable_text
53
+ else
54
+ @editable_text = !!value
55
+ end
56
+ end
57
+ alias editable_text= editable_text
58
+ alias set_editable_text editable_text
59
+ alias editable_text? editable_text
60
+
61
+ private
62
+
63
+ def build_control
64
+ @parent_proxy.append_checkbox_text_column(name, column_index, editable_checkbox_value, second_column_index, editable_text_value)
65
+ end
66
+
67
+ def editable_checkbox_value
68
+ (@parent_proxy.editable? || editable? || editable_checkbox?) ? -2 : -1
69
+ end
70
+
71
+ def editable_text_value
72
+ (@parent_proxy.editable? || editable? || editable_text?) ? -2 : -1
73
+ end
74
+ end
75
+ end
76
+ 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
@@ -71,8 +71,16 @@ module Glimmer
71
71
  @last_cell_rows = @cell_rows.clone
72
72
  Glimmer::DataBinding::Observer.proc do
73
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)
74
+ @last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |row|
75
+ ::LibUI.table_model_row_deleted(model, row)
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 |row|
79
+ ::LibUI.table_model_row_inserted(model, row)
80
+ end
81
+ else
82
+ @cell_rows.each_with_index do |new_row_data, row|
83
+ ::LibUI.table_model_row_changed(model, row) if new_row_data != @last_cell_rows[row]
76
84
  end
77
85
  end
78
86
  @last_cell_rows = @cell_rows.clone
@@ -111,12 +119,8 @@ module Glimmer
111
119
  0
112
120
  when ImageColumnProxy, ImageTextColumnProxy
113
121
  1
114
- when CheckboxColumnProxy
122
+ when CheckboxColumnProxy, CheckboxTextColumnProxy, ProgressBarColumnProxy
115
123
  2
116
- # when CheckboxTextColumnProxy
117
- # 2
118
- # when ProgressBarColumnProxy
119
- # 2
120
124
  end
121
125
  end
122
126
  @model_handler.NumRows = rbcallback(4) { cell_rows.count }
@@ -127,8 +131,10 @@ module Glimmer
127
131
  ::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
128
132
  when ImageColumnProxy, ImageTextColumnProxy
129
133
  ::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
134
+ when CheckboxColumnProxy, CheckboxTextColumnProxy
131
135
  ::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)))
136
+ when ProgressBarColumnProxy
137
+ ::LibUI.new_table_value_int((expanded_cell_rows[row] && (expanded_cell_rows[row][column].to_i)))
132
138
  end
133
139
  end
134
140
  @model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
@@ -142,7 +148,7 @@ module Glimmer
142
148
  @cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
143
149
  when ButtonColumnProxy
144
150
  @columns[column].notify_listeners(:on_clicked, row)
145
- when CheckboxColumnProxy
151
+ when CheckboxColumnProxy, CheckboxTextColumnProxy
146
152
  column = @columns[column].index
147
153
  @cell_rows[row] ||= []
148
154
  @cell_rows[row][column] = ::LibUI.table_value_int(val).to_i == 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-libui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
@@ -199,8 +199,10 @@ files:
199
199
  - examples/basic_table.rb
200
200
  - examples/basic_table_button.rb
201
201
  - examples/basic_table_checkbox.rb
202
+ - examples/basic_table_checkbox_text.rb
202
203
  - examples/basic_table_image.rb
203
204
  - examples/basic_table_image_text.rb
205
+ - examples/basic_table_progress_bar.rb
204
206
  - examples/basic_window.rb
205
207
  - examples/basic_window2.rb
206
208
  - examples/color_button.rb
@@ -210,6 +212,7 @@ files:
210
212
  - examples/editable_table.rb
211
213
  - examples/font_button.rb
212
214
  - examples/form.rb
215
+ - examples/form_table.rb
213
216
  - examples/grid.rb
214
217
  - examples/meta_example.rb
215
218
  - examples/midi_player.rb
@@ -231,6 +234,7 @@ files:
231
234
  - lib/glimmer/libui/check_menu_item_proxy.rb
232
235
  - lib/glimmer/libui/checkbox_column_proxy.rb
233
236
  - lib/glimmer/libui/checkbox_proxy.rb
237
+ - lib/glimmer/libui/checkbox_text_column_proxy.rb
234
238
  - lib/glimmer/libui/color_button_proxy.rb
235
239
  - lib/glimmer/libui/column.rb
236
240
  - lib/glimmer/libui/combobox_proxy.rb
@@ -256,6 +260,7 @@ files:
256
260
  - lib/glimmer/libui/multiline_entry_proxy.rb
257
261
  - lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb
258
262
  - lib/glimmer/libui/preferences_menu_item_proxy.rb
263
+ - lib/glimmer/libui/progress_bar_column_proxy.rb
259
264
  - lib/glimmer/libui/quit_menu_item_proxy.rb
260
265
  - lib/glimmer/libui/radio_buttons_proxy.rb
261
266
  - lib/glimmer/libui/separator_menu_item_proxy.rb