glimmer-dsl-libui 0.0.18 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +273 -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 +47 -0
- data/examples/editable_column_table.rb +31 -0
- data/examples/editable_table.rb +29 -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 +11 -2
- 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 -1
- data/lib/glimmer/libui/image_text_column_proxy.rb +44 -0
- data/lib/glimmer/libui/table_proxy.rb +68 -11
- data/lib/glimmer/libui/text_column_proxy.rb +4 -2
- data/lib/glimmer/libui/window_proxy.rb +19 -10
- data/lib/glimmer-dsl-libui.rb +1 -0
- metadata +14 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 974aa189dcfa34a3e96c581592d2acaa4fa1e14edeb784c3b80e47cf21b1f90d
|
4
|
+
data.tar.gz: 6bb99a56fe942706ec3a773cd90d0cfd88554fc03cb27465fb375538a56ac351
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08fcb654b14c8bf9bdca6e1d3b28477cd8d1d389447d4162dabe7f8f743cd9ee68e033012e01feadc5e9ac92daeca0feb74c794d0323ad4c083dde1f0fc90125'
|
7
|
+
data.tar.gz: e215a320873a70904062254fd63c32296b917c661592983d89bd6fa940413a5e554b6aa42c8e637409d777c3e739c6e80d1fef8072d1c72b4f275fc8985b775e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.0.22
|
4
|
+
|
5
|
+
- New examples/basic_table_button.rb
|
6
|
+
- Support table `button_column`
|
7
|
+
- Support table `button_column` `enabled` property
|
8
|
+
- Support `on_clicked` listener for `button_column`
|
9
|
+
- Support automatic table cell value reading management (table row deletion upon actual `cell_rows` deletion due to implicit data-binding)
|
10
|
+
|
11
|
+
## 0.0.21
|
12
|
+
|
13
|
+
- New examples/editable_column_table_image_text.rb
|
14
|
+
- Support table `image_text_column`
|
15
|
+
|
16
|
+
## 0.0.20
|
17
|
+
|
18
|
+
- New examples/editable_column_table.rb
|
19
|
+
- Support `editable` property for `text_column`
|
20
|
+
|
21
|
+
## 0.0.19
|
22
|
+
|
23
|
+
- New examples/editable_table.rb
|
24
|
+
- Support editable `table` control
|
25
|
+
- Fix issue with table `text_column` repeating the first column as the second
|
26
|
+
|
3
27
|
## 0.0.18
|
4
28
|
|
5
29
|
- Support examples/basic_table_image.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.22
|
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.
|
46
|
+
- [Glimmer DSL for LibUI 0.0.22](#-glimmer-dsl-for-libui-0022)
|
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.22'
|
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)) | 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,7 +317,7 @@ 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.
|
316
322
|
- `image` instances are automatically freed from memory after `window` is destroyed.
|
317
323
|
|
@@ -1880,6 +1886,126 @@ window('Animal sounds', 300, 200) {
|
|
1880
1886
|
}.show
|
1881
1887
|
```
|
1882
1888
|
|
1889
|
+
### Editable Table
|
1890
|
+
|
1891
|
+
[examples/editable_table.rb](examples/editable_table.rb)
|
1892
|
+
|
1893
|
+
Run with this command from the root of the project if you cloned the project:
|
1894
|
+
|
1895
|
+
```
|
1896
|
+
ruby -r './lib/glimmer-dsl-libui' examples/editable_table.rb
|
1897
|
+
```
|
1898
|
+
|
1899
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1900
|
+
|
1901
|
+
```
|
1902
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/editable_table'"
|
1903
|
+
```
|
1904
|
+
|
1905
|
+
Mac
|
1906
|
+
|
1907
|
+
![glimmer-dsl-libui-mac-editable-table.png](images/glimmer-dsl-libui-mac-editable-table.png)
|
1908
|
+
![glimmer-dsl-libui-mac-editable-table-editing.png](images/glimmer-dsl-libui-mac-editable-table-editing.png)
|
1909
|
+
![glimmer-dsl-libui-mac-editable-table-edited.png](images/glimmer-dsl-libui-mac-editable-table-edited.png)
|
1910
|
+
|
1911
|
+
Linux
|
1912
|
+
|
1913
|
+
![glimmer-dsl-libui-linux-editable-table.png](images/glimmer-dsl-libui-linux-editable-table.png)
|
1914
|
+
![glimmer-dsl-libui-linux-editable-table-editing.png](images/glimmer-dsl-libui-linux-editable-table-editing.png)
|
1915
|
+
![glimmer-dsl-libui-linux-editable-table-edited.png](images/glimmer-dsl-libui-linux-editable-table-edited.png)
|
1916
|
+
|
1917
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1918
|
+
|
1919
|
+
```ruby
|
1920
|
+
require 'glimmer-dsl-libui'
|
1921
|
+
|
1922
|
+
include Glimmer
|
1923
|
+
|
1924
|
+
data = [
|
1925
|
+
%w[cat meow],
|
1926
|
+
%w[dog woof],
|
1927
|
+
%w[chicken cock-a-doodle-doo],
|
1928
|
+
%w[hourse neigh],
|
1929
|
+
%w[cow moo]
|
1930
|
+
]
|
1931
|
+
|
1932
|
+
window('Editable animal sounds', 300, 200) {
|
1933
|
+
horizontal_box {
|
1934
|
+
table {
|
1935
|
+
text_column('Animal')
|
1936
|
+
text_column('Description')
|
1937
|
+
|
1938
|
+
cell_rows data
|
1939
|
+
editable true
|
1940
|
+
}
|
1941
|
+
}
|
1942
|
+
|
1943
|
+
on_closing do
|
1944
|
+
puts 'Bye Bye'
|
1945
|
+
end
|
1946
|
+
}.show
|
1947
|
+
```
|
1948
|
+
|
1949
|
+
### Editable Column Table
|
1950
|
+
|
1951
|
+
[examples/editable_column_table.rb](examples/editable_column_table.rb)
|
1952
|
+
|
1953
|
+
Run with this command from the root of the project if you cloned the project:
|
1954
|
+
|
1955
|
+
```
|
1956
|
+
ruby -r './lib/glimmer-dsl-libui' examples/editable_column_table.rb
|
1957
|
+
```
|
1958
|
+
|
1959
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
1960
|
+
|
1961
|
+
```
|
1962
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/editable_column_table'"
|
1963
|
+
```
|
1964
|
+
|
1965
|
+
Mac
|
1966
|
+
|
1967
|
+
![glimmer-dsl-libui-mac-editable-column-table-editing.png](images/glimmer-dsl-libui-mac-editable-column-table-editing.png)
|
1968
|
+
![glimmer-dsl-libui-mac-editable-column-table-edited.png](images/glimmer-dsl-libui-mac-editable-column-table-edited.png)
|
1969
|
+
|
1970
|
+
Linux
|
1971
|
+
|
1972
|
+
![glimmer-dsl-libui-linux-editable-column-table-editing.png](images/glimmer-dsl-libui-linux-editable-column-table-editing.png)
|
1973
|
+
![glimmer-dsl-libui-linux-editable-column-table-edited.png](images/glimmer-dsl-libui-linux-editable-column-table-edited.png)
|
1974
|
+
|
1975
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
1976
|
+
|
1977
|
+
```ruby
|
1978
|
+
require 'glimmer-dsl-libui'
|
1979
|
+
|
1980
|
+
include Glimmer
|
1981
|
+
|
1982
|
+
data = [
|
1983
|
+
%w[cat calm meow],
|
1984
|
+
%w[dog loyal woof],
|
1985
|
+
%w[chicken bird cock-a-doodle-doo],
|
1986
|
+
%w[hourse fast neigh],
|
1987
|
+
%w[cow slow moo]
|
1988
|
+
]
|
1989
|
+
|
1990
|
+
window('Editable column animal sounds', 400, 200) {
|
1991
|
+
horizontal_box {
|
1992
|
+
table {
|
1993
|
+
text_column('Animal')
|
1994
|
+
text_column('Description')
|
1995
|
+
text_column('Sound (Editable)') {
|
1996
|
+
editable true
|
1997
|
+
}
|
1998
|
+
|
1999
|
+
cell_rows data
|
2000
|
+
}
|
2001
|
+
}
|
2002
|
+
|
2003
|
+
on_closing do
|
2004
|
+
puts 'Bye Bye'
|
2005
|
+
end
|
2006
|
+
}.show
|
2007
|
+
```
|
2008
|
+
|
1883
2009
|
### Basic Table Image
|
1884
2010
|
|
1885
2011
|
This example has a prerequisite of installing `chunky_png` Ruby gem:
|
@@ -2030,14 +2156,154 @@ window('The Red Turtle', 310, 350, false) {
|
|
2030
2156
|
|
2031
2157
|
cell_rows IMAGE_ROWS
|
2032
2158
|
}
|
2033
|
-
|
2034
2159
|
}
|
2160
|
+
|
2035
2161
|
on_closing do
|
2036
2162
|
puts 'Bye Bye'
|
2037
2163
|
end
|
2038
2164
|
}.show
|
2039
2165
|
```
|
2040
2166
|
|
2167
|
+
### Basic Table Image Text
|
2168
|
+
|
2169
|
+
This example has a prerequisite of installing `chunky_png` Ruby gem:
|
2170
|
+
|
2171
|
+
```
|
2172
|
+
gem install chunky_png -v1.4.0
|
2173
|
+
```
|
2174
|
+
|
2175
|
+
Also, note that behavior varies per platform (i.e. how `table` chooses to size images by default).
|
2176
|
+
|
2177
|
+
[examples/basic_table_image_text.rb](examples/basic_table_image_text.rb)
|
2178
|
+
|
2179
|
+
Run with this command from the root of the project if you cloned the project:
|
2180
|
+
|
2181
|
+
```
|
2182
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_image_text.rb
|
2183
|
+
```
|
2184
|
+
|
2185
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
2186
|
+
|
2187
|
+
```
|
2188
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_image_text'"
|
2189
|
+
```
|
2190
|
+
|
2191
|
+
Mac
|
2192
|
+
|
2193
|
+
![glimmer-dsl-libui-mac-basic-table-image-text.png](images/glimmer-dsl-libui-mac-basic-table-image-text.png)
|
2194
|
+
|
2195
|
+
Linux
|
2196
|
+
|
2197
|
+
![glimmer-dsl-libui-linux-basic-table-image-text.png](images/glimmer-dsl-libui-linux-basic-table-image-text.png)
|
2198
|
+
|
2199
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2200
|
+
|
2201
|
+
```ruby
|
2202
|
+
# NOTE:
|
2203
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
2204
|
+
|
2205
|
+
require 'glimmer-dsl-libui'
|
2206
|
+
require 'chunky_png'
|
2207
|
+
require 'open-uri'
|
2208
|
+
|
2209
|
+
include Glimmer
|
2210
|
+
|
2211
|
+
IMAGE_ROWS = []
|
2212
|
+
|
2213
|
+
5.times do |i|
|
2214
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
2215
|
+
puts "Processing Image: #{url}"
|
2216
|
+
f = URI.open(url)
|
2217
|
+
canvas = ChunkyPNG::Canvas.from_io(f)
|
2218
|
+
f.close
|
2219
|
+
data = canvas.to_rgba_stream
|
2220
|
+
width = canvas.width
|
2221
|
+
height = canvas.height
|
2222
|
+
img = image(width, height) {
|
2223
|
+
image_part(data, width, height, width * 4)
|
2224
|
+
}
|
2225
|
+
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
2226
|
+
IMAGE_ROWS << [[img, text], text, text, [img, text]]
|
2227
|
+
rescue StandardError => e
|
2228
|
+
warn url, e.message
|
2229
|
+
end
|
2230
|
+
|
2231
|
+
window('The Red Turtle', 900, 350) {
|
2232
|
+
horizontal_box {
|
2233
|
+
table {
|
2234
|
+
image_text_column('image/number')
|
2235
|
+
text_column('number')
|
2236
|
+
text_column('number (editable)') {
|
2237
|
+
editable true
|
2238
|
+
}
|
2239
|
+
image_text_column('image/number (editable)') {
|
2240
|
+
editable true
|
2241
|
+
}
|
2242
|
+
|
2243
|
+
cell_rows IMAGE_ROWS
|
2244
|
+
}
|
2245
|
+
}
|
2246
|
+
}.show
|
2247
|
+
```
|
2248
|
+
|
2249
|
+
### Basic Table Button
|
2250
|
+
|
2251
|
+
[examples/basic_table_button.rb](examples/basic_table_button.rb)
|
2252
|
+
|
2253
|
+
Run with this command from the root of the project if you cloned the project:
|
2254
|
+
|
2255
|
+
```
|
2256
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_button.rb
|
2257
|
+
```
|
2258
|
+
|
2259
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
2260
|
+
|
2261
|
+
```
|
2262
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_button'"
|
2263
|
+
```
|
2264
|
+
|
2265
|
+
Mac
|
2266
|
+
|
2267
|
+
![glimmer-dsl-libui-mac-basic-table-button.png](images/glimmer-dsl-libui-mac-basic-table-button.png)
|
2268
|
+
![glimmer-dsl-libui-mac-basic-table-button-deleted.png](images/glimmer-dsl-libui-mac-basic-table-button-deleted.png)
|
2269
|
+
|
2270
|
+
Linux
|
2271
|
+
|
2272
|
+
![glimmer-dsl-libui-linux-basic-table-button.png](images/glimmer-dsl-libui-linux-basic-table-button.png)
|
2273
|
+
![glimmer-dsl-libui-linux-basic-table-button-deleted.png](images/glimmer-dsl-libui-linux-basic-table-button-deleted.png)
|
2274
|
+
|
2275
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2276
|
+
|
2277
|
+
```ruby
|
2278
|
+
require 'glimmer-dsl-libui'
|
2279
|
+
|
2280
|
+
include Glimmer
|
2281
|
+
|
2282
|
+
data = [
|
2283
|
+
%w[cat meow delete],
|
2284
|
+
%w[dog woof delete],
|
2285
|
+
%w[chicken cock-a-doodle-doo delete],
|
2286
|
+
%w[hourse neigh delete],
|
2287
|
+
%w[cow moo delete]
|
2288
|
+
]
|
2289
|
+
|
2290
|
+
window('Animal sounds', 300, 200) {
|
2291
|
+
horizontal_box {
|
2292
|
+
table {
|
2293
|
+
text_column('Animal')
|
2294
|
+
text_column('Description')
|
2295
|
+
button_column('Action') {
|
2296
|
+
on_clicked do |row|
|
2297
|
+
data.delete_at(row) # automatically deletes actual table row due to implicit data-binding
|
2298
|
+
end
|
2299
|
+
}
|
2300
|
+
|
2301
|
+
cell_rows data # implicit data-binding
|
2302
|
+
}
|
2303
|
+
}
|
2304
|
+
}.show
|
2305
|
+
```
|
2306
|
+
|
2041
2307
|
## Contributing to glimmer-dsl-libui
|
2042
2308
|
|
2043
2309
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.22
|
@@ -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,47 @@
|
|
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(width, height) {
|
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], text, text, [img, text]]
|
28
|
+
rescue StandardError => e
|
29
|
+
warn url, e.message
|
30
|
+
end
|
31
|
+
|
32
|
+
window('The Red Turtle', 900, 350) {
|
33
|
+
horizontal_box {
|
34
|
+
table {
|
35
|
+
image_text_column('image/number')
|
36
|
+
text_column('number')
|
37
|
+
text_column('number (editable)') {
|
38
|
+
editable true
|
39
|
+
}
|
40
|
+
image_text_column('image/number (editable)') {
|
41
|
+
editable true
|
42
|
+
}
|
43
|
+
|
44
|
+
cell_rows IMAGE_ROWS
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}.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
|
@@ -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],
|
9
|
+
%w[dog woof],
|
10
|
+
%w[chicken cock-a-doodle-doo],
|
11
|
+
%w[hourse neigh],
|
12
|
+
%w[cow moo]
|
13
|
+
]
|
14
|
+
|
15
|
+
window('Editable animal sounds', 300, 200) {
|
16
|
+
horizontal_box {
|
17
|
+
table {
|
18
|
+
text_column('Animal')
|
19
|
+
text_column('Description')
|
20
|
+
|
21
|
+
cell_rows data
|
22
|
+
editable true
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
on_closing do
|
27
|
+
puts 'Bye Bye'
|
28
|
+
end
|
29
|
+
}.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,8 +19,6 @@
|
|
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
|
@@ -37,6 +35,17 @@ module Glimmer
|
|
37
35
|
def name
|
38
36
|
@args.first
|
39
37
|
end
|
38
|
+
|
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)
|
43
|
+
end
|
44
|
+
|
45
|
+
# actual index within table columns (disregarding nil fillings that account for DualColumn instances)
|
46
|
+
def index
|
47
|
+
@parent_proxy.columns.compact.index(self)
|
48
|
+
end
|
40
49
|
end
|
41
50
|
end
|
42
51
|
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
|
@@ -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,34 +66,81 @@ 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
|
+
|
93
|
+
def editable(value = nil)
|
94
|
+
if value.nil?
|
95
|
+
@editable
|
96
|
+
else
|
97
|
+
@editable = !!value
|
98
|
+
end
|
99
|
+
end
|
100
|
+
alias editable= editable
|
101
|
+
alias set_editable editable
|
102
|
+
alias editable? editable
|
103
|
+
|
71
104
|
private
|
72
105
|
|
73
106
|
def build_control
|
74
107
|
@model_handler = ::LibUI::FFI::TableModelHandler.malloc
|
75
|
-
@model_handler.NumColumns = rbcallback(4) { @columns.
|
76
|
-
@model_handler.ColumnType = rbcallback(4) do
|
77
|
-
|
78
|
-
|
79
|
-
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
|
80
112
|
0
|
81
|
-
when ImageColumnProxy
|
113
|
+
when ImageColumnProxy, ImageTextColumnProxy
|
82
114
|
1
|
115
|
+
# when CheckboxColumnProxy
|
116
|
+
# 2
|
117
|
+
# when CheckboxTextColumnProxy
|
118
|
+
# 2
|
119
|
+
# when ProgressBarColumnProxy
|
120
|
+
# 2
|
83
121
|
end
|
84
122
|
end
|
85
123
|
@model_handler.NumRows = rbcallback(4) { cell_rows.count }
|
86
124
|
@model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
|
125
|
+
the_cell_rows = expanded_cell_rows
|
126
|
+
case @columns[column]
|
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])))
|
131
|
+
end
|
132
|
+
end
|
133
|
+
@model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
|
87
134
|
case @columns[column]
|
88
135
|
when TextColumnProxy
|
89
|
-
|
90
|
-
|
91
|
-
|
136
|
+
column = @columns[column].index
|
137
|
+
@cell_rows[row] ||= []
|
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)
|
92
144
|
end
|
93
145
|
end
|
94
146
|
|
@@ -100,7 +152,7 @@ module Glimmer
|
|
100
152
|
|
101
153
|
@libui = ControlProxy.new_control(@keyword, [@table_params])
|
102
154
|
@libui.tap do
|
103
|
-
@columns.each {|column| column
|
155
|
+
@columns.each {|column| column&.send(:build_control) }
|
104
156
|
end
|
105
157
|
end
|
106
158
|
|
@@ -114,6 +166,11 @@ module Glimmer
|
|
114
166
|
blockcaller
|
115
167
|
end
|
116
168
|
|
169
|
+
def next_column_index
|
170
|
+
@next_column_index ||= -1
|
171
|
+
@next_column_index += 1
|
172
|
+
end
|
173
|
+
|
117
174
|
end
|
118
175
|
end
|
119
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,11 +30,12 @@ module Glimmer
|
|
29
30
|
# Follows the Proxy Design Pattern
|
30
31
|
class TextColumnProxy < ControlProxy
|
31
32
|
include Column
|
32
|
-
|
33
|
+
include EditableColumn
|
34
|
+
|
33
35
|
private
|
34
36
|
|
35
37
|
def build_control
|
36
|
-
@
|
38
|
+
@parent_proxy.append_text_column(name, column_index, editable_value)
|
37
39
|
end
|
38
40
|
end
|
39
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.22
|
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-25 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
|
@@ -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,16 @@ 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
|
209
|
+
- examples/editable_table.rb
|
206
210
|
- examples/font_button.rb
|
207
211
|
- examples/form.rb
|
208
212
|
- examples/grid.rb
|
@@ -221,6 +225,7 @@ files:
|
|
221
225
|
- lib/glimmer/dsl/libui/tab_item_expression.rb
|
222
226
|
- lib/glimmer/libui/about_menu_item_proxy.rb
|
223
227
|
- lib/glimmer/libui/box.rb
|
228
|
+
- lib/glimmer/libui/button_column_proxy.rb
|
224
229
|
- lib/glimmer/libui/button_proxy.rb
|
225
230
|
- lib/glimmer/libui/check_menu_item_proxy.rb
|
226
231
|
- lib/glimmer/libui/checkbox_proxy.rb
|
@@ -230,7 +235,10 @@ files:
|
|
230
235
|
- lib/glimmer/libui/control_proxy.rb
|
231
236
|
- lib/glimmer/libui/date_picker_proxy.rb
|
232
237
|
- lib/glimmer/libui/date_time_picker_proxy.rb
|
238
|
+
- lib/glimmer/libui/dual_column.rb
|
239
|
+
- lib/glimmer/libui/editable_column.rb
|
233
240
|
- lib/glimmer/libui/editable_combobox_proxy.rb
|
241
|
+
- lib/glimmer/libui/enableable_column.rb
|
234
242
|
- lib/glimmer/libui/font_button_proxy.rb
|
235
243
|
- lib/glimmer/libui/form_proxy.rb
|
236
244
|
- lib/glimmer/libui/grid_proxy.rb
|
@@ -238,6 +246,7 @@ files:
|
|
238
246
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
239
247
|
- lib/glimmer/libui/image_column_proxy.rb
|
240
248
|
- lib/glimmer/libui/image_part_proxy.rb
|
249
|
+
- lib/glimmer/libui/image_text_column_proxy.rb
|
241
250
|
- lib/glimmer/libui/label_proxy.rb
|
242
251
|
- lib/glimmer/libui/menu_item_proxy.rb
|
243
252
|
- lib/glimmer/libui/menu_proxy.rb
|