From 5f237f8559da76d3c2fd6251b324360fcf25515f Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Fri, 18 Dec 2009 14:01:18 +0200 Subject: Implemented major sub-task EXT-3525 (Context menu for Notifications well) --HG-- branch : product-engine --- indra/newview/llchiclet.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'indra/newview/llchiclet.cpp') diff --git a/indra/newview/llchiclet.cpp b/indra/newview/llchiclet.cpp index c6fe076911..5695f7cac1 100644 --- a/indra/newview/llchiclet.cpp +++ b/indra/newview/llchiclet.cpp @@ -154,6 +154,7 @@ LLSysWellChiclet::LLSysWellChiclet(const Params& p) , mMaxDisplayedCount(p.max_displayed_count) , mIsNewMessagesState(false) , mFlashToLitTimer(NULL) +, mContextMenu(NULL) { LLButton::Params button_params = p.button; mButton = LLUICtrlFactory::create(button_params); @@ -229,6 +230,21 @@ void LLSysWellChiclet::setNewMessagesState(bool new_messages) mIsNewMessagesState = new_messages; } +// virtual +BOOL LLSysWellChiclet::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + if(!mContextMenu) + { + createMenu(); + } + if (mContextMenu) + { + mContextMenu->show(x, y); + LLMenuGL::showPopup(this, mContextMenu, x, y); + } + return TRUE; +} + /************************************************************************/ /* LLIMWellChiclet implementation */ /************************************************************************/ @@ -248,6 +264,11 @@ LLIMWellChiclet::~LLIMWellChiclet() LLIMMgr::getInstance()->removeSessionObserver(this); } +void LLIMWellChiclet::createMenu() +{ + // TODO: implement context menu for IM well +} + void LLIMWellChiclet::messageCountChanged(const LLSD& session_data) { setCounter(LLBottomTray::getInstance()->getTotalUnreadIMCount()); @@ -281,6 +302,47 @@ void LLNotificationChiclet::connectCounterUpdatersToSignal(const std::string& no } } +void LLNotificationChiclet::onMenuItemClicked(const LLSD& user_data) +{ + std::string action = user_data.asString(); + if("close all" == action) + { + LLNotificationWellWindow::getInstance()->closeAll(); + } +} + +bool LLNotificationChiclet::enableMenuItem(const LLSD& user_data) +{ + std::string item = user_data.asString(); + if (item == "can close all") + { + return mUreadSystemNotifications != 0; + } + return true; +} + +void LLNotificationChiclet::createMenu() +{ + if(mContextMenu) + { + llwarns << "Menu already exists" << llendl; + return; + } + + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + registrar.add("NotificationWellChicletMenu.Action", + boost::bind(&LLNotificationChiclet::onMenuItemClicked, this, _2)); + + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + enable_registrar.add("NotificationWellChicletMenu.EnableItem", + boost::bind(&LLNotificationChiclet::enableMenuItem, this, _2)); + + mContextMenu = LLUICtrlFactory::getInstance()->createFromFile + ("menu_notification_well_button.xml", + LLMenuGL::sMenuContainer, + LLViewerMenuHolderGL::child_registry_t::instance()); +} + ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3