ofxKuTextGui - openFrameworks addon for creating textual GUI controlled by keyboard and mouse
It supports integers, floats, strings, stringlists (represented as integer, with string output in GUI) and buttons.
Values can be edited using keyboard or mouse, and stored in a file.
Supported smoothing values (read details below and see example of it at example-app-template).
Download and unzip as ofxKuTextGui to addons folder of your openFrameworks installation.
Addon works in openFrameworks 0.10.1 and older, Windows/MacOS/Linux.
For working with addon, you need only four files in your project:
ofxKuGextGui.h/cpp - its GUI itself, see example-basic example and
ofxKuTextGuiGen.h/cpp - this module allows to generate C++ code from GUI script, see example-gui-generate example.
Files ofxKuTextGuiEnvelope and ofxKuTextGuiEnvelopeEditor adds functionality for working with envelopes.
The other files requires adding additional addons to the project, so just exlude this files from your project this functionality is not required and you don't want to add addinional addons:
ofxKuTextGuiPreset works with presets and requires ofxKu addon,
ofxKuTextGuiRemote is used for remote control GUI via OSC and requires ofxOsc addon, see example-remote and also https://github.com/perevalovds/KuRemote app which indended to control such GUIs remotely.
example-basic demonstrates creating GUI manually: you need to define variables and then link them with GUI.
example-gui-generate demonstrates generation of H/CPP files for constructing GUI from a GUI script file (see below). By pressing Shift+G it creates source files, which contain GUI creation and also variables definition.
Note: variables names started with "*" means constants, such as *FPS, and defined in C++ code as
PRM FPS - constant,
PRM _FPS_ - its current value in GUI.
Variables names started with "-" means output values, such as -fps, and defined in C++ code as
- example-gui-dyncreate shows how to create GUI during runtime from a script file. In this case, GUI stores values itself, and to get access to value, use the following functions:
gui.button_(), for example:
- example-app-template example is a template for creating full-fledge applications. Just use App class for performing your custom actions.
Also it shows how to use feature of smoothing values (see technical details below).
Please take care on the following notes:
'stringlist' is int value.
'button' is int value. Button fires only once after pressing, and then set to 0 automatically.
GUI script file
A GUI script file looks as the following:
int *FPS=30 1:100 1,10
dummy Screen size:
int *w=1024 1:2000 1,10
int *h=768 1:2000 1,10
`stringlist enabled=OFF [OFF,ON]
float -fps=30 0:100 100,10
Then in the code you just link it to gui object:
And for access to parameters use PRM:
PRM fps_ = ofGetFrameRate();
Note about constants: you can get access to changed valued of constants by adding "_" at the beginning and end. For example, for '*FPS' value, PRM FPS means constant value, not changed after program start, and PRM FPS is value, possible changed by user.
Float and int values can be smoothed, so they change that smooth value with given period of time for whole range.
Smoothed values drawn automatically as think lines at the bottom of value's widget.
Code for smoothing currently binded to string names of variables:
//Smoothing values float time_smooth = PRM time_smoothing; float smoothed1 = gui.updateSmoothedValue("smooth_float", dt, time_smooth); float smoothed2 = gui.updateSmoothedValue("smooth_int", dt, time_smooth); //Access to a smoothed value cout << "smooth_float smoothed = " << gui.getSmoothedValue("smooth_float") << endl;
The code above is a part of example-app-template example, so see it code for the more details.