| 520 | }; |
| 521 | |
| 522 | struct AudioFileWidget : ModuleWidgetWithSideScrews<23> { |
| 523 | static constexpr const float previewBoxHeight = 80.0f; |
| 524 | static constexpr const float previewBoxBottom = 20.0f; |
| 525 | static constexpr const float previewBoxRect[] = {8.0f, |
| 526 | 380.0f - previewBoxHeight - previewBoxBottom, |
| 527 | 15.0f * 23 - 16.0f, |
| 528 | previewBoxHeight}; |
| 529 | static constexpr const float startY_list = startY - 2.0f; |
| 530 | static constexpr const float fileListHeight = 380.0f - startY_list - previewBoxHeight - previewBoxBottom * 1.5f; |
| 531 | static constexpr const float startY_preview = startY_list + fileListHeight; |
| 532 | |
| 533 | CarlaInternalPluginModule* const module; |
| 534 | bool idleCallbackActive = false; |
| 535 | bool visible = false; |
| 536 | float lastPosition = 0.0f; |
| 537 | |
| 538 | AudioFileWidget(CarlaInternalPluginModule* const m) |
| 539 | : module(m) |
| 540 | { |
| 541 | setModule(module); |
| 542 | setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/AudioFile.svg"))); |
| 543 | |
| 544 | addChild(createWidget<ThemedScrew>(Vec(RACK_GRID_WIDTH, 0))); |
| 545 | addChild(createWidget<ThemedScrew>(Vec(box.size.x - 4 * RACK_GRID_WIDTH, 0))); |
| 546 | addChild(createWidget<ThemedScrew>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); |
| 547 | addChild(createWidget<ThemedScrew>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); |
| 548 | |
| 549 | addOutput(createOutput<PJ301MPort>(Vec(startX_Out, startY_list * 0.5f - padding + 2.0f), module, 0)); |
| 550 | addOutput(createOutput<PJ301MPort>(Vec(startX_Out, startY_list * 0.5f + 2.0f), module, 1)); |
| 551 | |
| 552 | if (m != nullptr) |
| 553 | { |
| 554 | AudioFileListWidget* const listw = new AudioFileListWidget(m); |
| 555 | listw->box.pos = Vec(0, startY_list); |
| 556 | listw->box.size = Vec(box.size.x, fileListHeight); |
| 557 | addChild(listw); |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | void drawLayer(const DrawArgs& args, int layer) override |
| 562 | { |
| 563 | if (layer != 1) |
| 564 | return ModuleWidget::drawLayer(args, layer); |
| 565 | |
| 566 | const float alpha = 1.0f - (0.5f - settings::rackBrightness * 0.5f); |
| 567 | char textInfo[0xff]; |
| 568 | |
| 569 | if (module != nullptr && module->audioInfo.channels != 0) |
| 570 | { |
| 571 | const float audioPreviewBarHeight = previewBoxRect[3] - 20.0f; |
| 572 | const size_t position = (module->audioInfo.position * 0.01f) * ARRAY_SIZE(module->audioInfo.preview); |
| 573 | |
| 574 | nvgFillColor(args.vg, nvgRGBAf(0.839f, 0.459f, 0.086f, alpha)); |
| 575 | |
| 576 | for (size_t i=0; i<ARRAY_SIZE(module->audioInfo.preview); ++i) |
| 577 | { |
| 578 | const float value = module->audioInfo.preview[i]; |
| 579 | const float height = std::max(0.01f, value * audioPreviewBarHeight); |
nothing calls this directly
no outgoing calls
no test coverage detected