Skip to content
Snippets Groups Projects
Commit c72de2ed authored by Vadim Savchuk's avatar Vadim Savchuk
Browse files

Added context menu to the group list (task EXT-3595).

--HG--
branch : product-engine
parent 7d308294
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
// libs // libs
#include "llbutton.h" #include "llbutton.h"
#include "lliconctrl.h" #include "lliconctrl.h"
#include "llmenugl.h"
#include "lltextbox.h" #include "lltextbox.h"
#include "lltrans.h" #include "lltrans.h"
...@@ -46,6 +47,7 @@ ...@@ -46,6 +47,7 @@
#include "llfloaterreg.h" #include "llfloaterreg.h"
#include "lltextutil.h" #include "lltextutil.h"
#include "llviewercontrol.h" // for gSavedSettings #include "llviewercontrol.h" // for gSavedSettings
#include "llviewermenu.h" // for gMenuHolder
static LLDefaultChildRegistry::Register<LLGroupList> r("group_list"); static LLDefaultChildRegistry::Register<LLGroupList> r("group_list");
S32 LLGroupListItem::sIconWidth = 0; S32 LLGroupListItem::sIconWidth = 0;
...@@ -88,11 +90,24 @@ LLGroupList::LLGroupList(const Params& p) ...@@ -88,11 +90,24 @@ LLGroupList::LLGroupList(const Params& p)
// Set default sort order. // Set default sort order.
setComparator(&GROUP_COMPARATOR); 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() LLGroupList::~LLGroupList()
{ {
gAgent.removeListener(this); gAgent.removeListener(this);
LLView::deleteViewByHandle(mContextMenuHandle);
} }
// virtual // virtual
...@@ -104,6 +119,22 @@ void LLGroupList::draw() ...@@ -104,6 +119,22 @@ void LLGroupList::draw()
LLFlatListView::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) void LLGroupList::setNameFilter(const std::string& filter)
{ {
if (mNameFilter != filter) if (mNameFilter != filter)
...@@ -203,6 +234,46 @@ bool LLGroupList::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& ...@@ -203,6 +234,46 @@ bool LLGroupList::handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD&
return false; 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 */ /* LLGroupListItem implementation */
/************************************************************************/ /************************************************************************/
......
...@@ -60,6 +60,7 @@ class LLGroupList: public LLFlatListView, public LLOldEvents::LLSimpleListener ...@@ -60,6 +60,7 @@ class LLGroupList: public LLFlatListView, public LLOldEvents::LLSimpleListener
virtual ~LLGroupList(); virtual ~LLGroupList();
virtual void draw(); // from LLView virtual void draw(); // from LLView
/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); // from LLView
void setNameFilter(const std::string& filter); void setNameFilter(const std::string& filter);
void toggleIcons(); void toggleIcons();
...@@ -71,6 +72,11 @@ class LLGroupList: public LLFlatListView, public LLOldEvents::LLSimpleListener ...@@ -71,6 +72,11 @@ class LLGroupList: public LLFlatListView, public LLOldEvents::LLSimpleListener
void addNewItem(const LLUUID& id, const std::string& name, const LLUUID& icon_id, EAddPosition pos = ADD_BOTTOM); 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 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 mShowIcons;
bool mDirty; bool mDirty;
std::string mNameFilter; std::string mNameFilter;
......
<?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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment