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:
Image may be NSFW.
Clik here to view.
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.
Image may be NSFW.
Clik here to view.
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!