| 683 | |
| 684 | struct EngineButton : MenuButton { |
| 685 | void onAction(const ActionEvent& e) override { |
| 686 | ui::Menu* menu = createMenu(); |
| 687 | menu->cornerFlags = BND_CORNER_TOP; |
| 688 | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); |
| 689 | |
| 690 | std::string cpuMeterText = widget::getKeyCommandName(GLFW_KEY_F3, 0); |
| 691 | if (settings::cpuMeter) |
| 692 | cpuMeterText += " " CHECKMARK_STRING; |
| 693 | menu->addChild(createMenuItem(string::translate("MenuBar.engine.cpuMeter"), cpuMeterText, [=]() { |
| 694 | settings::cpuMeter ^= true; |
| 695 | })); |
| 696 | |
| 697 | menu->addChild(createMenuItem<SampleRateItem>(string::translate("MenuBar.engine.sampleRate"), RIGHT_ARROW)); |
| 698 | |
| 699 | menu->addChild(createSubmenuItem(string::translate("MenuBar.engine.threads"), string::f("%d", settings::threadCount), [=](ui::Menu* menu) { |
| 700 | // BUG This assumes SMT is enabled. |
| 701 | int cores = system::getLogicalCoreCount() / 2; |
| 702 | |
| 703 | for (int i = 1; i <= 2 * cores; i++) { |
| 704 | std::string rightText; |
| 705 | if (i == cores) |
| 706 | rightText += string::translate("MenuBar.engine.threads.most"); |
| 707 | else if (i == 1) |
| 708 | rightText += string::translate("MenuBar.engine.threads.lowest"); |
| 709 | menu->addChild(createCheckMenuItem(string::f("%d", i), rightText, |
| 710 | [=]() {return settings::threadCount == i;}, |
| 711 | [=]() {settings::threadCount = i;} |
| 712 | )); |
| 713 | } |
| 714 | })); |
| 715 | } |
| 716 | }; |
| 717 | |
| 718 |
nothing calls this directly
no test coverage detected