bounds.h 567 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // Bounds.h
  3. // ncurses-wrapper
  4. //
  5. // Created by Sam Jaffe on 7/23/24.
  6. //
  7. #pragma once
  8. namespace curses {
  9. struct Bounds {
  10. int width;
  11. int height;
  12. };
  13. struct Offset {
  14. int x;
  15. int y;
  16. };
  17. struct Position {
  18. friend Position operator+(Position const &lhs, Offset const &rhs) {
  19. return {lhs.x + rhs.x, lhs.y + rhs.y};
  20. }
  21. friend Position operator-(Position const &lhs, Offset const &rhs) {
  22. return {lhs.x - rhs.x, lhs.y - rhs.y};
  23. }
  24. Position only_x() const { return {x, 0}; }
  25. Position only_y() const { return {0, y}; }
  26. int x;
  27. int y;
  28. };
  29. }