MCPcopy Create free account
hub / github.com/cogentcore/core / SortSliceAction

Method SortSliceAction

tensor/tensorcore/table.go:434–467  ·  view source on GitHub ↗

SortSliceAction sorts the slice for given field index -- toggles ascending vs. descending if already sorting on this dimension

(fldIndex int)

Source from the content-addressed store, hash-verified

432// SortSliceAction sorts the slice for given field index -- toggles ascending
433// vs. descending if already sorting on this dimension
434func (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

Callers 1

MakeHeaderMethod · 0.95

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 8

SliceHeaderMethod · 0.95
RowWidgetNsMethod · 0.95
ChildMethod · 0.80
SortIndexesMethod · 0.80
SetIconMethod · 0.65
UpdateMethod · 0.65
SetTypeMethod · 0.45
SortColumnMethod · 0.45

Tested by

no test coverage detected