so, just adding some more info/testing:
if I ditch the whole ‘recreate the tree on changes’, and make the toggle buttons follow the ‘completed’ property in the tree, and modify my propertyChanged callback to this:
void TaskQueueItemComponent::valueTreePropertyChanged(ValueTree &treeThatChanged,
const Identifier &property)
{
/*
when is this called?
whenever a child node changes
whenever a property on our tree changes
whenever a parent changes
*/
DBG( "" );
DBG("this tree: [" << tree[Identifiers::name].toString() << "]");
DBG("tree that changed: [" << treeThatChanged[Identifiers::name].toString() << "]");
DBG("property that changed: [" << property << "]");
if( treeThatChanged.isAChildOf(tree) )
{
DBG( " change occurred on a child" );
/*
update our completed/child count and update our toggle button
*/
updateLabelAndToggleButton();
if( property == Identifiers::completed )
{
DBG( " updating our property based on our children" );
bool childrenVal = isCompleted(tree);
bool ourVal = tree.getProperty(property);
if( ourVal != childrenVal )
{
tree.setProperty(property,
childrenVal,
nullptr);
}
}
}
else if( tree.isAChildOf(treeThatChanged) )
{
DBG( " change occurred on a parent" );
if( property == Identifiers::completed )
{
bool ourValue = tree.getProperty(property);
bool parentValue = treeThatChanged.getProperty(property);
if( ourValue != parentValue )
{
DBG( " updating our property" );
tree.setProperty(Identifiers::completed,
parentValue,
nullptr);
}
}
}
else if( treeThatChanged == tree)
{
DBG( " change occurred on our tree" );
}
}
clicking this checkbox for this tree:
generates this string of callbacks:
this tree: [checkbox colors when selected?]
tree that changed: [checkbox colors when selected?]
property that changed: [completed]
change occurred on our tree
this tree: [checkboxes]
tree that changed: [checkbox colors when selected?]
property that changed: [completed]
change occurred on a child
updating our property based on our children
this tree: [checkboxes]
tree that changed: [checkboxes]
property that changed: [completed]
change occurred on our tree
this tree: [graphics]
tree that changed: [checkboxes]
property that changed: [completed]
change occurred on a child
updating our property based on our children
this tree: [graphics]
tree that changed: [graphics]
property that changed: [completed]
change occurred on our tree
this tree: [TaskQueueTODO]
tree that changed: [graphics]
property that changed: [completed]
change occurred on a child
updating our property based on our children
this tree: [TaskQueueTODO]
tree that changed: [TaskQueueTODO]
property that changed: [completed]
change occurred on our tree
this tree: [HiddenRoot]
tree that changed: [TaskQueueTODO]
property that changed: [completed]
change occurred on a child
updating our property based on our children
this tree: [HiddenRoot]
tree that changed: [HiddenRoot]
property that changed: [completed]
change occurred on our tree
onValueTreePropertyChanged(HiddenRoot, completed)
onValueTreePropertyChanged(TaskQueue, completed)
this tree: [HiddenRoot]
tree that changed: [graphics]
property that changed: [completed]
change occurred on a child
updating our property based on our children
onValueTreePropertyChanged(Task, completed)
this tree: [TaskQueueTODO]
tree that changed: [checkboxes]
property that changed: [completed]
change occurred on a child
updating our property based on our children
this tree: [HiddenRoot]
tree that changed: [checkboxes]
property that changed: [completed]
change occurred on a child
updating our property based on our children
onValueTreePropertyChanged(Task, completed)
this tree: [graphics]
tree that changed: [checkbox colors when selected?]
property that changed: [completed]
change occurred on a child
updating our property based on our children
this tree: [TaskQueueTODO]
tree that changed: [checkbox colors when selected?]
property that changed: [completed]
change occurred on a child
updating our property based on our children
this tree: [HiddenRoot]
tree that changed: [checkbox colors when selected?]
property that changed: [completed]
change occurred on a child
updating our property based on our children
onValueTreePropertyChanged(Task, completed)
That just seems like a ridiculously high amount of extra callback happening for this. I can’t imagine what’ll happen if my tree becomes really complex.
Any ideas on how to lighten the callback load?