PageRenderTime 64ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llui/llbadge.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 174 lines | 98 code | 40 blank | 36 comment | 5 complexity | d7f45d19ace3d8b1348acb10defe9e60 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llbadge.h
  3. * @brief Header for badges
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLBADGE_H
  27. #define LL_LLBADGE_H
  28. #include <string>
  29. #include "lluicolor.h"
  30. #include "lluictrl.h"
  31. #include "llstring.h"
  32. #include "lluiimage.h"
  33. #include "llview.h"
  34. //
  35. // Declarations
  36. //
  37. class LLFontGL;
  38. class LLScrollContainer;
  39. class LLUICtrlFactory;
  40. //
  41. // Relative Position Alignment
  42. //
  43. namespace LLRelPos
  44. {
  45. enum Location
  46. {
  47. CENTER = 0,
  48. LEFT = (1 << 0),
  49. RIGHT = (1 << 1),
  50. TOP = (1 << 2),
  51. BOTTOM = (1 << 3),
  52. BOTTOM_LEFT = (BOTTOM | LEFT),
  53. BOTTOM_RIGHT = (BOTTOM | RIGHT),
  54. TOP_LEFT = (TOP | LEFT),
  55. TOP_RIGHT = (TOP | RIGHT),
  56. };
  57. inline bool IsBottom(Location relPos) { return (relPos & BOTTOM) == BOTTOM; }
  58. inline bool IsCenter(Location relPos) { return (relPos == CENTER); }
  59. inline bool IsLeft(Location relPos) { return (relPos & LEFT) == LEFT; }
  60. inline bool IsRight(Location relPos) { return (relPos & RIGHT) == RIGHT; }
  61. inline bool IsTop(Location relPos) { return (relPos & TOP) == TOP; }
  62. }
  63. // NOTE: This needs to occur before Optional<LLRelPos::Location> declaration for proper compilation.
  64. namespace LLInitParam
  65. {
  66. template<>
  67. struct TypeValues<LLRelPos::Location> : public TypeValuesHelper<LLRelPos::Location>
  68. {
  69. static void declareValues();
  70. };
  71. }
  72. //
  73. // Classes
  74. //
  75. class LLBadge
  76. : public LLUICtrl
  77. {
  78. public:
  79. struct Params
  80. : public LLInitParam::Block<Params, LLUICtrl::Params>
  81. {
  82. Optional< LLHandle<LLView> > owner; // Mandatory in code but not in xml
  83. Optional< LLUIImage* > border_image;
  84. Optional< LLUIColor > border_color;
  85. Optional< LLUIImage* > image;
  86. Optional< LLUIColor > image_color;
  87. Optional< std::string > label;
  88. Optional< LLUIColor > label_color;
  89. Optional< S32 > label_offset_horiz;
  90. Optional< S32 > label_offset_vert;
  91. Optional< LLRelPos::Location > location;
  92. Optional< S32 > location_offset_hcenter;
  93. Optional< S32 > location_offset_vcenter;
  94. Optional< U32 > location_percent_hcenter;
  95. Optional< U32 > location_percent_vcenter;
  96. Optional< F32 > padding_horiz;
  97. Optional< F32 > padding_vert;
  98. Params();
  99. bool equals(const Params&) const;
  100. };
  101. protected:
  102. friend class LLUICtrlFactory;
  103. LLBadge(const Params& p);
  104. public:
  105. ~LLBadge();
  106. bool addToView(LLView * view);
  107. virtual void draw();
  108. const std::string getLabel() const { return wstring_to_utf8str(mLabel); }
  109. void setLabel( const LLStringExplicit& label);
  110. private:
  111. LLPointer< LLUIImage > mBorderImage;
  112. LLUIColor mBorderColor;
  113. const LLFontGL* mGLFont;
  114. LLPointer< LLUIImage > mImage;
  115. LLUIColor mImageColor;
  116. LLUIString mLabel;
  117. LLUIColor mLabelColor;
  118. S32 mLabelOffsetHoriz;
  119. S32 mLabelOffsetVert;
  120. LLRelPos::Location mLocation;
  121. S32 mLocationOffsetHCenter;
  122. S32 mLocationOffsetVCenter;
  123. F32 mLocationPercentHCenter;
  124. F32 mLocationPercentVCenter;
  125. LLHandle< LLView > mOwner;
  126. F32 mPaddingHoriz;
  127. F32 mPaddingVert;
  128. LLScrollContainer* mParentScroller;
  129. };
  130. // Build time optimization, generate once in .cpp file
  131. #ifndef LLBADGE_CPP
  132. extern template class LLBadge* LLView::getChild<class LLBadge>(const std::string& name, BOOL recurse) const;
  133. #endif
  134. #endif // LL_LLBADGE_H