LLFolderViewItem* LLLandmarksPanel::selectItemInAccordionTab(LLPlacesInventoryPanel* inventory_list, const std::string& tab_name, const LLUUID& obj_id, BOOL take_keyboard_focus) const { if (!inventory_list) return NULL; LLFolderView* root = inventory_list->getRootFolder(); LLFolderViewItem* item = inventory_list->getItemByID(obj_id); if (!item) return NULL; LLAccordionCtrlTab* tab = getChild<LLAccordionCtrlTab>(tab_name); if (!tab->isExpanded()) { tab->changeOpenClose(false); } root->setSelection(item, FALSE, take_keyboard_focus); LLAccordionCtrl* accordion = getChild<LLAccordionCtrl>("landmarks_accordion"); LLRect screen_rc; localRectToScreen(item->getRect(), &screen_rc); accordion->notifyParent(LLSD().with("scrollToShowRect", screen_rc.getValue())); return item; }
BOOL LLAccordionCtrlTab::LLAccordionCtrlTabHeader::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, EAcceptance* accept, std::string& tooltip_msg) { LLAccordionCtrlTab* parent = dynamic_cast<LLAccordionCtrlTab*>(getParent()); if ( parent && !parent->getDisplayChildren() && parent->getCollapsible() && parent->canOpenClose() ) { if (mAutoOpenTimer.getStarted()) { if (mAutoOpenTimer.getElapsedTimeF32() > AUTO_OPEN_TIME) { parent->changeOpenClose(false); mAutoOpenTimer.stop(); return TRUE; } } else mAutoOpenTimer.start(); } return LLUICtrl::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); }
void LLPanelPicks::showAccordion(const std::string& name, bool show) { LLAccordionCtrlTab* tab = getChild<LLAccordionCtrlTab>(name); tab->setVisible(show); LLAccordionCtrl* acc = getChild<LLAccordionCtrl>("accordion"); acc->arrange(); }
void LLTeleportHistoryPanel::showTeleportHistory() { mDirty = true; // Starting to add items from last one, in reverse order, // since TeleportHistory keeps most recent item at the end if (!mTeleportHistory) { mTeleportHistory = LLTeleportHistoryStorage::getInstance(); } mCurrentItem = mTeleportHistory->getItems().size() - 1; for (S32 n = mItemContainers.size() - 1; n >= 0; --n) { LLAccordionCtrlTab* tab = mItemContainers.get(n); if (tab) { tab->setVisible(false); LLFlatListView* fv = getFlatListViewFromTab(tab); if (fv) { // Detached panels are managed by LLTeleportHistoryFlatItemStorage std::vector<LLPanel*> detached_items; fv->detachItems(detached_items); } } } }
// virtual void LLLandmarksPanel::onSearchEdit(const std::string& string) { // give FolderView a chance to be refreshed. So, made all accordions visible for (accordion_tabs_t::const_iterator iter = mAccordionTabs.begin(); iter != mAccordionTabs.end(); ++iter) { LLAccordionCtrlTab* tab = *iter; tab->setVisible(TRUE); // expand accordion to see matched items in each one. See EXT-2014. if (string != "") { tab->changeOpenClose(false); } LLPlacesInventoryPanel* inventory_list = dynamic_cast<LLPlacesInventoryPanel*>(tab->getAccordionView()); if (NULL == inventory_list) continue; filter_list(inventory_list, string); } if (sFilterSubString != string) sFilterSubString = string; // show all folders in Landmarks Accordion for empty filter // only if Landmarks inventory folder is not empty updateShowFolderState(); }
void LLTeleportHistoryPanel::handleItemSelect(LLFlatListView* selected) { mLastSelectedFlatlList = selected; LLTeleportHistoryFlatItem* item = dynamic_cast<LLTeleportHistoryFlatItem *> (mLastSelectedFlatlList->getSelectedItem()); if (item) mLastSelectedItemIndex = item->getIndex(); S32 tabs_cnt = mItemContainers.size(); for (S32 n = 0; n < tabs_cnt; n++) { LLAccordionCtrlTab* tab = mItemContainers.get(n); if (!tab->getVisible()) continue; LLFlatListView *flv = getFlatListViewFromTab(tab); if (!flv) continue; if (flv == selected) continue; flv->resetSelection(true); } updateVerbs(); }
void LLOutfitsList::onCOFChanged() { LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t item_array; // Collect current COF items gInventory.collectDescendents( LLAppearanceMgr::instance().getCOF(), cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH); uuid_vec_t vnew; uuid_vec_t vadded; uuid_vec_t vremoved; // From gInventory we get the UUIDs of links that are currently in COF. // These links UUIDs are not the same UUIDs that we have in each wearable items list. // So we collect base items' UUIDs to find them or links that point to them in wearable // items lists and update their worn state there. for (LLInventoryModel::item_array_t::const_iterator iter = item_array.begin(); iter != item_array.end(); ++iter) { vnew.push_back((*iter)->getLinkedUUID()); } // We need to update only items that were added or removed from COF. LLCommonUtils::computeDifference(vnew, mCOFLinkedItems, vadded, vremoved); // Store the ids of items currently linked from COF. mCOFLinkedItems = vnew; for (outfits_map_t::iterator iter = mOutfitsMap.begin(); iter != mOutfitsMap.end(); ++iter) { LLAccordionCtrlTab* tab = iter->second; if (!tab) continue; LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (!list) continue; // Append removed ids to added ids because we should update all of them. vadded.reserve(vadded.size() + vremoved.size()); vadded.insert(vadded.end(), vremoved.begin(), vremoved.end()); // Every list updates the labels of changed items or // the links that point to these items. list->updateChangedItems(vadded); } }
void LLOutfitsList::expand_all_folders() { for (outfits_map_t::iterator iter = mOutfitsMap.begin(); iter != mOutfitsMap.end(); ++iter) { LLAccordionCtrlTab* tab = iter->second; if(tab && !tab->isExpanded()) { tab->changeOpenClose(false); } } }
void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::draw() { S32 width = getRect().getWidth(); S32 height = getRect().getHeight(); F32 alpha = getCurrentTransparency(); gl_rect_2d(0,0,width - 1 ,height - 1,mHeaderBGColor.get() % alpha,true); LLAccordionCtrlTab* parent = dynamic_cast<LLAccordionCtrlTab*>(getParent()); bool collapsible = (parent && parent->getCollapsible()); bool expanded = (parent && parent->getDisplayChildren()); // Handle overlay images, if needed // Only show green "focus" background image if the accordion is open, // because the user's mental model of focus is that it goes away after // the accordion is closed. if (getParent()->hasFocus() || mIsSelected /*&& !(collapsible && !expanded)*/ // WHY?? ) { mImageHeaderFocused->draw(0,0,width,height); } else { mImageHeader->draw(0,0,width,height); } if(mNeedsHighlight) { mImageHeaderOver->draw(0,0,width,height); } if(collapsible) { LLPointer<LLUIImage> overlay_image; if(expanded) { overlay_image = mImageExpanded; } else { overlay_image = mImageCollapsed; } overlay_image->draw(HEADER_IMAGE_LEFT_OFFSET, (height - overlay_image->getHeight()) / 2); } LLUICtrl::draw(); }
static LLPanel *childGetVisibleTabWithHelp(LLView *parent) { LLView *child; // look through immediate children first for an active tab with help for (child = parent->getFirstChild(); child; child = parent->findNextSibling(child)) { LLPanel *curTabPanel = NULL; // do we have a tab container? LLTabContainer *tab = dynamic_cast<LLTabContainer *>(child); if (tab && tab->getVisible()) { curTabPanel = tab->getCurrentPanel(); } // do we have an accordion tab? LLAccordionCtrlTab* accordion = dynamic_cast<LLAccordionCtrlTab *>(child); if (accordion && accordion->getDisplayChildren()) { curTabPanel = dynamic_cast<LLPanel *>(accordion->getAccordionView()); } // if we found a valid tab, does it have a help topic? if (curTabPanel && !curTabPanel->getHelpTopic().empty()) { return curTabPanel; } } // then try a bit harder and recurse through all children for (child = parent->getFirstChild(); child; child = parent->findNextSibling(child)) { if (child->getVisible()) { LLPanel* tab = ::childGetVisibleTabWithHelp(child); if (tab) { return tab; } } } // couldn't find any active tabs with a help topic string return NULL; }
void LLOutfitsList::onFilteredWearableItemsListRefresh(LLUICtrl* ctrl) { if (!ctrl || sFilterSubString.empty()) return; for (outfits_map_t::iterator iter = mOutfitsMap.begin(), iter_end = mOutfitsMap.end(); iter != iter_end; ++iter) { LLAccordionCtrlTab* tab = iter->second; if (!tab) continue; LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (list != ctrl) continue; applyFilterToTab(iter->first, tab, sFilterSubString); } }
void LLOutfitsList::updateOutfitTab(const LLUUID& category_id) { outfits_map_t::iterator outfits_iter = mOutfitsMap.find(category_id); if (outfits_iter != mOutfitsMap.end()) { LLViewerInventoryCategory *cat = gInventory.getCategory(category_id); if (!cat) return; std::string name = cat->getName(); // Update tab name with the new category name. LLAccordionCtrlTab* tab = outfits_iter->second; if (tab) { tab->setName(name); tab->setTitle(name); } } }
bool LLTeleportHistoryPanel::isActionEnabled(const LLSD& userdata) const { S32 tabs_cnt = mItemContainers.size(); bool has_expanded_tabs = false; bool has_collapsed_tabs = false; for (S32 n = 0; n < tabs_cnt; n++) { LLAccordionCtrlTab* tab = mItemContainers.get(n); if (!tab->getVisible()) continue; if (tab->getDisplayChildren()) { has_expanded_tabs = true; } else { has_collapsed_tabs = true; } if (has_expanded_tabs && has_collapsed_tabs) { break; } } std::string command_name = userdata.asString(); if (has_expanded_tabs && command_name == "collapse_all") { return true; } if (has_collapsed_tabs && command_name == "expand_all") { return true; } return false; }
void LLPanelPeople::showAccordion(const std::string name, bool show) { if(name.empty()) { llwarns << "No name provided" << llendl; return; } LLAccordionCtrlTab* tab = getChild<LLAccordionCtrlTab>(name); tab->setVisible(show); if(show) { // don't expand accordion if it was collapsed by user if(!isAccordionCollapsedByUser(tab)) { // expand accordion tab->changeOpenClose(false); } } }
void LLOutfitsList::setSelectedOutfitByUUID(const LLUUID& outfit_uuid) { for (outfits_map_t::iterator iter = mOutfitsMap.begin(); iter != mOutfitsMap.end(); ++iter) { if (outfit_uuid == iter->first) { LLAccordionCtrlTab* tab = iter->second; if (!tab) continue; LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (!list) continue; tab->setFocus(TRUE); changeOutfitSelection(list, outfit_uuid); tab->setDisplayChildren(true); } } }
void LLTeleportHistoryPanel::onAccordionTabRightClick(LLView *view, S32 x, S32 y, MASK mask) { LLAccordionCtrlTab *tab = (LLAccordionCtrlTab *) view; // If click occurred below the header, don't show this menu if (y < tab->getRect().getHeight() - tab->getHeaderHeight() - tab->getPaddingBottom()) return; if (mAccordionTabMenu) { //preventing parent (menu holder) from deleting already "dead" context menus on exit LLView* parent = mAccordionTabMenu->getParent(); if (parent) { parent->removeChild(mAccordionTabMenu); } delete mAccordionTabMenu; } // set up the callbacks for all of the avatar menu items // (N.B. callbacks don't take const refs as mID is local scope) LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; registrar.add("TeleportHistory.TabOpen", boost::bind(&LLTeleportHistoryPanel::onAccordionTabOpen, this, tab)); registrar.add("TeleportHistory.TabClose", boost::bind(&LLTeleportHistoryPanel::onAccordionTabClose, this, tab)); // create the context menu from the XUI llassert(LLMenuGL::sMenuContainer != NULL); mAccordionTabMenu = LLUICtrlFactory::getInstance()->createFromFile<LLContextMenu>( "menu_teleport_history_tab.xml", LLMenuGL::sMenuContainer, LLViewerMenuHolderGL::child_registry_t::instance()); mAccordionTabMenu->setItemVisible("TabOpen", !tab->isExpanded() ? true : false); mAccordionTabMenu->setItemVisible("TabClose", tab->isExpanded() ? true : false); mAccordionTabMenu->show(x, y); LLMenuGL::showPopup(tab, mAccordionTabMenu, x, y); }
void LLOutfitsList::applyFilter(const std::string& new_filter_substring) { mAccordion->setFilterSubString(new_filter_substring); for (outfits_map_t::iterator iter = mOutfitsMap.begin(), iter_end = mOutfitsMap.end(); iter != iter_end; ++iter) { LLAccordionCtrlTab* tab = iter->second; if (!tab) continue; bool more_restrictive = sFilterSubString.size() < new_filter_substring.size() && !new_filter_substring.substr(0, sFilterSubString.size()).compare(sFilterSubString); // Restore tab visibility in case of less restrictive filter // to compare it with updated string if it was previously hidden. if (!more_restrictive) { tab->setVisible(TRUE); } LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (list) { list->setFilterSubString(new_filter_substring); } if(sFilterSubString.empty() && !new_filter_substring.empty()) { //store accordion tab state when filter is not empty tab->notifyChildren(LLSD().with("action","store_state")); } if (!new_filter_substring.empty()) { applyFilterToTab(iter->first, tab, new_filter_substring); } else { // restore tab title when filter is empty tab->setTitle(tab->getTitle()); //restore accordion state after all those accodrion tab manipulations tab->notifyChildren(LLSD().with("action","restore_state")); // Try restoring the tab selection. restoreOutfitSelection(tab, iter->first); } } mAccordion->arrange(); }
void LLAccordionCtrl::expandDefaultTab() { if (mAccordionTabs.size() > 0) { LLAccordionCtrlTab* tab = mAccordionTabs.front(); if (!tab->getDisplayChildren()) { tab->setDisplayChildren(true); } for (size_t i = 1; i < mAccordionTabs.size(); ++i) { tab = mAccordionTabs[i]; if (tab->getDisplayChildren()) { tab->setDisplayChildren(false); } } arrange(); } }
LLPanel* LLPanel::childGetVisibleTabWithHelp() { LLView *child; bfs_tree_iterator_t it = beginTreeBFS(); // skip ourselves ++it; for (; it != endTreeBFS(); ++it) { child = *it; LLPanel *curTabPanel = NULL; // do we have a tab container? LLTabContainer *tab = dynamic_cast<LLTabContainer *>(child); if (tab && tab->getVisible()) { curTabPanel = tab->getCurrentPanel(); } // do we have an accordion tab? LLAccordionCtrlTab* accordion = dynamic_cast<LLAccordionCtrlTab *>(child); if (accordion && accordion->getDisplayChildren()) { curTabPanel = dynamic_cast<LLPanel *>(accordion->getAccordionView()); } // if we found a valid tab, does it have a help topic? if (curTabPanel && !curTabPanel->getHelpTopic().empty()) { return curTabPanel; } } // couldn't find any active tabs with a help topic string return NULL; }
void LLOutfitsList::onCOFChanged() { LLInventoryModel::changed_items_t changed_linked_items; const LLInventoryModel::changed_items_t& changed_items = gInventory.getChangedIDs(); for (LLInventoryModel::changed_items_t::const_iterator iter = changed_items.begin(); iter != changed_items.end(); ++iter) { LLViewerInventoryItem* item = gInventory.getItem(*iter); if (item) { // From gInventory we get the UUIDs of new links added to COF // or removed from COF. These links UUIDs are not the same UUIDs // that we have in each wearable items list. So we collect base items // UUIDs to find all items or links that point to same base items in wearable // items lists and update their worn state there. changed_linked_items.insert(item->getLinkedUUID()); } } for (outfits_map_t::iterator iter = mOutfitsMap.begin(); iter != mOutfitsMap.end(); ++iter) { LLAccordionCtrlTab* tab = iter->second; if (!tab) continue; LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(tab->getAccordionView()); if (!list) continue; // Every list updates the labels of changed items or // the links that point to these items. list->updateChangedItems(changed_linked_items); } }
void LLTeleportHistoryPanel::replaceItem(S32 removed_index) { // Flat list for 'Today' (mItemContainers keeps accordion tabs in reverse order) LLFlatListView* fv = NULL; if (mItemContainers.size() > 0) { fv = getFlatListViewFromTab(mItemContainers[mItemContainers.size() - 1]); } // Empty flat list for 'Today' means that other flat lists are empty as well, // so all items from teleport history should be added. if (!fv || fv->size() == 0) { showTeleportHistory(); return; } const LLTeleportHistoryStorage::slurl_list_t& history_items = mTeleportHistory->getItems(); LLTeleportHistoryFlatItem* item = LLTeleportHistoryFlatItemStorage::instance() .getFlatItemForPersistentItem(&mContextMenu, history_items[history_items.size() - 1], // Most recent item, it was added instead of removed history_items.size(), // index will be decremented inside loop below sFilterSubString); fv->addItem(item, LLUUID::null, ADD_TOP); // Index of each item, from last to removed item should be decremented // to point to the right item in LLTeleportHistoryStorage for (S32 tab_idx = mItemContainers.size() - 1; tab_idx >= 0; --tab_idx) { LLAccordionCtrlTab* tab = mItemContainers.get(tab_idx); if (!tab->getVisible()) continue; fv = getFlatListViewFromTab(tab); if (!fv) { showTeleportHistory(); return; } std::vector<LLPanel*> items; fv->getItems(items); S32 items_cnt = items.size(); for (S32 n = 0; n < items_cnt; ++n) { LLTeleportHistoryFlatItem *item = (LLTeleportHistoryFlatItem*) items[n]; if (item->getIndex() == removed_index) { LLTeleportHistoryFlatItemStorage::instance().removeItem(item); fv->removeItem(item); // If flat list becames empty, then accordion tab should be hidden if (fv->size() == 0) tab->setVisible(false); mHistoryAccordion->arrange(); return; // No need to decrement idexes for the rest of items } item->setIndex(item->getIndex() - 1); } } }
// Called to add items, no more, than ADD_LIMIT at time void LLTeleportHistoryPanel::refresh() { if (!mHistoryAccordion) { mDirty = false; return; } const LLTeleportHistoryStorage::slurl_list_t& items = mTeleportHistory->getItems(); // Setting tab_boundary_date to "now", so date from any item would be earlier, than boundary. // That leads to call to getNextTab to get right tab_idx in first pass LLDate tab_boundary_date = LLDate::now(); LLFlatListView* curr_flat_view = NULL; std::string filter_string = sFilterSubString; LLStringUtil::toUpper(filter_string); U32 added_items = 0; while (mCurrentItem >= 0) { // Filtering if (!filter_string.empty()) { std::string landmark_title(items[mCurrentItem].mTitle); LLStringUtil::toUpper(landmark_title); if( std::string::npos == landmark_title.find(filter_string) ) { mCurrentItem--; continue; } } // Checking whether date of item is earlier, than tab_boundary_date. // In that case, item should be added to another tab const LLDate &date = items[mCurrentItem].mDate; if (date < tab_boundary_date) { // Getting apropriate tab_idx for this and subsequent items, // tab_boundary_date would be earliest possible date for this tab S32 tab_idx = 0; getNextTab(date, tab_idx, tab_boundary_date); tab_idx = mItemContainers.size() - 1 - tab_idx; if (tab_idx >= 0) { LLAccordionCtrlTab* tab = mItemContainers.get(tab_idx); tab->setVisible(true); // Expand all accordion tabs when filtering if(!sFilterSubString.empty()) { //store accordion tab state when filter is not empty tab->notifyChildren(LLSD().with("action","store_state")); tab->setDisplayChildren(true); } // Restore each tab's expand state when not filtering else { bool collapsed = isAccordionCollapsedByUser(tab); tab->setDisplayChildren(!collapsed); //restore accordion state after all those accodrion tabmanipulations tab->notifyChildren(LLSD().with("action","restore_state")); } curr_flat_view = getFlatListViewFromTab(tab); } } if (curr_flat_view) { LLTeleportHistoryFlatItem* item = LLTeleportHistoryFlatItemStorage::instance() .getFlatItemForPersistentItem(&mContextMenu, items[mCurrentItem], mCurrentItem, filter_string); if ( !curr_flat_view->addItem(item, LLUUID::null, ADD_BOTTOM, false) ) llerrs << "Couldn't add flat item to teleport history." << llendl; if (mLastSelectedItemIndex == mCurrentItem) curr_flat_view->selectItem(item, true); } mCurrentItem--; if (++added_items >= ADD_LIMIT) break; } for (S32 n = mItemContainers.size() - 1; n >= 0; --n) { LLAccordionCtrlTab* tab = mItemContainers.get(n); LLFlatListView* fv = getFlatListViewFromTab(tab); if (fv) { fv->notify(LLSD().with("rearrange", LLSD())); } } mHistoryAccordion->setFilterSubString(sFilterSubString); mHistoryAccordion->arrange(); updateVerbs(); if (mCurrentItem < 0) mDirty = false; }
BOOL LLTeleportHistoryPanel::postBuild() { mTeleportHistory = LLTeleportHistoryStorage::getInstance(); if (mTeleportHistory) { mTeleportHistoryChangedConnection = mTeleportHistory->setHistoryChangedCallback(boost::bind(&LLTeleportHistoryPanel::onTeleportHistoryChange, this, _1)); } mHistoryAccordion = getChild<LLAccordionCtrl>("history_accordion"); if (mHistoryAccordion) { for (child_list_const_iter_t iter = mHistoryAccordion->beginChild(); iter != mHistoryAccordion->endChild(); iter++) { if (dynamic_cast<LLAccordionCtrlTab*>(*iter)) { LLAccordionCtrlTab* tab = (LLAccordionCtrlTab*)*iter; tab->setRightMouseDownCallback(boost::bind(&LLTeleportHistoryPanel::onAccordionTabRightClick, this, _1, _2, _3, _4)); tab->setDisplayChildren(false); tab->setDropDownStateChangedCallback(boost::bind(&LLTeleportHistoryPanel::onAccordionExpand, this, _1, _2)); // All accordion tabs are collapsed initially setAccordionCollapsedByUser(tab, true); mItemContainers.put(tab); LLFlatListView* fl = getFlatListViewFromTab(tab); if (fl) { fl->setCommitOnSelectionChange(true); fl->setDoubleClickCallback(boost::bind(&LLTeleportHistoryPanel::onDoubleClickItem, this)); fl->setCommitCallback(boost::bind(&LLTeleportHistoryPanel::handleItemSelect, this, fl)); fl->setReturnCallback(boost::bind(&LLTeleportHistoryPanel::onReturnKeyPressed, this)); } } } // Open first 2 accordion tabs if (mItemContainers.size() > 1) { LLAccordionCtrlTab* tab = mItemContainers.get(mItemContainers.size() - 1); tab->setDisplayChildren(true); setAccordionCollapsedByUser(tab, false); } if (mItemContainers.size() > 2) { LLAccordionCtrlTab* tab = mItemContainers.get(mItemContainers.size() - 2); tab->setDisplayChildren(true); setAccordionCollapsedByUser(tab, false); } } LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registrar; registrar.add("TeleportHistory.ExpandAllFolders", boost::bind(&LLTeleportHistoryPanel::onExpandAllFolders, this)); registrar.add("TeleportHistory.CollapseAllFolders", boost::bind(&LLTeleportHistoryPanel::onCollapseAllFolders, this)); registrar.add("TeleportHistory.ClearTeleportHistory", boost::bind(&LLTeleportHistoryPanel::onClearTeleportHistory, this)); mEnableCallbackRegistrar.add("TeleportHistory.GearMenu.Enable", boost::bind(&LLTeleportHistoryPanel::isActionEnabled, this, _2)); mMenuGearButton = getChild<LLMenuButton>("gear_btn"); LLToggleableMenu* gear_menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>("menu_teleport_history_gear.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());; if(gear_menu) { mGearMenuHandle = gear_menu->getHandle(); mMenuGearButton->setMenu(gear_menu); } return TRUE; }
void LLOutfitsList::refreshList(const LLUUID& category_id) { LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t item_array; // Collect all sub-categories of a given category. LLIsType is_category(LLAssetType::AT_CATEGORY); gInventory.collectDescendentsIf( category_id, cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH, is_category); uuid_vec_t vadded; uuid_vec_t vremoved; // Create added and removed items vectors. computeDifference(cat_array, vadded, vremoved); // Handle added tabs. for (uuid_vec_t::const_iterator iter = vadded.begin(); iter != vadded.end(); ++iter) { const LLUUID cat_id = (*iter); LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); if (!cat) continue; std::string name = cat->getName(); outfit_accordion_tab_params tab_params(get_accordion_tab_params()); LLAccordionCtrlTab* tab = LLUICtrlFactory::create<LLAccordionCtrlTab>(tab_params); if (!tab) continue; LLWearableItemsList* wearable_list = LLUICtrlFactory::create<LLWearableItemsList>(tab_params.wearable_list); wearable_list->setShape(tab->getLocalRect()); tab->addChild(wearable_list); tab->setName(name); tab->setTitle(name); // *TODO: LLUICtrlFactory::defaultBuilder does not use "display_children" from xml. Should be investigated. tab->setDisplayChildren(false); mAccordion->addCollapsibleCtrl(tab); // Start observing the new outfit category. LLWearableItemsList* list = tab->getChild<LLWearableItemsList>("wearable_items_list"); if (!mCategoriesObserver->addCategory(cat_id, boost::bind(&LLWearableItemsList::updateList, list, cat_id))) { // Remove accordion tab if category could not be added to observer. mAccordion->removeCollapsibleCtrl(tab); // kill removed tab tab->die(); continue; } // Map the new tab with outfit category UUID. mOutfitsMap.insert(LLOutfitsList::outfits_map_value_t(cat_id, tab)); tab->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onAccordionTabRightClick, this, _1, _2, _3, cat_id)); // Setting tab focus callback to monitor currently selected outfit. tab->setFocusReceivedCallback(boost::bind(&LLOutfitsList::changeOutfitSelection, this, list, cat_id)); // Setting callback to reset items selection inside outfit on accordion collapsing and expanding (EXT-7875) tab->setDropDownStateChangedCallback(boost::bind(&LLOutfitsList::resetItemSelection, this, list, cat_id)); // force showing list items that don't match current filter(EXT-7158) list->setForceShowingUnmatchedItems(true); // Setting list commit callback to monitor currently selected wearable item. list->setCommitCallback(boost::bind(&LLOutfitsList::onSelectionChange, this, _1)); // Setting list refresh callback to apply filter on list change. list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onFilteredWearableItemsListRefresh, this, _1)); list->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onWearableItemsListRightClick, this, _1, _2, _3)); // Fetch the new outfit contents. cat->fetch(); // Refresh the list of outfit items after fetch(). // Further list updates will be triggered by the category observer. list->updateList(cat_id); // If filter is currently applied we store the initial tab state and // open it to show matched items if any. if (!sFilterSubString.empty()) { tab->notifyChildren(LLSD().with("action","store_state")); tab->setDisplayChildren(true); // Setting mForceRefresh flag will make the list refresh its contents // even if it is not currently visible. This is required to apply the // filter to the newly added list. list->setForceRefresh(true); list->setFilterSubString(sFilterSubString); } } // Handle removed tabs. for (uuid_vec_t::const_iterator iter=vremoved.begin(); iter != vremoved.end(); ++iter) { outfits_map_t::iterator outfits_iter = mOutfitsMap.find((*iter)); if (outfits_iter != mOutfitsMap.end()) { const LLUUID& outfit_id = outfits_iter->first; LLAccordionCtrlTab* tab = outfits_iter->second; // An outfit is removed from the list. Do the following: // 1. Remove outfit category from observer to stop monitoring its changes. mCategoriesObserver->removeCategory(outfit_id); // 2. Remove the outfit from selection. deselectOutfit(outfit_id); // 3. Remove category UUID to accordion tab mapping. mOutfitsMap.erase(outfits_iter); // 4. Remove outfit tab from accordion. mAccordion->removeCollapsibleCtrl(tab); // kill removed tab if (tab != NULL) { tab->die(); } } } // Get changed items from inventory model and update outfit tabs // which might have been renamed. const LLInventoryModel::changed_items_t& changed_items = gInventory.getChangedIDs(); for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); items_iter != changed_items.end(); ++items_iter) { updateOutfitTab(*items_iter); } mAccordion->sort(); }
void LLOutfitsList::refreshList(const LLUUID& category_id) { LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t item_array; // Collect all sub-categories of a given category. // <FS:ND> FIRE-6958/VWR-2862; Make sure to only collect folders of type FT_OUTFIT class ndOutfitsCollector: public LLIsType { public: ndOutfitsCollector() : LLIsType( LLAssetType::AT_CATEGORY ) { } virtual bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) { if( !LLIsType::operator()( cat, item ) ) return false; if( cat && LLFolderType::FT_OUTFIT == cat->getPreferredType() ) return true; return false; } }; // LLIsType is_category(LLAssetType::AT_CATEGORY); ndOutfitsCollector is_category; // </FS:ND> gInventory.collectDescendentsIf( category_id, cat_array, item_array, LLInventoryModel::EXCLUDE_TRASH, is_category); uuid_vec_t vadded; uuid_vec_t vremoved; // Create added and removed items vectors. computeDifference(cat_array, vadded, vremoved); // <FS:ND> FIRE-6958/VWR-2862; Handle large amounts of outfits, write a least a warning into the logs. if( vadded.size() > 128 ) LL_WARNS() << "Large amount of outfits found: " << vadded.size() << " this may cause hangs and disconnects" << LL_ENDL; U32 nCap = gSavedSettings.getU32( "FSDisplaySavedOutfitsCap" ); if( nCap && nCap < vadded.size() ) { vadded.resize( nCap ); LL_WARNS() << "Capped outfits to " << nCap << " due to debug setting FSDisplaySavedOutfitsCap" << LL_ENDL; } // </FS:ND> // <FS:Ansariel> FIRE-12939: Add outfit count to outfits list getChild<LLTextBox>("OutfitcountText")->setTextArg("COUNT", llformat("%d", cat_array.size())); // Handle added tabs. for (uuid_vec_t::const_iterator iter = vadded.begin(); iter != vadded.end(); ++iter) { const LLUUID cat_id = (*iter); LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id); if (!cat) continue; std::string name = cat->getName(); outfit_accordion_tab_params tab_params(get_accordion_tab_params()); LLAccordionCtrlTab* tab = LLUICtrlFactory::create<LLAccordionCtrlTab>(tab_params); if (!tab) continue; LLWearableItemsList* wearable_list = LLUICtrlFactory::create<LLWearableItemsList>(tab_params.wearable_list); wearable_list->setShape(tab->getLocalRect()); tab->addChild(wearable_list); tab->setName(name); tab->setTitle(name); // *TODO: LLUICtrlFactory::defaultBuilder does not use "display_children" from xml. Should be investigated. tab->setDisplayChildren(false); // <FS:ND> Calling this when there's a lot of outfits causes horrible perfomance and disconnects, due to arrange eating so many cpu cycles. // mAccordion->addCollapsibleCtrl(tab); mAccordion->addCollapsibleCtrl(tab, false ); // </FS:ND> // Start observing the new outfit category. LLWearableItemsList* list = tab->getChild<LLWearableItemsList>("wearable_items_list"); if (!mCategoriesObserver->addCategory(cat_id, boost::bind(&LLWearableItemsList::updateList, list, cat_id))) { // Remove accordion tab if category could not be added to observer. mAccordion->removeCollapsibleCtrl(tab); // kill removed tab tab->die(); continue; } // Map the new tab with outfit category UUID. mOutfitsMap.insert(LLOutfitsList::outfits_map_value_t(cat_id, tab)); tab->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onAccordionTabRightClick, this, _1, _2, _3, cat_id)); // Setting tab focus callback to monitor currently selected outfit. tab->setFocusReceivedCallback(boost::bind(&LLOutfitsList::changeOutfitSelection, this, list, cat_id)); // Setting callback to reset items selection inside outfit on accordion collapsing and expanding (EXT-7875) tab->setDropDownStateChangedCallback(boost::bind(&LLOutfitsList::resetItemSelection, this, list, cat_id)); // force showing list items that don't match current filter(EXT-7158) list->setForceShowingUnmatchedItems(true); // Setting list commit callback to monitor currently selected wearable item. list->setCommitCallback(boost::bind(&LLOutfitsList::onSelectionChange, this, _1)); // Setting list refresh callback to apply filter on list change. list->setRefreshCompleteCallback(boost::bind(&LLOutfitsList::onFilteredWearableItemsListRefresh, this, _1)); list->setRightMouseDownCallback(boost::bind(&LLOutfitsList::onWearableItemsListRightClick, this, _1, _2, _3)); // Fetch the new outfit contents. cat->fetch(); // Refresh the list of outfit items after fetch(). // Further list updates will be triggered by the category observer. list->updateList(cat_id); // If filter is currently applied we store the initial tab state and // open it to show matched items if any. if (!sFilterSubString.empty()) { tab->notifyChildren(LLSD().with("action","store_state")); tab->setDisplayChildren(true); // Setting mForceRefresh flag will make the list refresh its contents // even if it is not currently visible. This is required to apply the // filter to the newly added list. list->setForceRefresh(true); list->setFilterSubString(sFilterSubString); } } // <FS:ND> We called mAccordion->addCollapsibleCtrl with false as second paramter and did not let it arrange itself each time. Do this here after all is said and done. mAccordion->arrange(); // </FS:ND> // Handle removed tabs. for (uuid_vec_t::const_iterator iter=vremoved.begin(); iter != vremoved.end(); ++iter) { outfits_map_t::iterator outfits_iter = mOutfitsMap.find((*iter)); if (outfits_iter != mOutfitsMap.end()) { const LLUUID& outfit_id = outfits_iter->first; LLAccordionCtrlTab* tab = outfits_iter->second; // An outfit is removed from the list. Do the following: // 1. Remove outfit category from observer to stop monitoring its changes. mCategoriesObserver->removeCategory(outfit_id); // 2. Remove the outfit from selection. deselectOutfit(outfit_id); // 3. Remove category UUID to accordion tab mapping. mOutfitsMap.erase(outfits_iter); // 4. Remove outfit tab from accordion. mAccordion->removeCollapsibleCtrl(tab); // kill removed tab if (tab != NULL) { tab->die(); } } } // Get changed items from inventory model and update outfit tabs // which might have been renamed. const LLInventoryModel::changed_items_t& changed_items = gInventory.getChangedIDs(); for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); items_iter != changed_items.end(); ++items_iter) { updateOutfitTab(*items_iter); } mAccordion->sort(); }