@@ -347,6 +347,24 @@ class OwlButton : public OwlParameterBase {
347347 }
348348};
349349
350+ class OwlCheckbox : public OwlParameterBase {
351+ protected:
352+ PatchButtonId fButton ; // OWL button id : PUSHBUTTON, ...
353+ bool wasHigh = false ; // Flag for edge detection
354+ bool state = false ; // Current state
355+ public:
356+ OwlCheckbox (Patch* pp, PatchButtonId button, FAUSTFLOAT* z, const char * l)
357+ : OwlParameterBase(pp, z, false )
358+ , fButton (button) {}
359+ void update () {
360+ bool isHigh = fPatch ->isButtonPressed (fButton );
361+ state ^= isHigh && !wasHigh;
362+ wasHigh = isHigh;
363+ fPatch ->setButton (fButton , state, 0 );
364+ *fZone = state;
365+ }
366+ };
367+
350368/* *************************************************************************************
351369 *
352370 * OwlUI : Faust User Interface builder. Passed to buildUserInterface OwlU
@@ -434,6 +452,21 @@ class OwlUI : public UI {
434452 fButton = NO_BUTTON; // clear current button ID
435453 }
436454
455+ void addOwlCheckbox (const char * label, FAUSTFLOAT* zone) {
456+ if (fParameterIndex < MAXOWLPARAMETERS) {
457+ if (meta.midiOn && strcasecmp (label, " gate" ) == 0 ) {
458+ fParameterTable [fParameterIndex ++] =
459+ new OwlVariable (fPatch , &fGate , zone, label, 0 .0f , 0 .0f , 1 .0f );
460+ }
461+ else if (fButton != NO_BUTTON) {
462+ fParameterTable [fParameterIndex ++] =
463+ new OwlCheckbox (fPatch , fButton , zone, label);
464+ }
465+ }
466+ fParameter = NO_PARAMETER;
467+ fButton = NO_BUTTON; // clear current button ID
468+ }
469+
437470 // we dont want to create a widget but we clear the current parameter ID just in case
438471 void skip () {
439472 fParameter = NO_PARAMETER; // clear current parameter ID
@@ -483,7 +516,7 @@ class OwlUI : public UI {
483516 addOwlButton (label, zone);
484517 }
485518 virtual void addCheckButton (const char * label, FAUSTFLOAT* zone) {
486- addOwlButton (label, zone);
519+ addOwlCheckbox (label, zone);
487520 }
488521 virtual void addVerticalSlider (const char * label, FAUSTFLOAT* zone,
489522 FAUSTFLOAT init, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step) {
0 commit comments