Working on a new GUI addon: ofxParvenu

Just in case someone is interested, I’m working on a GUI addon called ofxParvenu.
This addon is special (as I consider it) because there’s the concept of nested containers.

For example, to produce this window-like component:

The code looks like:

parvenu.setup(); // parvenu takes care of drawing all the GUI components

std::shared_ptr<ofxPTextArea> lorem = std::make_shared<ofxPTextArea>(&parvenu, "You are about to access new feature that is\ncurrently in active development.\nThis can mean unstability and unexpected loss of data.\n\nAre you sure you want to proceed?");
std::shared_ptr<ofxPButton> submit = std::make_shared<ofxPButton>(&parvenu, "OK");
std::shared_ptr<ofxPButton> reject = std::make_shared<ofxPButton>(&parvenu, "Cancel");
submit->_fill = ofColor(0);
submit->_labelColor = ofColor(255);
reject->_fill = ofColor(255);
reject->_stroke = ofColor(0);

std::shared_ptr<ofxPHContainer> phc = std::make_shared<ofxPHContainer>(&parvenu);
std::shared_ptr<ofxPVContainerWindow> pvcw = std::make_shared<ofxPVContainerWindow>(&parvenu, "Proceed?"); // the second parameter sets the title

phc->pushComponent(submit);
phc->pushComponent(reject);

pvcw->pushComponent(lorem);
pvcw->pushComponent(phc);

pvcw->calculateMinBox();
pvcw->fitOuterBoxToMinBox();
pvcw->setComponentPositions();

phc->calculateMinBox();
phc->fitOuterBoxToMinBox();
phc->setComponentPositions();

parvenu.pushComponent(pvcw);

You can see how the buttons submit and reject are in the horizontal container phc, which is nested inside the vertical container window pvcw along with the text area lorem.

Here’s a screenshot with the borders of each component drawn out. The nesting should be clear. The padding between components within one container can be adjusted freely.

The addon is not fully built yet. Soon I will pack it into a GitHub repository.

Disclaimer for people bothered by this GUI addon! I know that by writing a GUI addon, I’m re-inventing the wheel and most of you are going to laugh at it, but this came from a personal need as I’m now working on another project that requires a nestable GUI. I thought it would be good if someone could be possibly interested in, or maybe even potentially helped by this addon. I didn’t want to miss the chance to help anyone out by making it open source, so be it.

Suggestions and criticisms are welcome. I know that example code looks long and bad.

Merry Christmas!

4 Likes

The font being used is Liberation Sans.

One problem with this GUI addon is that there can’t be much customization done on the appearance of components. You can change:

  • the font
  • the fill, stroke and text colors of components
  • padding between components inside containers

But I understand to some people that’s far from enough.

One problem is that the addon makes an oF program slow.
It’s fine if you don’t drag anything, but dragging a window can cause FPS to fall all the way down to 35 or so, from the original steady 60.

The addon is live on GitHub.
Very much undocumented for now.

Now we have horizontal sliders.

And the FPS looks much better now!