PageRenderTime 79ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llhudnametag.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 185 lines | 124 code | 22 blank | 39 comment | 0 complexity | 690fc0b3177f9579c93b04d6c810b8c7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llhudnametag.h
  3. * @brief Name tags for avatars
  4. * @author James Cook
  5. *
  6. * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #ifndef LLHUDNAMETAG_H
  28. #define LLHUDNAMETAG_H
  29. #include "llpointer.h"
  30. #include "llhudobject.h"
  31. #include "v4color.h"
  32. //#include "v4coloru.h"
  33. #include "v2math.h"
  34. #include "llrect.h"
  35. //#include "llframetimer.h"
  36. #include "llfontgl.h"
  37. #include <set>
  38. #include <vector>
  39. class LLDrawable;
  40. class LLHUDNameTag;
  41. struct llhudnametag_further_away
  42. {
  43. bool operator()(const LLPointer<LLHUDNameTag>& lhs, const LLPointer<LLHUDNameTag>& rhs) const;
  44. };
  45. class LLHUDNameTag : public LLHUDObject
  46. {
  47. protected:
  48. class LLHUDTextSegment
  49. {
  50. public:
  51. LLHUDTextSegment(const LLWString& text, const LLFontGL::StyleFlags style, const LLColor4& color, const LLFontGL* font)
  52. : mColor(color),
  53. mStyle(style),
  54. mText(text),
  55. mFont(font)
  56. {}
  57. F32 getWidth(const LLFontGL* font);
  58. const LLWString& getText() const { return mText; }
  59. void clearFontWidthMap() { mFontWidthMap.clear(); }
  60. LLColor4 mColor;
  61. LLFontGL::StyleFlags mStyle;
  62. const LLFontGL* mFont;
  63. private:
  64. LLWString mText;
  65. std::map<const LLFontGL*, F32> mFontWidthMap;
  66. };
  67. public:
  68. typedef enum e_text_alignment
  69. {
  70. ALIGN_TEXT_LEFT,
  71. ALIGN_TEXT_CENTER
  72. } ETextAlignment;
  73. typedef enum e_vert_alignment
  74. {
  75. ALIGN_VERT_TOP,
  76. ALIGN_VERT_CENTER
  77. } EVertAlignment;
  78. public:
  79. // Set entire string, eliminating existing lines
  80. void setString(const std::string& text_utf8);
  81. void clearString();
  82. // Add text a line at a time, allowing custom formatting
  83. void addLine(const std::string &text_utf8, const LLColor4& color, const LLFontGL::StyleFlags style = LLFontGL::NORMAL, const LLFontGL* font = NULL);
  84. // For bubble chat, set the part above the chat text
  85. void setLabel(const std::string& label_utf8);
  86. void addLabel(const std::string& label_utf8);
  87. // Sets the default font for lines with no font specified
  88. void setFont(const LLFontGL* font);
  89. void setColor(const LLColor4 &color);
  90. void setAlpha(F32 alpha);
  91. void setZCompare(const BOOL zcompare);
  92. void setDoFade(const BOOL do_fade);
  93. void setVisibleOffScreen(BOOL visible) { mVisibleOffScreen = visible; }
  94. // mMaxLines of -1 means unlimited lines.
  95. void setMaxLines(S32 max_lines) { mMaxLines = max_lines; }
  96. void setFadeDistance(F32 fade_distance, F32 fade_range) { mFadeDistance = fade_distance; mFadeRange = fade_range; }
  97. void updateVisibility();
  98. LLVector2 updateScreenPos(LLVector2 &offset_target);
  99. void updateSize();
  100. // void setMass(F32 mass) { mMass = llmax(0.1f, mass); }
  101. void setTextAlignment(ETextAlignment alignment) { mTextAlignment = alignment; }
  102. void setVertAlignment(EVertAlignment alignment) { mVertAlignment = alignment; }
  103. /*virtual*/ void markDead();
  104. friend class LLHUDObject;
  105. /*virtual*/ F32 getDistance() const { return mLastDistance; }
  106. //void setUseBubble(BOOL use_bubble) { mUseBubble = use_bubble; }
  107. S32 getLOD() { return mLOD; }
  108. BOOL getVisible() { return mVisible; }
  109. BOOL getHidden() const { return mHidden; }
  110. void setHidden( BOOL hide ) { mHidden = hide; }
  111. void shift(const LLVector3& offset);
  112. BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, LLVector3& intersection, BOOL debug_render = FALSE);
  113. static void shiftAll(const LLVector3& offset);
  114. static void addPickable(std::set<LLViewerObject*> &pick_list);
  115. static void reshape();
  116. static void setDisplayText(BOOL flag) { sDisplayText = flag ; }
  117. protected:
  118. LLHUDNameTag(const U8 type);
  119. /*virtual*/ void render();
  120. /*virtual*/ void renderForSelect();
  121. void renderText(BOOL for_select);
  122. static void updateAll();
  123. void setLOD(S32 lod);
  124. S32 getMaxLines();
  125. private:
  126. ~LLHUDNameTag();
  127. BOOL mDoFade;
  128. F32 mFadeRange;
  129. F32 mFadeDistance;
  130. F32 mLastDistance;
  131. BOOL mZCompare;
  132. BOOL mVisibleOffScreen;
  133. BOOL mOffscreen;
  134. LLColor4 mColor;
  135. // LLVector3 mScale;
  136. F32 mWidth;
  137. F32 mHeight;
  138. // LLColor4U mPickColor;
  139. const LLFontGL* mFontp;
  140. const LLFontGL* mBoldFontp;
  141. LLRectf mSoftScreenRect;
  142. LLVector3 mPositionAgent;
  143. LLVector2 mPositionOffset;
  144. LLVector2 mTargetPositionOffset;
  145. F32 mMass;
  146. S32 mMaxLines;
  147. S32 mOffsetY;
  148. F32 mRadius;
  149. std::vector<LLHUDTextSegment> mTextSegments;
  150. std::vector<LLHUDTextSegment> mLabelSegments;
  151. // LLFrameTimer mResizeTimer;
  152. ETextAlignment mTextAlignment;
  153. EVertAlignment mVertAlignment;
  154. S32 mLOD;
  155. BOOL mHidden;
  156. static BOOL sDisplayText ;
  157. static std::set<LLPointer<LLHUDNameTag> > sTextObjects;
  158. static std::vector<LLPointer<LLHUDNameTag> > sVisibleTextObjects;
  159. // static std::vector<LLPointer<LLHUDNameTag> > sVisibleHUDTextObjects;
  160. typedef std::set<LLPointer<LLHUDNameTag> >::iterator TextObjectIterator;
  161. typedef std::vector<LLPointer<LLHUDNameTag> >::iterator VisibleTextObjectIterator;
  162. };
  163. #endif