diff options
Diffstat (limited to 'indra/newview/llpaneloutfitsinventory.cpp')
-rw-r--r-- | indra/newview/llpaneloutfitsinventory.cpp | 108 |
1 files changed, 82 insertions, 26 deletions
diff --git a/indra/newview/llpaneloutfitsinventory.cpp b/indra/newview/llpaneloutfitsinventory.cpp index 8b451c156c..1157c40b39 100644 --- a/indra/newview/llpaneloutfitsinventory.cpp +++ b/indra/newview/llpaneloutfitsinventory.cpp @@ -91,6 +91,7 @@ public: registrar.add("Gear.Create", boost::bind(&LLOutfitListGearMenu::onCreate, this, _2)); enable_registrar.add("Gear.OnEnable", boost::bind(&LLOutfitListGearMenu::onEnable, this, _2)); + enable_registrar.add("Gear.OnVisible", boost::bind(&LLOutfitListGearMenu::onVisible, this, _2)); mMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>( "menu_outfit_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); @@ -99,6 +100,28 @@ public: LLMenuGL* getMenu() { return mMenu; } + void show(LLView* spawning_view) + { + if (!mMenu) return; + + updateItemsVisibility(); + 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); + } + + void updateItemsVisibility() + { + if (!mMenu) return; + + bool have_selection = getSelectedOutfitID().notNull(); + mMenu->setItemVisible("sepatator1", have_selection); + mMenu->setItemVisible("sepatator2", have_selection); + mMenu->arrangeAndClear(); // update menu height + } + private: const LLUUID& getSelectedOutfitID() { @@ -169,6 +192,31 @@ private: bool onEnable(LLSD::String param) { const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.isNull()) // no selection or invalid outfit selected + { + return false; + } + + if ("rename" == param) + { + return get_is_category_renameable(&gInventory, selected_outfit_id); + } + else if ("delete" == param) + { + return LLAppearanceMgr::instance().getCanRemoveOutfit(selected_outfit_id); + } + + return true; + } + + bool onVisible(LLSD::String param) + { + const LLUUID& selected_outfit_id = getSelectedOutfitID(); + if (selected_outfit_id.isNull()) // no selection or invalid outfit selected + { + return false; + } + bool is_worn = LLAppearanceMgr::instance().getBaseOutfitUUID() == selected_outfit_id; if ("wear" == param) @@ -179,14 +227,6 @@ private: { return is_worn; } - else if ("rename" == param) - { - return get_is_category_renameable(&gInventory, selected_outfit_id); - } - else if ("delete" == param) - { - return LLAppearanceMgr::instance().getCanRemoveOutfit(selected_outfit_id); - } return true; } @@ -523,28 +563,21 @@ void LLPanelOutfitsInventory::updateListCommands() { bool trash_enabled = isActionEnabled("delete"); bool wear_enabled = isActionEnabled("wear"); + bool wear_visible = !isCOFPanelActive(); bool make_outfit_enabled = isActionEnabled("save_outfit"); mListCommands->childSetEnabled("trash_btn", trash_enabled); mListCommands->childSetEnabled("wear_btn", wear_enabled); - mListCommands->childSetVisible("wear_btn", wear_enabled); + mListCommands->childSetVisible("wear_btn", wear_visible); mSaveComboBtn->setMenuItemEnabled("save_outfit", make_outfit_enabled); } void LLPanelOutfitsInventory::showGearMenu() { - LLMenuGL* menu = mGearMenu ? mGearMenu->getMenu() : NULL; - if (menu) - { - menu->buildDrawLabels(); - menu->updateParent(LLMenuGL::sMenuContainer); - LLView* spawning_view = getChild<LLView>("options_gear_btn"); - S32 menu_x, menu_y; - //show menu in co-ordinates of panel - spawning_view->localPointToOtherView(0, spawning_view->getRect().getHeight(), &menu_x, &menu_y, this); - menu_y += menu->getRect().getHeight(); - LLMenuGL::showPopup(this, menu, menu_x, menu_y); - } + if (!mGearMenu) return; + + LLView* spawning_view = getChild<LLView>("options_gear_btn"); + mGearMenu->show(spawning_view); } void LLPanelOutfitsInventory::onTrashButtonClick() @@ -555,11 +588,25 @@ void LLPanelOutfitsInventory::onTrashButtonClick() void LLPanelOutfitsInventory::onClipboardAction(const LLSD& userdata) { std::string command_name = userdata.asString(); - // TODO: add handling "My Outfits" tab. if (isCOFPanelActive()) { getActivePanel()->getRootFolder()->doToSelected(getActivePanel()->getModel(),command_name); } + else // "My Outfits" tab active + { + if (command_name == "delete") + { + const LLUUID& selected_outfit_id = mMyOutfitsPanel->getSelectedOutfitUUID(); + if (selected_outfit_id.notNull()) + { + remove_category(&gInventory, selected_outfit_id); + } + } + else + { + llwarns << "Unrecognized action" << llendl; + } + } updateListCommands(); updateVerbs(); } @@ -614,7 +661,6 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) { BOOL can_delete = FALSE; - // TODO: add handling "My Outfits" tab. if (isCOFPanelActive()) { LLFolderView* root = getActivePanel()->getRootFolder(); @@ -630,10 +676,15 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) LLFolderViewItem *item = root->getItemByID(item_id); can_delete &= item->getListener()->isItemRemovable(); } - return can_delete; } } - return FALSE; + else // "My Outfits" tab active + { + const LLUUID& selected_outfit = mMyOutfitsPanel->getSelectedOutfitUUID(); + can_delete = LLAppearanceMgr::instance().getCanRemoveOutfit(selected_outfit); + } + + return can_delete; } if (command_name == "remove_link") { @@ -668,6 +719,7 @@ BOOL LLPanelOutfitsInventory::isActionEnabled(const LLSD& userdata) { return FALSE; } + return hasItemsSelected(); } if (command_name == "save_outfit") { @@ -690,7 +742,6 @@ bool LLPanelOutfitsInventory::hasItemsSelected() { bool has_items_selected = false; - // TODO: add handling "My Outfits" tab. if (isCOFPanelActive()) { LLFolderView* root = getActivePanel()->getRootFolder(); @@ -700,6 +751,10 @@ bool LLPanelOutfitsInventory::hasItemsSelected() has_items_selected = (selection_set.size() > 0); } } + else // My Outfits Tab is active + { + has_items_selected = mMyOutfitsPanel->getSelectedOutfitUUID().notNull(); + } return has_items_selected; } @@ -730,6 +785,7 @@ void LLPanelOutfitsInventory::initTabPanels() mCurrentOutfitPanel->setSelectCallback(boost::bind(&LLPanelOutfitsInventory::onTabSelectionChange, this, mCurrentOutfitPanel, _1, _2)); mMyOutfitsPanel = getChild<LLOutfitsList>(OUTFITS_TAB_NAME); + mMyOutfitsPanel->addSelectionChangeCallback(boost::bind(&LLPanelOutfitsInventory::updateVerbs, this)); mAppearanceTabs = getChild<LLTabContainer>("appearance_tabs"); mAppearanceTabs->setCommitCallback(boost::bind(&LLPanelOutfitsInventory::onTabChange, this)); |