From d56be1f1751f66bff09f0d223ed4712974e69e09 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 7 Feb 2012 12:31:48 -0800 Subject: EXP-1181 WIP as a designer I would like to specify default floater positions using realtive coordinates refactored LLCoord code to be templated, ultimately to support arbitrary conversions --- indra/llmath/llcoord.h | 74 +++++++++----------------------------------------- 1 file changed, 13 insertions(+), 61 deletions(-) (limited to 'indra/llmath/llcoord.h') diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h index 706ad92787..c0623e6d1f 100644 --- a/indra/llmath/llcoord.h +++ b/indra/llmath/llcoord.h @@ -27,79 +27,31 @@ #define LL_LLCOORD_H // A two-dimensional pixel value +template class LLCoord { public: - S32 mX; - S32 mY; + typedef LLCoord self_t; + VALUE_TYPE mX; + VALUE_TYPE mY; LLCoord(): mX(0), mY(0) {} LLCoord(S32 x, S32 y): mX(x), mY(y) {} - virtual ~LLCoord() - {} - - virtual void set(S32 x, S32 y) { mX = x; mY = y; } -}; + void set(S32 x, S32 y) { mX = x; mY = y;} + bool operator==(const self_t& other) const { return mX == other.mX && mY == other.mY; } + bool operator!=(const self_t& other) const { return !(*this == other); } -// GL coordinates start in the client region of a window, -// with left, bottom = 0, 0 -class LLCoordGL : public LLCoord -{ -public: - LLCoordGL() : LLCoord() - {} - LLCoordGL(S32 x, S32 y) : LLCoord(x, y) - {} - bool operator==(const LLCoordGL& other) const { return mX == other.mX && mY == other.mY; } - bool operator!=(const LLCoordGL& other) const { return !(*this == other); } }; -//bool operator ==(const LLCoordGL& a, const LLCoordGL& b); - -// Window coords include things like window borders, -// menu regions, etc. -class LLCoordWindow : public LLCoord -{ -public: - LLCoordWindow() : LLCoord() - {} - LLCoordWindow(S32 x, S32 y) : LLCoord(x, y) - {} - bool operator==(const LLCoordWindow& other) const { return mX == other.mX && mY == other.mY; } - bool operator!=(const LLCoordWindow& other) const { return !(*this == other); } -}; +struct LL_COORD_TYPE_GL {}; +struct LL_COORD_TYPE_WINDOW {}; +struct LL_COORD_TYPE_SCREEN {}; - -// Screen coords start at left, top = 0, 0 -class LLCoordScreen : public LLCoord -{ -public: - LLCoordScreen() : LLCoord() - {} - LLCoordScreen(S32 x, S32 y) : LLCoord(x, y) - {} - bool operator==(const LLCoordScreen& other) const { return mX == other.mX && mY == other.mY; } - bool operator!=(const LLCoordScreen& other) const { return !(*this == other); } -}; - -class LLCoordFont : public LLCoord -{ -public: - F32 mZ; - - LLCoordFont() : LLCoord(), mZ(0.f) - {} - LLCoordFont(S32 x, S32 y, F32 z = 0) : LLCoord(x,y), mZ(z) - {} - - void set(S32 x, S32 y) { LLCoord::set(x,y); mZ = 0.f; } - void set(S32 x, S32 y, F32 z) { mX = x; mY = y; mZ = z; } - bool operator==(const LLCoordFont& other) const { return mX == other.mX && mY == other.mY; } - bool operator!=(const LLCoordFont& other) const { return !(*this == other); } -}; - +typedef LLCoord LLCoordGL; +typedef LLCoord LLCoordWindow; +typedef LLCoord LLCoordScreen; #endif -- cgit v1.2.3