From 891f3c6cf880afd5d1cef083bb13f6d6d582f5cc Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 29 Oct 2017 06:14:26 -0400 Subject: [PATCH] Change SVG DPI to 75, add in2px and mm2px convenience functions --- include/gui.hpp | 6 +++--- include/rack.hpp | 10 ++++++++++ include/widgets.hpp | 3 +++ src/gui.cpp | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/gui.hpp b/include/gui.hpp index 920f6cba..3d64809f 100644 --- a/include/gui.hpp +++ b/include/gui.hpp @@ -4,9 +4,6 @@ #include -namespace rack { - - #ifdef ARCH_MAC #define GUI_MOD_KEY_NAME "Cmd" #else @@ -14,6 +11,8 @@ namespace rack { #endif +namespace rack { + extern GLFWwindow *gWindow; extern NVGcontext *gVg; @@ -34,4 +33,5 @@ void guiCursorUnlock(); bool guiIsModPressed(); bool guiIsShiftPressed(); + } // namespace rack diff --git a/include/rack.hpp b/include/rack.hpp index aaa6c56e..6b1595b7 100644 --- a/include/rack.hpp +++ b/include/rack.hpp @@ -17,6 +17,16 @@ namespace rack { // helpers //////////////////// + +inline Vec in2px(Vec inches) { + return inches.mult(SVG_DPI); +} + +inline Vec mm2px(Vec millimeters) { + return millimeters.mult(SVG_DPI / 25.4); +} + + template Model *createModel(std::string manufacturerSlug, std::string manufacturerName, std::string slug, std::string name) { struct TModel : Model { diff --git a/include/widgets.hpp b/include/widgets.hpp index a3fe6d92..a009c7fe 100644 --- a/include/widgets.hpp +++ b/include/widgets.hpp @@ -10,6 +10,9 @@ #include "util.hpp" +#define SVG_DPI 75.0 + + namespace rack { diff --git a/src/gui.cpp b/src/gui.cpp index d6e82fb9..bb859f2a 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -457,7 +457,7 @@ std::shared_ptr Image::load(const std::string &filename) { //////////////////// SVG::SVG(const std::string &filename) { - handle = nsvgParseFromFile(filename.c_str(), "px", 96.0); + handle = nsvgParseFromFile(filename.c_str(), "px", SVG_DPI); if (handle) { fprintf(stderr, "Loaded SVG %s\n", filename.c_str()); }