ValueTree and its use


#1

Hi all !

I spent some time to study the ValueTree class as well as the related posts in this forum.

I think I have a clear view for the use of ValueTree class in conjunction with the TreeView.
I think it is an excellent tool for displaying and manipulating *actual* data in a tree form, like:

- Displaying Master/Detail ordered data and having change messages on then
- Creating side menus in a tree style...

and so on.

Nevertheless, I still have an obscure point on the ValueTree class.
As I read on the Forum, some Juce users use it to control the appearance of the graphical interface. 
According to the above, it looks like a ValueTree class acts as a *parallel* data model which holds the same values as the program variables. However, the creation and maintenance of this model, requires additional procedures and enough code with many String constants.  

Especially for the UI, I understand the use of the ValueTree class as a tool that allows the end-user to make changes to the UI appearance.

Is this correct or is there something else that I do not understand?

Thanks for any suggestion that will make my mind goes up.


#2

There seem to be several ways to skin this particular cat. 

I'm playing with it properly for the first time at the moment, so you may find other people have better solutions. 

But, I've got the whole GUI configured from it, all my plugin parameters in it, and practically every piece of data the user might want to save is stored there too. 

Where possible I don't keep a parallel version of the data.  I have a bunch of classes which let me query the data in the tree whenever it's needed.  In a few places I have classes that do some interpretation of the data, and for the audio thread some performance optimisations.   I also have a few classes which store themselves as ReferenceCountedObjects directly in the ValueTree.

On the upside - saving and loading state has become really easy.  And I get notifications everywhere when values change. 

On the downside - its' hard to keep concerns nicely separated and requires quite a bit of thought not to get into a mess.  It's not too easy to debug either sometimes!