llcoord.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * @file llcoord.h
  3. *
  4. * $LicenseInfo:firstyear=2001&license=viewergpl$
  5. *
  6. * Copyright (c) 2001-2009, Linden Research, Inc.
  7. *
  8. * Second Life Viewer Source Code
  9. * The source code in this file ("Source Code") is provided by Linden Lab
  10. * to you under the terms of the GNU General Public License, version 2.0
  11. * ("GPL"), unless you have obtained a separate licensing agreement
  12. * ("Other License"), formally executed by you and Linden Lab. Terms of
  13. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  14. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  15. *
  16. * There are special exceptions to the terms and conditions of the GPL as
  17. * it is applied to this Source Code. View the full text of the exception
  18. * in the file doc/FLOSS-exception.txt in this software distribution, or
  19. * online at
  20. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  21. *
  22. * By copying, modifying or distributing this software, you acknowledge
  23. * that you have read and understood your obligations described above,
  24. * and agree to abide by those obligations.
  25. *
  26. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  27. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  28. * COMPLETENESS OR PERFORMANCE.
  29. * $/LicenseInfo$
  30. */
  31. #ifndef LL_LLCOORD_H
  32. #define LL_LLCOORD_H
  33. #include "llpreprocessor.h"
  34. // A two-dimensional pixel value
  35. class LLCoord
  36. {
  37. public:
  38. LL_INLINE LLCoord() noexcept
  39. : mX(0),
  40. mY(0)
  41. {
  42. }
  43. LL_INLINE LLCoord(S32 x, S32 y) noexcept
  44. : mX(x),
  45. mY(y)
  46. {
  47. }
  48. // Allow the use of the default C++11 move constructor and assignation
  49. LLCoord(LLCoord&& other) noexcept = default;
  50. LLCoord& operator=(LLCoord&& other) noexcept = default;
  51. LLCoord(const LLCoord& other) = default;
  52. LLCoord& operator=(const LLCoord& other) = default;
  53. virtual ~LLCoord() = default;
  54. LL_INLINE virtual void set(S32 x, S32 y) { mX = x; mY = y; }
  55. public:
  56. S32 mX;
  57. S32 mY;
  58. };
  59. // GL coordinates start in the client region of a window, with origin on bottom
  60. // left of the screen.
  61. class LLCoordGL : public LLCoord
  62. {
  63. public:
  64. LL_INLINE LLCoordGL() noexcept
  65. : LLCoord()
  66. {
  67. }
  68. LL_INLINE LLCoordGL(S32 x, S32 y) noexcept
  69. : LLCoord(x, y)
  70. {
  71. }
  72. // Allow the use of the default C++11 move constructor and assignation
  73. LLCoordGL(LLCoordGL&& other) noexcept = default;
  74. LLCoordGL& operator=(LLCoordGL&& other) noexcept = default;
  75. LLCoordGL(const LLCoordGL& other) = default;
  76. LLCoordGL& operator=(const LLCoordGL& other) = default;
  77. LL_INLINE bool operator==(const LLCoordGL& other) const
  78. {
  79. return mX == other.mX && mY == other.mY;
  80. }
  81. LL_INLINE bool operator!=(const LLCoordGL& other) const
  82. {
  83. return mX != other.mX || mY != other.mY;
  84. }
  85. };
  86. //bool operator ==(const LLCoordGL& a, const LLCoordGL& b);
  87. // Window coords include things like window borders, menu regions, etc.
  88. class LLCoordWindow : public LLCoord
  89. {
  90. public:
  91. LL_INLINE LLCoordWindow() noexcept
  92. : LLCoord()
  93. {
  94. }
  95. LL_INLINE LLCoordWindow(S32 x, S32 y) noexcept
  96. : LLCoord(x, y)
  97. {
  98. }
  99. // Allow the use of the default C++11 move constructor and assignation
  100. LLCoordWindow(LLCoordWindow&& other) noexcept = default;
  101. LLCoordWindow& operator=(LLCoordWindow&& other) noexcept = default;
  102. LLCoordWindow(const LLCoordWindow& other) = default;
  103. LLCoordWindow& operator=(const LLCoordWindow& other) = default;
  104. LL_INLINE bool operator==(const LLCoordWindow& other) const
  105. {
  106. return mX == other.mX && mY == other.mY;
  107. }
  108. LL_INLINE bool operator!=(const LLCoordWindow& other) const
  109. {
  110. return mX != other.mX || mY != other.mY;
  111. }
  112. };
  113. // Screen coords start at left, top = 0, 0
  114. class LLCoordScreen : public LLCoord
  115. {
  116. public:
  117. LL_INLINE LLCoordScreen() noexcept
  118. : LLCoord()
  119. {
  120. }
  121. LL_INLINE LLCoordScreen(S32 x, S32 y) noexcept
  122. : LLCoord(x, y)
  123. {
  124. }
  125. // Allow the use of the default C++11 move constructor and assignation
  126. LLCoordScreen(LLCoordScreen&& other) noexcept = default;
  127. LLCoordScreen& operator=(LLCoordScreen&& other) noexcept = default;
  128. LLCoordScreen(const LLCoordScreen& other) = default;
  129. LLCoordScreen& operator=(const LLCoordScreen& other) = default;
  130. LL_INLINE bool operator==(const LLCoordScreen& other) const
  131. {
  132. return mX == other.mX && mY == other.mY;
  133. }
  134. LL_INLINE bool operator!=(const LLCoordScreen& other) const
  135. {
  136. return mX != other.mX || mY != other.mY;
  137. }
  138. };
  139. #endif