openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.85k stars 2.55k forks source link

ofParameter::isInit() implementation #7898

Closed artificiel closed 5 months ago

artificiel commented 5 months ago

following the discussion in https://forum.openframeworks.cc/t/can-i-tell-if-an-ofabstractparameter-is-set-to-its-default-value/ this builds on the recent 'init' mechanism of ofParameter and adds the ability to verify if the value is at it's initial value or not, without the need to "unwrap" (cast) the internal data type of the abstract parameter at the call site.

isInit() will also work on a concrete ofParameter<T>, as well as ofParameterGroup (recursively calling isInit() on itself and returning true only if all the children are true).

note that isInit() is not linked to activity but current instantaneous value (if true, a parameter could have changed in the past, but is by some means back to it's init value). see didNotify() to check for "activity" (which will return true even if it's to go back to it's initial value).

ofTheo commented 5 months ago

looks good to me! thanks @artificiel