diff options
author | Aimee Linden <aimee@lindenlab.com> | 2010-09-03 15:30:16 +0100 |
---|---|---|
committer | Aimee Linden <aimee@lindenlab.com> | 2010-09-03 15:30:16 +0100 |
commit | 0a74d1593513dc3209fdb29a8dc56b2794b36a29 (patch) | |
tree | 1af644fe9ad3c62999c177ae37cbeff2ffe19d62 /indra/newview/llchathistory.cpp | |
parent | ce1a0c6bafad092f9687e3b5a6b4865569d96863 (diff) | |
parent | 54b9992eaefe2b68d16a6264c1901f12612e99dc (diff) |
Merge between james/viewer-identity-evolution and dessie/viewer-public
Diffstat (limited to 'indra/newview/llchathistory.cpp')
-rw-r--r-- | indra/newview/llchathistory.cpp | 80 |
1 files changed, 64 insertions, 16 deletions
diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index 7204e6c39c..1f1ccf5c14 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -32,10 +32,12 @@ #include "llviewerprecompiledheaders.h" +#include "llchathistory.h" + +#include "llavatarnamecache.h" #include "llinstantmessage.h" #include "llimview.h" -#include "llchathistory.h" #include "llcommandhandler.h" #include "llpanel.h" #include "lluictrlfactory.h" @@ -104,6 +106,18 @@ LLObjectIMHandler gObjectIMHandler; class LLChatHistoryHeader: public LLPanel { public: + LLChatHistoryHeader() + : LLPanel(), + mPopupMenuHandleAvatar(), + mPopupMenuHandleObject(), + mAvatarID(), + mSourceType(CHAT_SOURCE_UNKNOWN), + mFrom(), + mSessionID(), + mMinUserNameWidth(0), + mUserNameFont(NULL) + {} + static LLChatHistoryHeader* createInstance(const std::string& file_name) { LLChatHistoryHeader* pInstance = new LLChatHistoryHeader; @@ -246,7 +260,6 @@ public: mAvatarID = chat.mFromID; mSessionID = chat.mSessionID; mSourceType = chat.mSourceType; - gCacheName->get(mAvatarID, FALSE, boost::bind(&LLChatHistoryHeader::nameUpdatedCallback, this, _1, _2, _3, _4)); //*TODO overly defensive thing, source type should be maintained out there if((chat.mFromID.isNull() && chat.mFromName.empty()) || chat.mFromName == SYSTEM_FROM && chat.mFromID.isNull()) @@ -254,22 +267,40 @@ public: mSourceType = CHAT_SOURCE_SYSTEM; } - LLTextBox* userName = getChild<LLTextBox>("user_name"); + mUserNameFont = style_params.font(); + LLTextBox* user_name = getChild<LLTextBox>("user_name"); + user_name->setReadOnlyColor(style_params.readonly_color()); + user_name->setColor(style_params.color()); - userName->setReadOnlyColor(style_params.readonly_color()); - userName->setColor(style_params.color()); - - userName->setValue(chat.mFromName); - mFrom = chat.mFromName; - if (chat.mFromName.empty() || CHAT_SOURCE_SYSTEM == mSourceType) + if (chat.mFromName.empty() + || mSourceType == CHAT_SOURCE_SYSTEM + || mAvatarID.isNull()) { mFrom = LLTrans::getString("SECOND_LIFE"); - userName->setValue(mFrom); + user_name->setValue(mFrom); + updateMinUserNameWidth(); + } + else if (mSourceType == CHAT_SOURCE_AGENT + && chat.mChatStyle != CHAT_STYLE_HISTORY) + { + // ...from a normal user, lookup the name and fill in later. + // *NOTE: Do not do this for chat history logs, otherwise the viewer + // will flood the People API with lookup requests on startup + + // Start with blank so sample data from XUI XML doesn't + // flash on the screen + user_name->setValue( LLSD() ); + LLAvatarNameCache::get(mAvatarID, + boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2)); + } + else { + // ...from an object, just use name as given + mFrom = chat.mFromName; + user_name->setValue(mFrom); + updateMinUserNameWidth(); } - mMinUserNameWidth = style_params.font()->getWidth(userName->getWText().c_str()) + PADDING; - setTimeField(chat); LLAvatarIconCtrl* icon = getChild<LLAvatarIconCtrl>("avatar_icon"); @@ -323,12 +354,28 @@ public: LLPanel::draw(); } - void nameUpdatedCallback(const LLUUID& id,const std::string& first,const std::string& last,BOOL is_group) + void updateMinUserNameWidth() { - if (id != mAvatarID) - return; - mFrom = first + " " + last; + if (mUserNameFont) + { + LLTextBox* user_name = getChild<LLTextBox>("user_name"); + const LLWString& text = user_name->getWText(); + mMinUserNameWidth = mUserNameFont->getWidth(text.c_str()) + PADDING; + } } + + void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) + { + mFrom = av_name.mDisplayName; + + LLTextBox* user_name = getChild<LLTextBox>("user_name"); + user_name->setValue( LLSD(av_name.mDisplayName ) ); + user_name->setToolTip( av_name.mUsername ); + setToolTip( av_name.mUsername ); + // name might have changed, update width + updateMinUserNameWidth(); + } + protected: static const S32 PADDING = 20; @@ -455,6 +502,7 @@ protected: LLUUID mSessionID; S32 mMinUserNameWidth; + const LLFontGL* mUserNameFont; }; LLUICtrl* LLChatHistoryHeader::sInfoCtrl = NULL; |