diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-09-02 02:59:07 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-09-02 02:59:07 +0000 |
commit | 5612f13dc8693d89cb5c89f8b1a15115742fba8d (patch) | |
tree | 51e9fb2dcf50ad701deee378e6a146aa0ba600a5 /indra/newview/llchiclet.cpp | |
parent | 1a5cb4fbfb718a6740bdee0442efbb3ae2897b9b (diff) |
merge https://svn.aws.productengine.com/secondlife/export-from-ll/viewer-2-0@1516 https://svn.aws.productengine.com/secondlife/pe/stable-2@1526 -> viewer-2.0.0-3
* Bugs: EXT-622 EXT-702 EXT-626 EXT-638 EXT-600 EXT-543 EXT-656 EXT-801
* New Dev: EXT-282 EXT-782 EXT-694 EXT-797 EXT-798 EXT-799 EXT-453
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r-- | indra/newview/llchiclet.cpp | 437 |
1 files changed, 260 insertions, 177 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index 6b4dfa73a4..1109d8174f 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -47,13 +47,11 @@ #include "llvoicecontrolpanel.h" #include "llgroupmgr.h" -static const std::string P2P_MENU_NAME = "IMChiclet P2P Menu"; -static const std::string GROUP_MENU_NAME = "IMChiclet Group Menu"; - static LLDefaultChildRegistry::Register<LLChicletPanel> t1("chiclet_panel"); static LLDefaultChildRegistry::Register<LLTalkButton> t2("chiclet_talk"); static LLDefaultChildRegistry::Register<LLNotificationChiclet> t3("chiclet_notification"); -static LLDefaultChildRegistry::Register<LLIMChiclet> t4("chiclet_im"); +static LLDefaultChildRegistry::Register<LLIMP2PChiclet> t4("chiclet_im_p2p"); +static LLDefaultChildRegistry::Register<LLIMGroupChiclet> t5("chiclet_im_group"); S32 LLNotificationChiclet::mUreadSystemNotifications = 0; S32 LLNotificationChiclet::mUreadIMNotifications = 0; @@ -187,9 +185,48 @@ void LLChiclet::setValue(const LLSD& value) ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -LLIMChiclet::Params::Params() +LLIMChiclet::LLIMChiclet(const LLChiclet::Params& p) +: LLChiclet(p) +{ +} + +void LLIMChiclet::onMouseDown() +{ + LLIMFloater::toggle(getSessionId()); + setCounter(0); +} + +BOOL LLIMChiclet::handleMouseDown(S32 x, S32 y, MASK mask) +{ + onMouseDown(); + return LLChiclet::handleMouseDown(x, y, mask); +} + +void LLIMChiclet::draw() +{ + LLUICtrl::draw(); + + //if we have a docked floater, we want to position it relative to us + LLIMFloater* im_floater = LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", getSessionId()); + + if (im_floater && im_floater->isDocked()) + { + S32 x, y; + getParent()->localPointToScreen(getRect().getCenterX(), 0, &x, &y); + im_floater->translate(x - im_floater->getRect().getCenterX(), 10 - im_floater->getRect().mBottom); + //set this so the docked floater knows it's been positioned and can now draw + im_floater->setPositioned(true); + } + + gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.0f,0.0f,0.0f,1.f), FALSE); +} + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + +LLIMP2PChiclet::Params::Params() : avatar_icon("avatar_icon") -, group_insignia("group_insignia") , unread_notifications("unread_notifications") , speaker("speaker") , show_speaker("show_speaker") @@ -197,14 +234,8 @@ LLIMChiclet::Params::Params() rect(LLRect(0, 25, 45, 0)); avatar_icon.name("avatar_icon"); - avatar_icon.visible(false); avatar_icon.rect(LLRect(0, 25, 25, 0)); - //it's an icon for a group in case there is a group chat created - group_insignia.name("group_icon"); - group_insignia.visible(false); - group_insignia.rect(LLRect(0, 25, 25, 0)); - unread_notifications.name("unread"); unread_notifications.rect(LLRect(25, 25, 45, 0)); unread_notifications.font(LLFontGL::getFontSansSerif()); @@ -218,25 +249,16 @@ LLIMChiclet::Params::Params() show_speaker = false; } -LLIMChiclet::LLIMChiclet(const Params& p) -: LLChiclet(p) -, LLGroupMgrObserver(LLUUID()) -, mAvatarCtrl(NULL) -, mGroupInsignia(NULL) +LLIMP2PChiclet::LLIMP2PChiclet(const Params& p) +: LLIMChiclet(p) +, mChicletIconCtrl(NULL) , mCounterCtrl(NULL) , mSpeakerCtrl(NULL) -, mShowSpeaker(p.show_speaker) , mPopupMenu(NULL) { LLChicletAvatarIconCtrl::Params avatar_params = p.avatar_icon; - mAvatarCtrl = LLUICtrlFactory::create<LLChicletAvatarIconCtrl>(avatar_params); - addChild(mAvatarCtrl); - - //Before setOtherParticipantId() we are UNAWARE which dialog type will it be - //so keeping both icons for all both p2p and group chat cases - LLIconCtrl::Params grop_icon_params = p.group_insignia; - mGroupInsignia = LLUICtrlFactory::create<LLIconCtrl>(grop_icon_params); - addChild(mGroupInsignia); + mChicletIconCtrl = LLUICtrlFactory::create<LLChicletAvatarIconCtrl>(avatar_params); + addChild(mChicletIconCtrl); LLChicletNotificationCounterCtrl::Params unread_params = p.unread_notifications; mCounterCtrl = LLUICtrlFactory::create<LLChicletNotificationCounterCtrl>(unread_params); @@ -249,16 +271,10 @@ LLIMChiclet::LLIMChiclet(const Params& p) mSpeakerCtrl = LLUICtrlFactory::create<LLChicletSpeakerCtrl>(speaker_params); addChild(mSpeakerCtrl); - setShowSpeaker(getShowSpeaker()); -} - -LLIMChiclet::~LLIMChiclet() -{ - LLGroupMgr::getInstance()->removeObserver(this); + setShowSpeaker(p.show_speaker); } - -void LLIMChiclet::setCounter(S32 counter) +void LLIMP2PChiclet::setCounter(S32 counter) { mCounterCtrl->setCounter(counter); @@ -279,15 +295,9 @@ void LLIMChiclet::setCounter(S32 counter) } } -void LLIMChiclet::onMouseDown() +LLRect LLIMP2PChiclet::getRequiredRect() { - LLIMFloater::toggle(getSessionId()); - setCounter(0); -} - -LLRect LLIMChiclet::getRequiredRect() -{ - LLRect rect(0, 0, mAvatarCtrl->getRect().getWidth(), 0); + LLRect rect(0, 0, mChicletIconCtrl->getRect().getWidth(), 0); if(getShowCounter()) { rect.mRight += mCounterCtrl->getRequiredRect().getWidth(); @@ -299,169 +309,234 @@ LLRect LLIMChiclet::getRequiredRect() return rect; } -void LLIMChiclet::setShowCounter(bool show) +void LLIMP2PChiclet::setOtherParticipantId(const LLUUID& other_participant_id) { - bool needs_resize = getShowCounter() != show; - - LLChiclet::setShowCounter(show); - mCounterCtrl->setVisible(getShowCounter()); - - if(needs_resize) - { - onChicletSizeChanged(); - } + LLIMChiclet::setOtherParticipantId(other_participant_id); + mChicletIconCtrl->setValue(getOtherParticipantId()); } - -void LLIMChiclet::setSessionId(const LLUUID& session_id) +void LLIMP2PChiclet::updateMenuItems() { - LLChiclet::setSessionId(session_id); + if(!mPopupMenu) + return; + if(getSessionId().isNull()) + return; - //for a group chat session_id = group_id - LLFloaterIMPanel* im = LLIMMgr::getInstance()->findFloaterBySession(session_id); - if (!im) return; //should never happen - - EInstantMessage type = im->getDialogType(); - if (type == IM_SESSION_INVITE || type == IM_SESSION_GROUP_START) - { - if (!gAgent.isInGroup(session_id)) return; + bool is_friend = LLAvatarActions::isFriend(getOtherParticipantId()); - if (mGroupInsignia) { - LLGroupMgr* grp_mgr = LLGroupMgr::getInstance(); - LLGroupMgrGroupData* group_data = grp_mgr->getGroupData(session_id); - if (group_data && group_data->mInsigniaID.notNull()) - { - mGroupInsignia->setVisible(TRUE); - mGroupInsignia->setValue(group_data->mInsigniaID); - } - else - { - mID = session_id; //needed for LLGroupMgrObserver - grp_mgr->addObserver(this); - grp_mgr->sendGroupPropertiesRequest(session_id); - } - } - } + mPopupMenu->getChild<LLUICtrl>("Add Friend")->setEnabled(!is_friend); + mPopupMenu->getChild<LLUICtrl>("Remove Friend")->setEnabled(is_friend); } -void LLIMChiclet::setIMSessionName(const std::string& name) +BOOL LLIMP2PChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask) { - setToolTip(name); + if(!mPopupMenu) + { + createPopupMenu(); + } + + if (mPopupMenu) + { + updateMenuItems(); + mPopupMenu->arrangeAndClear(); + LLMenuGL::showPopup(this, mPopupMenu, x, y); + } + + return TRUE; } -//session id should be set before calling this -void LLIMChiclet::setOtherParticipantId(const LLUUID& other_participant_id) +void LLIMP2PChiclet::createPopupMenu() { - llassert(getSessionId().notNull()); + if(mPopupMenu) + { + llwarns << "Menu already exists" << llendl; + return; + } + if(getSessionId().isNull()) + { + return; + } - LLFloaterIMPanel*floater = gIMMgr->findFloaterBySession(getSessionId()); + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + registrar.add("IMChicletMenu.Action", boost::bind(&LLIMP2PChiclet::onMenuItemClicked, this, _2)); - //all alive sessions have alive floater, haven't they? - llassert(floater); + mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL> + ("menu_imchiclet_p2p.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); +} - mOtherParticipantId = other_participant_id; +void LLIMP2PChiclet::onMenuItemClicked(const LLSD& user_data) +{ + std::string level = user_data.asString(); + LLUUID other_participant_id = getOtherParticipantId(); - if (mAvatarCtrl && floater->getDialogType() == IM_NOTHING_SPECIAL) + if("profile" == level) + { + LLAvatarActions::showProfile(other_participant_id); + } + else if("im" == level) + { + LLAvatarActions::startIM(other_participant_id); + } + else if("add" == level) { - mAvatarCtrl->setVisible(TRUE); - mAvatarCtrl->setValue(other_participant_id); + LLAvatarActions::requestFriendshipDialog(other_participant_id); } } - -void LLIMChiclet::changed(LLGroupChange gc) +void LLIMP2PChiclet::setShowSpeaker(bool show) { - LLSD group_insignia = mGroupInsignia->getValue(); - if (group_insignia.isUUID() && group_insignia.asUUID().notNull()) return; + LLIMChiclet::setShowSpeaker(show); - if (GC_PROPERTIES == gc) + bool needs_resize = getShowSpeaker() != show; + mSpeakerCtrl->setVisible(getShowSpeaker()); + if(needs_resize) { - LLGroupMgrGroupData* group_data = LLGroupMgr::getInstance()->getGroupData(getSessionId()); - if (group_data && group_data->mInsigniaID.notNull()) - { - mGroupInsignia->setVisible(TRUE); - mGroupInsignia->setValue(group_data->mInsigniaID); - } + onChicletSizeChanged(); } } -LLUUID LLIMChiclet::getOtherParticipantId() +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + +LLIMGroupChiclet::Params::Params() +: group_icon("group_icon") { - return mOtherParticipantId; + rect(LLRect(0, 25, 45, 0)); + + group_icon.name("group_icon"); + group_icon.rect(LLRect(0, 25, 25, 0)); + + unread_notifications.name("unread"); + unread_notifications.rect(LLRect(25, 25, 45, 0)); + unread_notifications.font(LLFontGL::getFontSansSerif()); + unread_notifications.font_halign(LLFontGL::HCENTER); + unread_notifications.v_pad(5); + unread_notifications.text_color(LLColor4::white); + + speaker.name("speaker"); + speaker.rect(LLRect(45, 25, 65, 0)); + + show_speaker = false; } -void LLIMChiclet::updateMenuItems() +LLIMGroupChiclet::LLIMGroupChiclet(const Params& p) +: LLIMChiclet(p) +, LLGroupMgrObserver(LLUUID::null) +, mChicletIconCtrl(NULL) +, mCounterCtrl(NULL) +, mSpeakerCtrl(NULL) +, mPopupMenu(NULL) { - if(!mPopupMenu) - return; - if(getSessionId().isNull()) - return; + LLChicletGroupIconCtrl::Params avatar_params = p.group_icon; + mChicletIconCtrl = LLUICtrlFactory::create<LLChicletGroupIconCtrl>(avatar_params); + addChild(mChicletIconCtrl); - if(P2P_MENU_NAME == mPopupMenu->getName()) - { - bool is_friend = LLAvatarActions::isFriend(getOtherParticipantId()); + LLChicletNotificationCounterCtrl::Params unread_params = p.unread_notifications; + mCounterCtrl = LLUICtrlFactory::create<LLChicletNotificationCounterCtrl>(unread_params); + addChild(mCounterCtrl); - mPopupMenu->getChild<LLUICtrl>("Add Friend")->setEnabled(!is_friend); - mPopupMenu->getChild<LLUICtrl>("Remove Friend")->setEnabled(is_friend); - } + setCounter(getCounter()); + setShowCounter(getShowCounter()); + + LLChicletSpeakerCtrl::Params speaker_params = p.speaker; + mSpeakerCtrl = LLUICtrlFactory::create<LLChicletSpeakerCtrl>(speaker_params); + addChild(mSpeakerCtrl); + + setShowSpeaker(p.show_speaker); } -BOOL LLIMChiclet::handleMouseDown(S32 x, S32 y, MASK mask) +LLIMGroupChiclet::~LLIMGroupChiclet() { - onMouseDown(); - return LLChiclet::handleMouseDown(x, y, mask); + LLGroupMgr::getInstance()->removeObserver(this); } -void LLIMChiclet::setShowSpeaker(bool show) +void LLIMGroupChiclet::setCounter(S32 counter) { - bool needs_resize = getShowSpeaker() != show; - - mShowSpeaker = show; - mSpeakerCtrl->setVisible(getShowSpeaker()); + mCounterCtrl->setCounter(counter); - if(needs_resize) + if(getShowCounter()) { - onChicletSizeChanged(); + LLRect counter_rect = mCounterCtrl->getRect(); + LLRect required_rect = mCounterCtrl->getRequiredRect(); + bool needs_resize = required_rect.getWidth() != counter_rect.getWidth(); + + if(needs_resize) + { + counter_rect.mRight = counter_rect.mLeft + required_rect.getWidth(); + mCounterCtrl->reshape(counter_rect.getWidth(), counter_rect.getHeight()); + mCounterCtrl->setRect(counter_rect); + + onChicletSizeChanged(); + } } } -void LLIMChiclet::draw() +LLRect LLIMGroupChiclet::getRequiredRect() { - LLUICtrl::draw(); + LLRect rect(0, 0, mChicletIconCtrl->getRect().getWidth(), 0); + if(getShowCounter()) + { + rect.mRight += mCounterCtrl->getRequiredRect().getWidth(); + } + if(getShowSpeaker()) + { + rect.mRight += mSpeakerCtrl->getRect().getWidth(); + } + return rect; +} - //if we have a docked floater, we want to position it relative to us - LLIMFloater* im_floater = LLFloaterReg::findTypedInstance<LLIMFloater>("impanel", getSessionId()); +void LLIMGroupChiclet::setSessionId(const LLUUID& session_id) +{ + LLChiclet::setSessionId(session_id); - if (im_floater && im_floater->isDocked()) + LLGroupMgr* grp_mgr = LLGroupMgr::getInstance(); + LLGroupMgrGroupData* group_data = grp_mgr->getGroupData(session_id); + if (group_data && group_data->mInsigniaID.notNull()) { - S32 x, y; - getParent()->localPointToScreen(getRect().getCenterX(), 0, &x, &y); - im_floater->translate(x - im_floater->getRect().getCenterX(), 10 - im_floater->getRect().mBottom); - //set this so the docked floater knows it's been positioned and can now draw - im_floater->setPositioned(true); + mChicletIconCtrl->setValue(group_data->mInsigniaID); } + else + { + if(getSessionId() != mID) + { + grp_mgr->removeObserver(this); + mID = getSessionId(); + grp_mgr->addObserver(this); + } + grp_mgr->sendGroupPropertiesRequest(session_id); + } +} - gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0, LLColor4(0.0f,0.0f,0.0f,1.f), FALSE); +void LLIMGroupChiclet::changed(LLGroupChange gc) +{ + if (GC_PROPERTIES == gc) + { + LLGroupMgrGroupData* group_data = LLGroupMgr::getInstance()->getGroupData(getSessionId()); + if (group_data) + { + mChicletIconCtrl->setValue(group_data->mInsigniaID); + } + } } -BOOL LLIMChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask) +BOOL LLIMGroupChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask) { if(!mPopupMenu) + { createPopupMenu(); - - updateMenuItems(); + } if (mPopupMenu) { mPopupMenu->arrangeAndClear(); + LLMenuGL::showPopup(this, mPopupMenu, x, y); } - - LLMenuGL::showPopup(this, mPopupMenu, x, y); return TRUE; } -void LLIMChiclet::createPopupMenu() +void LLIMGroupChiclet::createPopupMenu() { if(mPopupMenu) { @@ -469,55 +544,41 @@ void LLIMChiclet::createPopupMenu() return; } if(getSessionId().isNull()) + { return; - - LLFloaterIMPanel*floater = gIMMgr->findFloaterBySession(getSessionId()); - if(!floater) - return; + } LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; - registrar.add("IMChicletMenu.Action", boost::bind(&LLIMChiclet::onMenuItemClicked, this, _2)); + registrar.add("IMChicletMenu.Action", boost::bind(&LLIMGroupChiclet::onMenuItemClicked, this, _2)); - switch(floater->getDialogType()) - { - case IM_SESSION_GROUP_START: - mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL> - ("menu_imchiclet_group.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - break; - case IM_NOTHING_SPECIAL: - mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL> - ("menu_imchiclet_p2p.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - break; - default: - llwarns << "Unexpected dialog type" << llendl; - break; - } + mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL> + ("menu_imchiclet_group.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); } -void LLIMChiclet::onMenuItemClicked(const LLSD& user_data) +void LLIMGroupChiclet::onMenuItemClicked(const LLSD& user_data) { std::string level = user_data.asString(); - LLUUID other_participant_id = getOtherParticipantId(); + LLUUID group_id = getSessionId(); - if("profile" == level) + if("group chat" == level) { - LLAvatarActions::showProfile(other_participant_id); + LLGroupActions::startChat(group_id); } - else if("im" == level) - { - LLAvatarActions::startIM(other_participant_id); - } - else if("add" == level) - { - LLAvatarActions::requestFriendshipDialog(other_participant_id); - } - else if("group chat" == level) + else if("info" == level) { - LLGroupActions::startChat(other_participant_id); + LLGroupActions::show(group_id); } - else if("info" == level) +} + +void LLIMGroupChiclet::setShowSpeaker(bool show) +{ + LLIMChiclet::setShowSpeaker(show); + + bool needs_resize = getShowSpeaker() != show; + mSpeakerCtrl->setVisible(getShowSpeaker()); + if(needs_resize) { - LLGroupActions::show(other_participant_id); + onChicletSizeChanged(); } } @@ -1178,6 +1239,28 @@ LLChicletAvatarIconCtrl::LLChicletAvatarIconCtrl(const Params& p) ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// +LLChicletGroupIconCtrl::LLChicletGroupIconCtrl(const Params& p) +: LLIconCtrl(p) +, mDefaultIcon(p.default_icon) +{ +} + +void LLChicletGroupIconCtrl::setValue(const LLSD& value ) +{ + if(value.asUUID().isNull()) + { + LLIconCtrl::setValue(mDefaultIcon); + } + else + { + LLIconCtrl::setValue(value); + } +} + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + LLChicletSpeakerCtrl::LLChicletSpeakerCtrl(const Params&p) : LLIconCtrl(p) { |