Creating groups of controls
When the number of visual controls increases, it's a good idea to organize them into groups. Grouping simplifies navigating through parameters and helps to save screen space from cluttering, by collapsing currently unused groups.
The ofxGuiGroup
class is used to create a group of controls. Let's create such a group consisting of three sliders, which will control the scale, rotation, and background of the image:
- Add the following lines to the
ofApp
class's declaration:ofxGuiGroup globalGroup; ofxFloatSlider Scale; ofxFloatSlider Rotate; ofxFloatSlider Background;
The first line declares a group, and the next lines declare sliders for it.
- Now set up the group and its controls by adding the following code to the
setup()
function (insert it right before thegui.loadFromFile...
command):globalGroup.setup( "Global" ); globalGroup.add( Scale.setup( "Scale", 1, 0.0, 1 ) ); globalGroup.add( Rotate.setup( "Rotate", 0, -180...