| 462 | } |
| 463 | |
| 464 | void drawLight(const DrawArgs& args) override { |
| 465 | // Background |
| 466 | NVGcolor backgroundColor = nvgRGB(0x20, 0x20, 0x20); |
| 467 | NVGcolor borderColor = nvgRGB(0x10, 0x10, 0x10); |
| 468 | NVGcolor textColor = nvgRGB(0xff, 0x10, 0x10); |
| 469 | |
| 470 | nvgBeginPath(args.vg); |
| 471 | nvgRoundedRect(args.vg, 0.0, 0.0, box.size.x, box.size.y, 2.0); |
| 472 | nvgFillColor(args.vg, backgroundColor); |
| 473 | nvgFill(args.vg); |
| 474 | nvgStrokeWidth(args.vg, 1.0); |
| 475 | |
| 476 | if (module) { |
| 477 | const bool isClipping = module->isClipping[col + row * 3]; |
| 478 | if (isClipping) { |
| 479 | borderColor = nvgRGB(0xff, 0x20, 0x20); |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | nvgStrokeColor(args.vg, borderColor); |
| 484 | nvgStroke(args.vg); |
| 485 | |
| 486 | std::shared_ptr<Font> font = APP->window->loadFont(asset::plugin(pluginInstance, "res/fonts/miso.otf")); |
| 487 | |
| 488 | if (font && font->handle >= 0) { |
| 489 | |
| 490 | std::string text; |
| 491 | if (module) { |
| 492 | text = module->cfgPortModeNames[module->getVoltageMode(row, col) + 1]; |
| 493 | } |
| 494 | else { |
| 495 | // fallback if module not yet defined |
| 496 | const char* cfgPortModeNames[4] = {"0/10v", "-5/5v", "0/8v", "0/5v"}; |
| 497 | const int randomModeForDisplay = rack::random::u32() % 4; |
| 498 | text = cfgPortModeNames[randomModeForDisplay]; |
| 499 | } |
| 500 | char buffer[numChars + 1]; |
| 501 | int l = text.size(); |
| 502 | if (l > numChars) |
| 503 | l = numChars; |
| 504 | |
| 505 | nvgGlobalTint(args.vg, color::WHITE); |
| 506 | |
| 507 | text.copy(buffer, l); |
| 508 | buffer[l] = '\0'; |
| 509 | |
| 510 | nvgFontSize(args.vg, fontSize); |
| 511 | nvgFontFaceId(args.vg, font->handle); |
| 512 | nvgFillColor(args.vg, textColor); |
| 513 | nvgTextAlign(args.vg, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM); |
| 514 | NVGtextRow textRow; |
| 515 | nvgTextBreakLines(args.vg, text.c_str(), NULL, box.size.x, &textRow, 1); |
| 516 | nvgTextBox(args.vg, textPos.x, textPos.y, box.size.x, textRow.start, textRow.end); |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | void onButton(const ButtonEvent& e) override { |
| 521 | if (e.button == GLFW_MOUSE_BUTTON_RIGHT && e.action == GLFW_PRESS) { |
no test coverage detected