From 887b2858d4d180d3679f1eb39fd37be5a551615e Mon Sep 17 00:00:00 2001 From: Sergei Litovchuk Date: Fri, 11 Jun 2010 20:02:42 +0300 Subject: EXT-7779 FIXED Changed wearing panel from inventory panel to a flat list similar to My Outfits view. - Added common interface for My Outfits and Wearing tabs. - Changed LLPanelOutfitsInventory to use common interface for My Outfits and Wearing tabs. - Removed dependency on outfits side panel from inventory bridge context menus. - Removed unused LLShowCreatedOutfit class from llagentwearables.cpp. - Restored opening newly created outfit in My Outfits tab. - Fixed worn items indication for Wearing tab items. Revieved by Neal Orman at https://codereview.productengine.com/secondlife/r/604/. --HG-- branch : product-engine --- indra/newview/llpanelwearing.cpp | 130 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 indra/newview/llpanelwearing.cpp (limited to 'indra/newview/llpanelwearing.cpp') diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp new file mode 100644 index 0000000000..27f13a8093 --- /dev/null +++ b/indra/newview/llpanelwearing.cpp @@ -0,0 +1,130 @@ +/** + * @file llpanelwearing.cpp + * @brief List of agent's worn items. + * + * $LicenseInfo:firstyear=2010&license=viewergpl$ + * + * Copyright (c) 2010, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llpanelwearing.h" + +#include "llappearancemgr.h" +#include "llinventorymodel.h" +#include "llinventoryobserver.h" +#include "llwearableitemslist.h" + + +std::string LLPanelAppearanceTab::sFilterSubString = LLStringUtil::null; + +static LLRegisterPanelClassWrapper t_panel_wearing("panel_wearing"); + +LLPanelWearing::LLPanelWearing() + : LLPanelAppearanceTab() + , mCOFItemsList(NULL) + , mIsInitialized(false) +{ + mCategoriesObserver = new LLInventoryCategoriesObserver(); +} + +LLPanelWearing::~LLPanelWearing() +{ + if (gInventory.containsObserver(mCategoriesObserver)) + { + gInventory.removeObserver(mCategoriesObserver); + delete mCategoriesObserver; + } +} + +BOOL LLPanelWearing::postBuild() +{ + mCOFItemsList = getChild("cof_items_list"); + return TRUE; +} + +//virtual +void LLPanelWearing::onOpen(const LLSD& /*info*/) +{ + if (!mIsInitialized) + { + // *TODO: I'm not sure is this check necessary but it never match while developing. + if (!gInventory.isInventoryUsable()) + return; + + const LLUUID cof = gInventory.findCategoryUUIDForType(LLFolderType::FT_CURRENT_OUTFIT); + + // *TODO: I'm not sure is this check necessary but it never match while developing. + LLViewerInventoryCategory* category = gInventory.getCategory(cof); + if (!category) + return; + + gInventory.addObserver(mCategoriesObserver); + + // Start observing changes in Current Outfit category. + mCategoriesObserver->addCategory(cof, boost::bind(&LLWearableItemsList::updateList, mCOFItemsList, cof)); + + // Fetch Current Outfit contents and refresh the list to display + // initially fetched items. If not all items are fetched now + // the observer will refresh the list as soon as the new items + // arrive. + category->fetch(); + + mCOFItemsList->updateList(cof); + + mIsInitialized = true; + } +} + +// virtual +void LLPanelWearing::setFilterSubString(const std::string& string) +{ + sFilterSubString = string; + mCOFItemsList->setFilterSubString(sFilterSubString); +} + +bool LLPanelWearing::isActionEnabled(const LLSD& userdata) +{ + const std::string command_name = userdata.asString(); + + if (command_name == "save_outfit") + { + bool outfit_locked = LLAppearanceMgr::getInstance()->isOutfitLocked(); + bool outfit_dirty = LLAppearanceMgr::getInstance()->isOutfitDirty(); + // allow save only if outfit isn't locked and is dirty + return !outfit_locked && outfit_dirty; + } + return false; +} + +boost::signals2::connection LLPanelWearing::setSelectionChangeCallback(commit_callback_t cb) +{ + if (!mCOFItemsList) return boost::signals2::connection(); + + return mCOFItemsList->setCommitCallback(cb); +} + +// EOF -- cgit v1.2.3 From 2583a4d6ea60aeefa1d21f578d6fbf1f2f68c72a Mon Sep 17 00:00:00 2001 From: Sergei Litovchuk Date: Tue, 22 Jun 2010 16:34:27 +0300 Subject: 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 --- indra/newview/llpanelwearing.cpp | 84 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'indra/newview/llpanelwearing.cpp') 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( + "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("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(ctrl); + if (!list) return; + + uuid_vec_t selected_uuids; + + list->getSelectedUUIDs(selected_uuids); + + mContextMenu->show(ctrl, selected_uuids, x, y); +} + // EOF -- cgit v1.2.3