2
0

Monitor.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "Defines.h"
  3. #include "Types.h"
  4. namespace gameplay
  5. {
  6. enum class MonitorChangeEvent : uint32_t
  7. {
  8. UNKNOWN,
  9. CONNECTED,
  10. DISCONNECTED
  11. };
  12. struct MonitorHandle;
  13. /**
  14. * Defines a monitor.
  15. */
  16. class GP_API Monitor
  17. {
  18. friend class App;
  19. friend class Window;
  20. public:
  21. struct VideoMode
  22. {
  23. int32_t width;
  24. int32_t height;
  25. int32_t redBits;
  26. int32_t greenBits;
  27. int32_t blueBits;
  28. int32_t refreshRate;
  29. };
  30. struct WorkArea
  31. {
  32. Int2 pos;
  33. Int2 size;
  34. };
  35. /**
  36. * Constructor.
  37. */
  38. Monitor();
  39. /**
  40. * Destructor.
  41. */
  42. ~Monitor();
  43. /**
  44. * Gets the name of the monitor.
  45. *
  46. * @return The name of the monitor.
  47. */
  48. const char* get_name() const;
  49. /**
  50. * Gets the video mode information.
  51. *
  52. * @return The video mode information.
  53. */
  54. VideoMode get_video_mode() const;
  55. /**
  56. * Gets the physical size, in millimetres, of the display area of the specified monitor.
  57. *
  58. * @return The physical size.
  59. */
  60. Int2 get_physical_size() const;
  61. /**
  62. * Gets the position of the monitor's viewport on the virtual screen.
  63. *
  64. * @return The position of the monitor's viewport.
  65. */
  66. Int2 get_pos() const;
  67. /**
  68. * Gets the content scale for the monitor.
  69. *
  70. * The content scale is the ratio between the current DPI and
  71. * the platform's default DPI. This is especially important for
  72. * text and any UI elements. If the pixel dimensions of your UI
  73. * scaled by this look appropriate on your machine then it should
  74. * appear at a reasonable size on other machines regardless of
  75. * their DPI and scaling settings. This relies on the system DPI
  76. * and scaling settings being somewhat correct.
  77. *
  78. * @return The content scale for the monitor.
  79. */
  80. Float2 get_content_scale() const;
  81. /**
  82. * Gets the position and size of the work area.
  83. *
  84. * The position, in screen coordinates, of the upper-left corner
  85. * of the work area of the specified monitor along with the
  86. * work area size in screen coordinates. The work area is defined
  87. * as the area of the monitor not occluded by the operating
  88. * system task bar where present. If no task bar exists then the
  89. * work area is the monitor resolution in screen coordinates.
  90. *
  91. * @return The work area.
  92. */
  93. WorkArea get_work_area() const;
  94. /**
  95. * Sets user pointer associated with this monitor.
  96. *
  97. * @param userPtr The user pointer to associate.
  98. */
  99. void set_user_ptr(void* userPtr);
  100. /**
  101. * Gets the user pointer associated with this monitor.
  102. *
  103. * @return The user pointer to associate.
  104. */
  105. void* get_user_ptr() const;
  106. std::unique_ptr<MonitorHandle> handle;
  107. };
  108. }