Browse Source

Add intro message when the rack is empty. Round zoom level to nearest percent.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
d737504011
7 changed files with 41 additions and 6 deletions
  1. +1
    -0
      include/app/RackScrollWidget.hpp
  2. +1
    -0
      include/app/RackWidget.hpp
  3. +18
    -0
      src/app/RackScrollWidget.cpp
  4. +4
    -0
      src/app/RackWidget.cpp
  5. +1
    -1
      src/app/Scene.cpp
  6. +5
    -5
      src/app/Toolbar.cpp
  7. +11
    -0
      src/engine/Engine.cpp

+ 1
- 0
include/app/RackScrollWidget.hpp View File

@@ -8,6 +8,7 @@ namespace rack {

struct RackScrollWidget : ScrollWidget {
void step() override;
void draw(NVGcontext *vg) override;
};




+ 1
- 0
include/app/RackWidget.hpp View File

@@ -50,6 +50,7 @@ struct RackWidget : OpaqueWidget {
/** Moves a module to the closest non-colliding position */
bool requestModuleBoxNearest(ModuleWidget *mw, math::Rect requestedBox);
ModuleWidget *getModule(int moduleId);
bool isEmpty();

// Cable methods



+ 18
- 0
src/app/RackScrollWidget.cpp View File

@@ -27,4 +27,22 @@ void RackScrollWidget::step() {
}


void RackScrollWidget::draw(NVGcontext *vg) {
ScrollWidget::draw(vg);

if (app()->scene->rackWidget->isEmpty()) {
math::Rect b;
b.size = math::Vec(600, 300);
b.pos = box.size.minus(b.size).div(2);
NVGcolor bg = nvgRGBAf(0, 0, 0, 0.4);
bndInnerBox(vg, b.pos.x, b.pos.y, b.size.x, b.size.y,
0, 0, 0, 0, bg, bg);

NVGcolor fg = nvgRGBAf(1, 1, 1, 0.25);
std::string text = "Right-click or press Enter to add modules";
bndIconLabelValue(vg, b.pos.x, b.pos.y + 80, b.size.x, b.size.y, -1, fg, BND_CENTER, 80, text.c_str(), NULL);
}
}


} // namespace rack

+ 4
- 0
src/app/RackWidget.cpp View File

@@ -416,6 +416,10 @@ ModuleWidget *RackWidget::getModule(int moduleId) {
return NULL;
}

bool RackWidget::isEmpty() {
return moduleContainer->children.empty();
}

void RackWidget::clearCables() {
for (Widget *w : cableContainer->children) {
CableWidget *cw = dynamic_cast<CableWidget*>(w);


+ 1
- 1
src/app/Scene.cpp View File

@@ -64,7 +64,7 @@ void Scene::step() {

// Set zoom every few frames
if (app()->window->frame % 10 == 0)
zoomWidget->setZoom(settings::zoom);
zoomWidget->setZoom(std::round(settings::zoom * 100) / 100);

// Request latest version from server
if (!devMode && checkVersion && !checkedVersion) {


+ 5
- 5
src/app/Toolbar.cpp View File

@@ -187,8 +187,8 @@ struct ZoomQuantity : Quantity {
float getMinValue() override {return 0.25;}
float getMaxValue() override {return 2.0;}
float getDefaultValue() override {return 1.0;}
float getDisplayValue() override {return getValue() * 100.0;}
void setDisplayValue(float displayValue) override {setValue(displayValue / 100.0);}
float getDisplayValue() override {return std::round(getValue() * 100);}
void setDisplayValue(float displayValue) override {setValue(displayValue / 100);}
std::string getLabel() override {return "Zoom";}
std::string getUnit() override {return "%";}
};
@@ -202,8 +202,8 @@ struct CableOpacityQuantity : Quantity {
return settings::cableOpacity;
}
float getDefaultValue() override {return 0.5;}
float getDisplayValue() override {return getValue() * 100.0;}
void setDisplayValue(float displayValue) override {setValue(displayValue / 100.0);}
float getDisplayValue() override {return getValue() * 100;}
void setDisplayValue(float displayValue) override {setValue(displayValue / 100);}
std::string getLabel() override {return "Cable opacity";}
std::string getUnit() override {return "%";}
};
@@ -225,7 +225,7 @@ struct CableTensionQuantity : Quantity {

struct PowerMeterItem : MenuItem {
PowerMeterItem() {
text = "Power meter";
text = "CPU meter";
rightText = CHECKMARK(settings::powerMeter);
}
void onAction(const event::Action &e) override {


+ 11
- 0
src/engine/Engine.cpp View File

@@ -1,6 +1,7 @@
#include "engine/Engine.hpp"
#include "settings.hpp"
#include "system.hpp"
#include "random.hpp"

#include <algorithm>
#include <chrono>
@@ -150,6 +151,16 @@ static void Engine_step(Engine *engine) {
}
}

#if 0
if (random::u32() % 1000 == 0 && settings::powerMeter) {
float cpuTotal = 0.f;
for (Module *module : engine->modules) {
cpuTotal += module->cpuTime;
}
DEBUG("%fus %f%% CPU", cpuTotal * 1e6, cpuTotal * engine->internal->sampleRate * 100);
}
#endif

// Step cables
for (Cable *cable : engine->cables) {
cable->step();


Loading…
Cancel
Save