From c72de2edf0a2f7590fd43d86c59e83afcf7e8bcf Mon Sep 17 00:00:00 2001 From: Vadim Savchuk Date: Mon, 21 Dec 2009 20:56:38 +0200 Subject: Added context menu to the group list (task EXT-3595). --HG-- branch : product-engine --- indra/newview/llgrouplist.cpp | 71 ++++++++++++++++++++++ indra/newview/llgrouplist.h | 6 ++ .../skins/default/xui/en/menu_people_groups.xml | 57 +++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 indra/newview/skins/default/xui/en/menu_people_groups.xml diff --git a/indra/newview/llgrouplist.cpp b/indra/newview/llgrouplist.cpp index ab9db10f38..3ca459a403 100644 --- a/indra/newview/llgrouplist.cpp +++ b/indra/newview/llgrouplist.cpp @@ -37,6 +37,7 @@ // libs #include "llbutton.h" #include "lliconctrl.h" +#include "llmenugl.h" #include "lltextbox.h" #include "lltrans.h" @@ -46,6 +47,7 @@ #include "llfloaterreg.h" #include "lltextutil.h" #include "llviewercontrol.h" // for gSavedSettings +#include "llviewermenu.h" // for gMenuHolder static LLDefaultChildRegistry::Register r("group_list"); S32 LLGroupListItem::sIconWidth = 0; @@ -88,11 +90,24 @@ LLGroupList::LLGroupList(const Params& p) // Set default sort order. setComparator(&GROUP_COMPARATOR); + + // Set up context menu. + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + registrar.add("People.Groups.Action", boost::bind(&LLGroupList::onContextMenuItemClick, this, _2)); + enable_registrar.add("People.Groups.Enable", boost::bind(&LLGroupList::onContextMenuItemEnable, this, _2)); + + LLMenuGL* context_menu = LLUICtrlFactory::getInstance()->createFromFile("menu_people_groups.xml", + gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); + if(context_menu) + mContextMenuHandle = context_menu->getHandle(); } LLGroupList::~LLGroupList() { gAgent.removeListener(this); + LLView::deleteViewByHandle(mContextMenuHandle); } // virtual @@ -104,6 +119,22 @@ void LLGroupList::draw() LLFlatListView::draw(); } +// virtual +BOOL LLGroupList::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask); + + LLMenuGL* context_menu = (LLMenuGL*)mContextMenuHandle.get(); + if (context_menu) + { + context_menu->buildDrawLabels(); + context_menu->updateParent(LLMenuGL::sMenuContainer); + LLMenuGL::showPopup(this, context_menu, x, y); + } + + return handled; +} + void LLGroupList::setNameFilter(const std::string& filter) { if (mNameFilter != filter) @@ -203,6 +234,46 @@ bool LLGroupList::handleEvent(LLPointer event, const LLSD& return false; } +bool LLGroupList::onContextMenuItemClick(const LLSD& userdata) +{ + std::string action = userdata.asString(); + LLUUID selected_group = getSelectedUUID(); + + if (action == "view_info") + { + LLGroupActions::show(selected_group); + } + else if (action == "chat") + { + LLGroupActions::startIM(selected_group); + } + else if (action == "call") + { + LLGroupActions::startCall(selected_group); + } + else if (action == "activate") + { + LLGroupActions::activate(selected_group); + } + else if (action == "leave") + { + LLGroupActions::leave(selected_group); + } + + return true; +} + +bool LLGroupList::onContextMenuItemEnable(const LLSD& userdata) +{ + LLUUID selected_group_id = getSelectedUUID(); + bool real_group_selected = selected_group_id.notNull(); // a "real" (not "none") group is selected + + if (userdata.asString() == "activate") + return real_group_selected && gAgent.getGroupID() != selected_group_id; + + return real_group_selected; +} + /************************************************************************/ /* LLGroupListItem implementation */ /************************************************************************/ diff --git a/indra/newview/llgrouplist.h b/indra/newview/llgrouplist.h index 33cfe005b9..f7afe0c0b2 100644 --- a/indra/newview/llgrouplist.h +++ b/indra/newview/llgrouplist.h @@ -60,6 +60,7 @@ public: virtual ~LLGroupList(); virtual void draw(); // from LLView + /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); // from LLView void setNameFilter(const std::string& filter); void toggleIcons(); @@ -71,6 +72,11 @@ private: void addNewItem(const LLUUID& id, const std::string& name, const LLUUID& icon_id, EAddPosition pos = ADD_BOTTOM); bool handleEvent(LLPointer event, const LLSD& userdata); // called on agent group list changes + bool onContextMenuItemClick(const LLSD& userdata); + bool onContextMenuItemEnable(const LLSD& userdata); + + LLHandle mContextMenuHandle; + bool mShowIcons; bool mDirty; std::string mNameFilter; diff --git a/indra/newview/skins/default/xui/en/menu_people_groups.xml b/indra/newview/skins/default/xui/en/menu_people_groups.xml new file mode 100644 index 0000000000..afa680139d --- /dev/null +++ b/indra/newview/skins/default/xui/en/menu_people_groups.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3