Skip to content

Commit b93284b

Browse files
committed
Header cleanup
1 parent 6036237 commit b93284b

File tree

7 files changed

+42
-42
lines changed

7 files changed

+42
-42
lines changed

src/gui/widget.cpp

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
#include <random>
2-
#include "asset.hpp"
3-
#include "components.hpp"
4-
#include "engine.hpp"
5-
#include "math.hpp"
6-
#include "plugin.hpp"
7-
#include "rack.hpp"
2+
3+
#include <app.hpp>
4+
#include <components.hpp>
5+
#include <engine.hpp>
6+
#include <math.hpp>
7+
#include <plugin.hpp>
8+
89
#include "widget.h"
910

1011
extern rack::Plugin *plugin;
1112

1213
namespace DHE {
1314
Widget::Widget(rack::Module *module, int widget_hp, const char *background) {
1415
setModule(module);
15-
box.size = rack::Vec(widget_hp*RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
16+
box.size = rack::Vec{(float) widget_hp*RACK_GRID_WIDTH, (float) RACK_GRID_HEIGHT};
1617

1718
auto *panel = new rack::SVGPanel();
1819
panel->box.size = box.size;
@@ -51,4 +52,12 @@ void Widget::install_screws() {
5152
}
5253
}
5354
}
55+
56+
void Widget::moveTo(rack::Rect &box, rack::Vec pos) {
57+
box.pos = pos.minus(box.size.mult(0.5f));
58+
}
59+
60+
void Widget::moveTo(rack::Rect &box, float x, float y) {
61+
moveTo(box, {x, y});
62+
}
5463
}

src/gui/widget.h

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#ifndef DHE_GUI_WIDGET_H
22
#define DHE_GUI_WIDGET_H
33

4-
#include "app.hpp"
5-
#include "engine.hpp"
6-
#include "math.hpp"
7-
#include "rack.hpp"
4+
#include <app.hpp>
5+
#include <math.hpp>
6+
#include <rack.hpp>
87

98
namespace DHE {
109
class Widget : public rack::ModuleWidget {
@@ -14,7 +13,7 @@ class Widget : public rack::ModuleWidget {
1413
Widget(rack::Module *module, int widget_hp, const char *background);
1514

1615
rack::Vec center() {
17-
return box.getCenter();
16+
return box.getCenter();
1817
}
1918

2019
float height() const {
@@ -27,7 +26,7 @@ class Widget : public rack::ModuleWidget {
2726

2827
template<class T>
2928
void install_input(int index, float x, float y) {
30-
auto input{rack::createInput<T>(rack::Vec(x, y), module, index)};
29+
auto input{rack::createInput<T>({x, y}, module, index)};
3130
moveTo(input->box, x, y);
3231
addInput(input);
3332
}
@@ -47,7 +46,7 @@ class Widget : public rack::ModuleWidget {
4746
}
4847

4948
template<class T>
50-
void install_light(int index, float x, float y, float initial = 0.5f) {
49+
void install_light(int index, float x, float y, float initial = 0.f) {
5150
auto light{rack::createLight<T>({x, y}, module, index)};
5251
moveTo(light->box, x, y);
5352
addChild(light);
@@ -64,14 +63,9 @@ class Widget : public rack::ModuleWidget {
6463
moveTo(widget->box, pos);
6564
addChild(widget);
6665
}
66+
static void moveTo(rack::Rect &box, rack::Vec pos);
6767

68-
static void moveTo(rack::Rect &box, rack::Vec pos) {
69-
box.pos = pos.minus(box.size.mult(0.5f));
70-
}
71-
72-
static void moveTo(rack::Rect &box, float x, float y) {
73-
moveTo(box, {x, y});
74-
}
68+
static void moveTo(rack::Rect &box, float x, float y);
7569

7670
void install_screws();
7771
};

src/plugin/dhe-modules.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
#include <upstage/upstage-widget.h>
2-
#include <upstage/upstage.h>
3-
#include "dhe-modules.h"
41
#include "stage/stage-widget.h"
5-
#include "stage/stage.h"
2+
#include "upstage/upstage-widget.h"
63

74
rack::Plugin *plugin;
85

6+
namespace DHE {
7+
template<typename TWidget, typename... TTag>
8+
void installModule(std::string moduleSlug, TTag... tags) {
9+
plugin->addModel(rack::createModel<TWidget>(plugin->slug, moduleSlug, moduleSlug, tags...));
10+
}
11+
}
12+
913
void init(rack::Plugin *p) {
1014
plugin = p;
11-
p->slug = DHE::MANUFACTURER;
15+
p->slug = "DHE-Modules";
1216
p->version = TOSTRING(VERSION);
1317
p->website = "https://github.com/dhemery/DHE-Modules";
1418
p->manual = "https://github.com/dhemery/DHE-Modules/wiki";
1519

16-
DHE::installModule<DHE::StageWidget, rack::ModelTag>(p, "Stage", rack::ENVELOPE_GENERATOR_TAG);
17-
DHE::installModule<DHE::UpstageWidget, rack::ModelTag>(p, "Upstage", rack::ENVELOPE_GENERATOR_TAG);
20+
DHE::installModule<DHE::StageWidget, rack::ModelTag>("Stage", rack::ENVELOPE_GENERATOR_TAG);
21+
DHE::installModule<DHE::UpstageWidget, rack::ModelTag>("Upstage", rack::ENVELOPE_GENERATOR_TAG);
1822
}
23+

src/plugin/dhe-modules.h

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
#ifndef DHE_PLUGIN_DHE_MODULES_H
22
#define DHE_PLUGIN_DHE_MODULES_H
33

4-
#include "plugin.hpp"
4+
#include <plugin.hpp>
55

66
extern rack::Plugin *plugin;
77

8-
namespace DHE {
9-
static constexpr char const *MANUFACTURER = "DHE-Modules";
10-
11-
template<typename TWidget, typename... TTag>
12-
static void installModule(rack::Plugin *plugin, std::string moduleSlug, TTag... tags) {
13-
plugin->addModel(rack::createModel<TWidget>(MANUFACTURER, moduleSlug, moduleSlug, tags...));
14-
}
15-
16-
};
178
#endif

src/stage/stage.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include <cmath>
2+
3+
#include <engine.hpp>
4+
25
#include "stage.h"
36

47
namespace DHE {

src/stage/stage.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
#include <memory>
55

6-
#include "dsp/digital.hpp"
7-
#include "rack.hpp"
8-
#include "plugin.hpp"
6+
#include <engine.hpp>
97

108
#include "util/d-flip-flop.h"
119
#include "util/ramp.h"

src/upstage/upstage.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#define DHE_UPSTAGE_UPSTAGE_H
77

88
#include <algorithm>
9+
#include <engine.hpp>
910

10-
#include "engine.hpp"
1111
#include "util/range.h"
1212

1313
namespace DHE {

0 commit comments

Comments
 (0)