diff options
Diffstat (limited to 'indra/newview/llpaneloutfitedit.cpp')
-rw-r--r-- | indra/newview/llpaneloutfitedit.cpp | 245 |
1 files changed, 231 insertions, 14 deletions
diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index 31c427d2ba..74669b44f4 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -42,8 +42,8 @@ #include "lloutfitobserver.h" #include "llcofwearables.h" #include "llfilteredwearablelist.h" +#include "llfolderviewitem.h" #include "llinventory.h" -#include "llinventoryitemslist.h" #include "llviewercontrol.h" #include "llui.h" #include "llfloater.h" @@ -84,6 +84,11 @@ const U64 ALL_ITEMS_MASK = WEARABLE_MASK | ATTACHMENT_MASK; static const std::string REVERT_BTN("revert_btn"); + +/////////////////////////////////////////////////////////////////////////////// +// LLShopURLDispatcher +/////////////////////////////////////////////////////////////////////////////// + class LLShopURLDispatcher { public: @@ -143,6 +148,10 @@ std::string LLShopURLDispatcher::resolveURL(LLAssetType::EType asset_type, ESex return gSavedSettings.getString(setting_name); } +/////////////////////////////////////////////////////////////////////////////// +// LLPanelOutfitEditGearMenu +/////////////////////////////////////////////////////////////////////////////// + class LLPanelOutfitEditGearMenu { public: @@ -158,7 +167,6 @@ public: if (menu) { populateCreateWearableSubmenus(menu); - menu->buildDrawLabels(); } return menu; @@ -207,6 +215,131 @@ private: } }; +/////////////////////////////////////////////////////////////////////////////// +// LLAddWearablesGearMenu +/////////////////////////////////////////////////////////////////////////////// + +class LLAddWearablesGearMenu : public LLInitClass<LLAddWearablesGearMenu> +{ +public: + static LLMenuGL* create(LLWearableItemsList* flat_list, LLInventoryPanel* inventory_panel) + { + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_registrar; + + llassert(flat_list); + llassert(inventory_panel); + + registrar.add("AddWearable.Gear.Sort", boost::bind(onSort, flat_list, inventory_panel, _2)); + enable_registrar.add("AddWearable.Gear.Check", boost::bind(onCheck, flat_list, inventory_panel, _2)); + enable_registrar.add("AddWearable.Gear.Visible", boost::bind(onVisible, inventory_panel, _2)); + + LLMenuGL* menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>( + "menu_add_wearable_gear.xml", + LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); + + return menu; + } + +private: + static void onSort(LLWearableItemsList* flat_list, + LLInventoryPanel* inventory_panel, + LLSD::String sort_order_str) + { + if (!flat_list || !inventory_panel) return; + + LLWearableItemsList::ESortOrder sort_order; + + if ("by_most_recent" == sort_order_str) + { + sort_order = LLWearableItemsList::E_SORT_BY_MOST_RECENT; + } + else if ("by_name" == sort_order_str) + { + sort_order = LLWearableItemsList::E_SORT_BY_NAME; + } + else if ("by_type" == sort_order_str) + { + sort_order = LLWearableItemsList::E_SORT_BY_TYPE; + } + else + { + llwarns << "Unrecognized sort order action" << llendl; + return; + } + + if (inventory_panel->getVisible()) + { + inventory_panel->setSortOrder(sort_order); + } + else + { + flat_list->setSortOrder(sort_order); + gSavedSettings.setU32("AddWearableSortOrder", sort_order); + } + } + + static bool onCheck(LLWearableItemsList* flat_list, + LLInventoryPanel* inventory_panel, + LLSD::String sort_order_str) + { + if (!inventory_panel || !flat_list) return false; + + // Inventory panel uses its own sort order independent from + // flat list view so this flag is used to distinguish between + // currently visible "tree" or "flat" representation of inventory. + bool inventory_tree_visible = inventory_panel->getVisible(); + + if (inventory_tree_visible) + { + U32 sort_order = inventory_panel->getSortOrder(); + + if ("by_most_recent" == sort_order_str) + { + return LLWearableItemsList::E_SORT_BY_MOST_RECENT & sort_order; + } + else if ("by_name" == sort_order_str) + { + // If inventory panel is not sorted by date then it is sorted by name. + return LLWearableItemsList::E_SORT_BY_MOST_RECENT & ~sort_order; + } + llwarns << "Unrecognized inventory panel sort order" << llendl; + } + else + { + LLWearableItemsList::ESortOrder sort_order = flat_list->getSortOrder(); + + if ("by_most_recent" == sort_order_str) + { + return LLWearableItemsList::E_SORT_BY_MOST_RECENT == sort_order; + } + else if ("by_name" == sort_order_str) + { + return LLWearableItemsList::E_SORT_BY_NAME == sort_order; + } + else if ("by_type" == sort_order_str) + { + return LLWearableItemsList::E_SORT_BY_TYPE == sort_order; + } + llwarns << "Unrecognized wearable list sort order" << llendl; + } + return false; + } + + static bool onVisible(LLInventoryPanel* inventory_panel, + LLSD::String sort_order_str) + { + // Enable sorting by type only for the flat list of items + // because inventory panel doesn't support this kind of sorting. + return ( "by_type" == sort_order_str ) + && ( !inventory_panel || !inventory_panel->getVisible() ); + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// LLCOFDragAndDropObserver +/////////////////////////////////////////////////////////////////////////////// + class LLCOFDragAndDropObserver : public LLInventoryAddItemByAssetObserver { public: @@ -242,12 +375,17 @@ void LLCOFDragAndDropObserver::done() LLAppearanceMgr::instance().updateAppearanceFromCOF(); } +/////////////////////////////////////////////////////////////////////////////// +// LLPanelOutfitEdit +/////////////////////////////////////////////////////////////////////////////// + LLPanelOutfitEdit::LLPanelOutfitEdit() : LLPanel(), mSearchFilter(NULL), mCOFWearables(NULL), mInventoryItemsPanel(NULL), mGearMenu(NULL), + mAddWearablesGearMenu(NULL), mCOFDragAndDropObserver(NULL), mInitialized(false), mAddWearablesPanel(NULL), @@ -325,7 +463,9 @@ BOOL LLPanelOutfitEdit::postBuild() childSetCommitCallback("filter_button", boost::bind(&LLPanelOutfitEdit::showWearablesFilter, this), NULL); childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesFolderView, this), NULL); + childSetCommitCallback("folder_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL); childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL); + childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::saveListSelection, this), NULL); childSetCommitCallback("wearables_gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL); childSetCommitCallback("gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL); childSetCommitCallback("shop_btn_1", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL); @@ -386,10 +526,11 @@ BOOL LLPanelOutfitEdit::postBuild() childSetAction(REVERT_BTN, boost::bind(&LLAppearanceMgr::wearBaseOutfit, LLAppearanceMgr::getInstance())); mWearablesListViewPanel = getChild<LLPanel>("filtered_wearables_panel"); - mWearableItemsList = getChild<LLInventoryItemsList>("list_view"); + mWearableItemsList = getChild<LLWearableItemsList>("list_view"); mWearableItemsList->setCommitOnSelectionChange(true); mWearableItemsList->setCommitCallback(boost::bind(&LLPanelOutfitEdit::onInventorySelectionChange, this)); mWearableItemsList->setDoubleClickCallback(boost::bind(&LLPanelOutfitEdit::onPlusBtnClicked, this)); + mWearableItemsList->setSortOrder((LLWearableItemsList::ESortOrder)gSavedSettings.getU32("AddWearableSortOrder")); mSaveComboBtn.reset(new LLSaveOutfitComboBtn(this)); return TRUE; @@ -470,9 +611,7 @@ void LLPanelOutfitEdit::showWearablesListView() { if(switchPanels(mInventoryItemsPanel, mWearablesListViewPanel)) { - mFolderViewBtn->setToggleState(FALSE); - mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign()); - mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign()); + updateWearablesPanelVerbButtons(); updateFiltersVisibility(); } mListViewBtn->setToggleState(TRUE); @@ -482,9 +621,7 @@ void LLPanelOutfitEdit::showWearablesFolderView() { if(switchPanels(mWearablesListViewPanel, mInventoryItemsPanel)) { - mListViewBtn->setToggleState(FALSE); - mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign()); - mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign()); + updateWearablesPanelVerbButtons(); updateFiltersVisibility(); } mFolderViewBtn->setToggleState(TRUE); @@ -930,13 +1067,33 @@ bool LLPanelOutfitEdit::switchPanels(LLPanel* switch_from_panel, LLPanel* switch void LLPanelOutfitEdit::onGearButtonClick(LLUICtrl* clicked_button) { - if(!mGearMenu) + LLMenuGL* menu = NULL; + + if (mAddWearablesPanel->getVisible()) + { + if (!mAddWearablesGearMenu) + { + mAddWearablesGearMenu = LLAddWearablesGearMenu::create(mWearableItemsList, mInventoryItemsPanel); + } + + menu = mAddWearablesGearMenu; + } + else { - mGearMenu = LLPanelOutfitEditGearMenu::create(); + if (!mGearMenu) + { + mGearMenu = LLPanelOutfitEditGearMenu::create(); + } + + menu = mGearMenu; } - S32 menu_y = mGearMenu->getRect().getHeight() + clicked_button->getRect().getHeight(); - LLMenuGL::showPopup(clicked_button, mGearMenu, 0, menu_y); + if (!menu) return; + + menu->arrangeAndClear(); // update menu height + S32 menu_y = menu->getRect().getHeight() + clicked_button->getRect().getHeight(); + menu->buildDrawLabels(); + LLMenuGL::showPopup(clicked_button, menu, 0, menu_y); } void LLPanelOutfitEdit::onAddMoreButtonClicked() @@ -1019,6 +1176,67 @@ void LLPanelOutfitEdit::getSelectedItemsUUID(uuid_vec_t& uuid_list) // return selected_id; } +void LLPanelOutfitEdit::updateWearablesPanelVerbButtons() +{ + if(mWearablesListViewPanel->getVisible()) + { + mFolderViewBtn->setToggleState(FALSE); + mFolderViewBtn->setImageOverlay(getString("folder_view_off"), mFolderViewBtn->getImageOverlayHAlign()); + mListViewBtn->setImageOverlay(getString("list_view_on"), mListViewBtn->getImageOverlayHAlign()); + } + else if(mInventoryItemsPanel->getVisible()) + { + mListViewBtn->setToggleState(FALSE); + mListViewBtn->setImageOverlay(getString("list_view_off"), mListViewBtn->getImageOverlayHAlign()); + mFolderViewBtn->setImageOverlay(getString("folder_view_on"), mFolderViewBtn->getImageOverlayHAlign()); + } +} + +void LLPanelOutfitEdit::saveListSelection() +{ + if(mWearablesListViewPanel->getVisible()) + { + std::set<LLUUID> selected_ids = mInventoryItemsPanel->getRootFolder()->getSelectionList(); + + if(!selected_ids.size()) return; + + mWearableItemsList->resetSelection(); + + for (std::set<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id) + { + mWearableItemsList->selectItemByUUID(*item_id, true); + } + mWearableItemsList->scrollToShowFirstSelectedItem(); + } + else if(mInventoryItemsPanel->getVisible()) + { + std::vector<LLUUID> selected_ids; + mWearableItemsList->getSelectedUUIDs(selected_ids); + + if(!selected_ids.size()) return; + + mInventoryItemsPanel->clearSelection(); + LLFolderView* root = mInventoryItemsPanel->getRootFolder(); + + if(!root) return; + + for(std::vector<LLUUID>::const_iterator item_id = selected_ids.begin(); item_id != selected_ids.end(); ++item_id) + { + LLFolderViewItem* item = root->getItemByID(*item_id); + if (!item) continue; + + LLFolderViewFolder* parent = item->getParentFolder(); + if(parent) + { + parent->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP); + } + mInventoryItemsPanel->getRootFolder()->changeSelection(item, TRUE); + } + mInventoryItemsPanel->getRootFolder()->scrollToShowSelection(); + } + +} + void LLPanelOutfitEdit::onCOFChanged() { //the panel is only updated when is visible to a user @@ -1027,5 +1245,4 @@ void LLPanelOutfitEdit::onCOFChanged() update(); } - // EOF |