PageRenderTime 35ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llavatariconctrl.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 105 lines | 57 code | 22 blank | 26 comment | 0 complexity | d66895ae03d93a8e5d1811e246600d7b MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llavatariconctrl.h
  3. * @brief LLAvatarIconCtrl base class
  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_LLAVATARICONCTRL_H
  27. #define LL_LLAVATARICONCTRL_H
  28. #include "lliconctrl.h"
  29. #include "llavatarpropertiesprocessor.h"
  30. #include "llviewermenu.h"
  31. class LLAvatarName;
  32. class LLAvatarIconIDCache: public LLSingleton<LLAvatarIconIDCache>
  33. {
  34. public:
  35. struct LLAvatarIconIDCacheItem
  36. {
  37. LLUUID icon_id;
  38. LLDate cached_time;
  39. bool expired();
  40. };
  41. LLAvatarIconIDCache():mFilename("avatar_icons_cache.txt")
  42. {
  43. }
  44. void load ();
  45. void save ();
  46. LLUUID* get (const LLUUID& id);
  47. void add (const LLUUID& avatar_id,const LLUUID& icon_id);
  48. void remove (const LLUUID& id);
  49. protected:
  50. std::string mFilename;
  51. std::map<LLUUID,LLAvatarIconIDCacheItem> mCache;//we cache only LLUID and time
  52. };
  53. class LLAvatarIconCtrl
  54. : public LLIconCtrl, public LLAvatarPropertiesObserver
  55. {
  56. public:
  57. struct Params : public LLInitParam::Block<Params, LLIconCtrl::Params>
  58. {
  59. Optional <LLUUID> avatar_id;
  60. Optional <bool> draw_tooltip;
  61. Optional <std::string> default_icon_name;
  62. Params();
  63. };
  64. protected:
  65. LLAvatarIconCtrl(const Params&);
  66. friend class LLUICtrlFactory;
  67. public:
  68. virtual ~LLAvatarIconCtrl();
  69. virtual void setValue(const LLSD& value);
  70. // LLAvatarPropertiesProcessor observer trigger
  71. virtual void processProperties(void* data, EAvatarProcessorType type);
  72. void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
  73. const LLUUID& getAvatarId() const { return mAvatarId; }
  74. const std::string& getFullName() const { return mFullName; }
  75. void setDrawTooltip(bool value) { mDrawTooltip = value;}
  76. protected:
  77. LLUUID mAvatarId;
  78. std::string mFullName;
  79. bool mDrawTooltip;
  80. std::string mDefaultIconName;
  81. bool updateFromCache();
  82. };
  83. #endif // LL_LLAVATARICONCTRL_H