PageRenderTime 562ms CodeModel.GetById 547ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmath/llcoord.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 105 lines | 59 code | 15 blank | 31 comment | 16 complexity | 499bc2d79b30ba70071194378eb89a9e MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llcoord.h
  3. *
  4. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  5. * Second Life Viewer Source Code
  6. * Copyright (C) 2010, Linden Research, Inc.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation;
  11. * version 2.1 of the License only.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  23. * $/LicenseInfo$
  24. */
  25. #ifndef LL_LLCOORD_H
  26. #define LL_LLCOORD_H
  27. // A two-dimensional pixel value
  28. class LLCoord
  29. {
  30. public:
  31. S32 mX;
  32. S32 mY;
  33. LLCoord(): mX(0), mY(0)
  34. {}
  35. LLCoord(S32 x, S32 y): mX(x), mY(y)
  36. {}
  37. virtual ~LLCoord()
  38. {}
  39. virtual void set(S32 x, S32 y) { mX = x; mY = y; }
  40. };
  41. // GL coordinates start in the client region of a window,
  42. // with left, bottom = 0, 0
  43. class LLCoordGL : public LLCoord
  44. {
  45. public:
  46. LLCoordGL() : LLCoord()
  47. {}
  48. LLCoordGL(S32 x, S32 y) : LLCoord(x, y)
  49. {}
  50. bool operator==(const LLCoordGL& other) const { return mX == other.mX && mY == other.mY; }
  51. bool operator!=(const LLCoordGL& other) const { return !(*this == other); }
  52. };
  53. //bool operator ==(const LLCoordGL& a, const LLCoordGL& b);
  54. // Window coords include things like window borders,
  55. // menu regions, etc.
  56. class LLCoordWindow : public LLCoord
  57. {
  58. public:
  59. LLCoordWindow() : LLCoord()
  60. {}
  61. LLCoordWindow(S32 x, S32 y) : LLCoord(x, y)
  62. {}
  63. bool operator==(const LLCoordWindow& other) const { return mX == other.mX && mY == other.mY; }
  64. bool operator!=(const LLCoordWindow& other) const { return !(*this == other); }
  65. };
  66. // Screen coords start at left, top = 0, 0
  67. class LLCoordScreen : public LLCoord
  68. {
  69. public:
  70. LLCoordScreen() : LLCoord()
  71. {}
  72. LLCoordScreen(S32 x, S32 y) : LLCoord(x, y)
  73. {}
  74. bool operator==(const LLCoordScreen& other) const { return mX == other.mX && mY == other.mY; }
  75. bool operator!=(const LLCoordScreen& other) const { return !(*this == other); }
  76. };
  77. class LLCoordFont : public LLCoord
  78. {
  79. public:
  80. F32 mZ;
  81. LLCoordFont() : LLCoord(), mZ(0.f)
  82. {}
  83. LLCoordFont(S32 x, S32 y, F32 z = 0) : LLCoord(x,y), mZ(z)
  84. {}
  85. void set(S32 x, S32 y) { LLCoord::set(x,y); mZ = 0.f; }
  86. void set(S32 x, S32 y, F32 z) { mX = x; mY = y; mZ = z; }
  87. bool operator==(const LLCoordFont& other) const { return mX == other.mX && mY == other.mY; }
  88. bool operator!=(const LLCoordFont& other) const { return !(*this == other); }
  89. };
  90. #endif