summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llgrouplist.cpp71
-rw-r--r--indra/newview/llgrouplist.h6
-rw-r--r--indra/newview/skins/default/xui/en/menu_people_groups.xml57
3 files changed, 134 insertions, 0 deletions
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<LLGroupList> 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<LLMenuGL>("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<LLOldEvents::LLEvent> 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<LLOldEvents::LLEvent> event, const LLSD& userdata); // called on agent group list changes
+ bool onContextMenuItemClick(const LLSD& userdata);
+ bool onContextMenuItemEnable(const LLSD& userdata);
+
+ LLHandle<LLView> 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 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<menu name="menu_group_plus"
+ left="0" bottom="0" visible="false"
+ mouse_opaque="false" opaque="true" color="MenuDefaultBgColor" drop_shadow="false">
+ <menu_item_call
+ label="View Info"
+ name="View Info">
+ <menu_item_call.on_click
+ function="People.Groups.Action"
+ parameter="view_info" />
+ <menu_item_call.on_enable
+ function="People.Groups.Enable"
+ parameter="view_info" />
+ </menu_item_call>
+ <menu_item_call
+ label="Chat"
+ name="Chat">
+ <menu_item_call.on_click
+ function="People.Groups.Action"
+ parameter="chat" />
+ <menu_item_call.on_enable
+ function="People.Groups.Enable"
+ parameter="chat" />
+ </menu_item_call>
+ <menu_item_call
+ label="Call"
+ name="Call">
+ <menu_item_call.on_click
+ function="People.Groups.Action"
+ parameter="call" />
+ <menu_item_call.on_enable
+ function="People.Groups.Enable"
+ parameter="call" />
+ </menu_item_call>
+ <menu_item_separator />
+ <menu_item_call
+ label="Activate"
+ name="Activate">
+ <menu_item_call.on_click
+ function="People.Groups.Action"
+ parameter="activate" />
+ <menu_item_call.on_enable
+ function="People.Groups.Enable"
+ parameter="activate" />
+ </menu_item_call>
+ <menu_item_separator />
+ <menu_item_call
+ label="Leave"
+ name="Leave">
+ <menu_item_call.on_click
+ function="People.Groups.Action"
+ parameter="leave" />
+ <menu_item_call.on_enable
+ function="People.Groups.Enable"
+ parameter="leave" />
+ </menu_item_call>
+</menu>