Ui.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include "glm/vec4.hpp"
  3. #include "glm/vec2.hpp"
  4. namespace Ui
  5. {
  6. class Frame
  7. {
  8. int lastW;
  9. int lastH;
  10. int lastX;
  11. int lastY;
  12. bool loaded = 0;
  13. public:
  14. Frame(const Frame &other) = delete;
  15. Frame(const Frame &&other) = delete;
  16. Frame(glm::ivec4 size);
  17. ~Frame();
  18. };
  19. struct Box
  20. {
  21. glm::ivec4 dimensions = {};
  22. float aspect = 0;
  23. //-1 left
  24. // 0 none
  25. // 1 center
  26. // 2 right
  27. char XcenterState = 0;
  28. char YcenterState = 0;
  29. // 0 pixelSize
  30. // 1 xDominant
  31. // 2 yDominant
  32. char dimensionsState;
  33. Box &xDistancePixels(int dist);
  34. Box &yDistancePixels(int dist);
  35. Box &xCenter(int dist = 0);
  36. Box &yCenter(int dist = 0);
  37. Box &xLeft(int dist = 0);
  38. Box &yTop(int dist = 0);
  39. Box &xRight(int dist = 0);
  40. Box &yBottom(int dist = 0);
  41. Box &xDimensionPixels(int dim);
  42. Box &yDimensionPixels(int dim);
  43. Box &xDimensionPercentage(float p);
  44. Box &yDimensionPercentage(float p);
  45. Box &xAspectRatio(float r);
  46. Box &yAspectRatio(float r);
  47. glm::ivec4 operator()();
  48. operator glm::vec4 () { return (*this)(); }
  49. };
  50. bool isInButton(const glm::vec2 &p, const glm::vec4 &box);
  51. bool isButtonReleased(const glm::vec2 &p, const glm::vec4 &box);
  52. };