Browse Source

Fix Audio-2 device choice button and menu.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
7dd6c59d5d
2 changed files with 15 additions and 4 deletions
  1. +14
    -3
      src/app/AudioWidget.cpp
  2. +1
    -1
      src/core/AudioInterface.cpp

+ 14
- 3
src/app/AudioWidget.cpp View File

@@ -88,7 +88,7 @@ static void appendAudioDeviceMenu(ui::Menu* menu, audio::Port* port) {
for (int deviceId : port->driver->getDeviceIds()) {
int channels = std::max(port->driver->getDeviceNumInputs(deviceId), port->driver->getDeviceNumOutputs(deviceId));
// Prevents devices with a ridiculous number of channels from being displayed
const int maxTotalChannels = 128;
const int maxTotalChannels = port->maxChannels * 8;
channels = std::min(maxTotalChannels, channels);

for (int offset = 0; offset < channels; offset += port->maxChannels) {
@@ -121,7 +121,10 @@ struct AudioDeviceChoice : LedDisplayChoice {
color.a = 1.0;
}
else {
text += "(No device)";
if (box.size.x >= 80.0)
text += "(No device)";
else
text += "No device";
color.a = 0.5;
}
}
@@ -304,8 +307,16 @@ void AudioWidget::setAudioPort(audio::Port* port) {
}


struct AudioDeviceMenuChoice : AudioDeviceChoice {
void onAction(const event::Action& e) override {
ui::Menu* menu = createMenu();
appendAudioMenu(menu, port);
}
};


void AudioDeviceWidget::setAudioPort(audio::Port* port) {
AudioDeviceChoice* deviceChoice = createWidget<AudioDeviceChoice>(math::Vec());
AudioDeviceMenuChoice* deviceChoice = createWidget<AudioDeviceMenuChoice>(math::Vec());
deviceChoice->box.size.x = box.size.x;
deviceChoice->box.size.y = box.size.y;
deviceChoice->port = port;


+ 1
- 1
src/core/AudioInterface.cpp View File

@@ -444,7 +444,7 @@ struct AudioInterfaceWidget : ModuleWidget {
audioWidget->box.size = mm2px(Vec(21.128, 6.725));
audioWidget->setAudioPort(module);
// Adjust deviceChoice position
audioWidget->deviceChoice->box.pos = Vec(-4, -4);
audioWidget->deviceChoice->textOffset = Vec(6, 14);
addChild(audioWidget);
}
}


Loading…
Cancel
Save