Hi Joshua... I have a treeview, filled with TreeViewItems. This subclass of TreeViewItem let's call ServerTreeViewItem
It has overriden - Component * createItemComponent()
Let's call this ServerCustomComponent
Everything works great... I've got items visible. Now something has happened... state has changed, and the ServerCustomComponent's needs to be redrawn/refreshed, told this new state. I've been passing in the state when I createItemComponent and new ServerCustomComponent(state);
Logically I would think calling treeHasChanged() would mark all those custom components as needing to be re-created. It doesn't.
It also seems different to how I think a table list box works, which can pass in a component to update, or null if it needs a new one.
In juce_Treeview there's updateComponents, which is called when treeHasChanged() is called... my comments added... might be clearer that way....
for (int i = items.size(); --i >= 0;)
items.getUnchecked(i)->shouldKeep = false;
TreeViewItem* item = owner.rootItem;
int y = (item != nullptr && ! owner.rootItemVisible) ? -item->itemHeight : 0;
while (item != nullptr && y < visibleBottom)
y += item->itemHeight;
if (y >= visibleTop)
if (RowItem* const ri = findItem (item->uid)) // ITEM IS FOUND BECAUSE ITS VISIBLE, maybe it needs to be if (!refereshAllComponents && RowItem* const ri = findItem(item->uid)) and pass refreshAllComponents as a parameter to updateComponents? Its not as elegant as how the tableview works but still...
// Component is found and is used as is... never having a chance to be updated...
ri->shouldKeep = true;
else if (Component* const comp = item->createItemComponent())
items.add (new RowItem (item, comp, item->uid));
item = item->getNextVisibleItem (true);
If it was safe(I know its not though)... to keep a pointer to the custom component inside my TreeViewItem subclass, I could simply update it myself. But there doesn't seem to be anyway for me to get at the current OwnedArray of custom components myself...