Browse Source

Set zoom every few frames. Add ModuleWidget::setModule(). Add Port::set/getChannels().

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
ede6295516
12 changed files with 42 additions and 15 deletions
  1. +6
    -1
      include/app/ModuleWidget.hpp
  2. +12
    -0
      include/engine/Port.hpp
  3. +2
    -1
      src/Core/AudioInterface.cpp
  4. +2
    -1
      src/Core/Blank.cpp
  5. +3
    -2
      src/Core/CV_MIDI.cpp
  6. +2
    -1
      src/Core/MIDICCToCVInterface.cpp
  7. +2
    -1
      src/Core/MIDIToCVInterface.cpp
  8. +2
    -1
      src/Core/MIDITriggerToCVInterface.cpp
  9. +2
    -1
      src/Core/Notes.cpp
  10. +2
    -1
      src/Core/QuadMIDIToCVInterface.cpp
  11. +4
    -4
      src/app/ModuleWidget.cpp
  12. +3
    -1
      src/app/Scene.cpp

+ 6
- 1
include/app/ModuleWidget.hpp View File

@@ -24,8 +24,13 @@ struct ModuleWidget : OpaqueWidget {
math::Vec dragPos;
math::Vec oldPos;

ModuleWidget(Module *module);
ModuleWidget() {}
DEPRECATED ModuleWidget(Module *module) {
setModule(module);
}
~ModuleWidget();

void setModule(Module *module);
/** Convenience functions for adding special widgets (calls addChild()) */
void addInput(PortWidget *input);
void addOutput(PortWidget *output);


+ 12
- 0
include/engine/Port.hpp View File

@@ -33,6 +33,18 @@ struct Port {
void setVoltage(float voltage, int channel = 0) {
values[channel] = voltage;
}

void setChannels(int channels) {
// Set higher channel values to 0
for (int c = channels; c < this->channels; c++) {
values[c] = 0.f;
}
this->channels = channels;
}

int getChannels() {
return channels;
}
};




+ 2
- 1
src/Core/AudioInterface.cpp View File

@@ -237,7 +237,8 @@ void AudioInterface::step() {


struct AudioInterfaceWidget : ModuleWidget {
AudioInterfaceWidget(AudioInterface *module) : ModuleWidget(module) {
AudioInterfaceWidget(AudioInterface *module) {
setModule(module);
setPanel(SVG::load(asset::system("res/Core/AudioInterface.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));


+ 2
- 1
src/Core/Blank.cpp View File

@@ -83,7 +83,8 @@ struct BlankWidget : ModuleWidget {
Widget *bottomRightScrew;
Widget *rightHandle;

BlankWidget(Module *module) : ModuleWidget(module) {
BlankWidget(Module *module) {
setModule(module);
box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT);

panel = new BlankPanel;


+ 3
- 2
src/Core/CV_MIDI.cpp View File

@@ -235,7 +235,7 @@ struct CV_MIDI : Module {
}

void step() override {
for (int c = 0; c < inputs[PITCH_INPUT].channels; c++) {
for (int c = 0; c < inputs[PITCH_INPUT].getChannels(); c++) {
int vel = (int) std::round(inputs[VEL_INPUT].normalize(10.f * 100 / 127, c) / 10.f * 127);
vel = clamp(vel, 0, 127);
midiOutput.setVel(vel, c);
@@ -286,7 +286,8 @@ struct CV_MIDI : Module {


struct CV_MIDIWidget : ModuleWidget {
CV_MIDIWidget(CV_MIDI *module) : ModuleWidget(module) {
CV_MIDIWidget(CV_MIDI *module) {
setModule(module);
setPanel(SVG::load(asset::system("res/Core/CV-MIDI.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));


+ 2
- 1
src/Core/MIDICCToCVInterface.cpp View File

@@ -220,7 +220,8 @@ struct MidiCcWidget : Grid16MidiWidget {


struct MIDICCToCVInterfaceWidget : ModuleWidget {
MIDICCToCVInterfaceWidget(MIDICCToCVInterface *module) : ModuleWidget(module) {
MIDICCToCVInterfaceWidget(MIDICCToCVInterface *module) {
setModule(module);
setPanel(SVG::load(asset::system("res/Core/MIDICCToCVInterface.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));


+ 2
- 1
src/Core/MIDIToCVInterface.cpp View File

@@ -259,7 +259,8 @@ struct MIDIToCVInterface : Module {


struct MIDIToCVInterfaceWidget : ModuleWidget {
MIDIToCVInterfaceWidget(MIDIToCVInterface *module) : ModuleWidget(module) {
MIDIToCVInterfaceWidget(MIDIToCVInterface *module) {
setModule(module);
setPanel(SVG::load(asset::system("res/Core/MIDIToCVInterface.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));


+ 2
- 1
src/Core/MIDITriggerToCVInterface.cpp View File

@@ -207,7 +207,8 @@ struct MidiTrigWidget : Grid16MidiWidget {


struct MIDITriggerToCVInterfaceWidget : ModuleWidget {
MIDITriggerToCVInterfaceWidget(MIDITriggerToCVInterface *module) : ModuleWidget(module) {
MIDITriggerToCVInterfaceWidget(MIDITriggerToCVInterface *module) {
setModule(module);
setPanel(SVG::load(asset::system("res/Core/MIDITriggerToCVInterface.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));


+ 2
- 1
src/Core/Notes.cpp View File

@@ -7,7 +7,8 @@ using namespace rack;
struct NotesWidget : ModuleWidget {
TextField *textField;

NotesWidget(Module *module) : ModuleWidget(module) {
NotesWidget(Module *module) {
setModule(module);
setPanel(SVG::load(asset::system("res/Core/Notes.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));


+ 2
- 1
src/Core/QuadMIDIToCVInterface.cpp View File

@@ -302,7 +302,8 @@ struct QuadMIDIToCVInterface : Module {


struct QuadMIDIToCVInterfaceWidget : ModuleWidget {
QuadMIDIToCVInterfaceWidget(QuadMIDIToCVInterface *module) : ModuleWidget(module) {
QuadMIDIToCVInterfaceWidget(QuadMIDIToCVInterface *module) {
setModule(module);
setPanel(SVG::load(asset::system("res/Core/QuadMIDIToCVInterface.svg")));

addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));


+ 4
- 4
src/app/ModuleWidget.cpp View File

@@ -15,16 +15,16 @@
namespace rack {


ModuleWidget::ModuleWidget(Module *module) {
this->module = module;
}

ModuleWidget::~ModuleWidget() {
if (module) {
delete module;
}
}

void ModuleWidget::setModule(Module *module) {
this->module = module;
}

void ModuleWidget::addInput(PortWidget *input) {
assert(input->type == PortWidget::INPUT);
inputs.push_back(input);


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

@@ -53,7 +53,9 @@ void Scene::step() {
zoomWidget->box.size = rackWidget->box.size.mult(zoomWidget->zoom);
moduleBrowser->box.size = box.size;

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

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


Loading…
Cancel
Save