JUCE HBox or VBox?


#1

How are you meant to align components (such as buttons, labels, text boxes)?


#2

Are these java concepts?

Override Component::resized(), call your child components’ setBounds(x, y, width, height).

You can make arrays of them, and place them accordingly with a bit of math…


#3

You can also, as I recently discovered, give Components ID's which can then be used to align them with a string expression e.g.

compA.setComponentID("CompA");

compB.setComponentID("CompB");

compC.setBounds("CompA.right, 0, parent.width, CompB.top");

See https://www.juce.com/api/classComponent.html#a821833808f451753df397802d9d6160a


#4

I'd probably recommend against this method nowadays.. It works, but from experience we've generally found that the most debuggable and readable way to lay them out is using Rectangle methods (grep the codebase for "removeFromTop", "removeFromLeft" etc and you'll find many examples of this)

(A new layout system that uses a more "flexbox" style paradigm is on our to-do list though!)