glimmer-dsl-libui 0.0.20 → 0.0.24

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: d4f4c60e8967700c477acdd623d75af1b119ab243f90e22b4f9861d9fbde3705
4
- data.tar.gz: f92952b04a511a54107114cad3b7b336b4731720b4a6844097353c97fd16f4a5
3
+ metadata.gz: 48620214d8ee4d8658822fd623fbc35cacca3a65fdb9b50b9c0e594f37bce0ad
4
+ data.tar.gz: 595c65cc0ec5c8f94eea6b2aa542cd3f55870d537d3de4fa230b237e58a13835
5
5
  SHA512:
6
- metadata.gz: 7fb3cd049cadd55cfb9750c6167804a8af54d793498bc3a67ac1efe913ec4497e2dec7ed19c176d644ecf8f49e721ad33e5b4d49fc32cafb073ccf5b0b08cc9c
7
- data.tar.gz: bf246270c2651c86fa311ac72e02dd75c1ba03074286e254edfb6a99ae2dc59a1084e4317649d04cea31abf1c6b68908bf962d5b091a5a205d56830b138eb0ee
6
+ metadata.gz: 52bfdf8599bc77a418a96a3ed4e3e072c06c328a9597325d66b21419cfde80ade7475f3744870ad0413383d72154db9caea0158e5a2f82e2e7446f231b1eb800
7
+ data.tar.gz: b8f10cae326f757cf6fdbff6085db5d9302696109158046c19cca0d57aaad63f9d28e30509155e69fa3d26bcc48541e3276e04d21c27969425663177da32a3a5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.24
4
+
5
+ - New examples/basic_table_checkbox.rb
6
+ - Support table `checkbox_column`
7
+ - Improve support for table row deletion upon actual `cell_rows` deletion by handling multiple-row deletion not just single-row deletion
8
+
9
+ ## 0.0.23
10
+
11
+ - Have `image` not require `width` and `height` if it only has one `image_part` (defaults to `image_part` `width` and `height`)
12
+ - Upgrade to LibUI version 0.0.10
13
+
14
+ ## 0.0.22
15
+
16
+ - New examples/basic_table_button.rb
17
+ - Support table `button_column`
18
+ - Support table `button_column` `enabled` property
19
+ - Support `on_clicked` listener for `button_column`
20
+ - Support automatic table cell value reading management (table row deletion upon actual `cell_rows` deletion due to implicit data-binding)
21
+
22
+ ## 0.0.21
23
+
24
+ - New examples/editable_column_table_image_text.rb
25
+ - Support table `image_text_column`
26
+
3
27
  ## 0.0.20
4
28
 
5
29
  - New examples/editable_column_table.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.20
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
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.20](#-glimmer-dsl-for-libui-0020)
46
+ - [Glimmer DSL for LibUI 0.0.24](#-glimmer-dsl-for-libui-0024)
47
47
  - [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
48
48
  - [Usage](#usage)
49
49
  - [API](#api)
@@ -73,6 +73,9 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
73
73
  - [Editable Table](#editable-table)
74
74
  - [Editable Column Table](#editable-column-table)
75
75
  - [Basic Table Image](#basic-table-image)
76
+ - [Basic Table Image Text](#basic-table-image-text)
77
+ - [Basic Table Button](#basic-table-button)
78
+ - [Basic Table Checkbox](#basic-table-checkbox)
76
79
  - [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
77
80
  - [Help](#help)
78
81
  - [Issues](#issues)
@@ -160,7 +163,7 @@ gem install glimmer-dsl-libui
160
163
  Or install via Bundler `Gemfile`:
161
164
 
162
165
  ```ruby
163
- gem 'glimmer-dsl-libui', '~> 0.0.20'
166
+ gem 'glimmer-dsl-libui', '~> 0.0.24'
164
167
  ```
165
168
 
166
169
  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.
@@ -217,7 +220,9 @@ Control(Args) | Properties | Listeners
217
220
  ------------- | ---------- | ---------
218
221
  `about_menu_item` | None | `on_clicked`
219
222
  `button(text as String)` | `text` (`String`) | `on_clicked`
223
+ `button_column(name as String)` | `enabled` (Boolean) | None
220
224
  `checkbox(text as String)` | `checked` (Boolean), `text` (`String`) | `on_toggled`
225
+ `checkbox_column(name as String)` | None | None
221
226
  `combobox` | `items` (`Array` of `String`), `selected` (`Integer`) | `on_selected`
222
227
  `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`
223
228
  `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`
@@ -233,6 +238,7 @@ Control(Args) | Properties | Listeners
233
238
  `image(width as Numeric, height as Numeric)` | None | None
234
239
  `image_part(pixels as String [encoded image rgba byte array], width as Numeric, height as Numeric, byte_stride as Numeric [usually width*4])` | None | None
235
240
  `image_column(name as String)` | None | None
241
+ `image_text_column(name as String)` | None | None
236
242
  `label(text as String)` | `text` (`String`) | None
237
243
  `menu(text as String)` | None | None
238
244
  `menu_item(text as String)` | `checked` (Boolean) | `on_clicked`
@@ -248,7 +254,7 @@ Control(Args) | Properties | Listeners
248
254
  `spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
249
255
  `tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
250
256
  `tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
251
- `table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values)), `editable` as Boolean | None
257
+ `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
252
258
  `text_column(name as String)` | `editable` as Boolean | None
253
259
  `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`
254
260
  `vertical_box` | `padded` (Boolean) | None
@@ -316,7 +322,9 @@ Control(Args) | Properties | Listeners
316
322
  - Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
317
323
  - 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`)
318
324
  - 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.
319
326
  - `image` instances are automatically freed from memory after `window` is destroyed.
327
+ - `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`
320
328
 
321
329
  ### API Gotchas
322
330
 
@@ -1805,7 +1813,7 @@ data = [
1805
1813
  %w[cat meow],
1806
1814
  %w[dog woof],
1807
1815
  %w[checken cock-a-doodle-doo],
1808
- %w[hourse neigh],
1816
+ %w[horse neigh],
1809
1817
  %w[cow moo]
1810
1818
  ]
1811
1819
 
@@ -1863,7 +1871,7 @@ data = [
1863
1871
  %w[cat meow],
1864
1872
  %w[dog woof],
1865
1873
  %w[chicken cock-a-doodle-doo],
1866
- %w[hourse neigh],
1874
+ %w[horse neigh],
1867
1875
  %w[cow moo]
1868
1876
  ]
1869
1877
 
@@ -1922,7 +1930,7 @@ data = [
1922
1930
  %w[cat meow],
1923
1931
  %w[dog woof],
1924
1932
  %w[chicken cock-a-doodle-doo],
1925
- %w[hourse neigh],
1933
+ %w[horse neigh],
1926
1934
  %w[cow moo]
1927
1935
  ]
1928
1936
 
@@ -1980,7 +1988,7 @@ data = [
1980
1988
  %w[cat calm meow],
1981
1989
  %w[dog loyal woof],
1982
1990
  %w[chicken bird cock-a-doodle-doo],
1983
- %w[hourse fast neigh],
1991
+ %w[horse fast neigh],
1984
1992
  %w[cow slow moo]
1985
1993
  ]
1986
1994
 
@@ -2138,7 +2146,7 @@ IMAGE_ROWS = []
2138
2146
  data = canvas.to_rgba_stream
2139
2147
  width = canvas.width
2140
2148
  height = canvas.height
2141
- img = image(width, height) {
2149
+ img = image {
2142
2150
  image_part(data, width, height, width * 4)
2143
2151
  }
2144
2152
  IMAGE_ROWS << [img] # array of one column cell
@@ -2161,6 +2169,194 @@ window('The Red Turtle', 310, 350, false) {
2161
2169
  }.show
2162
2170
  ```
2163
2171
 
2172
+ ### Basic Table Image Text
2173
+
2174
+ This example has a prerequisite of installing `chunky_png` Ruby gem:
2175
+
2176
+ ```
2177
+ gem install chunky_png -v1.4.0
2178
+ ```
2179
+
2180
+ Also, note that behavior varies per platform (i.e. how `table` chooses to size images by default).
2181
+
2182
+ [examples/basic_table_image_text.rb](examples/basic_table_image_text.rb)
2183
+
2184
+ Run with this command from the root of the project if you cloned the project:
2185
+
2186
+ ```
2187
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_image_text.rb
2188
+ ```
2189
+
2190
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2191
+
2192
+ ```
2193
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_image_text'"
2194
+ ```
2195
+
2196
+ Mac
2197
+
2198
+ ![glimmer-dsl-libui-mac-basic-table-image-text.png](images/glimmer-dsl-libui-mac-basic-table-image-text.png)
2199
+
2200
+ Linux
2201
+
2202
+ ![glimmer-dsl-libui-linux-basic-table-image-text.png](images/glimmer-dsl-libui-linux-basic-table-image-text.png)
2203
+
2204
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2205
+
2206
+ ```ruby
2207
+ # NOTE:
2208
+ # This example displays images that can be freely downloaded from the Studio Ghibli website.
2209
+
2210
+ require 'glimmer-dsl-libui'
2211
+ require 'chunky_png'
2212
+ require 'open-uri'
2213
+
2214
+ include Glimmer
2215
+
2216
+ IMAGE_ROWS = []
2217
+
2218
+ 5.times do |i|
2219
+ url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
2220
+ puts "Processing Image: #{url}"
2221
+ f = URI.open(url)
2222
+ canvas = ChunkyPNG::Canvas.from_io(f)
2223
+ f.close
2224
+ data = canvas.to_rgba_stream
2225
+ width = canvas.width
2226
+ height = canvas.height
2227
+ img = image {
2228
+ image_part(data, width, height, width * 4)
2229
+ }
2230
+ text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
2231
+ IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
2232
+ rescue StandardError => e
2233
+ warn url, e.message
2234
+ end
2235
+
2236
+ window('The Red Turtle', 670, 350) {
2237
+ horizontal_box {
2238
+ table {
2239
+ image_text_column('image/number')
2240
+ image_text_column('image/number (editable)') {
2241
+ editable true
2242
+ }
2243
+
2244
+ cell_rows IMAGE_ROWS
2245
+ }
2246
+ }
2247
+ }.show
2248
+ ```
2249
+
2250
+ ### Basic Table Button
2251
+
2252
+ [examples/basic_table_button.rb](examples/basic_table_button.rb)
2253
+
2254
+ Run with this command from the root of the project if you cloned the project:
2255
+
2256
+ ```
2257
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_button.rb
2258
+ ```
2259
+
2260
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2261
+
2262
+ ```
2263
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_button'"
2264
+ ```
2265
+
2266
+ Mac
2267
+
2268
+ ![glimmer-dsl-libui-mac-basic-table-button.png](images/glimmer-dsl-libui-mac-basic-table-button.png)
2269
+ ![glimmer-dsl-libui-mac-basic-table-button-deleted.png](images/glimmer-dsl-libui-mac-basic-table-button-deleted.png)
2270
+
2271
+ Linux
2272
+
2273
+ ![glimmer-dsl-libui-linux-basic-table-button.png](images/glimmer-dsl-libui-linux-basic-table-button.png)
2274
+ ![glimmer-dsl-libui-linux-basic-table-button-deleted.png](images/glimmer-dsl-libui-linux-basic-table-button-deleted.png)
2275
+
2276
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2277
+
2278
+ ```ruby
2279
+ require 'glimmer-dsl-libui'
2280
+
2281
+ include Glimmer
2282
+
2283
+ data = [
2284
+ %w[cat meow delete],
2285
+ %w[dog woof delete],
2286
+ %w[chicken cock-a-doodle-doo delete],
2287
+ %w[horse neigh delete],
2288
+ %w[cow moo delete]
2289
+ ]
2290
+
2291
+ window('Animal sounds', 300, 200) {
2292
+ horizontal_box {
2293
+ table {
2294
+ text_column('Animal')
2295
+ text_column('Description')
2296
+ button_column('Action') {
2297
+ on_clicked do |row|
2298
+ data.delete_at(row) # automatically deletes actual table row due to implicit data-binding
2299
+ end
2300
+ }
2301
+
2302
+ cell_rows data # implicit data-binding
2303
+ }
2304
+ }
2305
+ }.show
2306
+ ```
2307
+
2308
+ ### Basic Table Checkbox
2309
+
2310
+ [examples/basic_table_checkbox.rb](examples/basic_table_checkbox.rb)
2311
+
2312
+ Run with this command from the root of the project if you cloned the project:
2313
+
2314
+ ```
2315
+ ruby -r './lib/glimmer-dsl-libui' examples/basic_table_checkbox.rb
2316
+ ```
2317
+
2318
+ Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
2319
+
2320
+ ```
2321
+ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_checkbox'"
2322
+ ```
2323
+
2324
+ Mac
2325
+
2326
+ ![glimmer-dsl-libui-mac-basic-table-checkbox.png](images/glimmer-dsl-libui-mac-basic-table-checkbox.png)
2327
+
2328
+ Linux
2329
+
2330
+ ![glimmer-dsl-libui-linux-basic-table-checkbox.png](images/glimmer-dsl-libui-linux-basic-table-checkbox.png)
2331
+
2332
+ New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
2333
+
2334
+ ```ruby
2335
+ require 'glimmer-dsl-libui'
2336
+
2337
+ include Glimmer
2338
+
2339
+ data = [
2340
+ ['cat', 'meow', true],
2341
+ ['dog', 'woof', true],
2342
+ ['chicken', 'cock-a-doodle-doo', false],
2343
+ ['horse', 'neigh', true],
2344
+ ['cow', 'moo', true]
2345
+ ]
2346
+
2347
+ window('Animal sounds', 300, 200) {
2348
+ horizontal_box {
2349
+ table {
2350
+ text_column('Animal')
2351
+ text_column('Description')
2352
+ checkbox_column('Mammal')
2353
+
2354
+ cell_rows data
2355
+ }
2356
+ }
2357
+ }.show
2358
+ ```
2359
+
2164
2360
  ## Contributing to glimmer-dsl-libui
2165
2361
 
2166
2362
  - Check out the latest master to make sure the feature hasn't been
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.20
1
+ 0.0.24
@@ -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,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+
5
+ include Glimmer
6
+
7
+ data = [
8
+ %w[cat meow delete],
9
+ %w[dog woof delete],
10
+ %w[chicken cock-a-doodle-doo delete],
11
+ %w[horse neigh delete],
12
+ %w[cow moo delete]
13
+ ]
14
+
15
+ window('Animal sounds', 300, 200) {
16
+ horizontal_box {
17
+ table {
18
+ text_column('Animal')
19
+ text_column('Description')
20
+ button_column('Action') {
21
+ on_clicked do |row|
22
+ data.delete_at(row) # automatically deletes actual table row due to implicit data-binding
23
+ end
24
+ }
25
+
26
+ cell_rows data # implicit data-binding
27
+ }
28
+ }
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
@@ -20,7 +20,7 @@ IMAGE_ROWS = []
20
20
  data = canvas.to_rgba_stream
21
21
  width = canvas.width
22
22
  height = canvas.height
23
- img = image(width, height) {
23
+ img = image {
24
24
  image_part(data, width, height, width * 4)
25
25
  }
26
26
  IMAGE_ROWS << [img] # array of one column cell
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ # NOTE:
4
+ # This example displays images that can be freely downloaded from the Studio Ghibli website.
5
+
6
+ require 'glimmer-dsl-libui'
7
+ require 'chunky_png'
8
+ require 'open-uri'
9
+
10
+ include Glimmer
11
+
12
+ IMAGE_ROWS = []
13
+
14
+ 5.times do |i|
15
+ url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
16
+ puts "Processing Image: #{url}"
17
+ f = URI.open(url)
18
+ canvas = ChunkyPNG::Canvas.from_io(f)
19
+ f.close
20
+ data = canvas.to_rgba_stream
21
+ width = canvas.width
22
+ height = canvas.height
23
+ img = image {
24
+ image_part(data, width, height, width * 4)
25
+ }
26
+ text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
27
+ IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
28
+ rescue StandardError => e
29
+ warn url, e.message
30
+ end
31
+
32
+ window('The Red Turtle', 670, 350) {
33
+ horizontal_box {
34
+ table {
35
+ image_text_column('image/number')
36
+ image_text_column('image/number (editable)') {
37
+ editable true
38
+ }
39
+
40
+ cell_rows IMAGE_ROWS
41
+ }
42
+ }
43
+ }.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
 
Binary file
@@ -35,10 +35,6 @@ module Glimmer
35
35
  module Libui
36
36
  Engine.add_dynamic_expressions(
37
37
  Libui,
38
- # list_selection_data_binding
39
- # data_binding
40
- # block_attribute
41
- # attribute
42
38
  %w[
43
39
  listener
44
40
  property
@@ -0,0 +1,67 @@
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/enableable_column'
25
+
26
+ module Glimmer
27
+ module LibUI
28
+ # Proxy for LibUI button column objects
29
+ #
30
+ # Follows the Proxy Design Pattern
31
+ class ButtonColumnProxy < ControlProxy
32
+ include Column
33
+ include EnableableColumn
34
+
35
+ def on_clicked(&block)
36
+ # TODO consider generalizing into custom listeners and moving to ControlProxy
37
+ @on_clicked_procs ||= []
38
+ @on_clicked_procs << block
39
+ end
40
+
41
+ def can_handle_listener?(listener_name)
42
+ listener_name == 'on_clicked' || super
43
+ end
44
+
45
+ def handle_listener(listener_name, &listener)
46
+ case listener_name
47
+ when 'on_clicked'
48
+ on_clicked(&listener)
49
+ else
50
+ super
51
+ end
52
+ end
53
+
54
+ def notify_listeners(listener_name, *args)
55
+ @on_clicked_procs&.each do |on_clicked_proc|
56
+ on_clicked_proc.call(*args)
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ def build_control
63
+ @parent_proxy.append_button_column(name, column_index, enabled_value)
64
+ end
65
+ end
66
+ end
67
+ end
@@ -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
@@ -19,15 +19,10 @@
19
19
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
- require 'glimmer/libui/control_proxy'
23
-
24
22
  module Glimmer
25
23
  module LibUI
26
24
  # Common logic for all column proxy objects
27
25
  module Column
28
- attr_reader :appended
29
- alias appended? appended
30
-
31
26
  def initialize(keyword, parent, args, &block)
32
27
  @keyword = keyword
33
28
  @parent_proxy = parent
@@ -41,14 +36,15 @@ module Glimmer
41
36
  @args.first
42
37
  end
43
38
 
44
- private
45
-
46
- def build_control
47
- @appended = true
39
+ # column index used in table append column API call
40
+ # expanded to ensure DualColumn index accounts for two columns acting as one
41
+ def column_index
42
+ @column_index ||= @parent_proxy.send(:next_column_index)
48
43
  end
49
44
 
50
- def next_column_index
51
- @parent_proxy.columns.map(&:appended?).compact.count
45
+ # actual index within table columns (disregarding nil fillings that account for DualColumn instances)
46
+ def index
47
+ @parent_proxy.columns.compact.index(self)
52
48
  end
53
49
  end
54
50
  end
@@ -0,0 +1,38 @@
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
+ module Glimmer
23
+ module LibUI
24
+ # A dual column is one that represents two values (e.g. image and text or checkbox and text)
25
+ # It is meant to be included in a column proxy class that already includes Column
26
+ module DualColumn
27
+ def second_column_index
28
+ column_index + 1
29
+ end
30
+
31
+ def column_index
32
+ @column_index ||= @parent_proxy.send(:next_column_index).tap do
33
+ @parent_proxy.send(:next_column_index)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ 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
+ module Glimmer
23
+ module LibUI
24
+ module EditableColumn
25
+ def editable(value = nil)
26
+ if value.nil?
27
+ @editable = false if @editable.nil?
28
+ @editable
29
+ else
30
+ @editable = !!value
31
+ end
32
+ end
33
+ alias editable= editable
34
+ alias set_editable editable
35
+ alias editable? editable
36
+
37
+ private
38
+
39
+ def editable_value
40
+ (@parent_proxy.editable? || editable?) ? -2 : -1
41
+ end
42
+ end
43
+ end
44
+ 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
+ module Glimmer
23
+ module LibUI
24
+ module EnableableColumn
25
+ def enabled(value = nil)
26
+ if value.nil?
27
+ @enabled = true if @enabled.nil?
28
+ @enabled
29
+ else
30
+ @enabled = !!value
31
+ end
32
+ end
33
+ alias enabled= enabled
34
+ alias set_enabled enabled
35
+ alias enabled? enabled
36
+
37
+ private
38
+
39
+ def enabled_value
40
+ enabled? ? -2 : -1
41
+ end
42
+ end
43
+ end
44
+ end
@@ -33,8 +33,7 @@ module Glimmer
33
33
  private
34
34
 
35
35
  def build_control
36
- @parent_proxy.append_image_column(name, next_column_index)
37
- super
36
+ @parent_proxy.append_image_column(name, column_index)
38
37
  end
39
38
  end
40
39
  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,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 image text column objects
30
+ #
31
+ # Follows the Proxy Design Pattern
32
+ class ImageTextColumnProxy < ControlProxy
33
+ include Column
34
+ include DualColumn
35
+ include EditableColumn
36
+
37
+ private
38
+
39
+ def build_control
40
+ @parent_proxy.append_image_text_column(name, column_index, second_column_index, editable_value)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -20,6 +20,9 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/libui/control_proxy'
23
+ require 'glimmer/data_binding/observer'
24
+
25
+ using ArrayIncludeMethods
23
26
 
24
27
  module Glimmer
25
28
  module LibUI
@@ -50,6 +53,8 @@ module Glimmer
50
53
 
51
54
  def post_initialize_child(child)
52
55
  @columns << child
56
+ # add an extra complementary nil column if it is a dual column (i.e. ImageTextColumnProxy or CheckboxTextColumnProxy
57
+ @columns << nil if child.is_a?(DualColumn)
53
58
  end
54
59
 
55
60
  def destroy
@@ -61,13 +66,29 @@ module Glimmer
61
66
  if rows.nil?
62
67
  @cell_rows
63
68
  else
64
- rows = rows.map {|row| row.map {|cell| cell.respond_to?(:libui) ? cell.libui : cell }}
65
69
  @cell_rows = rows
70
+ @cell_rows.tap do
71
+ @last_cell_rows = @cell_rows.clone
72
+ Glimmer::DataBinding::Observer.proc do
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
+ end
78
+ @last_cell_rows = @cell_rows.clone
79
+ end.observe(self, :cell_rows)
80
+ end
66
81
  end
67
82
  end
68
83
  alias cell_rows= cell_rows
69
84
  alias set_cell_rows cell_rows
70
85
 
86
+ def expanded_cell_rows
87
+ cell_rows.map do |row|
88
+ row.flatten(1)
89
+ end
90
+ end
91
+
71
92
  def editable(value = nil)
72
93
  if value.nil?
73
94
  @editable
@@ -83,31 +104,48 @@ module Glimmer
83
104
 
84
105
  def build_control
85
106
  @model_handler = ::LibUI::FFI::TableModelHandler.malloc
86
- @model_handler.NumColumns = rbcallback(4) { @columns.count }
87
- @model_handler.ColumnType = rbcallback(4) do
88
- # Note: this assumes all columns are the same type
89
- # TODO support different values per different columns
90
- case @columns.first
91
- when TextColumnProxy
107
+ @model_handler.NumColumns = rbcallback(4) { @columns.map {|c| c.is_a?(DualColumn) ? 2 : 1}.sum }
108
+ @model_handler.ColumnType = rbcallback(4, [1, 1, 4]) do |_, _, column|
109
+ case @columns[column]
110
+ when TextColumnProxy, ButtonColumnProxy, NilClass
92
111
  0
93
- when ImageColumnProxy
112
+ when ImageColumnProxy, ImageTextColumnProxy
94
113
  1
114
+ when CheckboxColumnProxy
115
+ 2
116
+ # when CheckboxTextColumnProxy
117
+ # 2
118
+ # when ProgressBarColumnProxy
119
+ # 2
95
120
  end
96
121
  end
97
122
  @model_handler.NumRows = rbcallback(4) { cell_rows.count }
98
123
  @model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
124
+ the_cell_rows = expanded_cell_rows
99
125
  case @columns[column]
100
- when TextColumnProxy
101
- ::LibUI.new_table_value_string((@cell_rows[row] && @cell_rows[row][column]).to_s)
102
- when ImageColumnProxy
103
- ::LibUI.new_table_value_image((@cell_rows[row] && @cell_rows[row][column]))
126
+ when TextColumnProxy, ButtonColumnProxy, NilClass
127
+ ::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
128
+ when ImageColumnProxy, ImageTextColumnProxy
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
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)))
104
132
  end
105
133
  end
106
134
  @model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
107
135
  case @columns[column]
108
136
  when TextColumnProxy
137
+ column = @columns[column].index
109
138
  @cell_rows[row] ||= []
110
139
  @cell_rows[row][column] = ::LibUI.table_value_string(val).to_s
140
+ when NilClass
141
+ column = @columns[column - 1].index
142
+ @cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
143
+ when ButtonColumnProxy
144
+ @columns[column].notify_listeners(:on_clicked, row)
145
+ when CheckboxColumnProxy
146
+ column = @columns[column].index
147
+ @cell_rows[row] ||= []
148
+ @cell_rows[row][column] = ::LibUI.table_value_int(val).to_i == 1
111
149
  end
112
150
  end
113
151
 
@@ -119,7 +157,7 @@ module Glimmer
119
157
 
120
158
  @libui = ControlProxy.new_control(@keyword, [@table_params])
121
159
  @libui.tap do
122
- @columns.each {|column| column.send(:build_control) }
160
+ @columns.each {|column| column&.send(:build_control) }
123
161
  end
124
162
  end
125
163
 
@@ -133,6 +171,11 @@ module Glimmer
133
171
  blockcaller
134
172
  end
135
173
 
174
+ def next_column_index
175
+ @next_column_index ||= -1
176
+ @next_column_index += 1
177
+ end
178
+
136
179
  end
137
180
  end
138
181
  end
@@ -21,6 +21,7 @@
21
21
 
22
22
  require 'glimmer/libui/control_proxy'
23
23
  require 'glimmer/libui/column'
24
+ require 'glimmer/libui/editable_column'
24
25
 
25
26
  module Glimmer
26
27
  module LibUI
@@ -29,23 +30,12 @@ module Glimmer
29
30
  # Follows the Proxy Design Pattern
30
31
  class TextColumnProxy < ControlProxy
31
32
  include Column
32
-
33
- def editable(value = nil)
34
- if value.nil?
35
- @editable
36
- else
37
- @editable = !!value
38
- end
39
- end
40
- alias editable= editable
41
- alias set_editable editable
42
- alias editable? editable
33
+ include EditableColumn
43
34
 
44
35
  private
45
36
 
46
37
  def build_control
47
- @parent_proxy.append_text_column(name, next_column_index, @parent_proxy.editable? || editable? ? -2 : -1)
48
- super
38
+ @parent_proxy.append_text_column(name, column_index, editable_value)
49
39
  end
50
40
  end
51
41
  end
@@ -61,20 +61,29 @@ module Glimmer
61
61
  end
62
62
  end
63
63
 
64
+ def can_handle_listener?(listener_name)
65
+ listener_name == 'on_destroy' || super
66
+ end
67
+
64
68
  def handle_listener(listener_name, &listener)
65
- if listener_name == 'on_closing'
66
- default_behavior_listener = Proc.new do
67
- return_value = listener.call(self)
68
- if return_value.is_a?(Numeric)
69
- return_value
70
- else
71
- destroy
72
- ::LibUI.quit
73
- 0
69
+ case listener_name
70
+ when 'on_destroy'
71
+ on_destroy(&listener)
72
+ else
73
+ if listener_name == 'on_closing'
74
+ default_behavior_listener = Proc.new do
75
+ return_value = listener.call(self)
76
+ if return_value.is_a?(Numeric)
77
+ return_value
78
+ else
79
+ destroy
80
+ ::LibUI.quit
81
+ 0
82
+ end
74
83
  end
75
84
  end
85
+ super(listener_name, &default_behavior_listener)
76
86
  end
77
- super(listener_name, &default_behavior_listener)
78
87
  end
79
88
 
80
89
  private
@@ -27,6 +27,7 @@ require 'glimmer'
27
27
  # require 'puts_debuggerer' if ENV['pd'].to_s.downcase == 'true'
28
28
  # require 'super_module'
29
29
  require 'os'
30
+ require 'array_include_methods'
30
31
  require 'libui'
31
32
 
32
33
  # Internal requires
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.20
4
+ version: 0.0.24
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-24 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.2
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.2
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.9
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.9
60
+ version: 0.0.10
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: juwelier
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -197,7 +197,10 @@ files:
197
197
  - examples/basic_button.rb
198
198
  - examples/basic_entry.rb
199
199
  - examples/basic_table.rb
200
+ - examples/basic_table_button.rb
201
+ - examples/basic_table_checkbox.rb
200
202
  - examples/basic_table_image.rb
203
+ - examples/basic_table_image_text.rb
201
204
  - examples/basic_window.rb
202
205
  - examples/basic_window2.rb
203
206
  - examples/color_button.rb
@@ -223,8 +226,10 @@ files:
223
226
  - lib/glimmer/dsl/libui/tab_item_expression.rb
224
227
  - lib/glimmer/libui/about_menu_item_proxy.rb
225
228
  - lib/glimmer/libui/box.rb
229
+ - lib/glimmer/libui/button_column_proxy.rb
226
230
  - lib/glimmer/libui/button_proxy.rb
227
231
  - lib/glimmer/libui/check_menu_item_proxy.rb
232
+ - lib/glimmer/libui/checkbox_column_proxy.rb
228
233
  - lib/glimmer/libui/checkbox_proxy.rb
229
234
  - lib/glimmer/libui/color_button_proxy.rb
230
235
  - lib/glimmer/libui/column.rb
@@ -232,7 +237,10 @@ files:
232
237
  - lib/glimmer/libui/control_proxy.rb
233
238
  - lib/glimmer/libui/date_picker_proxy.rb
234
239
  - lib/glimmer/libui/date_time_picker_proxy.rb
240
+ - lib/glimmer/libui/dual_column.rb
241
+ - lib/glimmer/libui/editable_column.rb
235
242
  - lib/glimmer/libui/editable_combobox_proxy.rb
243
+ - lib/glimmer/libui/enableable_column.rb
236
244
  - lib/glimmer/libui/font_button_proxy.rb
237
245
  - lib/glimmer/libui/form_proxy.rb
238
246
  - lib/glimmer/libui/grid_proxy.rb
@@ -240,6 +248,8 @@ files:
240
248
  - lib/glimmer/libui/horizontal_box_proxy.rb
241
249
  - lib/glimmer/libui/image_column_proxy.rb
242
250
  - lib/glimmer/libui/image_part_proxy.rb
251
+ - lib/glimmer/libui/image_proxy.rb
252
+ - lib/glimmer/libui/image_text_column_proxy.rb
243
253
  - lib/glimmer/libui/label_proxy.rb
244
254
  - lib/glimmer/libui/menu_item_proxy.rb
245
255
  - lib/glimmer/libui/menu_proxy.rb