Update and adapt to Rack 2.3
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
03055c2563
commit
1262f318da
41 changed files with 901 additions and 727 deletions
|
@ -17,7 +17,7 @@
|
|||
|
||||
/**
|
||||
* This file is an edited version of VCVRack's app/MenuBar.cpp
|
||||
* Copyright (C) 2016-2021 VCV.
|
||||
* Copyright (C) 2016-2023 VCV.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
|
@ -60,8 +60,6 @@
|
|||
# include <lo/lo.h>
|
||||
#endif
|
||||
|
||||
void switchDarkMode(bool darkMode);
|
||||
|
||||
namespace rack {
|
||||
namespace asset {
|
||||
std::string patchesPath();
|
||||
|
@ -739,7 +737,7 @@ struct HelpButton : MenuButton {
|
|||
patchUtils::openBrowser("https://vcvrack.com/manual");
|
||||
}));
|
||||
|
||||
menu->addChild(createMenuItem("Cardinal Project page", "", [=]() {
|
||||
menu->addChild(createMenuItem("Cardinal project page", "", [=]() {
|
||||
patchUtils::openBrowser("https://github.com/DISTRHO/Cardinal/");
|
||||
}));
|
||||
|
||||
|
@ -751,7 +749,6 @@ struct HelpButton : MenuButton {
|
|||
|
||||
menu->addChild(new ui::MenuSeparator);
|
||||
|
||||
menu->addChild(createMenuLabel("Cardinal " + APP_EDITION + " " + CARDINAL_VERSION));
|
||||
menu->addChild(createMenuLabel("Rack " + APP_VERSION + " Compatible"));
|
||||
}
|
||||
};
|
||||
|
@ -762,23 +759,25 @@ struct HelpButton : MenuButton {
|
|||
////////////////////
|
||||
|
||||
|
||||
struct MeterLabel : ui::Label {
|
||||
int frameIndex = 0;
|
||||
struct InfoLabel : ui::Label {
|
||||
int frameCount = 0;
|
||||
double frameDurationTotal = 0.0;
|
||||
double frameDurationAvg = 0.0;
|
||||
double uiLastTime = 0.0;
|
||||
double uiLastThreadTime = 0.0;
|
||||
double uiFrac = 0.0;
|
||||
double frameDurationAvg = NAN;
|
||||
// double uiLastTime = 0.0;
|
||||
// double uiLastThreadTime = 0.0;
|
||||
// double uiFrac = 0.0;
|
||||
|
||||
void step() override {
|
||||
// Compute frame rate
|
||||
double frameDuration = APP->window->getLastFrameDuration();
|
||||
frameDurationTotal += frameDuration;
|
||||
frameIndex++;
|
||||
if (std::isfinite(frameDuration)) {
|
||||
frameDurationTotal += frameDuration;
|
||||
frameCount++;
|
||||
}
|
||||
if (frameDurationTotal >= 1.0) {
|
||||
frameDurationAvg = frameDurationTotal / frameIndex;
|
||||
frameDurationAvg = frameDurationTotal / frameCount;
|
||||
frameDurationTotal = 0.0;
|
||||
frameIndex = 0;
|
||||
frameCount = 0;
|
||||
}
|
||||
|
||||
// Compute UI thread CPU
|
||||
|
@ -791,13 +790,21 @@ struct MeterLabel : ui::Label {
|
|||
// uiLastTime = time;
|
||||
// }
|
||||
|
||||
text = "";
|
||||
|
||||
if (box.size.x >= 400) {
|
||||
double fps = std::isfinite(frameDurationAvg) ? 1.0 / frameDurationAvg : 0.0;
|
||||
#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
|
||||
double meterAverage = APP->engine->getMeterAverage();
|
||||
double meterMax = APP->engine->getMeterMax();
|
||||
text = string::f("%.1f fps %.1f%% avg %.1f%% max", 1.0 / frameDurationAvg, meterAverage * 100, meterMax * 100);
|
||||
double meterAverage = APP->engine->getMeterAverage();
|
||||
double meterMax = APP->engine->getMeterMax();
|
||||
text = string::f("%.1f fps %.1f%% avg %.1f%% max", fps, meterAverage * 100, meterMax * 100);
|
||||
#else
|
||||
text = string::f("%.1f fps", 1.0 / frameDurationAvg);
|
||||
text = string::f("%.1f fps", fps);
|
||||
#endif
|
||||
text += " ";
|
||||
}
|
||||
|
||||
text += "Cardinal " + APP_EDITION + " " + CARDINAL_VERSION;
|
||||
|
||||
Label::step();
|
||||
}
|
||||
|
@ -805,7 +812,7 @@ struct MeterLabel : ui::Label {
|
|||
|
||||
|
||||
struct MenuBar : widget::OpaqueWidget {
|
||||
MeterLabel* meterLabel;
|
||||
InfoLabel* infoLabel;
|
||||
|
||||
MenuBar(const bool isStandalone)
|
||||
: widget::OpaqueWidget()
|
||||
|
@ -840,16 +847,10 @@ struct MenuBar : widget::OpaqueWidget {
|
|||
helpButton->text = "Help";
|
||||
layout->addChild(helpButton);
|
||||
|
||||
// ui::Label* titleLabel = new ui::Label;
|
||||
// titleLabel->color.a = 0.5;
|
||||
// layout->addChild(titleLabel);
|
||||
|
||||
meterLabel = new MeterLabel;
|
||||
meterLabel->box.pos.y = margin;
|
||||
meterLabel->box.size.x = 300;
|
||||
meterLabel->alignment = ui::Label::RIGHT_ALIGNMENT;
|
||||
meterLabel->color.a = 0.5;
|
||||
addChild(meterLabel);
|
||||
infoLabel = new InfoLabel;
|
||||
infoLabel->box.size.x = 600;
|
||||
infoLabel->alignment = ui::Label::RIGHT_ALIGNMENT;
|
||||
layout->addChild(infoLabel);
|
||||
}
|
||||
|
||||
void draw(const DrawArgs& args) override {
|
||||
|
@ -860,8 +861,10 @@ struct MenuBar : widget::OpaqueWidget {
|
|||
}
|
||||
|
||||
void step() override {
|
||||
meterLabel->box.pos.x = box.size.x - meterLabel->box.size.x - 5;
|
||||
Widget::step();
|
||||
infoLabel->box.size.x = box.size.x - infoLabel->box.pos.x - 5;
|
||||
// Setting 50% alpha prevents Label from using the default UI theme color, so set the color manually here.
|
||||
infoLabel->color = color::alpha(bndGetTheme()->regularTheme.textColor, 0.5);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue