cushy
cushy copied to clipboard
Add Tabbed widget
We should have a Tabbed widget that offers a tab bar and associated content section. This should be implemented by composing two widgets: a tab bar and a multi-widget switcher (#208).
Tab bar implementations vary widely across frameworks. We should spend some time researching common features we want to make sure to include.
Initial wish-list:
- Tabs retain their state when inactive, including for example: focus, text-selection, cursor position.
- Tabs can be optionally closed, with 'try_close' and 'on_close' callbacks (use-case: a tab with a document may be unsaved and the user needs to be prompted to save, to which they could answer: 'Yes', 'No', 'Cancel')
- Tabs width should be 'fit to content' by default, minimum/maximum widths usually also required.
- When there's too many tabs to display, some way of accessing them is required. In 2024 an 'Overflow' menu would be ideal. Other less than ideal options include
<and>buttons or a horizontal scrollable area. - Owner of the Tab bar may need to access all the labels and to change them. (use-case: in order to distinguish between two tabs with the same name, a prefix may need to be added, e.g. instead of two 'mod.rs' tabs, show 'dir1/mod.rs' and 'dir2/mod.rs').
- Should still render a tab bar, even when no tabs have been added to it.
See also: https://github.com/hydra/cushy/tree/tabbed-document-ui-example/examples/tabbed-document-ui#requirements
Would-be-nice:
- tabs that can be re-ordered by dragging-and-dropping.
- API that supports programmatic re-ordering of tabs.