Dynamic List
Overview and characteristics
Create a list in a binding source (all samples are included in cgi_studio_player)
<bindingSource name="SampleBindingSource" access="asynchronous" uid="{5fb25ecc-8223-42b5-8f00-edce8fe042f3}">
</bindingSource>
This binding source does not yet provide a list. Hence, we have to add a list item to that binding source.
<bindingSource name="SampleBindingSource" access="asynchronous" uid="{5fb25ecc-8223-42b5-8f00-edce8fe042f3}">
<list name="SampleList" uid="{1241d345-07af-46ec-b0cd-90a687c56140}" />
</bindingSource>
By default this list will be able to support any fragment size that is requested. Hence, the fragment has not a fixed size capacity but a dynamically growing capacity. This implies the use of allocating memory with different block sizes.
<list name="SampleList" windowSize="30" uid="{1241d345-07af-46ec-b0cd-90a687c56140}" />
In addition you can also define a complete list of a fixed size by providing the attribute maxCount. If both attributes are provided the attribute maxCount will be ignored and a list fragment will be used.
<list name="SampleList" maxCount="100" uid="{1241d345-07af-46ec-b0cd-90a687c56140}" />
At this point we are already able to define the list binding itself in SceneComposer.
Create the List view binding to the list data model










Create the binding source for the list item
<bindingSource name="SampleListEntry" access="asynchronous" uid="{86f39d72-8d42-43eb-87e7-475cdf384734}">
</bindingSource>
To mark it as a binding source that can be used as a list item we have to enable the attribute dataContextItem. DataContext items are a more generic concept in CGI Studio that can be used to define scene node local data context containing one or more local binding sources. The list item is an example that uses this concept to enable the binding of view list item properties to list data items.
<bindingSource name="SampleListEntry" access="asynchronous" dataContextItem="true" uid="{86f39d72-8d42-43eb-87e7-475cdf384734}">
</bindingSource>
Now we have to add some data items to that binding source.
<bindingSource name="SampleListEntry" access="asynchronous" dataContextItem="true" uid="{86f39d72-8d42-43eb-87e7-475cdf384734}">
<item name="UInt64Value" type="FeatStd::UInt64" uid="{5cb01d1b-9b9b-4982-99b2-4c82a4823d16}" />
<item name="FloatValue" type="FeatStd::Float" uid="{7a55879f-0a01-41bf-9d96-d3048280b79f}" />
Create the List item view binding to the list item data model


















Handling the List model code
bool DynamicListComponent::OnMessage(const Courier::Message & msg) { bool rc = false; switch (msg.GetId()) { case Courier::StartupMsg::ID: (*mSampleBindingSource).mVariantValue = FeatStd::Variant(10.0F); LoadSampleListFragmentMissingItems(0, 30); (*mSampleBindingSource).mSampleList.UpdateListItemCount(SAMPLE_LIST_SIZE); mSampleBindingSource.MarkItemModified(ItemKey::SampleBindingSource::SampleListItem); mSampleBindingSource.SendUpdate(true); break;
case UpdateModelMsg::ID: {
case Courier::ListRequestType::NewFragment: switch (request.ItemKey()) { case ItemKey::SampleBindingSource::SampleListItem: LoadSampleListFragmentMissingItems(request.NewIndex(), request.OldIndex()); break; } break;
case Courier::ListRequestType::ChangeDataItem:
switch (request.ItemKey()) {
case ItemKey::SampleBindingSource::SampleListItem:
switch (request.InnerItemKey()) {
case ItemKey::SampleListEntry::FloatValueItem: {
const FeatStd::Float* value = request.GetItem<FeatStd::Float>();
SetSampleListTestListValue(request.NewIndex(), *value);
}
break;
}
break;
}
break;