DataSource.h file
GGDataSource: a set of items, how they relate, and what each one shows.
The same items often need to be shown under different relations (entities by attachment, by owner, by prefab) and in different shapes (list, tree, table). Those are independent choices:
Shape which widget the source is given to Relation which source the widget is given
A view takes a GGDataSource and draws it. It doesn't own or copy the data. The integration layer implements one source per relation (for the engine: read from the published frame).
ui.Tree(byAttachment); ui.Tree(byOwner); // same items, different relation ui.List(byAttachment); // same relation, different shape ui.Table(byAttachment, { .RowHeight = 22 }); ui.Tree(source, {}, [&](ItemID item) { EntityRow(ui, item); }); // custom rows
With a RowHeight, a list or tree is virtualised: it builds only the visible rows, whatever the item count. Rows are rebuilt as it scrolls, and the cost depends on how row content is given:
[&](ItemID item) { ... } Not stored, so it may capture by reference. Building other rows re-runs the enclosing component: fine if that is just the list, expensive if it is a whole panel. [=](UI& ui, ItemID item) { ... } Stored by the view (capture by value). Rows rebuild on their own and nothing around them re-runs.
ItemIDs are the same in every source that shows an item, so identity, expansion, and selection follow the item across shapes and relations.
Namespaces
- namespace GGUI
- namespace GGUI::Tables
- Tables as they are, for tools and tests. Each takes the node ui.Table returned.
- namespace GGUI::PropertyGrids
- Property grids as they are, for tools and tests. Each takes the node ui.Properties returned.
- namespace GGUI::ItemViews
- Lists, trees, and tiles as they are, for tools and tests. Each takes the node ui.List, ui.Tree, or ui.Tiles returned.
Classes
- struct GGUI::ColumnInfo
- A column of a data source.
- struct GGUI::CellValue
- One cell. Text is only valid until the next call into the source.
- struct GGUI::GGDataSource
- Items, how they relate, and what each shows. Implemented by the integration layer, one per relation.
- class GGUI::ItemVisitor
- Non-owning callable taking an ItemID. Called during the call it is passed to, never stored.
- class GGUI::ItemSet
- ItemSet: a set of items owned by the caller, used for selection and expansion.
- struct GGUI::GGSort
- Sort order for a list's items, or for a tree's items under each parent.
- struct GGUI::ListProps
- Properties of ui.List.
- struct GGUI::TreeProps
- Properties of ui.Tree.
- struct GGUI::GGTableColumn
- A column a table shows.
- struct GGUI::TableProps
- TableProps: a source's items as rows, with columns under a header.
- class GGUI::GGPropertyFn
- Custom value cell:
[=](UI& ui, const FieldInfo& field) { ... }. - struct GGUI::PropertiesProps
- Properties of ui.Properties: a property grid, a FieldSource's fields as a two-column table of name and editor.
- struct GGUI::TilesProps
- TilesProps: a source's items as a grid of equal-sized tiles (ui.Tiles). For asset browsers.
- struct GGUI::PickerProps
- ui.Picker: a button showing the chosen item's name that opens a searchable list of the source's items. Also accepts a row dragged from a list.