openframeworks/openFrameworks — pull request #1368 by markpitchless (2012-06-30 23:53:02+00:00)
Title: Feature ofxgui ofxlabel

A simple label widget for ofxGui, because every gui toolkit needs one :)

I had to create empty stubs for all the event hook methods decalred as pure virtual in the base class. I was tempted to change ofxGuiBase to have empty methods instead to make the sub class smaller but was wondering why all those methods are not defined with empty implementations. Is there a subtle with event binding that I'm missing?

My first attempt at this I tried to make the label value an ofxParameter, so you could hook change events for the label. I was seeing ofxParameter as a generic way of adding a change event to any type. That failed because ofxParameter only works with numeric types due to the min, max functionality and the calls to numeric_limits.
I think it would be useful to be able to use ofxParameter with strings and maybe other types that are not numeric. Would you be interested in extending it that way?

Would likely still want to keep the numeric version. I see a few ways to do that. Sub class:
```
ofxParameter foo;
ofxNumericParameter scale;
```
Or maybe using another paramatised type:
```
ofxParameter< ofxLimted >
```
Or making the limiting more generic so that ofxParamter takes a function ref or function object that processes any set of the parameter:
```
ofxParameter size;
ofxMinMaxLimiter limit(0,255);
size.setLimiter( limit );
```
This is a little long winded but would allow for things other than basic min max. e.g. paramters whose values roll around. A screen width/height limiter. The verbosity could maybe be brought down with a useful set of limiter classes and some static factory functions to create them. A bit like:
```
size.setLimiter( ofxLimiters.minMax(0,255) )
```

The more genric stuff may well be over the top and having a base type and numeric specialization is enough.

Not sure which of those I like and I'm sure there are other approaches. I thought his might be a good place to start some discussions (let me know if there is a better place). I'm up for working on a patch if we can come up with a design.

hth,
mark