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.

50 lines
1.1KB

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