Browse Source

Change SVG DPI to 75, add in2px and mm2px convenience functions

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
891f3c6cf8
4 changed files with 17 additions and 4 deletions
  1. +3
    -3
      include/gui.hpp
  2. +10
    -0
      include/rack.hpp
  3. +3
    -0
      include/widgets.hpp
  4. +1
    -1
      src/gui.cpp

+ 3
- 3
include/gui.hpp View File

@@ -4,9 +4,6 @@
#include <GLFW/glfw3.h>


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

+ 10
- 0
include/rack.hpp View File

@@ -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 <class TModuleWidget>
Model *createModel(std::string manufacturerSlug, std::string manufacturerName, std::string slug, std::string name) {
struct TModel : Model {


+ 3
- 0
include/widgets.hpp View File

@@ -10,6 +10,9 @@
#include "util.hpp"


#define SVG_DPI 75.0


namespace rack {




+ 1
- 1
src/gui.cpp View File

@@ -457,7 +457,7 @@ std::shared_ptr<Image> 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());
}


Loading…
Cancel
Save