glimmer-dsl-libui 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +88 -4
- data/VERSION +1 -1
- data/examples/basic_table_image_text.rb +47 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/column.rb +7 -9
- data/lib/glimmer/libui/dual_column.rb +40 -0
- data/lib/glimmer/libui/editable_column.rb +45 -0
- data/lib/glimmer/libui/image_column_proxy.rb +1 -2
- data/lib/glimmer/libui/image_text_column_proxy.rb +42 -0
- data/lib/glimmer/libui/table_proxy.rb +48 -13
- data/lib/glimmer/libui/text_column_proxy.rb +2 -13
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a7491ce7cea65fb7025868e9fb2db5c4e6187ba269a177879e4276e50fa3d9f
|
4
|
+
data.tar.gz: 9b47cab46d79af36dd06b6914570f30662540b7b8c1e634dc326ed9af32ad041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 692870dd49de81f7d2840579f0de3b7bd414bda277db56a4c28597febd012446c6b8b098bf56e5afe8c9b17f68547bb24bceaba45e15c3e4fd3ca041e5c37d2a
|
7
|
+
data.tar.gz: 289ede334bc53171a6a028dca1d03e794d0e81329621f2278365bfdcb2079fd200da21161d4aed6cf8486f382c4e0b04afadf3883ba0e07790878dbfd8fad334
|
data/CHANGELOG.md
CHANGED
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.21
|
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.21](#-glimmer-dsl-for-libui-0021)
|
47
47
|
- [Glimmer GUI DSL Concepts](#glimmer-gui-dsl-concepts)
|
48
48
|
- [Usage](#usage)
|
49
49
|
- [API](#api)
|
@@ -73,6 +73,7 @@ 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)
|
76
77
|
- [Contributing to glimmer-dsl-libui](#contributing-to-glimmer-dsl-libui)
|
77
78
|
- [Help](#help)
|
78
79
|
- [Issues](#issues)
|
@@ -160,7 +161,7 @@ gem install glimmer-dsl-libui
|
|
160
161
|
Or install via Bundler `Gemfile`:
|
161
162
|
|
162
163
|
```ruby
|
163
|
-
gem 'glimmer-dsl-libui', '~> 0.0.
|
164
|
+
gem 'glimmer-dsl-libui', '~> 0.0.21'
|
164
165
|
```
|
165
166
|
|
166
167
|
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.
|
@@ -233,6 +234,7 @@ Control(Args) | Properties | Listeners
|
|
233
234
|
`image(width as Numeric, height as Numeric)` | None | None
|
234
235
|
`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
236
|
`image_column(name as String)` | None | None
|
237
|
+
`image_text_column(name as String)` | None | None
|
236
238
|
`label(text as String)` | `text` (`String`) | None
|
237
239
|
`menu(text as String)` | None | None
|
238
240
|
`menu_item(text as String)` | `checked` (Boolean) | `on_clicked`
|
@@ -248,7 +250,7 @@ Control(Args) | Properties | Listeners
|
|
248
250
|
`spinbox(min as Numeric, max as Numeric)` | `value` (`Numeric`) | `on_changed`
|
249
251
|
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
250
252
|
`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
|
253
|
+
`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
254
|
`text_column(name as String)` | `editable` as Boolean | None
|
253
255
|
`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
256
|
`vertical_box` | `padded` (Boolean) | None
|
@@ -2161,6 +2163,88 @@ window('The Red Turtle', 310, 350, false) {
|
|
2161
2163
|
}.show
|
2162
2164
|
```
|
2163
2165
|
|
2166
|
+
### Basic Table Image Text
|
2167
|
+
|
2168
|
+
This example has a prerequisite of installing `chunky_png` Ruby gem:
|
2169
|
+
|
2170
|
+
```
|
2171
|
+
gem install chunky_png -v1.4.0
|
2172
|
+
```
|
2173
|
+
|
2174
|
+
Also, note that behavior varies per platform (i.e. how `table` chooses to size images by default).
|
2175
|
+
|
2176
|
+
[examples/basic_table_image_text.rb](examples/basic_table_image_text.rb)
|
2177
|
+
|
2178
|
+
Run with this command from the root of the project if you cloned the project:
|
2179
|
+
|
2180
|
+
```
|
2181
|
+
ruby -r './lib/glimmer-dsl-libui' examples/basic_table_image_text.rb
|
2182
|
+
```
|
2183
|
+
|
2184
|
+
Run with this command if you installed the [Ruby gem](https://rubygems.org/gems/glimmer-dsl-libui):
|
2185
|
+
|
2186
|
+
```
|
2187
|
+
ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_image_text'"
|
2188
|
+
```
|
2189
|
+
|
2190
|
+
Mac
|
2191
|
+
|
2192
|
+
![glimmer-dsl-libui-mac-basic-table-image-text.png](images/glimmer-dsl-libui-mac-basic-table-image-text.png)
|
2193
|
+
|
2194
|
+
Linux
|
2195
|
+
|
2196
|
+
![glimmer-dsl-libui-linux-basic-table-image-text.png](images/glimmer-dsl-libui-linux-basic-table-image-text.png)
|
2197
|
+
|
2198
|
+
New [Glimmer DSL for LibUI](https://rubygems.org/gems/glimmer-dsl-libui) Version:
|
2199
|
+
|
2200
|
+
```ruby
|
2201
|
+
# NOTE:
|
2202
|
+
# This example displays images that can be freely downloaded from the Studio Ghibli website.
|
2203
|
+
|
2204
|
+
require 'glimmer-dsl-libui'
|
2205
|
+
require 'chunky_png'
|
2206
|
+
require 'open-uri'
|
2207
|
+
|
2208
|
+
include Glimmer
|
2209
|
+
|
2210
|
+
IMAGE_ROWS = []
|
2211
|
+
|
2212
|
+
5.times do |i|
|
2213
|
+
url = format('https://www.ghibli.jp/gallery/thumb-redturtle%03d.png', (i + 1))
|
2214
|
+
puts "Processing Image: #{url}"
|
2215
|
+
f = URI.open(url)
|
2216
|
+
canvas = ChunkyPNG::Canvas.from_io(f)
|
2217
|
+
f.close
|
2218
|
+
data = canvas.to_rgba_stream
|
2219
|
+
width = canvas.width
|
2220
|
+
height = canvas.height
|
2221
|
+
img = image(width, height) {
|
2222
|
+
image_part(data, width, height, width * 4)
|
2223
|
+
}
|
2224
|
+
text = url.sub('https://www.ghibli.jp/gallery/thumb-redturtle', '').sub('.png', '')
|
2225
|
+
IMAGE_ROWS << [[img, text], text, text, [img, text]]
|
2226
|
+
rescue StandardError => e
|
2227
|
+
warn url, e.message
|
2228
|
+
end
|
2229
|
+
|
2230
|
+
window('The Red Turtle', 900, 350) {
|
2231
|
+
horizontal_box {
|
2232
|
+
table {
|
2233
|
+
image_text_column('image/number')
|
2234
|
+
text_column('number')
|
2235
|
+
text_column('number (editable)') {
|
2236
|
+
editable true
|
2237
|
+
}
|
2238
|
+
image_text_column('image/number (editable)') {
|
2239
|
+
editable true
|
2240
|
+
}
|
2241
|
+
|
2242
|
+
cell_rows IMAGE_ROWS
|
2243
|
+
}
|
2244
|
+
}
|
2245
|
+
}.show
|
2246
|
+
```
|
2247
|
+
|
2164
2248
|
## Contributing to glimmer-dsl-libui
|
2165
2249
|
|
2166
2250
|
- Check out the latest master to make sure the feature hasn't been
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.21
|
@@ -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
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/lib/glimmer/libui/column.rb
CHANGED
@@ -25,9 +25,6 @@ module Glimmer
|
|
25
25
|
module LibUI
|
26
26
|
# Common logic for all column proxy objects
|
27
27
|
module Column
|
28
|
-
attr_reader :appended
|
29
|
-
alias appended? appended
|
30
|
-
|
31
28
|
def initialize(keyword, parent, args, &block)
|
32
29
|
@keyword = keyword
|
33
30
|
@parent_proxy = parent
|
@@ -41,14 +38,15 @@ module Glimmer
|
|
41
38
|
@args.first
|
42
39
|
end
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
def
|
47
|
-
@
|
41
|
+
# column index used in table append column API call
|
42
|
+
# expanded to ensure DualColumn index accounts for two columns acting as one
|
43
|
+
def column_index
|
44
|
+
@column_index ||= @parent_proxy.send(:next_column_index)
|
48
45
|
end
|
49
46
|
|
50
|
-
|
51
|
-
|
47
|
+
# actual index within table columns (disregarding nil fillings that account for DualColumn instances)
|
48
|
+
def index
|
49
|
+
@parent_proxy.columns.compact.index(self)
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
# A dual column is one that represents two values (e.g. image and text or checkbox and text)
|
27
|
+
# It is meant to be included in a column proxy class that already includes Column
|
28
|
+
module DualColumn
|
29
|
+
def second_column_index
|
30
|
+
column_index + 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def column_index
|
34
|
+
@column_index ||= @parent_proxy.send(:next_column_index).tap do
|
35
|
+
@parent_proxy.send(:next_column_index)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,45 @@
|
|
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
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
module EditableColumn
|
27
|
+
def editable(value = nil)
|
28
|
+
if value.nil?
|
29
|
+
@editable
|
30
|
+
else
|
31
|
+
@editable = !!value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
alias editable= editable
|
35
|
+
alias set_editable editable
|
36
|
+
alias editable? editable
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def editable_value
|
41
|
+
(@parent_proxy.editable? || editable?) ? -2 : -1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
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
|
+
|
25
|
+
module Glimmer
|
26
|
+
module LibUI
|
27
|
+
# Proxy for LibUI image text column objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class ImageTextColumnProxy < ControlProxy
|
31
|
+
include Column
|
32
|
+
include DualColumn
|
33
|
+
include EditableColumn
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def build_control
|
38
|
+
@parent_proxy.append_image_text_column(name, column_index, second_column_index, editable_value)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -50,6 +50,8 @@ module Glimmer
|
|
50
50
|
|
51
51
|
def post_initialize_child(child)
|
52
52
|
@columns << child
|
53
|
+
# add an extra complementary nil column if it is a dual column (i.e. ImageTextColumnProxy or CheckboxTextColumnProxy
|
54
|
+
@columns << nil if child.is_a?(DualColumn)
|
53
55
|
end
|
54
56
|
|
55
57
|
def destroy
|
@@ -61,13 +63,29 @@ module Glimmer
|
|
61
63
|
if rows.nil?
|
62
64
|
@cell_rows
|
63
65
|
else
|
64
|
-
rows = rows.map
|
66
|
+
rows = rows.map do |row|
|
67
|
+
row.map do |cell|
|
68
|
+
if cell.respond_to?(:libui)
|
69
|
+
cell.libui
|
70
|
+
elsif cell.is_a?(Array)
|
71
|
+
cell.map { |inner_cell| inner_cell.respond_to?(:libui) ? inner_cell.libui : inner_cell }
|
72
|
+
else
|
73
|
+
cell
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
65
77
|
@cell_rows = rows
|
66
78
|
end
|
67
79
|
end
|
68
80
|
alias cell_rows= cell_rows
|
69
81
|
alias set_cell_rows cell_rows
|
70
82
|
|
83
|
+
def expanded_cell_rows
|
84
|
+
cell_rows.map do |row|
|
85
|
+
row.flatten(1)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
71
89
|
def editable(value = nil)
|
72
90
|
if value.nil?
|
73
91
|
@editable
|
@@ -83,31 +101,43 @@ module Glimmer
|
|
83
101
|
|
84
102
|
def build_control
|
85
103
|
@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
|
104
|
+
@model_handler.NumColumns = rbcallback(4) { @columns.map {|c| c.is_a?(DualColumn) ? 2 : 1}.sum }
|
105
|
+
@model_handler.ColumnType = rbcallback(4, [1, 1, 4]) do |_, _, column|
|
106
|
+
case @columns[column]
|
107
|
+
when TextColumnProxy, NilClass
|
92
108
|
0
|
93
|
-
when ImageColumnProxy
|
109
|
+
when ImageColumnProxy, ImageTextColumnProxy
|
94
110
|
1
|
111
|
+
# when CheckboxColumnProxy
|
112
|
+
# 2
|
113
|
+
# when CheckboxTextColumnProxy
|
114
|
+
# 2
|
115
|
+
# when ProgressBarColumnProxy
|
116
|
+
# 2
|
117
|
+
# when ButtonColumnProxy
|
118
|
+
# 0
|
95
119
|
end
|
96
120
|
end
|
97
121
|
@model_handler.NumRows = rbcallback(4) { cell_rows.count }
|
98
122
|
@model_handler.CellValue = rbcallback(1, [1, 1, 4, 4]) do |_, _, row, column|
|
123
|
+
the_cell_rows = expanded_cell_rows
|
99
124
|
case @columns[column]
|
100
|
-
when TextColumnProxy
|
101
|
-
::LibUI.new_table_value_string((
|
102
|
-
when ImageColumnProxy
|
103
|
-
::LibUI.new_table_value_image((
|
125
|
+
when TextColumnProxy, NilClass
|
126
|
+
::LibUI.new_table_value_string((expanded_cell_rows[row] && expanded_cell_rows[row][column]).to_s)
|
127
|
+
when ImageColumnProxy, ImageTextColumnProxy
|
128
|
+
::LibUI.new_table_value_image((expanded_cell_rows[row] && expanded_cell_rows[row][column]))
|
104
129
|
end
|
105
130
|
end
|
106
131
|
@model_handler.SetCellValue = rbcallback(0, [1, 1, 4, 4, 1]) do |_, _, row, column, val|
|
107
132
|
case @columns[column]
|
108
133
|
when TextColumnProxy
|
134
|
+
column = @columns[column].index
|
109
135
|
@cell_rows[row] ||= []
|
110
136
|
@cell_rows[row][column] = ::LibUI.table_value_string(val).to_s
|
137
|
+
when NilClass
|
138
|
+
# TODO ensure this works for editable table
|
139
|
+
column = @columns[column - 1].index
|
140
|
+
@cell_rows[row][column][1] = ::LibUI.table_value_string(val).to_s
|
111
141
|
end
|
112
142
|
end
|
113
143
|
|
@@ -119,7 +149,7 @@ module Glimmer
|
|
119
149
|
|
120
150
|
@libui = ControlProxy.new_control(@keyword, [@table_params])
|
121
151
|
@libui.tap do
|
122
|
-
@columns.each {|column| column
|
152
|
+
@columns.each {|column| column&.send(:build_control) }
|
123
153
|
end
|
124
154
|
end
|
125
155
|
|
@@ -133,6 +163,11 @@ module Glimmer
|
|
133
163
|
blockcaller
|
134
164
|
end
|
135
165
|
|
166
|
+
def next_column_index
|
167
|
+
@next_column_index ||= -1
|
168
|
+
@next_column_index += 1
|
169
|
+
end
|
170
|
+
|
136
171
|
end
|
137
172
|
end
|
138
173
|
end
|
@@ -29,23 +29,12 @@ module Glimmer
|
|
29
29
|
# Follows the Proxy Design Pattern
|
30
30
|
class TextColumnProxy < ControlProxy
|
31
31
|
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
|
32
|
+
include EditableColumn
|
43
33
|
|
44
34
|
private
|
45
35
|
|
46
36
|
def build_control
|
47
|
-
@parent_proxy.append_text_column(name,
|
48
|
-
super
|
37
|
+
@parent_proxy.append_text_column(name, column_index, editable_value)
|
49
38
|
end
|
50
39
|
end
|
51
40
|
end
|
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.21
|
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
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- examples/basic_entry.rb
|
199
199
|
- examples/basic_table.rb
|
200
200
|
- examples/basic_table_image.rb
|
201
|
+
- examples/basic_table_image_text.rb
|
201
202
|
- examples/basic_window.rb
|
202
203
|
- examples/basic_window2.rb
|
203
204
|
- examples/color_button.rb
|
@@ -232,6 +233,8 @@ files:
|
|
232
233
|
- lib/glimmer/libui/control_proxy.rb
|
233
234
|
- lib/glimmer/libui/date_picker_proxy.rb
|
234
235
|
- lib/glimmer/libui/date_time_picker_proxy.rb
|
236
|
+
- lib/glimmer/libui/dual_column.rb
|
237
|
+
- lib/glimmer/libui/editable_column.rb
|
235
238
|
- lib/glimmer/libui/editable_combobox_proxy.rb
|
236
239
|
- lib/glimmer/libui/font_button_proxy.rb
|
237
240
|
- lib/glimmer/libui/form_proxy.rb
|
@@ -240,6 +243,7 @@ files:
|
|
240
243
|
- lib/glimmer/libui/horizontal_box_proxy.rb
|
241
244
|
- lib/glimmer/libui/image_column_proxy.rb
|
242
245
|
- lib/glimmer/libui/image_part_proxy.rb
|
246
|
+
- lib/glimmer/libui/image_text_column_proxy.rb
|
243
247
|
- lib/glimmer/libui/label_proxy.rb
|
244
248
|
- lib/glimmer/libui/menu_item_proxy.rb
|
245
249
|
- lib/glimmer/libui/menu_proxy.rb
|