Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/table.h

A list with columns you can sort and resize.

#include <sonore/gfx/table.h>
On this page

Design notes

What it is for

A preset browser with Name, Author and Category. A sample list with Name, Length and Rate. Anything where one string per row is not enough and the user wants to reorder by whichever column they are thinking in.

It does not reorder your data

Clicking a header reports which column and which direction, and the OWNER re-sorts its own rows and says so. That is the conventional contract and the only one without an ambiguity: a table that kept its own permutation would have to decide whether getCellText(3) means the fourth row of the model or the fourth row on screen, and every bug in every such table is that question answered differently in two places.

The cost is five lines of std::sort in the caller. The benefit is that a numeric column sorts numerically, which a table sorting its own cell TEXT cannot do -- "10" comes before "9" and nobody notices until the list is long enough to matter.

Virtual, like everything else here

Rows are drawn from a callback, on demand. Four hundred presets paint the twelve on screen.

Types 2

One column of a TableListBox: its header text and its width in pixels, which the user can drag down to minWidth but no further.

class TableListBox : public Widget

Rows of text under column headers that can be resized and clicked to sort -- the reference's TableListBox, driven by callbacks rather than a model class. The file comment says why sorting is left to the owner.

The table holds no row data. Tell it how many rows there are (setNumRows), answer getCellText for the rows on screen, and call updateContent() after changing or re-sorting the data; a row index always means the owner's row. Message thread only.

↑↓ to move↵ to openEvery public name in the headers, and every guide