Browse Source

Move app name, version, and arch from Help menu to menu bar.

tags/v2.2.2
Andrew Belt 1 year ago
parent
commit
8f432d536b
1 changed files with 20 additions and 21 deletions
  1. +20
    -21
      src/app/MenuBar.cpp

+ 20
- 21
src/app/MenuBar.cpp View File

@@ -842,10 +842,6 @@ struct HelpButton : MenuButton {


menu->addChild(new ui::MenuSeparator); menu->addChild(new ui::MenuSeparator);


menu->addChild(createMenuLabel(APP_NAME + " " + APP_EDITION_NAME + " " + APP_VERSION));

menu->addChild(createMenuLabel(APP_OS_NAME + " " + APP_CPU_NAME));

menu->addChild(createMenuItem("Open user folder", "", [=]() { menu->addChild(createMenuItem("Open user folder", "", [=]() {
system::openDirectory(asset::user("")); system::openDirectory(asset::user(""));
})); }));
@@ -882,7 +878,7 @@ struct HelpButton : MenuButton {
//////////////////// ////////////////////




struct MeterLabel : ui::Label {
struct InfoLabel : ui::Label {
int frameCount = 0; int frameCount = 0;
double frameDurationTotal = 0.0; double frameDurationTotal = 0.0;
double frameDurationAvg = NAN; double frameDurationAvg = NAN;
@@ -913,17 +909,25 @@ struct MeterLabel : ui::Label {
// uiLastTime = time; // uiLastTime = time;
// } // }


double fps = std::isfinite(frameDurationAvg) ? 1.0 / frameDurationAvg : 0.0;
double meterAverage = APP->engine->getMeterAverage();
double meterMax = APP->engine->getMeterMax();
text = string::f("%.1f fps %.1f%% avg %.1f%% max", fps, meterAverage * 100, meterMax * 100);
text = "";

if (box.size.x >= 460) {
double fps = std::isfinite(frameDurationAvg) ? 1.0 / frameDurationAvg : 0.0;
double meterAverage = APP->engine->getMeterAverage();
double meterMax = APP->engine->getMeterMax();
text += string::f("%.1f fps %.1f%% avg %.1f%% max", fps, meterAverage * 100, meterMax * 100);
text += " ";
}

text += APP_NAME + " " + APP_EDITION_NAME + " " + APP_VERSION + " " + APP_OS_NAME + " " + APP_CPU_NAME;

Label::step(); Label::step();
} }
}; };




struct MenuBar : widget::OpaqueWidget { struct MenuBar : widget::OpaqueWidget {
MeterLabel* meterLabel;
InfoLabel* infoLabel;


MenuBar() { MenuBar() {
const float margin = 5; const float margin = 5;
@@ -958,16 +962,11 @@ struct MenuBar : widget::OpaqueWidget {
helpButton->text = "Help"; helpButton->text = "Help";
layout->addChild(helpButton); 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;
infoLabel->color.a = 0.5;
layout->addChild(infoLabel);
} }


void draw(const DrawArgs& args) override { void draw(const DrawArgs& args) override {
@@ -978,8 +977,8 @@ struct MenuBar : widget::OpaqueWidget {
} }


void step() override { void step() override {
meterLabel->box.pos.x = box.size.x - meterLabel->box.size.x - 5;
Widget::step(); Widget::step();
infoLabel->box.size.x = box.size.x - infoLabel->box.pos.x - 5;
} }
}; };




Loading…
Cancel
Save