glimmer-dsl-libui 0.0.26 → 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: 3a22a20e6928aba5a45b52a05d55c4b6fc8fe33ff4e39c71701e4f3675c8c118
4
- data.tar.gz: 13549e3b443fcc717a8ebee91694568a868bb7f3a6a6028f063b063d79af2e79
3
+ metadata.gz: 1014e0c2243936dc61a783c96c3f5760faf93692f8d60535667b29f5a0378cf9
4
+ data.tar.gz: 4176b09e4f89d5cdf2d182f1dceb9ae67aab71b3b28696d1a77e191708b931d8
5
5
  SHA512:
6
- metadata.gz: ce691f8f98fcae7063245d9a8cd14b61ed64f6207236a7b111de8a35c6e84225634faaf1968218567827b06cd2f4b1b20a664c013c85b1b761bcecd6fd87e095
7
- data.tar.gz: 662d181cac9f3d86996b85d0aa8b725e99c154502867cdb8e1814dfc452956864772e31e6cac1127acf5966c29fd5aa017aea1cb4a3ad11c8331b7e42b49d756
6
+ metadata.gz: 7080a17729c2059e0b7459a6087466d38a7fda9aa91be1964109418ec2bb8c55187d45fa75f6b2c83fa9c30d886c8efb84ca1c1714cf73e5e02b6a6a51741559
7
+ data.tar.gz: 9f21040ea200f827efcb235541fe28565361819aae0005653778d480b80b6e9d43e6ec7008e5512199abeb2e5832f2776beacda806cf260b73795bf5bfa7e9e5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
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
+
3
8
  ## 0.0.26
4
9
 
5
10
  - New examples/basic_table_progress_bar.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.26
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.26](#-glimmer-dsl-for-libui-0026)
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)
@@ -78,6 +78,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
78
78
  - [Basic Table Checkbox](#basic-table-checkbox)
79
79
  - [Basic Table Checkbox Text](#basic-table-checkbox-text)
80
80
  - [Basic Table Progress Bar](#basic-table-progress-bar)
81
+ - [Form Table](#form-table)
81
82
  - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
82
83
  - [Help](#help)
83
84
  - [Issues](#issues)
@@ -165,7 +166,7 @@ gem install glimmer-dsl-libui
165
166
  Or install via Bundler `Gemfile`:
166
167
 
167
168
  ```ruby
168
- gem 'glimmer-dsl-libui', '~> 0.0.26'
169
+ gem 'glimmer-dsl-libui', '~> 0.0.27'
169
170
  ```
170
171
 
171
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.
@@ -326,7 +327,7 @@ Control(Args) | Properties | Listeners
326
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`)
327
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`)
328
329
  - 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.
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.
330
331
  - `image` instances are automatically freed from memory after `window` is destroyed.
331
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`
332
333
 
@@ -2464,6 +2465,102 @@ window('Task progress', 300, 200) {
2464
2465
  }.show
2465
2466
  ```
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
+
2467
2564
  ## Contributing to glimmer-dsl-libui
2468
2565
 
2469
2566
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.26
1
+ 0.0.27
@@ -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
@@ -74,6 +74,10 @@ module Glimmer
74
74
  @last_cell_rows.array_diff_indexes(@cell_rows).reverse.each do |index|
75
75
  ::LibUI.table_model_row_deleted(model, index)
76
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)
80
+ end
77
81
  end
78
82
  @last_cell_rows = @cell_rows.clone
79
83
  end.observe(self, :cell_rows)
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.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
@@ -212,6 +212,7 @@ files:
212
212
  - examples/editable_table.rb
213
213
  - examples/font_button.rb
214
214
  - examples/form.rb
215
+ - examples/form_table.rb
215
216
  - examples/grid.rb
216
217
  - examples/meta_example.rb
217
218
  - examples/midi_player.rb