monitor.hpp 836 B

12345678910111213141516171819202122232425262728
  1. #if defined(Hiro_Monitor)
  2. struct Monitor {
  3. Monitor() = delete;
  4. static auto count() -> uint;
  5. static auto dpi(maybe<uint> monitor = nothing) -> Position;
  6. static auto geometry(maybe<uint> monitor = nothing) -> Geometry;
  7. static auto primary() -> uint;
  8. static auto workspace(maybe<uint> monitor = nothing) -> Geometry;
  9. };
  10. //DPI scale X
  11. inline auto sx(float x) -> float {
  12. //round DPI scalar to increments of 0.5 (eg 1.0, 1.5, 2.0, ...)
  13. static auto scale = round(Monitor::dpi().x() / 96.0 * 2.0) / 2.0;
  14. return x * scale;
  15. }
  16. //DPI scale y
  17. inline auto sy(float y) -> float {
  18. static auto scale = round(Monitor::dpi().y() / 96.0 * 2.0) / 2.0;
  19. return y * scale;
  20. }
  21. inline auto operator"" _sx(unsigned long long x) -> float { return sx(x); }
  22. inline auto operator"" _sy(unsigned long long y) -> float { return sy(y); }
  23. #endif