| @@ -70,10 +70,13 @@ inline float nearf(float a, float b, float epsilon = 1e-6) { | |||||
| } | } | ||||
| /** Limits a value between a minimum and maximum | /** Limits a value between a minimum and maximum | ||||
| If min > max, returns min | |||||
| If min > max, clamps the range to [max, min] | |||||
| */ | */ | ||||
| inline float clampf(float x, float min, float max) { | inline float clampf(float x, float min, float max) { | ||||
| return fmaxf(fminf(x, max), min); | |||||
| if (min <= max) | |||||
| return fmaxf(fminf(x, max), min); | |||||
| else | |||||
| return fmaxf(fminf(x, min), max); | |||||
| } | } | ||||
| /** If the magnitude of x if less than eps, return 0 */ | /** If the magnitude of x if less than eps, return 0 */ | ||||
| @@ -43,6 +43,7 @@ struct MidiIO { | |||||
| struct MidiInput : MidiIO { | struct MidiInput : MidiIO { | ||||
| RtMidiIn *rtMidiIn = NULL; | |||||
| MidiInput(); | MidiInput(); | ||||
| ~MidiInput(); | ~MidiInput(); | ||||
| virtual void onMessage(const MidiMessage &message) {} | virtual void onMessage(const MidiMessage &message) {} | ||||
| @@ -56,6 +57,7 @@ struct MidiInputQueue : MidiInput { | |||||
| struct MidiOutput : MidiIO { | struct MidiOutput : MidiIO { | ||||
| RtMidiOut *rtMidiOut = NULL; | |||||
| MidiOutput(); | MidiOutput(); | ||||
| ~MidiOutput(); | ~MidiOutput(); | ||||
| }; | }; | ||||
| @@ -11,6 +11,8 @@ namespace rack { | |||||
| static std::string newVersion = ""; | static std::string newVersion = ""; | ||||
| #if defined(RELEASE) | |||||
| static void checkVersion() { | static void checkVersion() { | ||||
| json_t *resJ = requestJson(METHOD_GET, gApiHost + "/version", NULL); | json_t *resJ = requestJson(METHOD_GET, gApiHost + "/version", NULL); | ||||
| @@ -25,6 +27,7 @@ static void checkVersion() { | |||||
| json_decref(resJ); | json_decref(resJ); | ||||
| } | } | ||||
| } | } | ||||
| #endif | |||||
| RackScene::RackScene() { | RackScene::RackScene() { | ||||
| @@ -43,13 +43,13 @@ bool MidiIO::isActive() { | |||||
| json_t *MidiIO::toJson() { | json_t *MidiIO::toJson() { | ||||
| json_t *rootJ = json_object(); | json_t *rootJ = json_object(); | ||||
| std::string deviceName = getDeviceName(device); | std::string deviceName = getDeviceName(device); | ||||
| json_object_set_new(rootJ, "device", json_string(deviceName.c_str())); | |||||
| json_object_set_new(rootJ, "deviceName", json_string(deviceName.c_str())); | |||||
| json_object_set_new(rootJ, "channel", json_integer(channel)); | json_object_set_new(rootJ, "channel", json_integer(channel)); | ||||
| return rootJ; | return rootJ; | ||||
| } | } | ||||
| void MidiIO::fromJson(json_t *rootJ) { | void MidiIO::fromJson(json_t *rootJ) { | ||||
| json_t *deviceNameJ = json_object_get(rootJ, "device"); | |||||
| json_t *deviceNameJ = json_object_get(rootJ, "deviceName"); | |||||
| if (deviceNameJ) { | if (deviceNameJ) { | ||||
| std::string deviceName = json_string_value(deviceNameJ); | std::string deviceName = json_string_value(deviceNameJ); | ||||
| // Search for device with equal name | // Search for device with equal name | ||||
| @@ -83,13 +83,13 @@ static void midiInputCallback(double timeStamp, std::vector<unsigned char> *mess | |||||
| } | } | ||||
| MidiInput::MidiInput() { | MidiInput::MidiInput() { | ||||
| RtMidiIn *rtMidiIn = new RtMidiIn(); | |||||
| rtMidiIn = new RtMidiIn(); | |||||
| rtMidi = rtMidiIn; | rtMidi = rtMidiIn; | ||||
| rtMidiIn->setCallback(midiInputCallback, this); | rtMidiIn->setCallback(midiInputCallback, this); | ||||
| } | } | ||||
| MidiInput::~MidiInput() { | MidiInput::~MidiInput() { | ||||
| delete dynamic_cast<RtMidiIn*>(rtMidi); | |||||
| delete rtMidiIn; | |||||
| } | } | ||||
| void MidiInputQueue::onMessage(const MidiMessage &message) { | void MidiInputQueue::onMessage(const MidiMessage &message) { | ||||
| @@ -107,11 +107,12 @@ void MidiInputQueue::onMessage(const MidiMessage &message) { | |||||
| //////////////////// | //////////////////// | ||||
| MidiOutput::MidiOutput() { | MidiOutput::MidiOutput() { | ||||
| rtMidi = new RtMidiOut(); | |||||
| rtMidiOut = new RtMidiOut(); | |||||
| rtMidi = rtMidiOut; | |||||
| } | } | ||||
| MidiOutput::~MidiOutput() { | MidiOutput::~MidiOutput() { | ||||
| delete dynamic_cast<RtMidiOut*>(rtMidi); | |||||
| delete rtMidiOut; | |||||
| } | } | ||||
| @@ -54,7 +54,7 @@ void Menu::onScroll(EventScroll &e) { | |||||
| if (!parent) | if (!parent) | ||||
| return; | return; | ||||
| if (!parent->box.contains(box)) | if (!parent->box.contains(box)) | ||||
| box.pos = box.pos.plus(e.scrollRel); | |||||
| box.pos.y += e.scrollRel.y; | |||||
| e.consumed = true; | e.consumed = true; | ||||
| } | } | ||||
| @@ -9,7 +9,7 @@ void MenuOverlay::step() { | |||||
| // Fit all children in the box | // Fit all children in the box | ||||
| for (Widget *child : children) { | for (Widget *child : children) { | ||||
| child->box = child->box.nudge(Rect(Vec(0, 0), parent->box.size)); | |||||
| child->box = child->box.nudge(box.zeroPos()); | |||||
| } | } | ||||
| } | } | ||||