StretchableLayoutManager - how to use

"...for applications with multiple nested panels, you would use more than one StretchableLayoutManager" (from juce docs)

This is what I want to do... I have a series of roughly 10 columns that I want equally spaced, and inside each I have 2-4 items that I want stacked upwards (and downwards in other cases). Normally I would use something like a "VBox" or "HBox" in other API's, but it looks like StretchableLayoutManager is the closest thing available in JUCE.

It looks like I can't add components to this manager, but need to have components so that I can extract the calculated values. I *think* what I need to do is create 10 components for the 10 columns, and then use those coords to calculate where the items go in each column.

1. Regarding the docs above, how does it help to have more than one StretchablelayoutManager? It looks like it contains no state. I am creating a list of Components just to extract the horizontal positioning, but maybe I'm using this incorrectly?

2. Is there a way to add padding (between components)? I don't really want them immediately adjacent.

3. Am I going about this incorrectly? Is there a better class?

4. The API takes a Component*[] list which is kind of annoying when working with std::vector (my display changes sizes), but that's just a nit.

Do you need your columns to be resizable with a StretchableLayoutResizerBar? If not, I don't really recommend using that class, it's a complicated beastie that was designed for a particular purpose. If you just want to lay out a bunch of components, I've always found the easiest way is just to do the maths manually.

(However, I am interested in the new HTML flexbox stuff - that seems like it might be worth copying now that a lot of smart people seem to have finally agreed on it being the best way to structure box-style layouts)

Based on what you say, I think I'll do the calculations for the horiz aspect and use the StretchableLayout for the vertical columns, where I'll be using -.x% to use up the space appropriately. 

I just glanced at FlexBox, but really I like the flexibility/simplicity of this class:

The implementation doesn't look complicated, although I don't know what implications there are to make it JUCEable, it may turn out looking a lot like StretchableLayout with the API args being passed %'s, whereas it makes more sense to set those on the children:



I went with custom calculations as you suggested... It does work out simpler.