SortSliceAction sorts the slice for given field index -- toggles ascending vs. descending if already sorting on this dimension
(fldIndex int)
| 432 | // SortSliceAction sorts the slice for given field index -- toggles ascending |
| 433 | // vs. descending if already sorting on this dimension |
| 434 | func (tb *Table) SortSliceAction(fldIndex int) { |
| 435 | sgh := tb.SliceHeader() |
| 436 | _, idxOff := tb.RowWidgetNs() |
| 437 | |
| 438 | ascending := true |
| 439 | |
| 440 | for fli := 0; fli < tb.NCols; fli++ { |
| 441 | hdr := sgh.Child(idxOff + fli).(*core.Button) |
| 442 | hdr.SetType(core.ButtonAction) |
| 443 | if fli == fldIndex { |
| 444 | if tb.SortIndex == fli { |
| 445 | tb.SortDescending = !tb.SortDescending |
| 446 | ascending = !tb.SortDescending |
| 447 | } else { |
| 448 | tb.SortDescending = false |
| 449 | } |
| 450 | if ascending { |
| 451 | hdr.SetIcon(icons.KeyboardArrowUp) |
| 452 | } else { |
| 453 | hdr.SetIcon(icons.KeyboardArrowDown) |
| 454 | } |
| 455 | } else { |
| 456 | hdr.SetIcon("none") |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | tb.SortIndex = fldIndex |
| 461 | if fldIndex == -1 { |
| 462 | tb.Table.SortIndexes() |
| 463 | } else { |
| 464 | tb.Table.SortColumn(tb.SortIndex, !tb.SortDescending) |
| 465 | } |
| 466 | tb.Update() // requires full update due to sort button icon |
| 467 | } |
| 468 | |
| 469 | // TensorDisplayAction allows user to select tensor display options for column |
| 470 | // pass -1 for global params for the entire table |
no test coverage detected