Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion FaustCode/owl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,24 @@ class OwlButton : public OwlParameterBase {
}
};

class OwlCheckbox : public OwlParameterBase {
protected:
PatchButtonId fButton; // OWL button id : PUSHBUTTON, ...
bool wasHigh = false; // Flag for edge detection
bool state = false; // Current state
public:
OwlCheckbox(Patch* pp, PatchButtonId button, FAUSTFLOAT* z, const char* l)
: OwlParameterBase(pp, z, false)
, fButton(button) {}
void update() {
bool isHigh = fPatch->isButtonPressed(fButton);
state ^= isHigh && !wasHigh;
wasHigh = isHigh;
fPatch->setButton(fButton, state, 0);
*fZone = state;
}
};

/**************************************************************************************
*
* OwlUI : Faust User Interface builder. Passed to buildUserInterface OwlU
Expand Down Expand Up @@ -434,6 +452,21 @@ class OwlUI : public UI {
fButton = NO_BUTTON; // clear current button ID
}

void addOwlCheckbox(const char* label, FAUSTFLOAT* zone) {
if (fParameterIndex < MAXOWLPARAMETERS) {
if (meta.midiOn && strcasecmp(label, "gate") == 0) {
fParameterTable[fParameterIndex++] =
new OwlVariable(fPatch, &fGate, zone, label, 0.0f, 0.0f, 1.0f);
}
else if (fButton != NO_BUTTON) {
fParameterTable[fParameterIndex++] =
new OwlCheckbox(fPatch, fButton, zone, label);
}
}
fParameter = NO_PARAMETER;
fButton = NO_BUTTON; // clear current button ID
}

// we dont want to create a widget but we clear the current parameter ID just in case
void skip() {
fParameter = NO_PARAMETER; // clear current parameter ID
Expand Down Expand Up @@ -483,7 +516,7 @@ class OwlUI : public UI {
addOwlButton(label, zone);
}
virtual void addCheckButton(const char* label, FAUSTFLOAT* zone) {
addOwlButton(label, zone);
addOwlCheckbox(label, zone);
}
virtual void addVerticalSlider(const char* label, FAUSTFLOAT* zone,
FAUSTFLOAT init, FAUSTFLOAT lo, FAUSTFLOAT hi, FAUSTFLOAT step) {
Expand Down