summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelwearing.cpp
diff options
context:
space:
mode:
authorSergei Litovchuk <slitovchuk@productengine.com>2010-06-22 16:34:27 +0300
committerSergei Litovchuk <slitovchuk@productengine.com>2010-06-22 16:34:27 +0300
commit2583a4d6ea60aeefa1d21f578d6fbf1f2f68c72a (patch)
treedad6042b2fe1cb41609f78ec927c45e6aadf5b0d /indra/newview/llpanelwearing.cpp
parent887b2858d4d180d3679f1eb39fd37be5a551615e (diff)
EXT-4295 FIXED Added gear and context menus for Wearing tab.
- Moved My Outfits gear menu from llpaneloutfitsinventory.cpp to lloutfitslist.cpp Revieved by Neal Orman and Mike Antipov at https://codereview.productengine.com/secondlife/r/604/. --HG-- branch : product-engine
Diffstat (limited to 'indra/newview/llpanelwearing.cpp')
-rw-r--r--indra/newview/llpanelwearing.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp
index 27f13a8093..b8852890ad 100644
--- a/indra/newview/llpanelwearing.cpp
+++ b/indra/newview/llpanelwearing.cpp
@@ -36,8 +36,64 @@
#include "llappearancemgr.h"
#include "llinventorymodel.h"
#include "llinventoryobserver.h"
+#include "llsidetray.h"
+#include "llviewermenu.h"
#include "llwearableitemslist.h"
+// Context menu and Gear menu helper.
+static void edit_outfit()
+{
+ LLSideTray::getInstance()->showPanel("sidepanel_appearance", LLSD().with("type", "edit_outfit"));
+}
+
+//////////////////////////////////////////////////////////////////////////
+
+class LLWearingGearMenu
+{
+public:
+ LLWearingGearMenu()
+ : mMenu(NULL)
+ {
+ LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
+
+ registrar.add("Gear.Edit", boost::bind(&edit_outfit));
+
+ mMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>(
+ "menu_wearing_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+ llassert(mMenu);
+ }
+
+ void show(LLView* spawning_view)
+ {
+ if (!mMenu) return;
+
+ mMenu->buildDrawLabels();
+ mMenu->updateParent(LLMenuGL::sMenuContainer);
+ S32 menu_x = 0;
+ S32 menu_y = spawning_view->getRect().getHeight() + mMenu->getRect().getHeight();
+ LLMenuGL::showPopup(spawning_view, mMenu, menu_x, menu_y);
+ }
+
+private:
+ LLMenuGL* mMenu;
+};
+
+//////////////////////////////////////////////////////////////////////////
+
+class LLWearingContextMenu : public LLListContextMenu
+{
+protected:
+ /* virtual */ LLContextMenu* createMenu()
+ {
+ LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar;
+
+ registrar.add("Wearing.Edit", boost::bind(&edit_outfit));
+
+ return createFromFile("menu_wearing_tab.xml");
+ }
+};
+
+//////////////////////////////////////////////////////////////////////////
std::string LLPanelAppearanceTab::sFilterSubString = LLStringUtil::null;
@@ -49,10 +105,16 @@ LLPanelWearing::LLPanelWearing()
, mIsInitialized(false)
{
mCategoriesObserver = new LLInventoryCategoriesObserver();
+
+ mGearMenu = new LLWearingGearMenu();
+ mContextMenu = new LLWearingContextMenu();
}
LLPanelWearing::~LLPanelWearing()
{
+ delete mGearMenu;
+ delete mContextMenu;
+
if (gInventory.containsObserver(mCategoriesObserver))
{
gInventory.removeObserver(mCategoriesObserver);
@@ -63,6 +125,8 @@ LLPanelWearing::~LLPanelWearing()
BOOL LLPanelWearing::postBuild()
{
mCOFItemsList = getChild<LLWearableItemsList>("cof_items_list");
+ mCOFItemsList->setRightMouseDownCallback(boost::bind(&LLPanelWearing::onWearableItemsListRightClick, this, _1, _2, _3));
+
return TRUE;
}
@@ -106,6 +170,7 @@ void LLPanelWearing::setFilterSubString(const std::string& string)
mCOFItemsList->setFilterSubString(sFilterSubString);
}
+// virtual
bool LLPanelWearing::isActionEnabled(const LLSD& userdata)
{
const std::string command_name = userdata.asString();
@@ -120,6 +185,13 @@ bool LLPanelWearing::isActionEnabled(const LLSD& userdata)
return false;
}
+// virtual
+void LLPanelWearing::showGearMenu(LLView* spawning_view)
+{
+ if (!mGearMenu) return;
+ mGearMenu->show(spawning_view);
+}
+
boost::signals2::connection LLPanelWearing::setSelectionChangeCallback(commit_callback_t cb)
{
if (!mCOFItemsList) return boost::signals2::connection();
@@ -127,4 +199,16 @@ boost::signals2::connection LLPanelWearing::setSelectionChangeCallback(commit_ca
return mCOFItemsList->setCommitCallback(cb);
}
+void LLPanelWearing::onWearableItemsListRightClick(LLUICtrl* ctrl, S32 x, S32 y)
+{
+ LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(ctrl);
+ if (!list) return;
+
+ uuid_vec_t selected_uuids;
+
+ list->getSelectedUUIDs(selected_uuids);
+
+ mContextMenu->show(ctrl, selected_uuids, x, y);
+}
+
// EOF