glimmer-dsl-libui 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7aedcfa3ba9a8d44ce0df9ee4f684535d3492c858ca0171f4181a80ed4772899
4
- data.tar.gz: 21f8b0577f27116216821c2bcbe3fd458261a5f8c957c5c0a2aa4683d370310d
3
+ metadata.gz: 5f7eb8d1c417de9910ff49f86592694558a3333f4840971f65be1232adf7408b
4
+ data.tar.gz: 9cdf9733b7026aae945ec183ba4551ee2bbe120454c0a094c02a99bd5338069a
5
5
  SHA512:
6
- metadata.gz: fc1404d69d320e772a50506bfde13942cc7f981fb932c1c0999340c1c048ce64935eeac799d6af3b258a1a18ccb3472b9915814da72a96f5fb4d5f0b9af13fb6
7
- data.tar.gz: eac5a371a0d685fab5cd397a43f7b25c333d855b5972c898dd0794c4001f61c08440d5da4f80911017155f0c051cea79391eefa5e603e13fb5292db12f4d2689
6
+ metadata.gz: 5a6c290b75e8301cadd8c837be2612dd4e653192577ea0c8f2493d4fa4a0b7198f2f8008c99d7adeef42320e5b4d86be339b37fe9ca588ee4cc9e22ad36c0a48
7
+ data.tar.gz: b51a3e1e878b9adde67cc6670f682df5d7ab09a6678b8b16655fbcb0d5e3770b5119f867ea58c4b025a78e043ed56cd0309f86eccdec0b90d31c19b375a0007b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.7.4
4
+
5
+ - `table` `sortable` property (default: `true`) to enable automatic table sorting support when `cell_rows` is an `Array` (does not sort if `cell_rows` is a lazy enumerable)
6
+ - Fix issue with not auto-checking checkboxes for zero-or-many table selection in `examples/basic_table_selection2.rb`
7
+ - Rename `examples/basic_table_selection.rb` to `examples/basic_table_selection3.rb` and add new `examples/basic_table_selection.rb` with automated `table` selection via `sortable` property (default: `true`)
8
+ - Disable automatic sorting by default in `refined_table` (set its `table` `sortable` property to `false`) since it does not sort over the entire collection, yet the visible collection only
9
+ - Disable `sortable` sorting for `table` `button_column` since it does not make sense for it
10
+
11
+ ## 0.7.3
12
+
13
+ - `table` `selection` data-binding support
14
+ - `table` column `sort_indicator` data-binding support
15
+ - New `examples/basic_table_selection2.rb` that uses `selection`, `selection_mode`, `header_visible`, and `sort_indicator` data-binding support
16
+
3
17
  ## 0.7.2
4
18
 
5
19
  - `table` `on_selection_changed` listener arguments now provide extra arguments of `selection`, `added_selection`, `removed_selection` after first argument (`table`)
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.2
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.4
2
2
  ## Prerequisite-Free Ruby Desktop Development GUI Library
3
3
  ### The Quickest Way From Zero To GUI
4
4
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-libui.svg)](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.2'
547
+ gem 'glimmer-dsl-libui', '~> 0.7.4'
548
548
  ```
549
549
 
550
550
  Test that installation worked by running the [Meta-Example](#examples):
@@ -824,7 +824,7 @@ There are additional useful `Glimmer::LibUI` operations that are not found in `L
824
824
 
825
825
  The `table` control must first declare its columns via one of these column keywords (mentioned in [Supported Keywords](#supported-keywords)):
826
826
  - `background_color_column`: expects color cell values
827
- - `button_column`: expects `String` cell values
827
+ - `button_column`: expects `String` cell values and a nested `on_clicked` listener that gets triggerd when a button is clicked
828
828
  - `checkbox_column`: expects Boolean cell values
829
829
  - `checkbox_text_column`: expects dual-element `Array` of Boolean and `String` cell values
830
830
  - `checkbox_text_color_column`: expects triple-element `Array` of Boolean, `String`, and color cell values
@@ -842,6 +842,22 @@ Note that the `cell_rows` property declaration results in "implicit data-binding
842
842
  - Inserting cell rows: Calling `Array#<<`, `Array#push`, `Array#prepend`, or any insertion/addition `Array` method automatically inserts rows in actual `table` control
843
843
  - Changing cell rows: Calling `Array#[]=`, `Array#map!`, or any update `Array` method automatically updates rows in actual `table` control
844
844
 
845
+ More details about table data-binding can be found in [examples/basic_table.rb](https://github.com/AndyObtiva/glimmer-dsl-libui/blob/master/docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md#basic-table) or other `table` [basic examples](https://github.com/AndyObtiva/glimmer-dsl-libui/blob/master/docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md) and [advanced examples](https://github.com/AndyObtiva/glimmer-dsl-libui/blob/master/docs/examples/GLIMMER-DSL-LIBUI-ADVANCED-EXAMPLES.md).
846
+
847
+ The `table` control supports table selection and table sorting automatically as smart defaults, which can also be configured if needed as per the options below.
848
+
849
+ There are other properties that `table` supports:
850
+ - `selection_mode` (`Symbol`) [default: `:zero_or_one`]: sets selection mode to `:one`, `:zero_or_one`, `:zero_or_many`, or `:none`
851
+ - `selection` (`Integer` or `Array` of `Integer`s): a single `Integer` row index for `:one` and `:zero_or_one` selection modes, or an `Array` of `Integer` row indexes if selection mode is `:zero_or_many`
852
+ - `header_visible` (Boolean): shows or hides column headers
853
+ - `sortable` (Boolean) [default: `true`]: enables automatic table sorting support
854
+
855
+ To handle `table` sorting manually, the following can be set inside a table column:
856
+ - `sort_indicator` (`Symbol`): sets sort indicator to ascending or descending with the value being `:ascending`, `:descending`, `:asc`, `:desc`, `:a`, or `:d`
857
+ - `on_clicked` (`Proc`): this listener is triggered when a table column is clicked
858
+
859
+ More details about table selection and table sorting can be found in [examples/basic_table_selection.rb](https://github.com/AndyObtiva/glimmer-dsl-libui/blob/master/docs/examples/GLIMMER-DSL-LIBUI-BASIC-EXAMPLES.md#basic-table-selection).
860
+
845
861
  ([explicit data-binding](#data-binding) supports everything available with implicit data-binding too)
846
862
 
847
863
  Example (you may copy/paste in [`girb`](#girb-glimmer-irb)):
@@ -1976,7 +1992,8 @@ Data-binding supports utilizing the [MVP (Model View Presenter)](https://en.wiki
1976
1992
  - `search_entry`: `text`
1977
1993
  - `slider`: `value`
1978
1994
  - `spinbox`: `value`
1979
- - `table`: `cell_rows` (explicit data-binding by using `<=>` and [implicit data-binding](#table-api) by assigning value directly)
1995
+ - `table`: `cell_rows`, `selection`
1996
+ - `table` columns (e.g. `text_column`): `sort_indicator`
1980
1997
  - `time_picker`: `time`
1981
1998
 
1982
1999
  Example of bidirectional data-binding:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.7.4
@@ -1506,8 +1506,6 @@ Mac | Windows | Linux
1506
1506
 
1507
1507
  ## Basic Table Selection
1508
1508
 
1509
- [examples/basic_table_selection.rb](/examples/basic_table_selection.rb)
1510
-
1511
1509
  Run with this command from the root of the project if you cloned the project:
1512
1510
 
1513
1511
  ```
@@ -1526,6 +1524,14 @@ ruby -r glimmer-dsl-libui -e "require 'examples/basic_table_selection'"
1526
1524
  ![glimmer-dsl-libui-mac-basic-table-selection-none.png](/images/glimmer-dsl-libui-mac-basic-table-selection-none.png)
1527
1525
  ![glimmer-dsl-libui-mac-basic-table-selection-header-not-visible.png](/images/glimmer-dsl-libui-mac-basic-table-selection-header-not-visible.png)
1528
1526
 
1527
+ Version 1 (without data-binding):
1528
+
1529
+ [examples/basic_table_selection.rb](/examples/basic_table_selection.rb)
1530
+
1531
+ Version 2 (with data-binding):
1532
+
1533
+ [examples/basic_table_selection2.rb](/examples/basic_table_selection2.rb)
1534
+
1529
1535
  ## Basic Area
1530
1536
 
1531
1537
  [examples/basic_area.rb](/examples/basic_area.rb)
@@ -1,6 +1,45 @@
1
1
  require 'glimmer-dsl-libui'
2
2
 
3
3
  class BasicTableSelection
4
+ TableColumnPresenter = Struct.new(:name,
5
+ :column,
6
+ :table_presenter,
7
+ keyword_init: true)
8
+
9
+ TablePresenter = Struct.new(:data,
10
+ :column_names,
11
+ :selection_mode,
12
+ :selection,
13
+ :header_visible,
14
+ :sortable,
15
+ keyword_init: true) do
16
+ def selection_items
17
+ data.size.times.map { |row| "Row #{row} Selection" }
18
+ end
19
+
20
+ def toggle_header_visible
21
+ self.header_visible = !(header_visible.nil? || header_visible)
22
+ end
23
+
24
+ def toggle_sortable
25
+ self.sortable = !(sortable.nil? || sortable)
26
+ end
27
+
28
+ def column_presenters
29
+ @column_presenters ||= column_names.each_with_index.map do |column_name, column|
30
+ TableColumnPresenter.new(name: column_name, column: column, table_presenter: self)
31
+ end
32
+ end
33
+
34
+ def selected_row
35
+ selection && data[selection]
36
+ end
37
+
38
+ def selected_rows
39
+ selection && selection.is_a?(Array) && selection.map { |row| data[row] }
40
+ end
41
+ end
42
+
4
43
  include Glimmer::LibUI::Application
5
44
 
6
45
  before_body do
@@ -11,10 +50,38 @@ class BasicTableSelection
11
50
  %w[horse neigh],
12
51
  %w[cow moo]
13
52
  ]
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
53
+ @one_table_presenter = TablePresenter.new(
54
+ data: data.dup,
55
+ column_names: ['Name', 'Description'],
56
+ selection_mode: :one, # other values are :zero_or_many , :zero_or_one, :none (default is :zero_or_one if not specified)
57
+ selection: 2, # initial selection row index (could be nil too or just left off, defaulting to 0)
58
+ header_visible: nil, # defaults to true
59
+ sortable: nil, # defaults to true
60
+ )
61
+ @zero_or_one_table_presenter = TablePresenter.new(
62
+ data: data.dup,
63
+ column_names: ['Name', 'Description'],
64
+ selection_mode: :zero_or_one, # other values are :zero_or_many , :one, :none (default is :zero_or_one if not specified)
65
+ selection: nil, # initial selection row index (could be an integer too or just left off, defaulting to nil)
66
+ header_visible: nil, # defaults to true
67
+ sortable: nil, # defaults to true
68
+ )
69
+ @zero_or_many_table_presenter = TablePresenter.new(
70
+ data: data.dup,
71
+ column_names: ['Name', 'Description'],
72
+ selection_mode: :zero_or_many, # other values are :zero_or_many , :one, :none (default is :zero_or_one if not specified)
73
+ selection: [0, 2, 4], # initial selection row index (could be an integer too or just left off, defaulting to nil)
74
+ header_visible: nil, # defaults to true
75
+ sortable: nil, # defaults to true
76
+ )
77
+ @none_table_presenter = TablePresenter.new(
78
+ data: data.dup,
79
+ column_names: ['Name', 'Description'],
80
+ selection_mode: :none, # other values are :zero_or_many , :zero_or_one, :one (default is :zero_or_one if not specified)
81
+ selection: nil, # defaults to nil
82
+ header_visible: nil, # defaults to true
83
+ sortable: nil, # defaults to true
84
+ )
18
85
  end
19
86
 
20
87
  body {
@@ -26,42 +93,37 @@ class BasicTableSelection
26
93
  stretchy false
27
94
 
28
95
  @one_table_selection_radio_buttons = radio_buttons {
29
- items @one_table_data.size.times.map { |row| "Row #{row} Selection" }
30
-
31
- on_selected do |rb|
32
- @one_table.selection = [rb.selected]
33
- end
96
+ items @one_table_presenter.selection_items
97
+ selected <=> [@one_table_presenter, :selection]
34
98
  }
35
99
  }
36
-
37
- button('Toggle Table Header Visibility') {
100
+
101
+ horizontal_box {
38
102
  stretchy false
39
103
 
40
- on_clicked do
41
- @one_table.header_visible = !@one_table.header_visible
42
- end
43
- }
44
-
45
- @one_table = table {
46
- text_column('Animal') {
47
- # sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
48
-
49
- on_clicked do |tc, column|
50
- sort_one_table_column(tc, column)
104
+ button('Toggle Table Header Visibility') {
105
+ on_clicked do
106
+ @one_table_presenter.toggle_header_visible
51
107
  end
52
108
  }
53
- text_column('Description') {
54
- # sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
55
-
56
- on_clicked do |tc, column|
57
- sort_one_table_column(tc, column)
109
+
110
+ button('Toggle Table Sortability') {
111
+ on_clicked do
112
+ @one_table_presenter.toggle_sortable # toggles sortable attribute to false or true
58
113
  end
59
114
  }
115
+ }
116
+
117
+ @one_table = table {
118
+ @one_table_presenter.column_presenters.each do |column_presenter|
119
+ text_column(column_presenter.name)
120
+ end
60
121
 
61
- cell_rows @one_table_data
62
- selection_mode :one # other values are :zero_or_many , :zero_or_one, :none (default is :zero_or_one if not specified)
63
- selection 2 # initial selection row index (could be nil too or just left off, defaulting to 0)
64
- # header_visible true # default
122
+ cell_rows @one_table_presenter.data
123
+ selection_mode <= [@one_table_presenter, :selection_mode]
124
+ selection <=> [@one_table_presenter, :selection]
125
+ header_visible <= [@one_table_presenter, :header_visible]
126
+ sortable <= [@one_table_presenter, :sortable]
65
127
 
66
128
  on_row_clicked do |t, row|
67
129
  puts "Row Clicked: #{row}"
@@ -77,54 +139,48 @@ class BasicTableSelection
77
139
  puts "Selection Changed: #{selection.inspect}"
78
140
  puts "Added Selection: #{added_selection.inspect}"
79
141
  puts "Removed Selection: #{removed_selection.inspect}"
80
- @one_table_selection_radio_buttons.selected = selection
81
142
  end
82
143
  }
83
144
  }
84
145
  }
85
-
146
+
86
147
  tab_item('Zero-Or-One') {
87
148
  vertical_box {
88
149
  vertical_box {
89
150
  stretchy false
90
151
 
91
152
  @zero_or_one_table_selection_radio_buttons = radio_buttons {
92
- items @zero_or_one_table_data.size.times.map { |row| "Row #{row} Selection" }
93
-
94
- on_selected do |rb|
95
- @zero_or_one_table.selection = [rb.selected]
96
- end
153
+ items @zero_or_one_table_presenter.selection_items
154
+ selected <=> [@zero_or_one_table_presenter, :selection]
97
155
  }
98
156
  }
99
157
 
100
- button('Toggle Table Header Visibility') {
158
+ horizontal_box {
101
159
  stretchy false
102
160
 
103
- on_clicked do
104
- @zero_or_one_table.header_visible = !@zero_or_one_table.header_visible
105
- end
106
- }
107
-
108
- @zero_or_one_table = table {
109
- text_column('Animal') {
110
- # sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
111
-
112
- on_clicked do |tc, column|
113
- sort_zero_or_one_table_column(tc, column)
161
+ button('Toggle Table Header Visibility') {
162
+ on_clicked do
163
+ @zero_or_one_table_presenter.toggle_header_visible
114
164
  end
115
165
  }
116
- text_column('Description') {
117
- # sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
118
-
119
- on_clicked do |tc, column|
120
- sort_zero_or_one_table_column(tc, column)
166
+
167
+ button('Toggle Table Sortability') {
168
+ on_clicked do
169
+ @zero_or_one_table_presenter.toggle_sortable # toggles sortable attribute to false or true
121
170
  end
122
171
  }
172
+ }
173
+
174
+ @zero_or_one_table = table {
175
+ @zero_or_one_table_presenter.column_presenters.each do |column_presenter|
176
+ text_column(column_presenter.name)
177
+ end
123
178
 
124
- cell_rows @zero_or_one_table_data
125
- selection_mode :zero_or_one # other values are :zero_or_many , :one, :none (default is :zero_or_one if not specified)
126
- # selection 0 # initial selection row index (could be nil too or just left off)
127
- # header_visible true # default
179
+ cell_rows @zero_or_one_table_presenter.data
180
+ selection_mode <= [@zero_or_one_table_presenter, :selection_mode]
181
+ selection <=> [@zero_or_one_table_presenter, :selection]
182
+ header_visible <= [@zero_or_one_table_presenter, :header_visible]
183
+ sortable <= [@zero_or_one_table_presenter, :sortable]
128
184
 
129
185
  on_row_clicked do |t, row|
130
186
  puts "Row Clicked: #{row}"
@@ -140,7 +196,6 @@ class BasicTableSelection
140
196
  puts "Selection Changed: #{selection.inspect}"
141
197
  puts "Added Selection: #{added_selection.inspect}"
142
198
  puts "Removed Selection: #{removed_selection.inspect}"
143
- @zero_or_one_table_selection_radio_buttons.selected = selection
144
199
  end
145
200
  }
146
201
  }
@@ -151,49 +206,46 @@ class BasicTableSelection
151
206
  vertical_box {
152
207
  stretchy false
153
208
 
154
- @zero_or_many_table_selection_checkboxes = @zero_or_many_table_data.size.times.map do |row|
209
+ @zero_or_many_table_selection_checkboxes = @zero_or_many_table_presenter.data.size.times.map do |row|
155
210
  checkbox("Row #{row} Selection") {
156
- on_toggled do |c|
157
- table_selection = @zero_or_many_table.selection.to_a
158
- if c.checked?
159
- table_selection << row unless table_selection.include?(row)
160
- else
161
- table_selection.delete(row) if table_selection.include?(row)
162
- end
163
- @zero_or_many_table.selection = table_selection
164
- end
211
+ checked <=> [@zero_or_many_table_presenter, :selection,
212
+ on_read: ->(selection_rows) {selection_rows.to_a.include?(row)},
213
+ on_write: ->(checked_value) {
214
+ checked_value ?
215
+ (@zero_or_many_table_presenter.selection.to_a + [row]).uniq :
216
+ @zero_or_many_table_presenter.selection.to_a.reject {|v| v == row }
217
+ },
218
+ ]
165
219
  }
166
220
  end
167
221
  }
168
222
 
169
- button('Toggle Table Header Visibility') {
223
+ horizontal_box {
170
224
  stretchy false
171
225
 
172
- on_clicked do
173
- @zero_or_many_table.header_visible = !@zero_or_many_table.header_visible
174
- end
175
- }
176
-
177
- @zero_or_many_table = table {
178
- text_column('Animal') {
179
- # sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
180
-
181
- on_clicked do |tc, column|
182
- sort_zero_or_many_table_column(tc, column)
226
+ button('Toggle Table Header Visibility') {
227
+ on_clicked do
228
+ @zero_or_many_table_presenter.toggle_header_visible
183
229
  end
184
230
  }
185
- text_column('Description') {
186
- # sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
187
-
188
- on_clicked do |tc, column|
189
- sort_zero_or_many_table_column(tc, column)
231
+
232
+ button('Toggle Table Sortability') {
233
+ on_clicked do
234
+ @zero_or_many_table_presenter.toggle_sortable # toggles sortable attribute to false or true
190
235
  end
191
236
  }
237
+ }
238
+
239
+ @zero_or_many_table = table {
240
+ @zero_or_many_table_presenter.column_presenters.each do |column_presenter|
241
+ text_column(column_presenter.name)
242
+ end
192
243
 
193
- cell_rows @zero_or_many_table_data
194
- selection_mode :zero_or_many # other values are :none , :zero_or_one , and :one (default is :zero_or_one if not specified)
195
- selection 0, 2, 4 # initial selection row indexes (could be empty array too or just left off)
196
- # header_visible true # default
244
+ cell_rows @zero_or_many_table_presenter.data
245
+ selection_mode <= [@zero_or_many_table_presenter, :selection_mode]
246
+ selection <=> [@zero_or_many_table_presenter, :selection]
247
+ header_visible <= [@zero_or_many_table_presenter, :header_visible]
248
+ sortable <= [@zero_or_many_table_presenter, :sortable]
197
249
 
198
250
  on_row_clicked do |t, row|
199
251
  puts "Row Clicked: #{row}"
@@ -209,46 +261,39 @@ class BasicTableSelection
209
261
  puts "Selection Changed: #{selection.inspect}"
210
262
  puts "Added Selection: #{added_selection.inspect}"
211
263
  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
217
- end
218
264
  end
219
265
  }
220
266
  }
221
267
  }
222
-
268
+
223
269
  tab_item('None') {
224
270
  vertical_box {
225
- button('Toggle Table Header Visibility') {
271
+ horizontal_box {
226
272
  stretchy false
227
273
 
228
- on_clicked do
229
- @none_table.header_visible = !@none_table.header_visible
230
- end
231
- }
232
-
233
- @none_table = table {
234
- text_column('Animal') {
235
- # sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
236
-
237
- on_clicked do |tc, column|
238
- sort_none_table_column(tc, column)
274
+ button('Toggle Table Header Visibility') {
275
+ on_clicked do
276
+ @none_table_presenter.toggle_header_visible
239
277
  end
240
278
  }
241
- text_column('Description') {
242
- # sort_indicator :descending # (optional) can be :ascending, :descending, or nil (default)
243
-
244
- on_clicked do |tc, column|
245
- sort_none_table_column(tc, column)
279
+
280
+ button('Toggle Table Sortability') {
281
+ on_clicked do
282
+ @none_table_presenter.toggle_sortable # toggles sortable attribute to false or true
246
283
  end
247
284
  }
285
+ }
286
+
287
+ @none_table = table {
288
+ @none_table_presenter.column_presenters.each do |column_presenter|
289
+ text_column(column_presenter.name)
290
+ end
248
291
 
249
- cell_rows @none_table_data
250
- selection_mode :none # other values are :zero_or_many , :zero_or_one, :one (default is :zero_or_one if not specified)
251
- # header_visible true # default
292
+ cell_rows @none_table_presenter.data
293
+ selection_mode <= [@none_table_presenter, :selection_mode]
294
+ selection <=> [@none_table_presenter, :selection]
295
+ header_visible <= [@none_table_presenter, :header_visible]
296
+ sortable <= [@none_table_presenter, :sortable]
252
297
 
253
298
  on_row_clicked do |t, row|
254
299
  puts "Row Clicked: #{row}"
@@ -264,40 +309,6 @@ class BasicTableSelection
264
309
  }
265
310
  }
266
311
  }
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
301
312
  end
302
313
 
303
314
  BasicTableSelection.launch