diff options
Diffstat (limited to 'indra/newview/llconversationview.cpp')
-rwxr-xr-x[-rw-r--r--] | indra/newview/llconversationview.cpp | 143 |
1 files changed, 141 insertions, 2 deletions
diff --git a/indra/newview/llconversationview.cpp b/indra/newview/llconversationview.cpp index 53971a3159..208a89cc8d 100644..100755 --- a/indra/newview/llconversationview.cpp +++ b/indra/newview/llconversationview.cpp @@ -28,15 +28,21 @@ #include "llviewerprecompiledheaders.h" #include "llconversationview.h" + +#include <boost/bind.hpp> #include "llconversationmodel.h" #include "llimconversation.h" #include "llimfloatercontainer.h" +#include "llfloaterreg.h" +#include "lluictrlfactory.h" // // Implementation of conversations list session widgets // static LLDefaultChildRegistry::Register<LLConversationViewSession> r_conversation_view_session("conversation_view_session"); + + LLConversationViewSession::Params::Params() : container() {} @@ -303,14 +309,57 @@ void LLConversationViewSession::refresh() // Implementation of conversations list participant (avatar) widgets // +static LLDefaultChildRegistry::Register<LLConversationViewParticipant> r("conversation_view_participant"); +bool LLConversationViewParticipant::sStaticInitialized = false; +S32 LLConversationViewParticipant::sChildrenWidths[LLConversationViewParticipant::ALIC_COUNT]; + LLConversationViewParticipant::Params::Params() : - participant_id() +container(), +participant_id(), +info_button("info_button"), +output_monitor("output_monitor") {} LLConversationViewParticipant::LLConversationViewParticipant( const LLConversationViewParticipant::Params& p ): LLFolderViewItem(p), - mUUID(p.participant_id) + mInfoBtn(NULL), + mSpeakingIndicator(NULL), + mUUID(p.participant_id) +{ + +} + +void LLConversationViewParticipant::initFromParams(const LLConversationViewParticipant::Params& params) +{ + LLButton::Params info_button_params(params.info_button()); + applyXUILayout(info_button_params, this); + LLButton * button = LLUICtrlFactory::create<LLButton>(info_button_params); + addChild(button); + + LLOutputMonitorCtrl::Params output_monitor_params(params.output_monitor()); + applyXUILayout(output_monitor_params, this); + LLOutputMonitorCtrl * outputMonitor = LLUICtrlFactory::create<LLOutputMonitorCtrl>(output_monitor_params); + addChild(outputMonitor); +} + +BOOL LLConversationViewParticipant::postBuild() { + mInfoBtn = getChild<LLButton>("info_btn"); + mInfoBtn->setClickedCallback(boost::bind(&LLConversationViewParticipant::onInfoBtnClick, this)); + mInfoBtn->setVisible(false); + + mSpeakingIndicator = getChild<LLOutputMonitorCtrl>("speaking_indicator"); + + if (!sStaticInitialized) + { + // Remember children widths including their padding from the next sibling, + // so that we can hide and show them again later. + initChildrenWidths(this); + sStaticInitialized = true; + } + + computeLabelRightPadding(); + return LLFolderViewItem::postBuild(); } void LLConversationViewParticipant::refresh() @@ -325,4 +374,94 @@ void LLConversationViewParticipant::refresh() LLFolderViewItem::refresh(); } +void LLConversationViewParticipant::addToFolder(LLFolderViewFolder* folder) +{ + //Add the item to the folder (conversation) + LLFolderViewItem::addToFolder(folder); + + //Now retrieve the folder (conversation) UUID, which is the speaker session + LLConversationItem* vmi = this->getParentFolder() ? dynamic_cast<LLConversationItem*>(this->getParentFolder()->getViewModelItem()) : NULL; + if(vmi) + { + mSpeakingIndicator->setSpeakerId(mUUID, + vmi->getUUID()); //set the session id + } +} + +void LLConversationViewParticipant::onInfoBtnClick() +{ + LLFloaterReg::showInstance("inspect_avatar", LLSD().with("avatar_id", mUUID)); +} + +void LLConversationViewParticipant::onMouseEnter(S32 x, S32 y, MASK mask) +{ + mInfoBtn->setVisible(true); + computeLabelRightPadding(); + LLFolderViewItem::onMouseEnter(x, y, mask); +} + +void LLConversationViewParticipant::onMouseLeave(S32 x, S32 y, MASK mask) +{ + mInfoBtn->setVisible(false); + computeLabelRightPadding(); + LLFolderViewItem::onMouseEnter(x, y, mask); +} + +// static +void LLConversationViewParticipant::initChildrenWidths(LLConversationViewParticipant* self) +{ + //speaking indicator width + padding + S32 speaking_indicator_width = self->getRect().getWidth() - self->mSpeakingIndicator->getRect().mLeft; + + //info btn width + padding + S32 info_btn_width = self->mSpeakingIndicator->getRect().mLeft - self->mInfoBtn->getRect().mLeft; + + S32 index = ALIC_COUNT; + sChildrenWidths[--index] = info_btn_width; + sChildrenWidths[--index] = speaking_indicator_width; + llassert(index == 0); +} + +void LLConversationViewParticipant::computeLabelRightPadding() +{ + mLabelPaddingRight = DEFAULT_TEXT_PADDING_RIGHT; + LLView* control; + S32 ctrl_width; + + for (S32 i = 0; i < ALIC_COUNT; ++i) + { + control = getItemChildView((EAvatarListItemChildIndex)i); + + // skip invisible views + if (!control->getVisible()) continue; + + ctrl_width = sChildrenWidths[i]; // including space between current & left controls + // accumulate the amount of space taken by the controls + mLabelPaddingRight += ctrl_width; + } +} + +LLView* LLConversationViewParticipant::getItemChildView(EAvatarListItemChildIndex child_view_index) +{ + LLView* child_view = NULL; + + switch (child_view_index) + { + case ALIC_SPEAKER_INDICATOR: + child_view = mSpeakingIndicator; + break; + case ALIC_INFO_BUTTON: + child_view = mInfoBtn; + break; + default: + LL_WARNS("AvatarItemReshape") << "Unexpected child view index is passed: " << child_view_index << LL_ENDL; + llassert(0); + break; + // leave child_view untouched + } + + return child_view; +} + // EOF + |