glimmer-dsl-libui 0.0.19 → 0.0.23
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 +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +210 -7
- data/VERSION +1 -1
- data/examples/basic_table_button.rb +33 -0
- data/examples/basic_table_image.rb +1 -1
- data/examples/basic_table_image_text.rb +43 -0
- data/examples/editable_column_table.rb +31 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/dsl.rb +0 -4
- data/lib/glimmer/libui/button_column_proxy.rb +67 -0
- data/lib/glimmer/libui/column.rb +7 -11
- data/lib/glimmer/libui/dual_column.rb +38 -0
- data/lib/glimmer/libui/editable_column.rb +44 -0
- data/lib/glimmer/libui/enableable_column.rb +44 -0
- data/lib/glimmer/libui/image_column_proxy.rb +1 -2
- data/lib/glimmer/libui/image_part_proxy.rb +10 -0
- data/lib/glimmer/libui/image_proxy.rb +63 -0
- data/lib/glimmer/libui/image_text_column_proxy.rb +44 -0
- data/lib/glimmer/libui/table_proxy.rb +51 -13
- data/lib/glimmer/libui/text_column_proxy.rb +3 -2
- data/lib/glimmer/libui/window_proxy.rb +19 -10
- data/lib/glimmer-dsl-libui.rb +1 -0
- metadata +16 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e29a14b4e8c65eaaa7ffa9d1ef5a7e1d13a592cf5d1090e850525b8d9188450
|
4
|
+
data.tar.gz: 37f077425a3627fddd8047a052fa55c43b8b907160ddb406a821757b544c5d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2447933bbdce2b03660b8d9c4eb13736b4989eb2632288951ad836b3bd25f0e8fa7075d976b42da1df8a2495540302dd18c02c162abb08ab5a9cd5fad4c1378d
|
7
|
+
data.tar.gz: f5018929934e70c3364f29ac124626ac1d9502e748e4b98ec1f44cdc5dae63e3baf7d856aa56dc50bb044e2909d040fff1c812ca66706bba4fa53fd92efdc97c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.23
|
4
|
+
|
5
|
+
- Have `image` not require `width` and `height` if it only has one `image_part` (defaults to `image_part` `width` and `height`)
|
6
|
+
- Upgrade to LibUI version 0.0.10
|
7
|
+
|
8
|
+
## 0.0.22
|
9
|
+
|
10
|
+
- New examples/basic_table_button.rb
|
11
|
+
- Support table `button_column`
|
12
|
+
- Support table `button_column` `enabled` property
|
13
|
+
- Support `on_clicked` listener for `button_column`
|
14
|
+
- Support automatic table cell value reading management (table row deletion upon actual `cell_rows` deletion due to implicit data-binding)
|
15
|
+
|
16
|
+
## 0.0.21
|
17
|
+
|
18
|
+
- New examples/editable_column_table_image_text.rb
|
19
|
+
- Support table `image_text_column`
|
20
|
+
|
21
|
+
## 0.0.20
|
22
|
+
|
23
|
+
- New examples/editable_column_table.rb
|
24
|
+
- Support `editable` property for `text_column`
|
25
|
+
|
3
26
|
## 0.0.19
|
4
27
|
|
5
28
|
- New examples/editable_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.
|
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
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
4
4
|
[](https://codeclimate.com/github/AndyObtiva/glimmer-dsl-libui/maintainability)
|
@@ -43,7 +43,7 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
43
43
|
|
44
44
|
## Table of Contents
|
45
45
|
|
46
|
-
- [Glimmer DSL for LibUI 0.0.
|
46
|
+
- [Glimmer DSL for LibUI 0.0.23](#-glimmer-dsl-for-libui-0023)
|
47
47
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
48
48
|
- [Usage](#usage)
|
49
49
|
- [API](#api)
|
@@ -70,6 +70,11 @@ Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interes
|
|
70
70
|
- [Grid](#grid)
|
71
71
|
- [Form](#form)
|
72
72
|
- [Basic Table](#basic-table)
|
73
|
+
- [Editable Table](#editable-table)
|
74
|
+
- [Editable Column Table](#editable-column-table)
|
75
|
+
- [Basic Table Image](#basic-table-image)
|
76
|
+
- [Basic Table Image Text](#basic-table-image-text)
|
77
|
+
- [Basic Table Button](#basic-table-button)
|
73
78
|
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
74
79
|
- [Help](#help)
|
75
80
|
- [Issues](#issues)
|
@@ -157,7 +162,7 @@ gem install glimmer-dsl-libui
|
|
157
162
|
Or install via Bundler `Gemfile`:
|
158
163
|
|
159
164
|
```ruby
|
160
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
165
|
+
gem 'glimmer-dsl-libui', '~> 0.0.23'
|
161
166
|
```
|
162
167
|
|
163
168
|
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.
|
@@ -230,6 +235,7 @@ Control(Args) | Properties | Listeners
|
|
230
235
|
`image(width as Numeric, height as Numeric)` | None | None
|
231
236
|
`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
|
232
237
|
`image_column(name as String)` | None | None
|
238
|
+
`image_text_column(name as String)` | None | None
|
233
239
|
`label(text as String)` | `text` (`String`) | None
|
234
240
|
`menu(text as String)` | None | None
|
235
241
|
`menu_item(text as String)` | `checked` (Boolean) | `on_clicked`
|
@@ -245,8 +251,8 @@ Control(Args) | Properties | Listeners
|
|
245
251
|
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
246
252
|
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
247
253
|
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
|
248
|
-
`table` | `cell_rows` (`Array` (rows) of `Arrays` (row columns) of cell values (e.g. `String` values)), `editable` as Boolean | None
|
249
|
-
`text_column(name as String)` |
|
254
|
+
`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
|
250
256
|
`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`
|
251
257
|
`vertical_box` | `padded` (Boolean) | None
|
252
258
|
`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`
|
@@ -311,9 +317,11 @@ Control(Args) | Properties | Listeners
|
|
311
317
|
- When destroying a control nested under a `window` or `group`, it is automatically unset as their child to allow successful destruction
|
312
318
|
- For `date_time_picker`, `date_picker`, and `time_picker`, make sure `time` hash values for `mon`, `wday`, and `yday` are 1-based instead of [libui](https://github.com/andlabs/libui) original 0-based values, and return `dst` as Boolean instead of `isdst` as `1`/`0`
|
313
319
|
- Smart defaults for `grid` child attributes are `left` (`0`), `top` (`0`), `xspan` (`1`), `yspan` (`1`), `hexpand` (`false`), `halign` (`0`), `vexpand` (`false`), and `valign` (`0`)
|
314
|
-
- The `table` control automatically constructs required `TableModelHandler`, `TableModel`, and `TableParams`, calculating all their arguments from `cell_rows`
|
320
|
+
- 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`)
|
315
321
|
- 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.
|
316
323
|
- `image` instances are automatically freed from memory after `window` is destroyed.
|
324
|
+
- `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`
|
317
325
|
|
318
326
|
### API Gotchas
|
319
327
|
|
@@ -1940,6 +1948,65 @@ window('Editable animal sounds', 300, 200) {
|
|
1940
1948
|
}.show
|
1941
1949
|
```
|
1942
1950
|
|
1951
|
+
### Editable Column Table
|
1952
|
+
|
1953
|
+
[examples/editable_column_table.rb](examples/editable_column_table.rb)
|
1954
|
+
|
1955
|
+
Run with this command from the root of the project if you cloned the project:
|
1956
|
+
|
1957
|
+
```
|
1958
|
+
ruby -r './lib/glimmer-dsl-libui' examples/editable_column_table.rb
|
1959
|
+
```
|
1960
|
+
|
1961
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1962
|
+
|
1963
|
+
```
|
1964
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/editable_column_table'"
|
1965
|
+
```
|
1966
|
+
|
1967
|
+
Mac
|
1968
|
+
|
1969
|
+

|
1970
|
+

|
1971
|
+
|
1972
|
+
Linux
|
1973
|
+
|
1974
|
+

|
1975
|
+

|
1976
|
+
|
1977
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1978
|
+
|
1979
|
+
```ruby
|
1980
|
+
require 'glimmer-dsl-libui'
|
1981
|
+
|
1982
|
+
include Glimmer
|
1983
|
+
|
1984
|
+
data = [
|
1985
|
+
%w[cat calm meow],
|
1986
|
+
%w[dog loyal woof],
|
1987
|
+
%w[chicken bird cock-a-doodle-doo],
|
1988
|
+
%w[hourse fast neigh],
|
1989
|
+
%w[cow slow moo]
|
1990
|
+
]
|
1991
|
+
|
1992
|
+
window('Editable column animal sounds', 400, 200) {
|
1993
|
+
horizontal_box {
|
1994
|
+
table {
|
1995
|
+
text_column('Animal')
|
1996
|
+
text_column('Description')
|
1997
|
+
text_column('Sound (Editable)') {
|
1998
|
+
editable true
|
1999
|
+
}
|
2000
|
+
|
2001
|
+
cell_rows data
|
2002
|
+
}
|
2003
|
+
}
|
2004
|
+
|
2005
|
+
on_closing do
|
2006
|
+
puts 'Bye Bye'
|
2007
|
+
end
|
2008
|
+
}.show
|
2009
|
+
```
|
1943
2010
|
|
1944
2011
|
### Basic Table Image
|
1945
2012
|
|
@@ -2076,7 +2143,7 @@ IMAGE_ROWS = []
|
|
2076
2143
|
data = canvas.to_rgba_stream
|
2077
2144
|
width = canvas.width
|
2078
2145
|
height = canvas.height
|
2079
|
-
img = image
|
2146
|
+
img = image {
|
2080
2147
|
image_part(data, width, height, width * 4)
|
2081
2148
|
}
|
2082
2149
|
IMAGE_ROWS << [img] # array of one column cell
|
@@ -2099,6 +2166,142 @@ window('The Red Turtle', 310, 350, false) {
|
|
2099
2166
|
}.show
|
2100
2167
|
```
|
2101
2168
|
|
2169
|
+
### Basic Table Image Text
|
2170
|
+
|
2171
|
+
This example has a prerequisite of installing `chunky_png` Ruby gem:
|
2172
|
+
|
2173
|
+
```
|
2174
|
+
gem install chunky_png -v1.4.0
|
2175
|
+
```
|
2176
|
+
|
2177
|
+
Also, note that behavior varies per platform (i.e. how `table` chooses to size images by default).
|
2178
|
+
|
2179
|
+
[examples/basic_table_image_text.rb](examples/basic_table_image_text.rb)
|
2180
|
+
|
2181
|
+
Run with this command from the root of the project if you cloned the project:
|
2182
|
+
|
2183
|
+
```
|
2184
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_image_text.rb
|
2185
|
+
```
|
2186
|
+
|
2187
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
2188
|
+
|
2189
|
+
```
|
2190
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_image_text'"
|
2191
|
+
```
|
2192
|
+
|
2193
|
+
Mac
|
2194
|
+
|
2195
|
+

|
2196
|
+
|
2197
|
+
Linux
|
2198
|
+
|
2199
|
+

|
2200
|
+
|
2201
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2202
|
+
|
2203
|
+
```ruby
|
2204
|
+
# NOTE:
|
2205
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
2206
|
+
|
2207
|
+
require 'glimmer-dsl-libui'
|
2208
|
+
require 'chunky_png'
|
2209
|
+
require 'open-uri'
|
2210
|
+
|
2211
|
+
include Glimmer
|
2212
|
+
|
2213
|
+
IMAGE_ROWS = []
|
2214
|
+
|
2215
|
+
5.times do |i|
|
2216
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
2217
|
+
puts "Processing Image: #{url}"
|
2218
|
+
f = URI.open(url)
|
2219
|
+
canvas = ChunkyPNG::Canvas.from_io(f)
|
2220
|
+
f.close
|
2221
|
+
data = canvas.to_rgba_stream
|
2222
|
+
width = canvas.width
|
2223
|
+
height = canvas.height
|
2224
|
+
img = image {
|
2225
|
+
image_part(data, width, height, width * 4)
|
2226
|
+
}
|
2227
|
+
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
2228
|
+
IMAGE_ROWS << [[img, text], [img, text]] # cell values are dual-element arrays
|
2229
|
+
rescue StandardError => e
|
2230
|
+
warn url, e.message
|
2231
|
+
end
|
2232
|
+
|
2233
|
+
window('The Red Turtle', 670, 350) {
|
2234
|
+
horizontal_box {
|
2235
|
+
table {
|
2236
|
+
image_text_column('image/number')
|
2237
|
+
image_text_column('image/number (editable)') {
|
2238
|
+
editable true
|
2239
|
+
}
|
2240
|
+
|
2241
|
+
cell_rows IMAGE_ROWS
|
2242
|
+
}
|
2243
|
+
}
|
2244
|
+
}.show
|
2245
|
+
```
|
2246
|
+
|
2247
|
+
### Basic Table Button
|
2248
|
+
|
2249
|
+
[examples/basic_table_button.rb](examples/basic_table_button.rb)
|
2250
|
+
|
2251
|
+
Run with this command from the root of the project if you cloned the project:
|
2252
|
+
|
2253
|
+
```
|
2254
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_button.rb
|
2255
|
+
```
|
2256
|
+
|
2257
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
2258
|
+
|
2259
|
+
```
|
2260
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_button'"
|
2261
|
+
```
|
2262
|
+
|
2263
|
+
Mac
|
2264
|
+
|
2265
|
+

|
2266
|
+

|
2267
|
+
|
2268
|
+
Linux
|
2269
|
+
|
2270
|
+

|
2271
|
+

|
2272
|
+
|
2273
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2274
|
+
|
2275
|
+
```ruby
|
2276
|
+
require 'glimmer-dsl-libui'
|
2277
|
+
|
2278
|
+
include Glimmer
|
2279
|
+
|
2280
|
+
data = [
|
2281
|
+
%w[cat meow delete],
|
2282
|
+
%w[dog woof delete],
|
2283
|
+
%w[chicken cock-a-doodle-doo delete],
|
2284
|
+
%w[hourse neigh delete],
|
2285
|
+
%w[cow moo delete]
|
2286
|
+
]
|
2287
|
+
|
2288
|
+
window('Animal sounds', 300, 200) {
|
2289
|
+
horizontal_box {
|
2290
|
+
table {
|
2291
|
+
text_column('Animal')
|
2292
|
+
text_column('Description')
|
2293
|
+
button_column('Action') {
|
2294
|
+
on_clicked do |row|
|
2295
|
+
data.delete_at(row) # automatically deletes actual table row due to implicit data-binding
|
2296
|
+
end
|
2297
|
+
}
|
2298
|
+
|
2299
|
+
cell_rows data # implicit data-binding
|
2300
|
+
}
|
2301
|
+
}
|
2302
|
+
}.show
|
2303
|
+
```
|
2304
|
+
|
2102
2305
|
## Contributing to glimmer-dsl-libui
|
2103
2306
|
|
2104
2307
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.23
|
@@ -0,0 +1,33 @@
|
|
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[hourse 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
|
+
|
30
|
+
on_closing do
|
31
|
+
puts 'Bye Bye'
|
32
|
+
end
|
33
|
+
}.show
|
@@ -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
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
data = [
|
8
|
+
%w[cat calm meow],
|
9
|
+
%w[dog loyal woof],
|
10
|
+
%w[chicken bird cock-a-doodle-doo],
|
11
|
+
%w[hourse fast neigh],
|
12
|
+
%w[cow slow moo]
|
13
|
+
]
|
14
|
+
|
15
|
+
window('Editable column animal sounds', 400, 200) {
|
16
|
+
horizontal_box {
|
17
|
+
table {
|
18
|
+
text_column('Animal')
|
19
|
+
text_column('Description')
|
20
|
+
text_column('Sound (Editable)') {
|
21
|
+
editable true
|
22
|
+
}
|
23
|
+
|
24
|
+
cell_rows data
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
on_closing do
|
29
|
+
puts 'Bye Bye'
|
30
|
+
end
|
31
|
+
}.show
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -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
|
data/lib/glimmer/libui/column.rb
CHANGED
@@ -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
|
-
|
45
|
-
|
46
|
-
def
|
47
|
-
@
|
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
|
-
|
51
|
-
|
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
|
@@ -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,30 @@ 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 - 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)
|
76
|
+
end
|
77
|
+
::LibUI.table_model_row_deleted(model, row)
|
78
|
+
end
|
79
|
+
@last_cell_rows = @cell_rows.clone
|
80
|
+
end.observe(self, :cell_rows)
|
81
|
+
end
|
66
82
|
end
|
67
83
|
end
|
68
84
|
alias cell_rows= cell_rows
|
69
85
|
alias set_cell_rows cell_rows
|
70
86
|
|
87
|
+
def expanded_cell_rows
|
88
|
+
cell_rows.map do |row|
|
89
|
+
row.flatten(1)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
71
93
|
def editable(value = nil)
|
72
94
|
if value.nil?
|
73
95
|
@editable
|
@@ -83,31 +105,42 @@ module Glimmer
|
|
83
105
|
|
84
106
|
def build_control
|
85
107
|
@model_handler = ::LibUI::FFI::TableModelHandler.malloc
|
86
|
-
@model_handler.NumColumns = rbcallback(4) { @columns.
|
87
|
-
@model_handler.ColumnType = rbcallback(4) do
|
88
|
-
|
89
|
-
|
90
|
-
case @columns.first
|
91
|
-
when TextColumnProxy
|
108
|
+
@model_handler.NumColumns = rbcallback(4) { @columns.map {|c| c.is_a?(DualColumn) ? 2 : 1}.sum }
|
109
|
+
@model_handler.ColumnType = rbcallback(4, [1, 1, 4]) do |_, _, column|
|
110
|
+
case @columns[column]
|
111
|
+
when TextColumnProxy, ButtonColumnProxy, NilClass
|
92
112
|
0
|
93
|
-
when ImageColumnProxy
|
113
|
+
when ImageColumnProxy, ImageTextColumnProxy
|
94
114
|
1
|
115
|
+
# when CheckboxColumnProxy
|
116
|
+
# 2
|
117
|
+
# when CheckboxTextColumnProxy
|
118
|
+
# 2
|
119
|
+
# when ProgressBarColumnProxy
|
120
|
+
# 2
|
95
121
|
end
|
96
122
|
end
|
97
123
|
@model_handler.NumRows = rbcallback(4) { cell_rows.count }
|
98
124
|
@model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
|
125
|
+
the_cell_rows = expanded_cell_rows
|
99
126
|
case @columns[column]
|
100
|
-
when TextColumnProxy
|
101
|
-
::LibUI.new_table_value_string((
|
102
|
-
when ImageColumnProxy
|
103
|
-
::LibUI.new_table_value_image((
|
127
|
+
when TextColumnProxy, ButtonColumnProxy, NilClass
|
128
|
+
::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
|
129
|
+
when ImageColumnProxy, ImageTextColumnProxy
|
130
|
+
::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])))
|
104
131
|
end
|
105
132
|
end
|
106
133
|
@model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
|
107
134
|
case @columns[column]
|
108
135
|
when TextColumnProxy
|
136
|
+
column = @columns[column].index
|
109
137
|
@cell_rows[row] ||= []
|
110
138
|
@cell_rows[row][column] = ::LibUI.table_value_string(val).to_s
|
139
|
+
when NilClass
|
140
|
+
column = @columns[column - 1].index
|
141
|
+
@cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
|
142
|
+
when ButtonColumnProxy
|
143
|
+
@columns[column].notify_listeners(:on_clicked, row)
|
111
144
|
end
|
112
145
|
end
|
113
146
|
|
@@ -119,7 +152,7 @@ module Glimmer
|
|
119
152
|
|
120
153
|
@libui = ControlProxy.new_control(@keyword, [@table_params])
|
121
154
|
@libui.tap do
|
122
|
-
@columns.each {|column| column
|
155
|
+
@columns.each {|column| column&.send(:build_control) }
|
123
156
|
end
|
124
157
|
end
|
125
158
|
|
@@ -133,6 +166,11 @@ module Glimmer
|
|
133
166
|
blockcaller
|
134
167
|
end
|
135
168
|
|
169
|
+
def next_column_index
|
170
|
+
@next_column_index ||= -1
|
171
|
+
@next_column_index += 1
|
172
|
+
end
|
173
|
+
|
136
174
|
end
|
137
175
|
end
|
138
176
|
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,12 +30,12 @@ module Glimmer
|
|
29
30
|
# Follows the Proxy Design Pattern
|
30
31
|
class TextColumnProxy < ControlProxy
|
31
32
|
include Column
|
33
|
+
include EditableColumn
|
32
34
|
|
33
35
|
private
|
34
36
|
|
35
37
|
def build_control
|
36
|
-
@parent_proxy.append_text_column(name,
|
37
|
-
super
|
38
|
+
@parent_proxy.append_text_column(name, column_index, editable_value)
|
38
39
|
end
|
39
40
|
end
|
40
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
data/lib/glimmer-dsl-libui.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-libui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.1.
|
19
|
+
version: 2.1.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.1.
|
26
|
+
version: 2.1.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: os
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.0.
|
53
|
+
version: 0.0.10
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.0.
|
60
|
+
version: 0.0.10
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: juwelier
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -177,7 +177,7 @@ dependencies:
|
|
177
177
|
- !ruby/object:Gem::Version
|
178
178
|
version: 1.4.0
|
179
179
|
description: Glimmer DSL for LibUI - Prerequisite-Free Ruby Desktop Development GUI
|
180
|
-
Library (
|
180
|
+
Library (No need to pre-install any prerequisites. Just install the gem and have
|
181
181
|
platform-independent native GUI that just works!)
|
182
182
|
email: andy.am@gmail.com
|
183
183
|
executables:
|
@@ -197,12 +197,15 @@ 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
|
200
201
|
- examples/basic_table_image.rb
|
202
|
+
- examples/basic_table_image_text.rb
|
201
203
|
- examples/basic_window.rb
|
202
204
|
- examples/basic_window2.rb
|
203
205
|
- examples/color_button.rb
|
204
206
|
- examples/control_gallery.rb
|
205
207
|
- examples/date_time_picker.rb
|
208
|
+
- examples/editable_column_table.rb
|
206
209
|
- examples/editable_table.rb
|
207
210
|
- examples/font_button.rb
|
208
211
|
- examples/form.rb
|
@@ -222,6 +225,7 @@ files:
|
|
222
225
|
- lib/glimmer/dsl/libui/tab_item_expression.rb
|
223
226
|
- lib/glimmer/libui/about_menu_item_proxy.rb
|
224
227
|
- lib/glimmer/libui/box.rb
|
228
|
+
- lib/glimmer/libui/button_column_proxy.rb
|
225
229
|
- lib/glimmer/libui/button_proxy.rb
|
226
230
|
- lib/glimmer/libui/check_menu_item_proxy.rb
|
227
231
|
- lib/glimmer/libui/checkbox_proxy.rb
|
@@ -231,7 +235,10 @@ files:
|
|
231
235
|
- lib/glimmer/libui/control_proxy.rb
|
232
236
|
- lib/glimmer/libui/date_picker_proxy.rb
|
233
237
|
- lib/glimmer/libui/date_time_picker_proxy.rb
|
238
|
+
- lib/glimmer/libui/dual_column.rb
|
239
|
+
- lib/glimmer/libui/editable_column.rb
|
234
240
|
- lib/glimmer/libui/editable_combobox_proxy.rb
|
241
|
+
- lib/glimmer/libui/enableable_column.rb
|
235
242
|
- lib/glimmer/libui/font_button_proxy.rb
|
236
243
|
- lib/glimmer/libui/form_proxy.rb
|
237
244
|
- lib/glimmer/libui/grid_proxy.rb
|
@@ -239,6 +246,8 @@ files:
|
|
239
246
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
240
247
|
- lib/glimmer/libui/image_column_proxy.rb
|
241
248
|
- lib/glimmer/libui/image_part_proxy.rb
|
249
|
+
- lib/glimmer/libui/image_proxy.rb
|
250
|
+
- lib/glimmer/libui/image_text_column_proxy.rb
|
242
251
|
- lib/glimmer/libui/label_proxy.rb
|
243
252
|
- lib/glimmer/libui/menu_item_proxy.rb
|
244
253
|
- lib/glimmer/libui/menu_proxy.rb
|