coordinatespull/1639/head
| @@ -4,13 +4,23 @@ | |||||
| #include "widgets.hpp" | #include "widgets.hpp" | ||||
| namespace rack { | |||||
| #define SVG_DPI 75.0 | |||||
| #define CHECKMARK_STRING "✔" | #define CHECKMARK_STRING "✔" | ||||
| #define CHECKMARK(_cond) ((_cond) ? CHECKMARK_STRING : "") | #define CHECKMARK(_cond) ((_cond) ? CHECKMARK_STRING : "") | ||||
| namespace rack { | |||||
| inline Vec in2px(Vec inches) { | |||||
| return inches.mult(SVG_DPI); | |||||
| } | |||||
| inline Vec mm2px(Vec millimeters) { | |||||
| return millimeters.mult(SVG_DPI / 25.4); | |||||
| } | |||||
| struct Model; | struct Model; | ||||
| struct Module; | struct Module; | ||||
| struct Wire; | struct Wire; | ||||
| @@ -11,21 +11,8 @@ | |||||
| #include "events.hpp" | #include "events.hpp" | ||||
| #define SVG_DPI 75.0 | |||||
| namespace rack { | namespace rack { | ||||
| inline Vec in2px(Vec inches) { | |||||
| return inches.mult(SVG_DPI); | |||||
| } | |||||
| inline Vec mm2px(Vec millimeters) { | |||||
| return millimeters.mult(SVG_DPI / 25.4); | |||||
| } | |||||
| //////////////////// | //////////////////// | ||||
| // resources | // resources | ||||
| //////////////////// | //////////////////// | ||||
| @@ -68,7 +68,8 @@ json_t *ModuleWidget::toJson() { | |||||
| // model | // model | ||||
| json_object_set_new(rootJ, "model", json_string(model->slug.c_str())); | json_object_set_new(rootJ, "model", json_string(model->slug.c_str())); | ||||
| // pos | // pos | ||||
| json_t *posJ = json_pack("[f, f]", (double) box.pos.x, (double) box.pos.y); | |||||
| Vec pos = box.pos.div(RACK_GRID_SIZE).round(); | |||||
| json_t *posJ = json_pack("[i, i]", (int) pos.x, (int) pos.y); | |||||
| json_object_set_new(rootJ, "pos", posJ); | json_object_set_new(rootJ, "pos", posJ); | ||||
| // params | // params | ||||
| json_t *paramsJ = json_array(); | json_t *paramsJ = json_array(); | ||||
| @@ -99,7 +100,13 @@ void ModuleWidget::fromJson(json_t *rootJ) { | |||||
| json_t *posJ = json_object_get(rootJ, "pos"); | json_t *posJ = json_object_get(rootJ, "pos"); | ||||
| double x, y; | double x, y; | ||||
| json_unpack(posJ, "[F, F]", &x, &y); | json_unpack(posJ, "[F, F]", &x, &y); | ||||
| box.pos = Vec(x, y); | |||||
| Vec pos = Vec(x, y); | |||||
| if (legacy && legacy <= 1) { | |||||
| box.pos = pos; | |||||
| } | |||||
| else { | |||||
| box.pos = pos.mult(RACK_GRID_SIZE); | |||||
| } | |||||
| // params | // params | ||||
| json_t *paramsJ = json_object_get(rootJ, "params"); | json_t *paramsJ = json_object_get(rootJ, "params"); | ||||
| @@ -27,6 +27,7 @@ | |||||
| #include <ApplicationServices/ApplicationServices.h> | #include <ApplicationServices/ApplicationServices.h> | ||||
| #endif | #endif | ||||
| namespace rack { | namespace rack { | ||||
| GLFWwindow *gWindow = NULL; | GLFWwindow *gWindow = NULL; | ||||