Browse Source

Add panic to context menu of all relevant Core MIDI modules.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
1f5cec827d
4 changed files with 73 additions and 20 deletions
  1. +22
    -8
      src/Core/CV_Gate.cpp
  2. +19
    -0
      src/Core/CV_MIDI.cpp
  3. +2
    -2
      src/Core/MIDI_CV.cpp
  4. +30
    -10
      src/Core/MIDI_Gate.cpp

+ 22
- 8
src/Core/CV_Gate.cpp View File

@@ -143,6 +143,22 @@ struct CV_Gate : Module {
};


struct CV_GateVelocityItem : MenuItem {
CV_Gate *module;
void onAction(const event::Action &e) override {
module->velocityMode ^= true;
}
};


struct CV_GatePanicItem : MenuItem {
CV_Gate *module;
void onAction(const event::Action &e) override {
module->midiOutput.panic();
}
};


struct CV_GateWidget : ModuleWidget {
CV_GateWidget(CV_Gate *module) {
setModule(module);
@@ -182,17 +198,15 @@ struct CV_GateWidget : ModuleWidget {
void appendContextMenu(Menu *menu) override {
CV_Gate *module = dynamic_cast<CV_Gate*>(this->module);

struct VelocityItem : MenuItem {
CV_Gate *module;
void onAction(const event::Action &e) override {
module->velocityMode ^= true;
}
};

menu->addChild(new MenuEntry);
VelocityItem *velocityItem = createMenuItem<VelocityItem>("Velocity mode", CHECKMARK(module->velocityMode));
CV_GateVelocityItem *velocityItem = createMenuItem<CV_GateVelocityItem>("Velocity mode", CHECKMARK(module->velocityMode));
velocityItem->module = module;
menu->addChild(velocityItem);

CV_GatePanicItem *panicItem = new CV_GatePanicItem;
panicItem->text = "Panic";
panicItem->module = module;
menu->addChild(panicItem);
}
};



+ 19
- 0
src/Core/CV_MIDI.cpp View File

@@ -313,6 +313,14 @@ struct CV_MIDI : Module {
};


struct CV_MIDIPanicItem : MenuItem {
CV_MIDI *module;
void onAction(const event::Action &e) override {
module->midiOutput.panic();
}
};


struct CV_MIDIWidget : ModuleWidget {
CV_MIDIWidget(CV_MIDI *module) {
setModule(module);
@@ -342,6 +350,17 @@ struct CV_MIDIWidget : ModuleWidget {
midiWidget->midiIO = &module->midiOutput;
addChild(midiWidget);
}

void appendContextMenu(Menu *menu) override {
CV_MIDI *module = dynamic_cast<CV_MIDI*>(this->module);

menu->addChild(new MenuEntry);

CV_MIDIPanicItem *panicItem = new CV_MIDIPanicItem;
panicItem->text = "Panic";
panicItem->module = module;
menu->addChild(panicItem);
}
};




+ 2
- 2
src/Core/MIDI_CV.cpp View File

@@ -507,7 +507,7 @@ struct PolyModeItem : MenuItem {
};


struct PanicItem : MenuItem {
struct MIDI_CVPanicItem : MenuItem {
MIDI_CV *module;
void onAction(const event::Action &e) override {
module->panic();
@@ -566,7 +566,7 @@ struct MIDI_CVWidget : ModuleWidget {
polyModeItem->module = module;
menu->addChild(polyModeItem);

PanicItem *panicItem = new PanicItem;
MIDI_CVPanicItem *panicItem = new MIDI_CVPanicItem;
panicItem->text = "Panic";
panicItem->module = module;
menu->addChild(panicItem);


+ 30
- 10
src/Core/MIDI_Gate.cpp View File

@@ -32,14 +32,20 @@ struct MIDI_Gate : Module {

void onReset() override {
for (int i = 0; i < 16; i++) {
gates[i] = false;
gateTimes[i] = 0.f;
learnedNotes[i] = i + 36;
}
learningId = -1;
panic();
midiInput.reset();
}

void panic() {
for (int i = 0; i < 16; i++) {
gates[i] = false;
gateTimes[i] = 0.f;
}
}

void pressNote(uint8_t note, uint8_t vel) {
// Learn
if (learningId >= 0) {
@@ -144,6 +150,22 @@ struct MIDI_Gate : Module {
};


struct MIDI_GateVelocityItem : MenuItem {
MIDI_Gate *module;
void onAction(const event::Action &e) override {
module->velocityMode ^= true;
}
};


struct MIDI_GatePanicItem : MenuItem {
MIDI_Gate *module;
void onAction(const event::Action &e) override {
module->panic();
}
};


struct MIDI_GateWidget : ModuleWidget {
MIDI_GateWidget(MIDI_Gate *module) {
setModule(module);
@@ -183,17 +205,15 @@ struct MIDI_GateWidget : ModuleWidget {
void appendContextMenu(Menu *menu) override {
MIDI_Gate *module = dynamic_cast<MIDI_Gate*>(this->module);

struct VelocityItem : MenuItem {
MIDI_Gate *module;
void onAction(const event::Action &e) override {
module->velocityMode ^= true;
}
};

menu->addChild(new MenuEntry);
VelocityItem *velocityItem = createMenuItem<VelocityItem>("Velocity mode", CHECKMARK(module->velocityMode));
MIDI_GateVelocityItem *velocityItem = createMenuItem<MIDI_GateVelocityItem>("Velocity mode", CHECKMARK(module->velocityMode));
velocityItem->module = module;
menu->addChild(velocityItem);

MIDI_GatePanicItem *panicItem = new MIDI_GatePanicItem;
panicItem->text = "Panic";
panicItem->module = module;
menu->addChild(panicItem);
}
};



Loading…
Cancel
Save