glimmer-dsl-libui 0.7.1 → 0.7.2
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 +5 -0
- data/README.md +3 -3
- data/VERSION +1 -1
- data/docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md +4 -0
- data/examples/basic_table_selection.rb +83 -86
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +18 -6
- data/lib/glimmer/libui/control_proxy.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aedcfa3ba9a8d44ce0df9ee4f684535d3492c858ca0171f4181a80ed4772899
|
4
|
+
data.tar.gz: 21f8b0577f27116216821c2bcbe3fd458261a5f8c957c5c0a2aa4683d370310d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc1404d69d320e772a50506bfde13942cc7f981fb932c1c0999340c1c048ce64935eeac799d6af3b258a1a18ccb3472b9915814da72a96f5fb4d5f0b9af13fb6
|
7
|
+
data.tar.gz: eac5a371a0d685fab5cd397a43f7b25c333d855b5972c898dd0794c4001f61c08440d5da4f80911017155f0c051cea79391eefa5e603e13fb5292db12f4d2689
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.7.2
|
4
|
+
|
5
|
+
- `table` `on_selection_changed` listener arguments now provide extra arguments of `selection`, `added_selection`, `removed_selection` after first argument (`table`)
|
6
|
+
- Update `examples/basic_table_selection.rb` to use new `on_selection_changed` arguments of `selection`, `added_selection`, and `removed_selection`
|
7
|
+
|
3
8
|
## 0.7.1
|
4
9
|
|
5
10
|
- `table` column `on_clicked` listener (can be nested under `text_column`, `text_color_column`, `button_column`, `checkbox_column`, `checkbox_text_color_column`, `image_column`, `image_text_color_column`, `image_text_column`, and `progress_bar_column`)
|
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.7.
|
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.7.2
|
2
2
|
## Prerequisite-Free Ruby Desktop Development GUI Library
|
3
3
|
### The Quickest Way From Zero To GUI
|
4
4
|
[](http://badge.fury.io/rb/glimmer-dsl-libui)
|
@@ -544,7 +544,7 @@ gem install glimmer-dsl-libui
|
|
544
544
|
Or install via Bundler `Gemfile`:
|
545
545
|
|
546
546
|
```ruby
|
547
|
-
gem 'glimmer-dsl-libui', '~> 0.7.
|
547
|
+
gem 'glimmer-dsl-libui', '~> 0.7.2'
|
548
548
|
```
|
549
549
|
|
550
550
|
Test that installation worked by running the [Meta-Example](#examples):
|
@@ -736,7 +736,7 @@ Keyword(Args) | Properties | Listeners
|
|
736
736
|
`string(string = '')` | `font`, `color` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `background` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `underline`, `underline_color` (`Hash` of `:r` as `0`-`255`, `:g` as `0`-`255`, `:b` as `0`-`255`, `:a` as `0.0`-`1.0`, hex, or [X11](https://en.wikipedia.org/wiki/X11_color_names) color), `open_type_features`, `string` (`String`) | None
|
737
737
|
`tab` | `margined` (Boolean), `num_pages` (`Integer`) | None
|
738
738
|
`tab_item(name as String)` | `index` [read-only] (`Integer`), `margined` (Boolean), `name` [read-only] (`String`) | None
|
739
|
-
`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, `selection_mode` (`:zero_or_many` , `:none` , `:zero_or_one` , or `:one`), `selection` (`Integer` for row index or `Array` of multiple row indexes), `header_visible` (Boolean) | `on_changed {|row, type, row_data| ...}`, `on_edited {|row, row_data| ...}`, `on_row_clicked {|table, row| }`, `on_row_double_clicked {|table, row| }`, and `on_selection_changed {|table| }`
|
739
|
+
`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, `selection_mode` (`:zero_or_many` , `:none` , `:zero_or_one` , or `:one`), `selection` (`Integer` for row index or `Array` of multiple row indexes), `header_visible` (Boolean) | `on_changed {|row, type, row_data| ...}`, `on_edited {|row, row_data| ...}`, `on_row_clicked {|table, row| }`, `on_row_double_clicked {|table, row| }`, and `on_selection_changed {|table, selection, added_selection, removed_selection| }`
|
740
740
|
`text(x = 0 as Numeric, y = 0 as Numeric, width = area_width as Numeric)` | `align`, `default_font` | None
|
741
741
|
`text_column(name as String)` | `editable` (Boolean), `sort_indicator` (`:ascending` [alias: `:asc`, `:a`], `:descending` [alias: `:desc`, `:d`], or `nil`) | `on_clicked {|tc, column_index| }`
|
742
742
|
`text_color_column(name as String)` | `editable` (Boolean) | None
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
@@ -1521,6 +1521,10 @@ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_selection'"
|
|
1521
1521
|
```
|
1522
1522
|
|
1523
1523
|

|
1524
|
+

|
1525
|
+

|
1526
|
+

|
1527
|
+

|
1524
1528
|
|
1525
1529
|
## Basic Area
|
1526
1530
|
|
@@ -4,16 +4,17 @@ class BasicTableSelection
|
|
4
4
|
include Glimmer::LibUI::Application
|
5
5
|
|
6
6
|
before_body do
|
7
|
-
|
7
|
+
data = [
|
8
8
|
%w[cat meow],
|
9
9
|
%w[dog woof],
|
10
10
|
%w[chicken cock-a-doodle-doo],
|
11
11
|
%w[horse neigh],
|
12
12
|
%w[cow moo]
|
13
13
|
]
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
14
|
+
@one_table_data = data.dup
|
15
|
+
@zero_or_one_table_data = data.dup
|
16
|
+
@zero_or_many_table_data = data.dup
|
17
|
+
@none_table_data = data.dup
|
17
18
|
end
|
18
19
|
|
19
20
|
body {
|
@@ -24,8 +25,8 @@ class BasicTableSelection
|
|
24
25
|
vertical_box {
|
25
26
|
stretchy false
|
26
27
|
|
27
|
-
@
|
28
|
-
items @
|
28
|
+
@one_table_selection_radio_buttons = radio_buttons {
|
29
|
+
items @one_table_data.size.times.map { |row| "Row #{row} Selection" }
|
29
30
|
|
30
31
|
on_selected do |rb|
|
31
32
|
@one_table.selection = [rb.selected]
|
@@ -43,31 +44,21 @@ class BasicTableSelection
|
|
43
44
|
|
44
45
|
@one_table = table {
|
45
46
|
text_column('Animal') {
|
46
|
-
# sort_indicator :descending # can be :ascending, :descending, or nil (default)
|
47
|
+
# sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
|
47
48
|
|
48
49
|
on_clicked do |tc, column|
|
49
|
-
|
50
|
-
selected_row = @one_table.selection && @one_data[@one_table.selection]
|
51
|
-
tc.toggle_sort_indicator
|
52
|
-
@one_data.sort_by! { |row_data| row_data[column] }
|
53
|
-
@one_data.reverse! if tc.sort_indicator == :descending
|
54
|
-
@one_table.selection = @one_data.index(selected_row)
|
50
|
+
sort_one_table_column(tc, column)
|
55
51
|
end
|
56
52
|
}
|
57
53
|
text_column('Description') {
|
58
|
-
# sort_indicator :descending # can be :ascending, :descending, or nil (default)
|
54
|
+
# sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
|
59
55
|
|
60
56
|
on_clicked do |tc, column|
|
61
|
-
|
62
|
-
selected_row = @one_table.selection && @one_data[@one_table.selection]
|
63
|
-
tc.toggle_sort_indicator
|
64
|
-
@one_data.sort_by! { |row_data| row_data[column] }
|
65
|
-
@one_data.reverse! if tc.sort_indicator == :descending
|
66
|
-
@one_table.selection = @one_data.index(selected_row)
|
57
|
+
sort_one_table_column(tc, column)
|
67
58
|
end
|
68
59
|
}
|
69
60
|
|
70
|
-
cell_rows @
|
61
|
+
cell_rows @one_table_data
|
71
62
|
selection_mode :one # other values are :zero_or_many , :zero_or_one, :none (default is :zero_or_one if not specified)
|
72
63
|
selection 2 # initial selection row index (could be nil too or just left off, defaulting to 0)
|
73
64
|
# header_visible true # default
|
@@ -80,11 +71,13 @@ class BasicTableSelection
|
|
80
71
|
puts "Row Double Clicked: #{row}"
|
81
72
|
end
|
82
73
|
|
83
|
-
on_selection_changed do |t|
|
74
|
+
on_selection_changed do |t, selection, added_selection, removed_selection|
|
84
75
|
# selection is an array or nil if selection mode is zero_or_many
|
85
76
|
# otherwise, selection is a single index integer or nil when not selected
|
86
|
-
puts "Selection Changed: #{
|
87
|
-
|
77
|
+
puts "Selection Changed: #{selection.inspect}"
|
78
|
+
puts "Added Selection: #{added_selection.inspect}"
|
79
|
+
puts "Removed Selection: #{removed_selection.inspect}"
|
80
|
+
@one_table_selection_radio_buttons.selected = selection
|
88
81
|
end
|
89
82
|
}
|
90
83
|
}
|
@@ -95,8 +88,8 @@ class BasicTableSelection
|
|
95
88
|
vertical_box {
|
96
89
|
stretchy false
|
97
90
|
|
98
|
-
@
|
99
|
-
items @
|
91
|
+
@zero_or_one_table_selection_radio_buttons = radio_buttons {
|
92
|
+
items @zero_or_one_table_data.size.times.map { |row| "Row #{row} Selection" }
|
100
93
|
|
101
94
|
on_selected do |rb|
|
102
95
|
@zero_or_one_table.selection = [rb.selected]
|
@@ -114,31 +107,21 @@ class BasicTableSelection
|
|
114
107
|
|
115
108
|
@zero_or_one_table = table {
|
116
109
|
text_column('Animal') {
|
117
|
-
# sort_indicator :descending # can be :ascending, :descending, or nil (default)
|
110
|
+
# sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
|
118
111
|
|
119
112
|
on_clicked do |tc, column|
|
120
|
-
|
121
|
-
selected_row = @zero_or_one_table.selection && @zero_or_one_data[@zero_or_one_table.selection]
|
122
|
-
tc.toggle_sort_indicator
|
123
|
-
@zero_or_one_data.sort_by! { |row_data| row_data[column] }
|
124
|
-
@zero_or_one_data.reverse! if tc.sort_indicator == :descending
|
125
|
-
@zero_or_one_table.selection = @zero_or_one_data.index(selected_row)
|
113
|
+
sort_zero_or_one_table_column(tc, column)
|
126
114
|
end
|
127
115
|
}
|
128
116
|
text_column('Description') {
|
129
|
-
# sort_indicator :descending # can be :ascending, :descending, or nil (default)
|
117
|
+
# sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
|
130
118
|
|
131
119
|
on_clicked do |tc, column|
|
132
|
-
|
133
|
-
selected_row = @zero_or_one_table.selection && @zero_or_one_data[@zero_or_one_table.selection]
|
134
|
-
tc.toggle_sort_indicator
|
135
|
-
@zero_or_one_data.sort_by! { |row_data| row_data[column] }
|
136
|
-
@zero_or_one_data.reverse! if tc.sort_indicator == :descending
|
137
|
-
@zero_or_one_table.selection = @zero_or_one_data.index(selected_row)
|
120
|
+
sort_zero_or_one_table_column(tc, column)
|
138
121
|
end
|
139
122
|
}
|
140
123
|
|
141
|
-
cell_rows @
|
124
|
+
cell_rows @zero_or_one_table_data
|
142
125
|
selection_mode :zero_or_one # other values are :zero_or_many , :one, :none (default is :zero_or_one if not specified)
|
143
126
|
# selection 0 # initial selection row index (could be nil too or just left off)
|
144
127
|
# header_visible true # default
|
@@ -151,11 +134,13 @@ class BasicTableSelection
|
|
151
134
|
puts "Row Double Clicked: #{row}"
|
152
135
|
end
|
153
136
|
|
154
|
-
on_selection_changed do |t|
|
137
|
+
on_selection_changed do |t, selection, added_selection, removed_selection|
|
155
138
|
# selection is an array or nil if selection mode is zero_or_many
|
156
139
|
# otherwise, selection is a single index integer or nil when not selected
|
157
|
-
puts "Selection Changed: #{
|
158
|
-
|
140
|
+
puts "Selection Changed: #{selection.inspect}"
|
141
|
+
puts "Added Selection: #{added_selection.inspect}"
|
142
|
+
puts "Removed Selection: #{removed_selection.inspect}"
|
143
|
+
@zero_or_one_table_selection_radio_buttons.selected = selection
|
159
144
|
end
|
160
145
|
}
|
161
146
|
}
|
@@ -166,7 +151,7 @@ class BasicTableSelection
|
|
166
151
|
vertical_box {
|
167
152
|
stretchy false
|
168
153
|
|
169
|
-
@
|
154
|
+
@zero_or_many_table_selection_checkboxes = @zero_or_many_table_data.size.times.map do |row|
|
170
155
|
checkbox("Row #{row} Selection") {
|
171
156
|
on_toggled do |c|
|
172
157
|
table_selection = @zero_or_many_table.selection.to_a
|
@@ -191,31 +176,21 @@ class BasicTableSelection
|
|
191
176
|
|
192
177
|
@zero_or_many_table = table {
|
193
178
|
text_column('Animal') {
|
194
|
-
# sort_indicator :descending # can be :ascending, :descending, or nil (default)
|
179
|
+
# sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
|
195
180
|
|
196
181
|
on_clicked do |tc, column|
|
197
|
-
|
198
|
-
selected_rows = @zero_or_many_table.selection&.map { |row| @zero_or_many_data[row] }
|
199
|
-
tc.toggle_sort_indicator
|
200
|
-
@zero_or_many_data.sort_by! { |row_data| row_data[column] }
|
201
|
-
@zero_or_many_data.reverse! if tc.sort_indicator == :descending
|
202
|
-
@zero_or_many_table.selection = selected_rows&.map {|row_data| @zero_or_many_data.index(row_data) }
|
182
|
+
sort_zero_or_many_table_column(tc, column)
|
203
183
|
end
|
204
184
|
}
|
205
185
|
text_column('Description') {
|
206
|
-
# sort_indicator :descending # can be :ascending, :descending, or nil (default)
|
186
|
+
# sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
|
207
187
|
|
208
188
|
on_clicked do |tc, column|
|
209
|
-
|
210
|
-
selected_rows = @zero_or_many_table.selection&.map { |row| @zero_or_many_data[row] }
|
211
|
-
tc.toggle_sort_indicator
|
212
|
-
@zero_or_many_data.sort_by! { |row_data| row_data[column] }
|
213
|
-
@zero_or_many_data.reverse! if tc.sort_indicator == :descending
|
214
|
-
@zero_or_many_table.selection = selected_rows&.map {|row_data| @zero_or_many_data.index(row_data) }
|
189
|
+
sort_zero_or_many_table_column(tc, column)
|
215
190
|
end
|
216
191
|
}
|
217
192
|
|
218
|
-
cell_rows @
|
193
|
+
cell_rows @zero_or_many_table_data
|
219
194
|
selection_mode :zero_or_many # other values are :none , :zero_or_one , and :one (default is :zero_or_one if not specified)
|
220
195
|
selection 0, 2, 4 # initial selection row indexes (could be empty array too or just left off)
|
221
196
|
# header_visible true # default
|
@@ -228,13 +203,17 @@ class BasicTableSelection
|
|
228
203
|
puts "Row Double Clicked: #{row}"
|
229
204
|
end
|
230
205
|
|
231
|
-
on_selection_changed do |t|
|
206
|
+
on_selection_changed do |t, selection, added_selection, removed_selection|
|
232
207
|
# selection is an array or nil if selection mode is zero_or_many
|
233
208
|
# otherwise, selection is a single index integer or nil when not selected
|
234
|
-
puts "Selection Changed: #{
|
235
|
-
|
236
|
-
|
237
|
-
|
209
|
+
puts "Selection Changed: #{selection.inspect}"
|
210
|
+
puts "Added Selection: #{added_selection.inspect}"
|
211
|
+
puts "Removed Selection: #{removed_selection.inspect}"
|
212
|
+
removed_selection&.each do |selected_row|
|
213
|
+
@zero_or_many_table_selection_checkboxes[selected_row].checked = false
|
214
|
+
end
|
215
|
+
added_selection&.each do |selected_row|
|
216
|
+
@zero_or_many_table_selection_checkboxes[selected_row].checked = true
|
238
217
|
end
|
239
218
|
end
|
240
219
|
}
|
@@ -253,31 +232,21 @@ class BasicTableSelection
|
|
253
232
|
|
254
233
|
@none_table = table {
|
255
234
|
text_column('Animal') {
|
256
|
-
# sort_indicator :descending # can be :ascending, :descending, or nil (default)
|
235
|
+
# sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
|
257
236
|
|
258
237
|
on_clicked do |tc, column|
|
259
|
-
|
260
|
-
selected_row = @none_table.selection && @none_data[@none_table.selection]
|
261
|
-
tc.toggle_sort_indicator
|
262
|
-
@none_data.sort_by! { |row_data| row_data[column] }
|
263
|
-
@none_data.reverse! if tc.sort_indicator == :descending
|
264
|
-
@none_table.selection = @none_data.index(selected_row)
|
238
|
+
sort_none_table_column(tc, column)
|
265
239
|
end
|
266
240
|
}
|
267
241
|
text_column('Description') {
|
268
|
-
# sort_indicator :descending # can be :ascending, :descending, or nil (default)
|
242
|
+
# sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
|
269
243
|
|
270
244
|
on_clicked do |tc, column|
|
271
|
-
|
272
|
-
selected_row = @none_table.selection && @none_data[@none_table.selection]
|
273
|
-
tc.toggle_sort_indicator
|
274
|
-
@none_data.sort_by! { |row_data| row_data[column] }
|
275
|
-
@none_data.reverse! if tc.sort_indicator == :descending
|
276
|
-
@none_table.selection = @none_data.index(selected_row)
|
245
|
+
sort_none_table_column(tc, column)
|
277
246
|
end
|
278
247
|
}
|
279
248
|
|
280
|
-
cell_rows @
|
249
|
+
cell_rows @none_table_data
|
281
250
|
selection_mode :none # other values are :zero_or_many , :zero_or_one, :one (default is :zero_or_one if not specified)
|
282
251
|
# header_visible true # default
|
283
252
|
|
@@ -288,12 +257,6 @@ class BasicTableSelection
|
|
288
257
|
on_row_double_clicked do |t, row|
|
289
258
|
puts "Row Double Clicked: #{row}"
|
290
259
|
end
|
291
|
-
|
292
|
-
on_selection_changed do |t|
|
293
|
-
# selection is an array or nil if selection mode is zero_or_many
|
294
|
-
# otherwise, selection is a single index integer or nil when not selected
|
295
|
-
puts "Selection Changed: #{t.selection.inspect}"
|
296
|
-
end
|
297
260
|
}
|
298
261
|
}
|
299
262
|
}
|
@@ -301,6 +264,40 @@ class BasicTableSelection
|
|
301
264
|
}
|
302
265
|
}
|
303
266
|
}
|
267
|
+
|
268
|
+
def sort_one_table_column(tc, column)
|
269
|
+
puts "Clicked column #{column}: #{tc.name}"
|
270
|
+
selected_row = @one_table.selection && @one_table_data[@one_table.selection]
|
271
|
+
tc.toggle_sort_indicator
|
272
|
+
@one_table_data.sort_by! { |row_data| row_data[column] }
|
273
|
+
@one_table_data.reverse! if tc.sort_indicator == :descending
|
274
|
+
@one_table.selection = @one_table_data.index(selected_row)
|
275
|
+
end
|
276
|
+
|
277
|
+
def sort_zero_or_one_table_column(tc, column)
|
278
|
+
puts "Clicked column #{column}: #{tc.name}"
|
279
|
+
selected_row = @zero_or_one_table.selection && @zero_or_one_table_data[@zero_or_one_table.selection]
|
280
|
+
tc.toggle_sort_indicator
|
281
|
+
@zero_or_one_table_data.sort_by! { |row_data| row_data[column] }
|
282
|
+
@zero_or_one_table_data.reverse! if tc.sort_indicator == :descending
|
283
|
+
@zero_or_one_table.selection = @zero_or_one_table_data.index(selected_row)
|
284
|
+
end
|
285
|
+
|
286
|
+
def sort_zero_or_many_table_column(tc, column)
|
287
|
+
puts "Clicked column #{column}: #{tc.name}"
|
288
|
+
selected_rows = @zero_or_many_table.selection&.map { |row| @zero_or_many_table_data[row] }
|
289
|
+
tc.toggle_sort_indicator
|
290
|
+
@zero_or_many_table_data.sort_by! { |row_data| row_data[column] }
|
291
|
+
@zero_or_many_table_data.reverse! if tc.sort_indicator == :descending
|
292
|
+
@zero_or_many_table.selection = selected_rows&.map {|row_data| @zero_or_many_table_data.index(row_data) }
|
293
|
+
end
|
294
|
+
|
295
|
+
def sort_none_table_column(tc, column)
|
296
|
+
puts "Clicked column #{column}: #{tc.name}"
|
297
|
+
tc.toggle_sort_indicator
|
298
|
+
@none_table_data.sort_by! { |row_data| row_data[column] }
|
299
|
+
@none_table_data.reverse! if tc.sort_indicator == :descending
|
300
|
+
end
|
304
301
|
end
|
305
302
|
|
306
303
|
BasicTableSelection.launch
|
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
@@ -164,11 +164,11 @@ module Glimmer
|
|
164
164
|
value = value.first if value.size == 1
|
165
165
|
@selection = value
|
166
166
|
return @selection if !@content_added
|
167
|
-
return if
|
167
|
+
return if @selection.nil?
|
168
168
|
|
169
169
|
ts = ::LibUI::FFI::TableSelection.malloc
|
170
|
-
ts.NumRows =
|
171
|
-
ts.Rows = [
|
170
|
+
ts.NumRows = @selection.is_a?(Array) ? @selection.size : 1
|
171
|
+
ts.Rows = [@selection].flatten.pack('i*')
|
172
172
|
super(ts)
|
173
173
|
# TODO figure out why ensure block is not working (perhaps libui auto-frees that resource upon setting selection)
|
174
174
|
# Delete following code if not needed.
|
@@ -248,9 +248,18 @@ module Glimmer
|
|
248
248
|
end
|
249
249
|
|
250
250
|
def handle_listener(listener_name, &listener)
|
251
|
-
# if content has been added, then you can register listeners immediately (without accumulation
|
252
|
-
if CUSTOM_LISTENER_NAMES.include?(listener_name
|
253
|
-
|
251
|
+
# if content has been added, then you can register listeners immediately (without accumulation)
|
252
|
+
if CUSTOM_LISTENER_NAMES.include?(listener_name) || @content_added
|
253
|
+
actual_listener = listener
|
254
|
+
case listener_name
|
255
|
+
when 'on_selection_changed'
|
256
|
+
actual_listener = Proc.new do |myself, *args|
|
257
|
+
added_selection = selection.is_a?(Array) ? (selection - @old_selection.to_a) : selection
|
258
|
+
removed_selection = selection.is_a?(Array) ? (@old_selection.to_a - selection) : @old_selection
|
259
|
+
listener.call(myself, selection, added_selection, removed_selection)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
super(listener_name, &actual_listener)
|
254
263
|
else
|
255
264
|
# if content is not added yet, then accumulate listeners to register later when table content is closed
|
256
265
|
@table_listeners ||= []
|
@@ -603,6 +612,9 @@ module Glimmer
|
|
603
612
|
@table_listeners&.each do |listener_name, listener|
|
604
613
|
handle_listener(listener_name, &listener)
|
605
614
|
end
|
615
|
+
handle_listener('on_selection_changed') do |myself, selection, added_selection, removed_selection|
|
616
|
+
@old_selection = selection
|
617
|
+
end
|
606
618
|
end
|
607
619
|
|
608
620
|
def register_column_listeners
|
@@ -167,6 +167,7 @@ module Glimmer
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def handle_listener(listener_name, &listener)
|
170
|
+
# replace first listener argument (control libui pointer) with actual Ruby libui object
|
170
171
|
safe_listener = Proc.new { |*args| listener.call(self, *args[1..-1]) }
|
171
172
|
if ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
|
172
173
|
if listeners[listener_name].nil?
|
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.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|