User interface design and architecture

I want to add UI to my project, I have a broad domain of classes, and for some of them I would like to represent values on screen. My question is regarding good practices when it comes to UI coding, should I embed UI layouts for each of my classes? Should I have a separate UI wrapper to which I can easily send information? (similar to ofLog).

I wouldn’t like to have everything on my ofApp.cpp, I’d prefer to have a GUI module that I can dettach at any time. How do you guys tackle this?

Any resources on UI architecture will be welcome!

I usually have ofParameters per class + an ofParameterGroup initialized in the class constructor, then you can plug every parameter group in a gui in ofApp or even in some gui class

1 Like

Here is how I approached it in a still work-in-progress project. It’s basically a camera controller where I wanted the option to display a GUI that could adjust different values of the camera.

I created a ControlPanel class and passed it a pointer to the videoGrabber-type class I wanted to control (this example is a bit more complicated as OSC is involved). Here is the setup call to create the ControlPanel

You can see in the ControlPanel class all of the ofParameters/callbacks and here is an where it talks to the videoGrabber

So like you are saying - I can take it out/not update/draw it just by disabling a few calls inside the ofApp (named texturedRemoteApp in this case)

1 Like

Thank you both! I will take a look at the ofParameter functionalities. Is ofParameter mainly GUI oriented? All I’ve found is this post from 2011.

Also, I noticed that some versions ago, the most used UI (at least the popular one) was ofxUI, and then ofxGui was added to the core OF. I’ve actually used ofxUI in most of my projects.

ofxUI can also associate attributes to sliders and other elements. Why is it preferable to use ofxGui+ofParameter? Or, why wasn’t ofxUI modified to accept ofParameters and ofParameterGroups?

ofParameter is fairly new and was kinda hard for me to get my head around. ofxGui uses it and I was mostly using it for the OSC sync.

I’ve done similar patterns with other GUIs/without ofParameter - the main idea being keeping it in a separate class that you tie the gui/parameters in