PageRenderTime 341ms CodeModel.GetById 175ms app.highlight 7ms RepoModel.GetById 158ms 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
  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
 27#ifndef LL_LLAVATARICONCTRL_H
 28#define LL_LLAVATARICONCTRL_H
 29
 30#include "lliconctrl.h"
 31#include "llavatarpropertiesprocessor.h"
 32#include "llviewermenu.h"
 33
 34class LLAvatarName;
 35
 36class LLAvatarIconIDCache: public LLSingleton<LLAvatarIconIDCache>
 37{
 38public:
 39	struct LLAvatarIconIDCacheItem
 40	{
 41		LLUUID icon_id;
 42		LLDate cached_time;	
 43
 44		bool expired();
 45	};
 46
 47	LLAvatarIconIDCache():mFilename("avatar_icons_cache.txt")
 48	{
 49	}
 50
 51	void				load	();
 52	void				save	();
 53
 54	LLUUID*				get		(const LLUUID& id);
 55	void				add		(const LLUUID& avatar_id,const LLUUID& icon_id);
 56
 57	void				remove	(const LLUUID& id);
 58protected:
 59	
 60
 61	std::string	mFilename;
 62	std::map<LLUUID,LLAvatarIconIDCacheItem> mCache;//we cache only LLUID and time
 63};
 64
 65class LLAvatarIconCtrl
 66: public LLIconCtrl, public LLAvatarPropertiesObserver
 67{
 68public:
 69	struct Params : public LLInitParam::Block<Params, LLIconCtrl::Params>
 70	{
 71		Optional <LLUUID> avatar_id;
 72		Optional <bool> draw_tooltip;
 73		Optional <std::string> default_icon_name;
 74		Params();
 75	};
 76	
 77protected:
 78	LLAvatarIconCtrl(const Params&);
 79	friend class LLUICtrlFactory;
 80
 81public:
 82	virtual ~LLAvatarIconCtrl();
 83
 84	virtual void setValue(const LLSD& value);
 85
 86	// LLAvatarPropertiesProcessor observer trigger
 87	virtual void processProperties(void* data, EAvatarProcessorType type);
 88
 89	void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
 90
 91	const LLUUID&		getAvatarId() const	{ return mAvatarId; }
 92	const std::string&	getFullName() const { return mFullName; }
 93
 94	void setDrawTooltip(bool value) { mDrawTooltip = value;}
 95
 96protected:
 97	LLUUID				mAvatarId;
 98	std::string			mFullName;
 99	bool				mDrawTooltip;
100	std::string			mDefaultIconName;
101
102	bool updateFromCache();
103};
104
105#endif  // LL_LLAVATARICONCTRL_H