I have a float attribute in a UI object which implements a custom getter and setter. Internally, the float is stored as an atom (it's part of a structure which is reused amongst multiple objects and can represent other data types), but the getter and setter handles the conversion. This all works fine in the object inspector, but attrui doesn't seem to be able to get the value, it displays zero for this attribute.
t_max_err hnpf_attrvalue_get(t_hn_pin_float *x, t_object *attr, long *argc, t_atom **argv)
{
char alloc;
long size = 0;
atom_alloc(argc, argv, &alloc);
if (alloc == true)
**argv = x->pinStruct_.value;
return MAX_ERR_NONE;
}
t_max_err hnpf_attrvalue_set(t_hn_pin_float *x, t_object *attr, long argc, t_atom *argv)
{
float newValue;
float minimum = atom_getfloat(&x->pinStruct_.minimum);
float maximum = atom_getfloat(&x->pinStruct_.maximum);
switch (atom_gettype(argv))
{
case (A_FLOAT) :
newValue = atom_getfloat(argv);
break;
case (A_LONG) :
newValue = (float)atom_getlong(argv);
break;
default:
return MAX_ERR_NONE;
}
newValue = max(minimum, newValue);
newValue = min(maximum, newValue);
atom_setfloat(&x->pinStruct_.value, newValue);
return MAX_ERR_NONE;
CLASS_ATTR_FLOAT(c, "value", 0, t_hn_pin_float, pinStruct_.value);
CLASS_ATTR_ACCESSORS(c, "value", hnpf_attrvalue_get, hnpf_attrvalue_set);
CLASS_ATTR_DEFAULT_SAVE_PAINT(c, "value", 0, "0");