diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2009-12-03 09:17:51 -0800 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2009-12-03 09:17:51 -0800 |
commit | 5fd2938da8d6709a6596833088fd83c60d591507 (patch) | |
tree | 9186f79b996eb60a9bb1f5cefada86c0596ac850 /indra/newview/llchiclet.cpp | |
parent | 97f97f286ccca1f736c575f516a61c6a32787807 (diff) | |
parent | 57b68d9bfe25fc7b9efe41a9fa30935c156acb34 (diff) |
Merge with recent viewer-2-0
Diffstat (limited to 'indra/newview/llchiclet.cpp')
-rw-r--r-- | indra/newview/llchiclet.cpp | 121 |
1 files changed, 120 insertions, 1 deletions
diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index f41e326dd0..588855d088 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -595,8 +595,49 @@ void LLAdHocChiclet::setCounter(S32 counter) setShowNewMessagesIcon(counter); } +void LLAdHocChiclet::createPopupMenu() +{ + if(mPopupMenu) + { + llwarns << "Menu already exists" << llendl; + return; + } + if(getSessionId().isNull()) + { + return; + } + + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + registrar.add("IMChicletMenu.Action", boost::bind(&LLAdHocChiclet::onMenuItemClicked, this, _2)); + + mPopupMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL> + ("menu_imchiclet_adhoc.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); +} + +void LLAdHocChiclet::onMenuItemClicked(const LLSD& user_data) +{ + std::string level = user_data.asString(); + LLUUID group_id = getSessionId(); + + if("end" == level) + { + LLGroupActions::endIM(group_id); + } +} + BOOL LLAdHocChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask) { + if(!mPopupMenu) + { + createPopupMenu(); + } + + if (mPopupMenu) + { + mPopupMenu->arrangeAndClear(); + LLMenuGL::showPopup(this, mPopupMenu, x, y); + } + return TRUE; } @@ -1362,7 +1403,7 @@ void LLChicletNotificationCounterCtrl::setCounter(S32 counter) LLRect LLChicletNotificationCounterCtrl::getRequiredRect() { LLRect rc; - S32 text_width = getContentsRect().getWidth(); + S32 text_width = getTextPixelWidth(); rc.mRight = rc.mLeft + llmax(text_width, mInitialWidth); @@ -1415,6 +1456,28 @@ void LLChicletGroupIconCtrl::setValue(const LLSD& value ) ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// +LLChicletInvOfferIconCtrl::LLChicletInvOfferIconCtrl(const Params& p) +: LLChicletAvatarIconCtrl(p) + , mDefaultIcon(p.default_icon) +{ +} + +void LLChicletInvOfferIconCtrl::setValue(const LLSD& value ) +{ + if(value.asUUID().isNull()) + { + LLIconCtrl::setValue(mDefaultIcon); + } + else + { + LLChicletAvatarIconCtrl::setValue(value); + } +} + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + LLChicletSpeakerCtrl::LLChicletSpeakerCtrl(const Params&p) : LLOutputMonitorCtrl(p) { @@ -1466,4 +1529,60 @@ BOOL LLScriptChiclet::handleMouseDown(S32 x, S32 y, MASK mask) return LLChiclet::handleMouseDown(x, y, mask); } +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// + +static const std::string INVENTORY_USER_OFFER ("UserGiveItem"); + +LLInvOfferChiclet::Params::Params() +{ + // *TODO Vadim: Get rid of hardcoded values. + rect(CHICLET_RECT); + icon.rect(CHICLET_ICON_RECT); +} + +LLInvOfferChiclet::LLInvOfferChiclet(const Params&p) + : LLIMChiclet(p) + , mChicletIconCtrl(NULL) +{ + LLChicletInvOfferIconCtrl::Params icon_params = p.icon; + mChicletIconCtrl = LLUICtrlFactory::create<LLChicletInvOfferIconCtrl>(icon_params); + // Let "new message" icon be on top, else it will be hidden behind chiclet icon. + addChildInBack(mChicletIconCtrl); +} + +void LLInvOfferChiclet::setSessionId(const LLUUID& session_id) +{ + setShowNewMessagesIcon( getSessionId() != session_id ); + + LLIMChiclet::setSessionId(session_id); + LLUUID notification_id = LLScriptFloaterManager::getInstance()->findNotificationId(session_id); + LLNotificationPtr notification = LLNotifications::getInstance()->find(notification_id); + if(notification) + { + setToolTip(notification->getSubstitutions()["TITLE"].asString()); + } + + if ( notification && notification->getName() == INVENTORY_USER_OFFER ) + { + mChicletIconCtrl->setValue(notification->getPayload()["from_id"]); + } + else + { + mChicletIconCtrl->setValue(LLUUID::null); + } +} + +void LLInvOfferChiclet::onMouseDown() +{ + LLScriptFloaterManager::instance().toggleScriptFloater(getSessionId()); +} + +BOOL LLInvOfferChiclet::handleMouseDown(S32 x, S32 y, MASK mask) +{ + onMouseDown(); + return LLChiclet::handleMouseDown(x, y, mask); +} + // EOF |