Book Image

OpenFrameworks Essentials

Book Image

OpenFrameworks Essentials

Overview of this book

Table of Contents (19 chapters)
openFrameworks Essentials
About the Authors
About the Reviewers

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:

  1. 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.

  2. Now set up the group and its controls by adding the following code to the setup() function (insert it right before the gui.loadFromFile... command):

    globalGroup.setup( "Global" );
    globalGroup.add( Scale.setup( "Scale", 1, 0.0, 1 ) );
    globalGroup.add( Rotate.setup( "Rotate", 0, -180, 180 ) );
    globalGroup.add( Background.setup...