You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3KB

  1. #pragma once
  2. #include <common.hpp>
  3. #include <math.hpp>
  4. #include <jansson.h>
  5. namespace rack {
  6. /** Rack-specific GUI widgets and functions that control and offer feedback for the rack state.
  7. */
  8. namespace app {
  9. extern std::string APP_NAME;
  10. extern std::string APP_VERSION;
  11. extern std::string APP_VERSION_UPDATE;
  12. extern std::string API_URL;
  13. extern std::string API_VERSION;
  14. static const float SVG_DPI = 75.0;
  15. static const float MM_PER_IN = 25.4;
  16. /** Converts inch measurements to pixels */
  17. inline float in2px(float in) {
  18. return in * SVG_DPI;
  19. }
  20. inline math::Vec in2px(math::Vec in) {
  21. return in.mult(SVG_DPI);
  22. }
  23. /** Converts millimeter measurements to pixels */
  24. inline float mm2px(float mm) {
  25. return mm * (SVG_DPI / MM_PER_IN);
  26. }
  27. inline math::Vec mm2px(math::Vec mm) {
  28. return mm.mult(SVG_DPI / MM_PER_IN);
  29. }
  30. // A 1HPx3U module should be 15x380 pixels. Thus the width of a module should be a factor of 15.
  31. static const float RACK_GRID_WIDTH = 15;
  32. static const float RACK_GRID_HEIGHT = 380;
  33. static const math::Vec RACK_GRID_SIZE = math::Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
  34. static const math::Vec RACK_OFFSET = RACK_GRID_SIZE.mult(math::Vec(2000, 100));
  35. static const math::Vec BUS_BOARD_GRID_SIZE = math::Vec(RACK_GRID_WIDTH * 20, RACK_GRID_HEIGHT);
  36. void init();
  37. } // namespace app
  38. } // namespace rack