summaryrefslogtreecommitdiff
path: root/indra/llmath/llcoord.h
diff options
context:
space:
mode:
authorRichard Linden <none@none>2012-02-07 19:29:10 -0800
committerRichard Linden <none@none>2012-02-07 19:29:10 -0800
commit4e08461f8ad23fb75ca8587c781c2cf65351b1ab (patch)
treec6f48cdffa3c3436d517b808b3d432f095eee159 /indra/llmath/llcoord.h
parentd56be1f1751f66bff09f0d223ed4712974e69e09 (diff)
EXP-1181 WIP as a designer I would like to specify default floater positions using realtive coordinates
changed over to new convert() method added LLCoordFloater
Diffstat (limited to 'indra/llmath/llcoord.h')
-rw-r--r--indra/llmath/llcoord.h69
1 files changed, 58 insertions, 11 deletions
diff --git a/indra/llmath/llcoord.h b/indra/llmath/llcoord.h
index c0623e6d1f..0b1d7e04f5 100644
--- a/indra/llmath/llcoord.h
+++ b/indra/llmath/llcoord.h
@@ -26,32 +26,79 @@
#ifndef LL_LLCOORD_H
#define LL_LLCOORD_H
+struct LL_COORD_TYPE_COMMON
+{
+ typedef S32 value_t;
+};
+
// A two-dimensional pixel value
-template<typename COORD_FRAME, typename VALUE_TYPE>
-class LLCoord
+template<typename COORD_FRAME>
+class LLCoord : protected COORD_FRAME
{
public:
- typedef LLCoord<COORD_FRAME, VALUE_TYPE> self_t;
- VALUE_TYPE mX;
- VALUE_TYPE mY;
+ typedef LLCoord<COORD_FRAME> self_t;
+ typename COORD_FRAME::value_t mX;
+ typename COORD_FRAME::value_t mY;
LLCoord(): mX(0), mY(0)
{}
LLCoord(S32 x, S32 y): mX(x), mY(y)
{}
+ LLCoord(const LLCoord<LL_COORD_TYPE_COMMON>& other)
+ {
+ COORD_FRAME::convertFromCommon(other);
+ }
+
+ LLCoord<LL_COORD_TYPE_COMMON> convert() const
+ {
+ return COORD_FRAME::convertToCommon();
+ }
+
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); }
};
-struct LL_COORD_TYPE_GL {};
-struct LL_COORD_TYPE_WINDOW {};
-struct LL_COORD_TYPE_SCREEN {};
+typedef LLCoord<LL_COORD_TYPE_COMMON> LLCoordCommon;
+
+struct LL_COORD_TYPE_GL
+{
+ typedef S32 value_t;
+
+ LLCoordCommon convertToCommon() const
+ {
+ const LLCoord<LL_COORD_TYPE_GL>& self = static_cast<const LLCoord<LL_COORD_TYPE_GL>&>(*this);
+ return LLCoordCommon(self.mX, self.mY);
+ }
+
+ void convertFromCommon(const LLCoordCommon& from)
+ {
+ LLCoord<LL_COORD_TYPE_GL>& self = static_cast<LLCoord<LL_COORD_TYPE_GL>&>(*this);
+ self.mX = from.mX;
+ self.mY = from.mY;
+ }
+};
+
+struct LL_COORD_TYPE_WINDOW
+{
+ typedef S32 value_t;
+
+ LLCoordCommon convertToCommon() const;
+ void convertFromCommon(const LLCoordCommon& from);
+};
+
+struct LL_COORD_TYPE_SCREEN
+{
+ typedef S32 value_t;
+
+ LLCoordCommon convertToCommon() const;
+ void convertFromCommon(const LLCoordCommon& from);
+};
-typedef LLCoord<LL_COORD_TYPE_GL, S32> LLCoordGL;
-typedef LLCoord<LL_COORD_TYPE_WINDOW, S32> LLCoordWindow;
-typedef LLCoord<LL_COORD_TYPE_SCREEN, S32> LLCoordScreen;
+typedef LLCoord<LL_COORD_TYPE_GL> LLCoordGL;
+typedef LLCoord<LL_COORD_TYPE_WINDOW> LLCoordWindow;
+typedef LLCoord<LL_COORD_TYPE_SCREEN> LLCoordScreen;
#endif