andlabs / libui

Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
Other
10.72k stars 614 forks source link

Add new API functions for table header clicks and sort indicators. #513

Open szanni opened 4 years ago

szanni commented 4 years ago

Proposal for introducing an enum sort type uiSort:

uiSortNone
uiSortAscending
uiSortDescending

Two functions for setting table header sort indicators (only visual, no sorting is performed):

uiSort uiTableHeaderSortIndicator(uiTable *t, int column);
void uiTableHeaderSetSortIndicator(uiTable *t, int column, uiSort order);

And a setter for a header on clicked callback function:

void uiTableHeaderOnClicked(uiTable *t, void (*f)(uiTable *table, int column, void *data), void *data);

Implementations are provided for darwin, unix, and windows.

Notes: The column is the index of the column when it was added to the table. It might be nice to be able to set a numeric identifier, similar to how table columns are handled on darwin. Or possibly even introducing a uiTableColumn type and cleaning up the uiTableAppendColumn API. This would however break the existing API, so I left it out for the time being.